diff --git a/00_m1284p_blink/.cproject b/00_m1284p_blink/.cproject deleted file mode 100644 index d2b8454..0000000 --- a/00_m1284p_blink/.cproject +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/00_m1284p_blink/.project b/00_m1284p_blink/.project deleted file mode 100644 index 7a96305..0000000 --- a/00_m1284p_blink/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 00_m1284p_blink - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/00_m1284p_blink/main.c b/00_m1284p_blink/main.c deleted file mode 100644 index a1ccc16..0000000 --- a/00_m1284p_blink/main.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - - program - true - true - true - - - - - - - - - - diff --git a/00_m1284p_blink_make/.gitignore b/00_m1284p_blink_make/.gitignore deleted file mode 100644 index a27771e..0000000 --- a/00_m1284p_blink_make/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.dep/ \ No newline at end of file diff --git a/00_m1284p_blink_make/.project b/00_m1284p_blink_make/.project deleted file mode 100644 index 89dd8fe..0000000 --- a/00_m1284p_blink_make/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - 00_m1284p_blink_make - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/00_m1284p_blink_make/Makefile b/00_m1284p_blink_make/Makefile deleted file mode 100644 index 5199792..0000000 --- a/00_m1284p_blink_make/Makefile +++ /dev/null @@ -1,650 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, J�rg Wunsch, et al. -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - -#_PG = stk500 -_PG = mkii -#_PG = usb-asp - - -# MCU name -MCU = atmega1284p - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# Typical values are: -# F_CPU = 1000000 -# F_CPU = 1843200 -# F_CPU = 2000000 -# F_CPU = 3686400 -# F_CPU = 4000000 -# F_CPU = 7372800 -# F_CPU = 8000000 -# F_CPU = 11059200 -# F_CPU = 14745600 -F_CPU = 16000000 -# F_CPU = 18432000 -# F_CPU = 20000000 -# F_CPU = 8000000 - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = main - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = . - - -# List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) - - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -#CPPDEFS += -D__STDC_LIMIT_MACROS -#CPPDEFS += -D__STDC_CONSTANT_MACROS - - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -#CFLAGS += -mshort-calls -#CFLAGS += -fno-unit-at-a-time -#CFLAGS += -Wundef -#CFLAGS += -Wunreachable-code -#CFLAGS += -Wsign-compare -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -#CPPFLAGS += -mshort-calls -#CPPFLAGS += -fno-unit-at-a-time -#CPPFLAGS += -Wstrict-prototypes -#CPPFLAGS += -Wunreachable-code -#CPPFLAGS += -Wsign-compare -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS += -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x -#LDFLAGS += -Wl,--section-start=.foo_far=0x10000 -#LDFLAGS += -Wl,--section-start=.foo=0x8000 -#LDFLAGS += -Wl,--section-start=.bootloader=0x1E000 -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware -# Type: avrdude -c ? -# to get a full listing. -# - - -ifeq ($(_PG), stk500) -AVRDUDE_PROGRAMMER = stk500v2 -#com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = com3 # programmer connected to serial device -endif - -ifeq ($(_PG), mkii) -AVRDUDE_PROGRAMMER = avrispmkii -AVRDUDE_PORT = usb -endif - -ifeq ($(_PG), usb-asp) -AVRDUDE_PROGRAMMER = usbasp -AVRDUDE_PORT = usb -endif - - - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - -#AVRDUDE_FLAGS = -p atmega1284p -P usb -c usbasp -v - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -#AVRDUDE = avrdude -AVRDUDE = E:\WinAVR-20100110\bin\avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -build: elf hex bin eep lss sym -#build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -bin: $(TARGET).bin -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=lib$(TARGET).a -lib: $(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep, .bin) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ - -%.bin: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O binary -R .eeprom -R .fuse -R .lock $< 1284BOOT.BIN - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).bin - $(REMOVE) 1284BOOT.BIN - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVEDIR) .dep - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff \ -clean clean_list program debug gdb-config - - diff --git a/00_m1284p_blink_make/README.md b/00_m1284p_blink_make/README.md deleted file mode 100644 index d309d27..0000000 --- a/00_m1284p_blink_make/README.md +++ /dev/null @@ -1 +0,0 @@ -Tiny AUX project to test Bootloader Zevero for AtMEGA 1284p diff --git a/00_m1284p_blink_make/main.c b/00_m1284p_blink_make/main.c deleted file mode 100644 index 8fbcb52..0000000 --- a/00_m1284p_blink_make/main.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - - program - true - true - true - - - - - - - - - - diff --git a/00_m644p_blink_make/.gitignore b/00_m644p_blink_make/.gitignore deleted file mode 100644 index a27771e..0000000 --- a/00_m644p_blink_make/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.dep/ \ No newline at end of file diff --git a/00_m644p_blink_make/.project b/00_m644p_blink_make/.project deleted file mode 100644 index 51b1930..0000000 --- a/00_m644p_blink_make/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - 00_m644p_blink_make - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/00_m644p_blink_make/Makefile b/00_m644p_blink_make/Makefile deleted file mode 100644 index afb425c..0000000 --- a/00_m644p_blink_make/Makefile +++ /dev/null @@ -1,650 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, J�rg Wunsch, et al. -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - -#_PG = stk500 -_PG = mkii -#_PG = usb-asp - - -# MCU name -MCU = atmega644p - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# Typical values are: -# F_CPU = 1000000 -# F_CPU = 1843200 -# F_CPU = 2000000 -# F_CPU = 3686400 -# F_CPU = 4000000 -# F_CPU = 7372800 -# F_CPU = 8000000 -# F_CPU = 11059200 -# F_CPU = 14745600 -F_CPU = 16000000 -# F_CPU = 18432000 -# F_CPU = 20000000 -# F_CPU = 8000000 - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = main - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = . - - -# List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) - - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -#CPPDEFS += -D__STDC_LIMIT_MACROS -#CPPDEFS += -D__STDC_CONSTANT_MACROS - - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -#CFLAGS += -mshort-calls -#CFLAGS += -fno-unit-at-a-time -#CFLAGS += -Wundef -#CFLAGS += -Wunreachable-code -#CFLAGS += -Wsign-compare -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -#CPPFLAGS += -mshort-calls -#CPPFLAGS += -fno-unit-at-a-time -#CPPFLAGS += -Wstrict-prototypes -#CPPFLAGS += -Wunreachable-code -#CPPFLAGS += -Wsign-compare -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS += -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x -#LDFLAGS += -Wl,--section-start=.foo_far=0x10000 -#LDFLAGS += -Wl,--section-start=.foo=0x8000 -#LDFLAGS += -Wl,--section-start=.bootloader=0x1E000 -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware -# Type: avrdude -c ? -# to get a full listing. -# - - -ifeq ($(_PG), stk500) -AVRDUDE_PROGRAMMER = stk500v2 -#com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = com3 # programmer connected to serial device -endif - -ifeq ($(_PG), mkii) -AVRDUDE_PROGRAMMER = avrispmkii -AVRDUDE_PORT = usb -endif - -ifeq ($(_PG), usb-asp) -AVRDUDE_PROGRAMMER = usbasp -AVRDUDE_PORT = usb -endif - - - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - -#AVRDUDE_FLAGS = -p atmega1284p -P usb -c usbasp -v - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -#AVRDUDE = avrdude -AVRDUDE = E:\WinAVR-20100110\bin\avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -build: elf hex bin eep lss sym -#build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -bin: $(TARGET).bin -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=lib$(TARGET).a -lib: $(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep, .bin) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ - -%.bin: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O binary -R .eeprom -R .fuse -R .lock $< 644BOOT.BIN - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).bin - $(REMOVE) 644BOOT.BIN - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVEDIR) .dep - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff \ -clean clean_list program debug gdb-config - - diff --git a/00_m644p_blink_make/README.md b/00_m644p_blink_make/README.md deleted file mode 100644 index 5fe60c0..0000000 --- a/00_m644p_blink_make/README.md +++ /dev/null @@ -1 +0,0 @@ -Tiny AUX project to test Bootloader Zevero for AtMEGA 644p diff --git a/00_m644p_blink_make/main.c b/00_m644p_blink_make/main.c deleted file mode 100644 index 23b7aa7..0000000 --- a/00_m644p_blink_make/main.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/01_m1284p_bb00_minimum/.project b/01_m1284p_bb00_minimum/.project deleted file mode 100644 index 8f94c56..0000000 --- a/01_m1284p_bb00_minimum/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 01_m1284p_bb00_minimum - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/01_m1284p_bb00_minimum/main.c b/01_m1284p_bb00_minimum/main.c deleted file mode 100644 index 0de854f..0000000 --- a/01_m1284p_bb00_minimum/main.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" - -//#include // itoa etc.. - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. -*/ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - unsigned long prev_millis = 0; - unsigned long rx_millis = 0; - unsigned long uptime = 0; - uint16_t CharIn; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - if((millis()-prev_millis)>TICK_PER_SEC) - { - //Here every 1sec - wdt_reset(); // WDT reset at least every sec - prev_millis = millis(); - led1_tgl(); - PRINTF("Uptime %lu sec\r\n", uptime++); - //PRINTF("ADC5: %d\r\n", adc_read(5)); - - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - //PRINTF("SW1 is pressed\r\n"); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - }//if((millis()-prev_millis)>TICK_PER_SEC) - - if((millis()-rx_millis)>0) - { - // Here every 1 msec, to check UART RX - rx_millis = millis(); - - // GET UART RX Symbol - CharIn = uart_getc(); - - // Check if char exist - // Read until data in RX buffer present - while (( CharIn & UART_NO_DATA ) == 0) - { - wdt_reset(); // WDT reset at least every sec - //!! Debug only - //Read data from UART0 RX ring buffer & send back echo - uart_putc(CharIn+1); - // GET UART RX Symbol - CharIn = uart_getc(); - } - }//if((millis()-rx_millis)>0) - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/02_m1284p_FATFS_Chang_tst/.cproject b/02_m1284p_FATFS_Chang_tst/.cproject deleted file mode 100644 index 057a2dc..0000000 --- a/02_m1284p_FATFS_Chang_tst/.cproject +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/02_m1284p_FATFS_Chang_tst/.project b/02_m1284p_FATFS_Chang_tst/.project deleted file mode 100644 index f588728..0000000 --- a/02_m1284p_FATFS_Chang_tst/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 02_m1284p_FATFS_Chang_tst - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/02_m1284p_FATFS_Chang_tst/ff/ccsbcs.c.unicode b/02_m1284p_FATFS_Chang_tst/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/02_m1284p_FATFS_Chang_tst/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/02_m1284p_FATFS_Chang_tst/ff/diskio.h b/02_m1284p_FATFS_Chang_tst/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/02_m1284p_FATFS_Chang_tst/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/02_m1284p_FATFS_Chang_tst/ff/ff.c b/02_m1284p_FATFS_Chang_tst/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/02_m1284p_FATFS_Chang_tst/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/02_m1284p_FATFS_Chang_tst/ff/ff.h b/02_m1284p_FATFS_Chang_tst/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/02_m1284p_FATFS_Chang_tst/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/02_m1284p_FATFS_Chang_tst/ff/ffconf.h b/02_m1284p_FATFS_Chang_tst/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/02_m1284p_FATFS_Chang_tst/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/02_m1284p_FATFS_Chang_tst/ff/integer.h b/02_m1284p_FATFS_Chang_tst/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/02_m1284p_FATFS_Chang_tst/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/02_m1284p_FATFS_Chang_tst/main.c b/02_m1284p_FATFS_Chang_tst/main.c deleted file mode 100644 index 5054dc3..0000000 --- a/02_m1284p_FATFS_Chang_tst/main.c +++ /dev/null @@ -1,1434 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * - * Author: maxx - */ -/* - * FatFS SD-card(SPI_SD-CS PB.0) monitor test - * Adapted for m1284p Eclipse 16Mhz - * (c) Ibragimov M. Russia Togliatty 15/12/2018 - * - * Optimization notes: - * -Os, not work!! (google reading says GCC version bug (FATFS monitos xprintf.. related)) - * -O3 - OK but size file huge - * -O2 - is OK - * Decide not use xitoa by Elm Chang (any way -Os not work :(( ) - * - * Two main functions for FATFS: - * 1. fatfs_tst() - Quick test base functions FATFS open-sd/work_with_directory/read-write_file etc.. - * 2. fatfs_monitor() - Command terminal for FATFS test - * Commands sequence example: - * - * >di 0 - * >fi 0 1 - * >fs - * >fl - * >fo 1 readme.txt - * >fd 100 - * >fc - * - * Warning!! - * To work properly, need disconnect SPI programmer (SD-Card not work with MKII programmer connected!!) - * - */ - -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" - -//#include // itoa etc.. - -//******************************* Fat FS declare related: BEGIN -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -//#include "xitoa.h" // ChaN light libs similar like && - -#define EN_FS_MONITOR 0 -//#define EN_FS_MONITOR 1 //works only with -O3/-O2/-O1/-O0 - preffered use -O2 - -typedef char PROGMEM prog_char; -#define xprintf printf_P -#define xputc uart_putc -#define xputs printf_P -#define xsprintf sprintf_P - - -DWORD AccSize; /* Work register for fs command */ -WORD AccFiles, AccDirs; -FILINFO Finfo; -#if _USE_LFN -char Lfname[_MAX_LFN+1]; -#endif - -char Line[80]; /* Console input buffer */ -BYTE Buff[2048]; /* Working buffer */ - -FATFS FatFs[_VOLUMES]; /* File system object for each logical drive */ //!! Urgent must be always global!! -FIL File[2]; /* File object */ -DIR Dir; /* Directory object */ - - -BYTE RtcOk; /* RTC is available */ - -volatile UINT Timer; /* Performance timer (100Hz increment) (for FatFS test)*/ - -/*----------------------------------------------*/ -/* Get a value of the string */ -/*----------------------------------------------*/ -/* "123 -5 0x3ff 0b1111 0377 w " - ^ 1st call returns 123 and next ptr - ^ 2nd call returns -5 and next ptr - ^ 3rd call returns 1023 and next ptr - ^ 4th call returns 15 and next ptr - ^ 5th call returns 255 and next ptr - ^ 6th call fails and returns 0 -*/ - -int xatoi ( /* 0:Failed, 1:Successful */ - char **str, /* Pointer to pointer to the string */ - long *res /* Pointer to the valiable to store the value */ -) -{ - unsigned long val; - unsigned char c, r, s = 0; - - - *res = 0; - - while ((c = **str) == ' ') (*str)++; /* Skip leading spaces */ - - if (c == '-') { /* negative? */ - s = 1; - c = *(++(*str)); - } - - if (c == '0') { - c = *(++(*str)); - switch (c) { - case 'x': /* hexdecimal */ - r = 16; c = *(++(*str)); - break; - case 'b': /* binary */ - r = 2; c = *(++(*str)); - break; - default: - if (c <= ' ') return 1; /* single zero */ - if (c < '0' || c > '9') return 0; /* invalid char */ - r = 8; /* octal */ - } - } else { - if (c < '0' || c > '9') return 0; /* EOL or invalid char */ - r = 10; /* decimal */ - } - - val = 0; - while (c > ' ') { - if (c >= 'a') c -= 0x20; - c -= '0'; - if (c >= 17) { - c -= 7; - if (c <= 9) return 0; /* invalid char */ - } - if (c >= r) return 0; /* invalid char for current radix */ - val = val * r + c; - c = *(++(*str)); - } - if (s) val = 0 - val; /* apply sign if needed */ - - *res = val; - return 1; -} - -//************************* Fat FS declare related: END - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -//#define PRINTF(FORMAT,args...) xprintf(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif -/* -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif -*/ -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -static inline unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. -*/ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<= ' ') && (i < len - 1)) // Fill symbols in buff - { - buff[i++] = c; - //uart1_putc(c); - uart_putc(c); - } - } - buff[i] = 0; - //uart1_putc('\n'); - uart_putc('\n'); -} - -static -void put_dump (const BYTE *buff, DWORD ofs, BYTE cnt) -{ - BYTE i; - - - xprintf(PSTR("%08lX:"), ofs); - - for(i = 0; i < cnt; i++) - xprintf(PSTR(" %02X"), buff[i]); - - xputc(' '); - for(i = 0; i < cnt; i++) - xputc((buff[i] >= ' ' && buff[i] <= '~') ? buff[i] : '.'); - - xputc('\n'); -} - -static void ls_dir(char* path) -{ - DIR Dir; - FILINFO _Finfo; - BYTE res; - long p1, p2; - UINT s1, s2; - //while (*ptr == ' ') ptr++; - res = f_opendir(&Dir, path); - if (res) { put_rc(res); return; } - p1 = s1 = s2 = 0; -#if _USE_LFN - //Init buffer for LFN NAME (Without this LFN NAME not visible!!) - //Also look here: - /* - * http://microsin.net/programming/file-systems/fatfs-read-dir.html - * https://electronix.ru/forum/index.php?app=forums&module=forums&controller=topic&id=122267 - */ - _Finfo.lfname = Lfname; - _Finfo.lfsize = sizeof(Lfname); -#endif - - for(;;) { - res = f_readdir(&Dir, &_Finfo); - if ((res != FR_OK) || !_Finfo.fname[0]) break; - if (_Finfo.fattrib & AM_DIR) { - s2++; - } else { - s1++; p1 += _Finfo.fsize; - } - PRINTF("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu %s", - (_Finfo.fattrib & AM_DIR) ? 'D' : '-', - (_Finfo.fattrib & AM_RDO) ? 'R' : '-', - (_Finfo.fattrib & AM_HID) ? 'H' : '-', - (_Finfo.fattrib & AM_SYS) ? 'S' : '-', - (_Finfo.fattrib & AM_ARC) ? 'A' : '-', - (_Finfo.fdate >> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - -} - -static -void put_rc (FRESULT rc) -{ - const prog_char *p; - static const prog_char str[] = - "OK\0" "DISK_ERR\0" "INT_ERR\0" "NOT_READY\0" "NO_FILE\0" "NO_PATH\0" - "INVALID_NAME\0" "DENIED\0" "EXIST\0" "INVALID_OBJECT\0" "WRITE_PROTECTED\0" - "INVALID_DRIVE\0" "NOT_ENABLED\0" "NO_FILE_SYSTEM\0" "MKFS_ABORTED\0" "TIMEOUT\0" - "LOCKED\0" "NOT_ENOUGH_CORE\0" "TOO_MANY_OPEN_FILES\0"; - FRESULT i; - - for (p = str, i = 0; i != rc && pgm_read_byte_near(p); i++) { - while(pgm_read_byte_near(p++)); - } - xprintf(PSTR("rc=%u FR_%S\r\n"), rc, p); -} - -//------------------------------------------------------------------ - -// Blocking receive one symbol from uart -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -void fatfs_tst(void) -{ - FRESULT f_err_code; - FIL fil_obj; - char buff[128]; // Read-write buffer - //disk_initialize(0); // Init drive - f_err_code=f_mount(&FatFs[0], "", 1); /* Give a work area to the default drive */ - /* - * f_mount(&Fatfs, "", 1) - mount immediatly - * f_mount(&Fatfs, "", 0) - not mount (delayed mount) - */ - - PRINTF (">>Try mounting SD-CARD FAT.. "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - - f_err_code=f_mkdir ("newdir"); // Create newdir - PRINTF (">>creating "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - f_err_code=f_chdir ("newdir"); // Set newdir to current directore - PRINTF (">>change default dir to "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - f_err_code=f_mkdir ("newdir2"); //Create newdir2 into newdir - PRINTF (">>creating into "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - //!! Open file only once - for creating - //f_err_code=f_open(&fil_obj, "newfile.txt",FA_CREATE_NEW|FA_WRITE); - - //!!Overwrite file on open - //f_err_code=f_open(&fil_obj, "newfile.txt",FA_CREATE_ALWAYS|FA_WRITE); - - //!!Auto Create && Append file mode (using f_lseek..) - f_err_code=f_open(&fil_obj, "newfile.txt",FA_OPEN_ALWAYS|FA_WRITE); - /* Move to end of the file to append data */ - //This need only for append - f_lseek(&fil_obj, f_size(&fil_obj)); - - - PRINTF (">>creating(appending) into "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - //!!Only if _USE_STRFUNC = 1/2 (ffconf.h) - //f_puts("creating and writing ok if you see this\r", &fil_obj); //Writing to newfile - UINT bw; - char msg[32]; - sprintf_P(msg, PSTR("%S"), PSTR("It works!\r\nAnd works..\r\n")); - f_write(&fil_obj, msg, strlen(msg), &bw); /* Write data to the file */ - PRINTF(">>writing data to \r\n"); - - f_err_code=f_close(&fil_obj); // Close newfile - PRINTF (">>closing "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - f_err_code=f_open(&fil_obj, "newfile.txt",FA_READ); //Open newfile for reading - PRINTF (">>open "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - PRINTF (">>data in :\r\n"); - //!!Only if _USE_STRFUNC = 1/2 (ffconf.h) - //PRINTF ("%s", f_gets (buff,128,&fil_obj)); //Read data from newfile - UINT cb; - f_read(&fil_obj, buff, 128, &cb); - if(cb < 128) - buff[cb] = 0x0; - else - buff[127] = 0x0; - PRINTF("%s", buff); - - f_err_code=f_close(&fil_obj); - PRINTF ("\r\n>>closing "); //Close newfile - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - -//TST:BEGIN - f_chdir("/"); - f_err_code=f_open(&fil_obj, "index.htm",FA_READ); //Open newfile for reading - PRINTF (">>open "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - PRINTF (">>data in :\r\n"); - //!!Only if _USE_STRFUNC = 1/2 (ffconf.h) - //PRINTF ("%s", f_gets (buff,128,&fil_obj)); //Read data from newfile - f_read(&fil_obj, buff, 128, &cb); - if(cb < 128) - buff[cb] = 0x0; - else - buff[127] = 0x0; - PRINTF("%s", buff); - - f_err_code=f_close(&fil_obj); - PRINTF ("\r\n>>closing "); //Close newfile - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } -//TST:END - - PRINTF ("OK\r\n\r\nSD-Card list:\r\n"); - PRINTF ("===============================================\r\n"); - f_chdir("/"); - //ls_dir("newdir"); //Scan newdir - ls_dir("/"); //Scan root dir - PRINTF ("===============================================\r\n\r\n"); - - //TST:BEGIN - f_chdir("/"); - f_err_code=f_open(&fil_obj, "index.htm",FA_READ); //Open newfile for reading - PRINTF (">>open "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - PRINTF (">>data in :\r\n"); - //!!Only if _USE_STRFUNC = 1/2 (ffconf.h) - //PRINTF ("%s", f_gets (buff,128,&fil_obj)); //Read data from newfile - f_read(&fil_obj, buff, 128, &cb); - if(cb < 128) - buff[cb] = 0x0; - else - buff[127] = 0x0; - PRINTF("%s", buff); - - f_err_code=f_close(&fil_obj); - PRINTF ("\r\n>>closing "); //Close newfile - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - //TST:END - - _delay_ms(100); - uart0_rx_flash(); - PRINTF("\r\n>>remove into y/N \r\n"); - if (uart0_receive()=='y') - { - f_chdir("newdir"); - f_err_code=f_unlink ("newdir2"); // Delete newdir2 - PRINTF ("\r\n>>removing "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - } - - _delay_ms(100); - uart0_rx_flash(); - PRINTF("\r\n>>remove into ? y/N \r\n"); - - if (uart0_receive()=='y') - { - f_err_code=f_unlink ("/newdir/newfile.txt"); //Delete newfile - PRINTF ("\r\n>>removing "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - } - - - _delay_ms(100); - uart0_rx_flash(); - PRINTF("\r\nFAT FS tests finished..\r\nReboot the programm? y/N \r\n"); - - if (uart0_receive()=='y') - { - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - - PRINTF("\r\n>>>Running main programm..\r\n"); - //*****************FAT FS Test: END - - /* - while(1) - { - wdt_reset(); - } - */ -} - -#if EN_FS_MONITOR -void fatfs_monitor(void) -{ - char *ptr, *ptr2; - long p1, p2, p3; - BYTE res, b1, *bp; - UINT s1, s2, cnt; - DWORD ofs, sect = 0; - FATFS *fs; - - // PRINT OUT FatFS cfg metrics - PRINTF("\nFatFs module test monitor for SD-CARD/MMC\n"); - xputs(_USE_LFN ? PSTR("LFN Enabled") : PSTR("LFN Disabled")); - PRINTF(", Code page: %u\n", _CODE_PAGE); - PRINTF("RTC is not available.\n"); - - for (;;) { - xputc('>'); - ptr = Line; - - get_line(ptr, sizeof Line); - switch (*ptr++) { - - case 'T' : - while (*ptr == ' ') ptr++; - - /* Quick test space */ - - break; - - case 'd' : - switch (*ptr++) { - case 'd' : /* dd [] - Dump secrtor */ - if (!xatoi(&ptr, &p1)) break; - if (!xatoi(&ptr, &p2)) p2 = sect; - res = disk_read((BYTE)p1, Buff, p2, 1); - if (res) { xprintf(PSTR("rc=%d\n"), res); break; } - sect = p2 + 1; - xprintf(PSTR("Sector:%lu\n"), p2); - for (bp=Buff, ofs = 0; ofs < 0x200; bp+=16, ofs+=16) - put_dump(bp, ofs, 16); - break; - - // - case 'i' : /* di - Initialize disk */ - if (!xatoi(&ptr, &p1)) break; - xprintf(PSTR("rc=%d\n"), disk_initialize((BYTE)p1)); - break; - - // - case 's' : /* ds - Show disk status */ - if (!xatoi(&ptr, &p1)) break; - if (disk_ioctl((BYTE)p1, GET_SECTOR_COUNT, &p2) == RES_OK) - { xprintf(PSTR("Drive size: %lu sectors\n"), p2); } - if (disk_ioctl((BYTE)p1, GET_BLOCK_SIZE, &p2) == RES_OK) - { xprintf(PSTR("Erase block: %lu sectors\n"), p2); } - if (disk_ioctl((BYTE)p1, MMC_GET_TYPE, &b1) == RES_OK) - { xprintf(PSTR("Card type: %u\n"), b1); } - if (disk_ioctl((BYTE)p1, MMC_GET_CSD, Buff) == RES_OK) - { xputs(PSTR("CSD:\n")); put_dump(Buff, 0, 16); } - if (disk_ioctl((BYTE)p1, MMC_GET_CID, Buff) == RES_OK) - { xputs(PSTR("CID:\n")); put_dump(Buff, 0, 16); } - if (disk_ioctl((BYTE)p1, MMC_GET_OCR, Buff) == RES_OK) - { xputs(PSTR("OCR:\n")); put_dump(Buff, 0, 4); } - if (disk_ioctl((BYTE)p1, MMC_GET_SDSTAT, Buff) == RES_OK) { - xputs(PSTR("SD Status:\n")); - for (s1 = 0; s1 < 64; s1 += 16) put_dump(Buff+s1, s1, 16); - } - if (disk_ioctl((BYTE)p1, ATA_GET_MODEL, Line) == RES_OK) - { Line[40] = '\0'; xprintf(PSTR("Model: %s\n"), Line); } - if (disk_ioctl((BYTE)p1, ATA_GET_SN, Line) == RES_OK) - { Line[20] = '\0'; xprintf(PSTR("S/N: %s\n"), Line); } - break; - - case 'c' : /* Disk ioctl */ - switch (*ptr++) { - case 's' : /* dcs - CTRL_SYNC */ - if (!xatoi(&ptr, &p1)) break; - xprintf(PSTR("rc=%d\n"), disk_ioctl((BYTE)p1, CTRL_SYNC, 0)); - break; - } - break; - } - break; - - case 'b' : - switch (*ptr++) { - case 'd' : /* bd - Dump R/W buffer */ - if (!xatoi(&ptr, &p1)) break; - for (bp=&Buff[p1], ofs = p1, cnt = 32; cnt; cnt--, ptr+=16, ofs+=16) - put_dump(bp, ofs, 16); - break; - - case 'e' : /* be [] ... - Edit R/W buffer */ - if (!xatoi(&ptr, &p1)) break; - if (xatoi(&ptr, &p2)) { - do { - Buff[p1++] = (BYTE)p2; - } while (xatoi(&ptr, &p2)); - break; - } - for (;;) { - xprintf(PSTR("%04X %02X-"), (WORD)p1, Buff[p1]); - get_line(Line, sizeof Line); - ptr = Line; - if (*ptr == '.') break; - if (*ptr < ' ') { p1++; continue; } - if (xatoi(&ptr, &p2)) - Buff[p1++] = (BYTE)p2; - else - xputs(PSTR("???\n")); - } - break; - - case 'r' : /* br [] - Read disk into R/W buffer */ - if (!xatoi(&ptr, &p1)) break; - if (!xatoi(&ptr, &p2)) break; - if (!xatoi(&ptr, &p3)) p3 = 1; - xprintf(PSTR("rc=%u\n"), disk_read((BYTE)p1, Buff, p2, p3)); - break; - - case 'w' : /* bw [] - Write R/W buffer into disk */ - if (!xatoi(&ptr, &p1)) break; - if (!xatoi(&ptr, &p2)) break; - if (!xatoi(&ptr, &p3)) p3 = 1; - xprintf(PSTR("rc=%u\n"), disk_write((BYTE)p1, Buff, p2, p3)); - break; - - case 'f' : /* bf - Fill working buffer */ - if (!xatoi(&ptr, &p1)) break; - memset(Buff, (BYTE)p1, sizeof Buff); - break; - - } - break; - - case 'f' : - switch (*ptr++) { - - //fi - case 'i' : /* fi []- Initialize logical drive */ - if (!xatoi(&ptr, &p1) || (UINT)p1 > 9) break; - if (!xatoi(&ptr, &p2)) p2 = 0; - xsprintf(Line, PSTR("%u:"), (UINT)p1); - put_rc(f_mount(&FatFs[p1], Line, (BYTE)p2)); - break; - - //fs - case 's' : /* fs [] - Show logical drive status */ - while (*ptr == ' ') ptr++; - ptr2 = ptr; - res = f_getfree(ptr, (DWORD*)&p2, &fs); - if (res) { put_rc(res); break; } - xprintf(PSTR("FAT type = %u\nBytes/Cluster = %lu\nNumber of FATs = %u\n" - "Root DIR entries = %u\nSectors/FAT = %lu\nNumber of clusters = %lu\n" - "FAT start (lba) = %lu\nDIR start (lba,clustor) = %lu\nData start (lba) = %lu\n\n"), - fs->fs_type, (DWORD)fs->csize * 512, fs->n_fats, - fs->n_rootdir, fs->fsize, fs->n_fatent - 2, - fs->fatbase, fs->dirbase, fs->database - ); -#if _USE_LABEL - res = f_getlabel(ptr2, (char*)Buff, (DWORD*)&p1); - if (res) { put_rc(res); break; } - xprintf(Buff[0] ? PSTR("Volume name is %s\n") : PSTR("No volume label\n"), Buff); - xprintf(PSTR("Volume S/N is %04X-%04X\n"), (WORD)((DWORD)p1 >> 16), (WORD)(p1 & 0xFFFF)); -#endif - xputs(PSTR("...")); - AccSize = AccFiles = AccDirs = 0; - strcpy((char*)Buff, ptr); - res = scan_files((char*)Buff); - if (res) { put_rc(res); break; } - xprintf(PSTR("\r%u files, %lu bytes.\n%u folders.\n" - "%lu KB total disk space.\n%lu KB available.\n"), - AccFiles, AccSize, AccDirs, - (fs->n_fatent - 2) * (fs->csize / 2), p2 * (fs->csize / 2) - ); - break; - - //fl - case 'l' : /* fl [] - Directory listing */ - while (*ptr == ' ') ptr++; - res = f_opendir(&Dir, ptr); - if (res) { put_rc(res); break; } - p1 = s1 = s2 = 0; - for(;;) { - res = f_readdir(&Dir, &Finfo); - if ((res != FR_OK) || !Finfo.fname[0]) break; - if (Finfo.fattrib & AM_DIR) { - s2++; - } else { - s1++; p1 += Finfo.fsize; - } - xprintf(PSTR("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu %s"), - (Finfo.fattrib & AM_DIR) ? 'D' : '-', - (Finfo.fattrib & AM_RDO) ? 'R' : '-', - (Finfo.fattrib & AM_HID) ? 'H' : '-', - (Finfo.fattrib & AM_SYS) ? 'S' : '-', - (Finfo.fattrib & AM_ARC) ? 'A' : '-', - (Finfo.fdate >> 9) + 1980, (Finfo.fdate >> 5) & 15, Finfo.fdate & 31, - (Finfo.ftime >> 11), (Finfo.ftime >> 5) & 63, - Finfo.fsize, &(Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\n"), Lfname); -#else - xputc('\n'); -#endif - } - if (res == FR_OK) { - xprintf(PSTR("%4u File(s),%10lu bytes total\n%4u Dir(s)"), s1, p1, s2); - if (f_getfree(ptr, (DWORD*)&p1, &fs) == FR_OK) - xprintf(PSTR(", %10luK bytes free\n"), p1 * fs->csize / 2); - } - if (res) put_rc(res); - break; - - // - Открываем для чтения(FA_OPEN_READ = 0x1) файл "123.txt" - case 'o' : /* fo - Open a file */ - if (!xatoi(&ptr, &p1)) break; - while (*ptr == ' ') ptr++; - put_rc(f_open(&File[0], ptr, (BYTE)p1)); - break; - - case 'c' : /* fc - Close a file */ - put_rc(f_close(&File[0])); - break; - - case 'e' : /* fe - Seek file pointer */ - if (!xatoi(&ptr, &p1)) break; - res = f_lseek(&File[0], p1); - put_rc(res); - if (res == FR_OK) - xprintf(PSTR("fptr = %lu(0x%lX)\n"), File[0].fptr, File[0].fptr); - break; - - case 'r' : /* fr - read file */ - if (!xatoi(&ptr, &p1)) break; - p2 = 0; - cli(); Timer = 0; sei(); - while (p1) { - if (p1 >= sizeof Buff) { cnt = sizeof Buff; p1 -= sizeof Buff; } - else { cnt = (WORD)p1; p1 = 0; } - res = f_read(&File[0], Buff, cnt, &s2); - if (res != FR_OK) { put_rc(res); break; } - p2 += s2; - if (cnt != s2) break; - } - cli(); s2 = Timer; sei(); - xprintf(PSTR("%lu bytes read with %lu bytes/sec.\n"), p2, s2 ? (p2 * 100 / s2) : 0); - break; - - case 'd' : /* fd - read and dump file from current fp */ - if (!xatoi(&ptr, &p1)) break; - ofs = File[0].fptr; - while (p1) { - if (p1 >= 16) { cnt = 16; p1 -= 16; } - else { cnt = (WORD)p1; p1 = 0; } - res = f_read(&File[0], Buff, cnt, &cnt); - if (res != FR_OK) { put_rc(res); break; } - if (!cnt) break; - put_dump(Buff, ofs, cnt); - ofs += 16; - } - break; - - case 'w' : /* fw - write file */ - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2)) break; - memset(Buff, (BYTE)p2, sizeof Buff); - p2 = 0; - cli(); Timer = 0; sei(); - while (p1) { - if (p1 >= sizeof Buff) { cnt = sizeof Buff; p1 -= sizeof Buff; } - else { cnt = (WORD)p1; p1 = 0; } - res = f_write(&File[0], Buff, cnt, &s2); - if (res != FR_OK) { put_rc(res); break; } - p2 += s2; - if (cnt != s2) break; - } - cli(); s2 = Timer; sei(); - xprintf(PSTR("%lu bytes written with %lu bytes/sec.\n"), p2, s2 ? (p2 * 100 / s2) : 0); - break; - - case 'v' : /* fv - Truncate file */ - put_rc(f_truncate(&File[0])); - break; - - case 'n' : /* fn - Change file/dir name */ - while (*ptr == ' ') ptr++; - ptr2 = strchr(ptr, ' '); - if (!ptr2) break; - *ptr2++ = 0; - while (*ptr2 == ' ') ptr2++; - put_rc(f_rename(ptr, ptr2)); - break; - - case 'u' : /* fu - Unlink a file or dir */ - while (*ptr == ' ') ptr++; - put_rc(f_unlink(ptr)); - break; - - case 'k' : /* fk - Create a directory */ - while (*ptr == ' ') ptr++; - put_rc(f_mkdir(ptr)); - break; - - case 'a' : /* fa - Change file/dir attribute */ - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2)) break; - while (*ptr == ' ') ptr++; - put_rc(f_chmod(ptr, p1, p2)); - break; - - case 't' : /* ft */ - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break; - Finfo.fdate = ((p1 - 1980) << 9) | ((p2 & 15) << 5) | (p3 & 31); - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break; - Finfo.ftime = ((p1 & 31) << 11) | ((p2 & 63) << 5) | ((p3 >> 1) & 31); - while (*ptr == ' ') ptr++; - put_rc(f_utime(ptr, &Finfo)); - break; - - case 'x' : /* fx - Copy file */ - while (*ptr == ' ') ptr++; - ptr2 = strchr(ptr, ' '); - if (!ptr2) break; - *ptr2++ = 0; - while (*ptr2 == ' ') ptr2++; - xprintf(PSTR("Opening \"%s\""), ptr); - res = f_open(&File[0], ptr, FA_OPEN_EXISTING | FA_READ); - if (res) { - put_rc(res); - break; - } - xprintf(PSTR("\nCreating \"%s\""), ptr2); - res = f_open(&File[1], ptr2, FA_CREATE_ALWAYS | FA_WRITE); - if (res) { - put_rc(res); - f_close(&File[0]); - break; - } - xprintf(PSTR("\nCopying...")); - cli(); Timer = 0; sei(); - p1 = 0; - for (;;) { - res = f_read(&File[0], Buff, sizeof Buff, &s1); - if (res || s1 == 0) break; /* error or eof */ - res = f_write(&File[1], Buff, s1, &s2); - p1 += s2; - if (res || s2 < s1) break; /* error or disk full */ - } - if (res) put_rc(res); - cli(); s2 = Timer; sei(); - xprintf(PSTR("\n%lu bytes copied with %lu bytes/sec.\n"), p1, p1 * 100 / s2); - f_close(&File[0]); - f_close(&File[1]); - break; -#if _FS_RPATH - case 'g' : /* fg - Change current directory */ - while (*ptr == ' ') ptr++; - put_rc(f_chdir(ptr)); - break; -#if _VOLUMES >= 2 - case 'j' : /* fj - Change current drive */ - while (*ptr == ' ') ptr++; - put_rc(f_chdrive(ptr)); - break; -#endif -#if _FS_RPATH >= 2 - case 'q' : /* fq - Show current dir path */ - res = f_getcwd(Line, sizeof Line); - if (res) - put_rc(res); - else - xprintf(PSTR("%s\n"), Line); - break; -#endif -#endif -#if _USE_LABEL - case 'b' : /* fb - Set volume label */ - while (*ptr == ' ') ptr++; - put_rc(f_setlabel(ptr)); - break; -#endif -#if _USE_MKFS - case 'm' : /* fm - Create file system */ - if (!xatoi(&ptr, &p1) || (UINT)p1 > 9 || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break; - xprintf(PSTR("The drive %u will be formatted. Are you sure? (Y/n)="), (WORD)p1); - get_line(Line, sizeof Line); - if (*ptr == 'Y') { - xsprintf(Line, PSTR("%u:"), (UINT)p1); - put_rc(f_mkfs(Line, (BYTE)p2, (WORD)p3)); - } - break; -#endif - } - break; -#ifdef SOUND_DEFINED - case 'p' : /* p - Play RIFF-WAV file (upto data rate of 48kB/sec) */ - while (*ptr == ' ') ptr++; - res = f_open(&File[0], ptr, FA_READ); - if (res) { - put_rc(res); - } else { - load_wav(&File[0], "**** WAV PLAYER ****", Buff, sizeof Buff); - f_close(&File[0]); - } - break; -#endif -//!! RTC not released yet -/* - case 't' : // t [ ] - if (!RtcOk) break; - if (xatoi(&ptr, &p1)) { - rtc.year = (WORD)p1; - xatoi(&ptr, &p1); rtc.month = (BYTE)p1; - xatoi(&ptr, &p1); rtc.mday = (BYTE)p1; - xatoi(&ptr, &p1); rtc.hour = (BYTE)p1; - xatoi(&ptr, &p1); rtc.min = (BYTE)p1; - if (!xatoi(&ptr, &p1)) break; - rtc.sec = (BYTE)p1; - rtc_settime(&rtc); - } - rtc_gettime(&rtc); - xprintf(PSTR("%u/%u/%u %02u:%02u:%02u\n"), rtc.year, rtc.month, rtc.mday, rtc.hour, rtc.min, rtc.sec); - break; -*/ - case '?' : /* Show Command List */ - xputs(PSTR( - "[Disk contorls]\n" - " di - Initialize disk\n" - " dd [ ] - Dump a secrtor\n" - " ds - Show disk status\n" - " dcs - ioctl(CTRL_SYNC)\n" - "[Buffer controls]\n" - " bd - Dump working buffer\n" - " be [] ... - Edit working buffer\n" - " br [] - Read disk into working buffer\n" - " bw [] - Write working buffer into disk\n" - " bf - Fill working buffer\n" - "[File system controls]\n" - " fi [] - Force initialized the volume\n" - " fs [] - Show volume status\n" - " fl [] - Show a directory\n" - " fo - Open a file\n" - " fc - Close the file\n" - " fe - Move fp in normal seek\n" - " fd - Read and dump the file\n" - " fr - Read the file\n" - " fw - Write to the file\n" - " fn - Rename an object\n" - " fu - Unlink an object\n" - " fv - Truncate the file at current fp\n" - " fk - Create a directory\n" - " fa - Change object attribute\n" - " ft - Change timestamp of an object\n" - " fx - Copy a file\n" - " fg - Change current directory\n" - " fj - Change current drive\n" - " fq - Show current directory\n" - " fm - Create file system\n" - "[Misc commands]\n" - " p - Play RIFF-WAVE file\n" - " t [ ] - Set/Show current time\n" - "\n")); - break; - - } - } -} -#endif -//***************** ChaN FATFS related functions: END - - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - fatfs_tst(); //Quick self-test FATFS -#if EN_FS_MONITOR - fatfs_monitor(); //FATFS monitor terminal -#endif - while(1) - { - ; - } - - unsigned long prev_millis = 0; - unsigned long rx_millis = 0; - unsigned long uptime = 0; - uint16_t CharIn; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - if((millis()-prev_millis)>TICK_PER_SEC) - { - //Here every 1sec - wdt_reset(); // WDT reset at least every sec - prev_millis = millis(); - led1_tgl(); - PRINTF("Uptime %lu sec\r\n", uptime++); - //PRINTF("ADC5: %d\r\n", adc_read(5)); - - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - //PRINTF("SW1 is pressed\r\n"); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - }//if((millis()-prev_millis)>TICK_PER_SEC) - - if((millis()-rx_millis)>0) - { - // Here every 1 msec, to check UART RX - rx_millis = millis(); - - // GET UART RX Symbol - CharIn = uart_getc(); - - // Check if char exist - // Read until data in RX buffer present - while (( CharIn & UART_NO_DATA ) == 0) - { - wdt_reset(); // WDT reset at least every sec - //!! Debug only - //Read data from UART0 RX ring buffer & send back echo - uart_putc(CharIn+1); - // GET UART RX Symbol - CharIn = uart_getc(); - } - }//if((millis()-rx_millis)>0) - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< Chan lib - // Should not used here, because Chan xprintf redirect via stdout - //xfunc_out = uart1_putc; - //xfunc_out = uart_putc; - - //ADC init - adc_init(); - adc_read(0); //Dummy read - - - led1_conf(); - led1_low();// LED1 is OFF - - - sw1_conf();//SW1 internal pull-up - - sei(); //re-enable global interrupts - - return; -} - diff --git a/02_m1284p_FATFS_Chang_tst/mmc_avr.c b/02_m1284p_FATFS_Chang_tst/mmc_avr.c deleted file mode 100644 index 2d59360..0000000 --- a/02_m1284p_FATFS_Chang_tst/mmc_avr.c +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Slightly modified for M128 using - * maxx_ir 28.05.2015 - * - * PS. SPI Speed (4/8Mhz on F_CPU=16Mhz) set-up at: - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/02_m1284p_FATFS_Chang_tst/uart_extd.c b/02_m1284p_FATFS_Chang_tst/uart_extd.c deleted file mode 100644 index f4ad484..0000000 --- a/02_m1284p_FATFS_Chang_tst/uart_extd.c +++ /dev/null @@ -1,706 +0,0 @@ -/* - * Modified for different BUFFER_SIZE for UART0 && UART1 - * see below: UART0_RX_BUFFER_SIZE/UART1_RX_BUFFER_SIZE && UART0_TX_BUFFER_SIZE/UART1_TX_BUFFER_SIZE - * Ibragimov M. 7/03/2015 -*/ -/************************************************************************* -Title: Interrupt UART library with receive/transmit circular buffers -Author: Peter Fleury http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/02_m1284p_FATFS_LFN_Chang_tst/.cproject b/02_m1284p_FATFS_LFN_Chang_tst/.cproject deleted file mode 100644 index 057a2dc..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/.cproject +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/02_m1284p_FATFS_LFN_Chang_tst/.project b/02_m1284p_FATFS_LFN_Chang_tst/.project deleted file mode 100644 index d3793e1..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 02_m1284p_FATFS_LFN_Chang_tst - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/02_m1284p_FATFS_LFN_Chang_tst/ff/ccsbcs.c b/02_m1284p_FATFS_LFN_Chang_tst/ff/ccsbcs.c deleted file mode 100644 index 42e8a57..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/ff/ccsbcs.c +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/02_m1284p_FATFS_LFN_Chang_tst/ff/diskio.h b/02_m1284p_FATFS_LFN_Chang_tst/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/02_m1284p_FATFS_LFN_Chang_tst/ff/ff.c b/02_m1284p_FATFS_LFN_Chang_tst/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/02_m1284p_FATFS_LFN_Chang_tst/ff/ff.h b/02_m1284p_FATFS_LFN_Chang_tst/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/02_m1284p_FATFS_LFN_Chang_tst/ff/ffconf.h b/02_m1284p_FATFS_LFN_Chang_tst/ff/ffconf.h deleted file mode 100644 index a2f1b11..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 1 -#define _MAX_LFN 128 -/* 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 0 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/02_m1284p_FATFS_LFN_Chang_tst/ff/integer.h b/02_m1284p_FATFS_LFN_Chang_tst/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/02_m1284p_FATFS_LFN_Chang_tst/main.c b/02_m1284p_FATFS_LFN_Chang_tst/main.c deleted file mode 100644 index 96d7d0d..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/main.c +++ /dev/null @@ -1,1363 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -/* - * FatFS SD-card(SPI_SD-CS PB.0) monitor and test LFN - * Adapted for m1284p Eclipse 16Mhz - * (c) Ibragimov M. Russia Togliatty 17/12/2018 - * - * Optimization notes: - * -Os, not work!! (google reading says GCC version bug (FATFS monitos xprintf.. related)) - * -O3 - OK but size file huge - * -O2 - is OK - * Decide not use xitoa by Elm Chang (any way -Os not work :(( ) - * - * Two main functions for FATFS: - * 1. fatfs_tst() - Quick test base functions FATFS open-sd/work_with_directory/read-write_file etc.. - * 2. fatfs_monitor() - Command terminal for FATFS test - * Commands sequence example: - * - * >di 0 - * >fi 0 1 - * >fs - * >fl - * >fo 1 readme.txt - * >fd 100 - * >fc - * - * Warning!! - * To work properly, need disconnect SPI programmer (SD-Card not work with MKII programmer connected!!) - * - */ - -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" - -//#include // itoa etc.. - -//******************************* Fat FS declare related: BEGIN -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -//#include "xitoa.h" // ChaN light libs similar like && - -#define EN_FS_MONITOR 0 -//#define EN_FS_MONITOR 1 //works only with -O3/-O2/-O1/-O0 - preffered use -O2 - -typedef char PROGMEM prog_char; -#define xprintf printf_P -#define xputc uart_putc -#define xputs printf_P -#define xsprintf sprintf_P - - -DWORD AccSize; /* Work register for fs command */ -WORD AccFiles, AccDirs; -FILINFO Finfo; -#if _USE_LFN -char Lfname[_MAX_LFN+1]; -#endif - -char Line[80]; /* Console input buffer */ -BYTE Buff[2048]; /* Working buffer */ - -FATFS FatFs[_VOLUMES]; /* File system object for each logical drive */ //!! Urgent must be always global!! -FIL File[2]; /* File object */ -DIR Dir; /* Directory object */ - - -BYTE RtcOk; /* RTC is available */ - -volatile UINT Timer; /* Performance timer (100Hz increment) (for FatFS test)*/ - -/*----------------------------------------------*/ -/* Get a value of the string */ -/*----------------------------------------------*/ -/* "123 -5 0x3ff 0b1111 0377 w " - ^ 1st call returns 123 and next ptr - ^ 2nd call returns -5 and next ptr - ^ 3rd call returns 1023 and next ptr - ^ 4th call returns 15 and next ptr - ^ 5th call returns 255 and next ptr - ^ 6th call fails and returns 0 -*/ - -int xatoi ( /* 0:Failed, 1:Successful */ - char **str, /* Pointer to pointer to the string */ - long *res /* Pointer to the valiable to store the value */ -) -{ - unsigned long val; - unsigned char c, r, s = 0; - - - *res = 0; - - while ((c = **str) == ' ') (*str)++; /* Skip leading spaces */ - - if (c == '-') { /* negative? */ - s = 1; - c = *(++(*str)); - } - - if (c == '0') { - c = *(++(*str)); - switch (c) { - case 'x': /* hexdecimal */ - r = 16; c = *(++(*str)); - break; - case 'b': /* binary */ - r = 2; c = *(++(*str)); - break; - default: - if (c <= ' ') return 1; /* single zero */ - if (c < '0' || c > '9') return 0; /* invalid char */ - r = 8; /* octal */ - } - } else { - if (c < '0' || c > '9') return 0; /* EOL or invalid char */ - r = 10; /* decimal */ - } - - val = 0; - while (c > ' ') { - if (c >= 'a') c -= 0x20; - c -= '0'; - if (c >= 17) { - c -= 7; - if (c <= 9) return 0; /* invalid char */ - } - if (c >= r) return 0; /* invalid char for current radix */ - val = val * r + c; - c = *(++(*str)); - } - if (s) val = 0 - val; /* apply sign if needed */ - - *res = val; - return 1; -} - -//************************* Fat FS declare related: END - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -//#define PRINTF(FORMAT,args...) xprintf(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif -/* -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif -*/ -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -static inline unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. -*/ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<= ' ') && (i < len - 1)) // Fill symbols in buff - { - buff[i++] = c; - //uart1_putc(c); - uart_putc(c); - } - } - buff[i] = 0; - //uart1_putc('\n'); - uart_putc('\n'); -} - -static -void put_dump (const BYTE *buff, DWORD ofs, BYTE cnt) -{ - BYTE i; - - - xprintf(PSTR("%08lX:"), ofs); - - for(i = 0; i < cnt; i++) - xprintf(PSTR(" %02X"), buff[i]); - - xputc(' '); - for(i = 0; i < cnt; i++) - xputc((buff[i] >= ' ' && buff[i] <= '~') ? buff[i] : '.'); - - xputc('\n'); -} - -static void ls_dir(char* path) -{ - DIR Dir; - FILINFO _Finfo; - BYTE res; - long p1, p2; - UINT s1, s2; - //while (*ptr == ' ') ptr++; - res = f_opendir(&Dir, path); - if (res) { put_rc(res); return; } - p1 = s1 = s2 = 0; -#if _USE_LFN - //Init buffer for LFN NAME (Without this LFN NAME not visible!!) - //Also look here: - /* - * http://microsin.net/programming/file-systems/fatfs-read-dir.html - * https://electronix.ru/forum/index.php?app=forums&module=forums&controller=topic&id=122267 - */ - _Finfo.lfname = Lfname; - _Finfo.lfsize = sizeof(Lfname); -#endif - - for(;;) { - res = f_readdir(&Dir, &_Finfo); - if ((res != FR_OK) || !_Finfo.fname[0]) break; - if (_Finfo.fattrib & AM_DIR) { - s2++; - } else { - s1++; p1 += _Finfo.fsize; - } - PRINTF("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu %s", - (_Finfo.fattrib & AM_DIR) ? 'D' : '-', - (_Finfo.fattrib & AM_RDO) ? 'R' : '-', - (_Finfo.fattrib & AM_HID) ? 'H' : '-', - (_Finfo.fattrib & AM_SYS) ? 'S' : '-', - (_Finfo.fattrib & AM_ARC) ? 'A' : '-', - (_Finfo.fdate >> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - -} - -static -void put_rc (FRESULT rc) -{ - const prog_char *p; - static const prog_char str[] = - "OK\0" "DISK_ERR\0" "INT_ERR\0" "NOT_READY\0" "NO_FILE\0" "NO_PATH\0" - "INVALID_NAME\0" "DENIED\0" "EXIST\0" "INVALID_OBJECT\0" "WRITE_PROTECTED\0" - "INVALID_DRIVE\0" "NOT_ENABLED\0" "NO_FILE_SYSTEM\0" "MKFS_ABORTED\0" "TIMEOUT\0" - "LOCKED\0" "NOT_ENOUGH_CORE\0" "TOO_MANY_OPEN_FILES\0"; - FRESULT i; - - for (p = str, i = 0; i != rc && pgm_read_byte_near(p); i++) { - while(pgm_read_byte_near(p++)); - } - xprintf(PSTR("rc=%u FR_%S\r\n"), rc, p); -} - -//------------------------------------------------------------------ - -// Blocking receive one symbol from uart -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -void fatfs_tst(void) -{ - FRESULT f_err_code; - FIL fil_obj; - char buff[128]; // Read-write buffer - //disk_initialize(0); // Init drive - //f_err_code=f_mount(0, &FATFS_Obj); //Mount Fat Fs - f_err_code=f_mount(&FatFs[0], "", 1); /* Give a work area to the default drive */ - /* - * f_mount(&Fatfs, "", 1) - mount immediatly - * f_mount(&Fatfs, "", 0) - not mount (delayed mount) - */ - - PRINTF (">>Try mounting SD-CARD FAT.. "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - - f_err_code=f_mkdir ("newdir"); // Create newdir - PRINTF (">>creating "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - f_err_code=f_chdir ("newdir"); // Set newdir to current directore - PRINTF (">>change default dir to "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - f_err_code=f_mkdir ("newdir2"); //Create newdir2 into newdir - PRINTF (">>creating into "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - //!! Open file only once - for creating - //f_err_code=f_open(&fil_obj, "newfile.txt",FA_CREATE_NEW|FA_WRITE); - - //!!Overwrite file on open - //f_err_code=f_open(&fil_obj, "newfile.txt",FA_CREATE_ALWAYS|FA_WRITE); - - //!!Auto Create && Append file mode (using f_lseek..) - f_err_code=f_open(&fil_obj, "newfile.txt",FA_OPEN_ALWAYS|FA_WRITE); - /* Move to end of the file to append data */ - //This need only for append - f_lseek(&fil_obj, f_size(&fil_obj)); - - - PRINTF (">>creating(appending) into "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - //!!Only if _USE_STRFUNC = 1/2 (ffconf.h) - //f_puts("creating and writing ok if you see this\r", &fil_obj); //Writing to newfile - UINT bw; - char msg[32]; - sprintf_P(msg, PSTR("%S"), PSTR("It works!\r\nAnd works..\r\n")); - f_write(&fil_obj, msg, strlen(msg), &bw); /* Write data to the file */ - PRINTF(">>writing data to \r\n"); - - f_err_code=f_close(&fil_obj); // Close newfile - PRINTF (">>closing "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - f_err_code=f_open(&fil_obj, "newfile.txt",FA_READ); //Open newfile for reading - PRINTF (">>open "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - PRINTF (">>data in :\r\n"); - //!!Only if _USE_STRFUNC = 1/2 (ffconf.h) - //PRINTF ("%s", f_gets (buff,128,&fil_obj)); //Read data from newfile - UINT cb; - f_read(&fil_obj, buff, 128, &cb); - if(cb < 128) - buff[cb] = 0x0; - else - buff[127] = 0x0; - PRINTF("%s", buff); - - f_err_code=f_close(&fil_obj); - PRINTF ("\r\n>>closing "); //Close newfile - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - - PRINTF ("OK\r\n\r\nSD-Card list:\r\n"); - PRINTF ("===============================================\r\n"); - f_chdir("/"); - //ls_dir("newdir"); //Scan newdir - ls_dir("/"); //Scan root dir - PRINTF ("===============================================\r\n\r\n"); - - - _delay_ms(100); - uart0_rx_flash(); - PRINTF("\r\n>>remove into y/N \r\n"); - if (uart0_receive()=='y') - { - f_chdir("newdir"); - f_err_code=f_unlink ("newdir2"); // Delete newdir2 - PRINTF ("\r\n>>removing "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - } - - _delay_ms(100); - uart0_rx_flash(); - PRINTF("\r\n>>remove into ? y/N \r\n"); - - if (uart0_receive()=='y') - { - f_err_code=f_unlink ("/newdir/newfile.txt"); //Delete newfile - PRINTF ("\r\n>>removing "); - if(f_err_code==0) - { - PRINTF ("OK\r\n"); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - } - } - - - _delay_ms(100); - uart0_rx_flash(); - PRINTF("\r\nFAT FS tests finished..\r\nReboot the programm? y/N \r\n"); - - if (uart0_receive()=='y') - { - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - - PRINTF("\r\n>>>Running main programm..\r\n"); - //*****************FAT FS Test: END - - /* - while(1) - { - wdt_reset(); - } - */ -} - -#if EN_FS_MONITOR -void fatfs_monitor(void) -{ - char *ptr, *ptr2; - long p1, p2, p3; - BYTE res, b1, *bp; - UINT s1, s2, cnt; - DWORD ofs, sect = 0; - FATFS *fs; - - // PRINT OUT FatFS cfg metrics - PRINTF("\nFatFs module test monitor for SD-CARD/MMC\n"); - xputs(_USE_LFN ? PSTR("LFN Enabled") : PSTR("LFN Disabled")); - PRINTF(", Code page: %u\n", _CODE_PAGE); - PRINTF("RTC is not available.\n"); - - for (;;) { - xputc('>'); - ptr = Line; - - get_line(ptr, sizeof Line); - switch (*ptr++) { - - case 'T' : - while (*ptr == ' ') ptr++; - - /* Quick test space */ - - break; - - case 'd' : - switch (*ptr++) { - case 'd' : /* dd [] - Dump secrtor */ - if (!xatoi(&ptr, &p1)) break; - if (!xatoi(&ptr, &p2)) p2 = sect; - res = disk_read((BYTE)p1, Buff, p2, 1); - if (res) { xprintf(PSTR("rc=%d\n"), res); break; } - sect = p2 + 1; - xprintf(PSTR("Sector:%lu\n"), p2); - for (bp=Buff, ofs = 0; ofs < 0x200; bp+=16, ofs+=16) - put_dump(bp, ofs, 16); - break; - - // - case 'i' : /* di - Initialize disk */ - if (!xatoi(&ptr, &p1)) break; - xprintf(PSTR("rc=%d\n"), disk_initialize((BYTE)p1)); - break; - - // - case 's' : /* ds - Show disk status */ - if (!xatoi(&ptr, &p1)) break; - if (disk_ioctl((BYTE)p1, GET_SECTOR_COUNT, &p2) == RES_OK) - { xprintf(PSTR("Drive size: %lu sectors\n"), p2); } - if (disk_ioctl((BYTE)p1, GET_BLOCK_SIZE, &p2) == RES_OK) - { xprintf(PSTR("Erase block: %lu sectors\n"), p2); } - if (disk_ioctl((BYTE)p1, MMC_GET_TYPE, &b1) == RES_OK) - { xprintf(PSTR("Card type: %u\n"), b1); } - if (disk_ioctl((BYTE)p1, MMC_GET_CSD, Buff) == RES_OK) - { xputs(PSTR("CSD:\n")); put_dump(Buff, 0, 16); } - if (disk_ioctl((BYTE)p1, MMC_GET_CID, Buff) == RES_OK) - { xputs(PSTR("CID:\n")); put_dump(Buff, 0, 16); } - if (disk_ioctl((BYTE)p1, MMC_GET_OCR, Buff) == RES_OK) - { xputs(PSTR("OCR:\n")); put_dump(Buff, 0, 4); } - if (disk_ioctl((BYTE)p1, MMC_GET_SDSTAT, Buff) == RES_OK) { - xputs(PSTR("SD Status:\n")); - for (s1 = 0; s1 < 64; s1 += 16) put_dump(Buff+s1, s1, 16); - } - if (disk_ioctl((BYTE)p1, ATA_GET_MODEL, Line) == RES_OK) - { Line[40] = '\0'; xprintf(PSTR("Model: %s\n"), Line); } - if (disk_ioctl((BYTE)p1, ATA_GET_SN, Line) == RES_OK) - { Line[20] = '\0'; xprintf(PSTR("S/N: %s\n"), Line); } - break; - - case 'c' : /* Disk ioctl */ - switch (*ptr++) { - case 's' : /* dcs - CTRL_SYNC */ - if (!xatoi(&ptr, &p1)) break; - xprintf(PSTR("rc=%d\n"), disk_ioctl((BYTE)p1, CTRL_SYNC, 0)); - break; - } - break; - } - break; - - case 'b' : - switch (*ptr++) { - case 'd' : /* bd - Dump R/W buffer */ - if (!xatoi(&ptr, &p1)) break; - for (bp=&Buff[p1], ofs = p1, cnt = 32; cnt; cnt--, ptr+=16, ofs+=16) - put_dump(bp, ofs, 16); - break; - - case 'e' : /* be [] ... - Edit R/W buffer */ - if (!xatoi(&ptr, &p1)) break; - if (xatoi(&ptr, &p2)) { - do { - Buff[p1++] = (BYTE)p2; - } while (xatoi(&ptr, &p2)); - break; - } - for (;;) { - xprintf(PSTR("%04X %02X-"), (WORD)p1, Buff[p1]); - get_line(Line, sizeof Line); - ptr = Line; - if (*ptr == '.') break; - if (*ptr < ' ') { p1++; continue; } - if (xatoi(&ptr, &p2)) - Buff[p1++] = (BYTE)p2; - else - xputs(PSTR("???\n")); - } - break; - - case 'r' : /* br [] - Read disk into R/W buffer */ - if (!xatoi(&ptr, &p1)) break; - if (!xatoi(&ptr, &p2)) break; - if (!xatoi(&ptr, &p3)) p3 = 1; - xprintf(PSTR("rc=%u\n"), disk_read((BYTE)p1, Buff, p2, p3)); - break; - - case 'w' : /* bw [] - Write R/W buffer into disk */ - if (!xatoi(&ptr, &p1)) break; - if (!xatoi(&ptr, &p2)) break; - if (!xatoi(&ptr, &p3)) p3 = 1; - xprintf(PSTR("rc=%u\n"), disk_write((BYTE)p1, Buff, p2, p3)); - break; - - case 'f' : /* bf - Fill working buffer */ - if (!xatoi(&ptr, &p1)) break; - memset(Buff, (BYTE)p1, sizeof Buff); - break; - - } - break; - - case 'f' : - switch (*ptr++) { - - //fi - case 'i' : /* fi []- Initialize logical drive */ - if (!xatoi(&ptr, &p1) || (UINT)p1 > 9) break; - if (!xatoi(&ptr, &p2)) p2 = 0; - xsprintf(Line, PSTR("%u:"), (UINT)p1); - put_rc(f_mount(&FatFs[p1], Line, (BYTE)p2)); - break; - - //fs - case 's' : /* fs [] - Show logical drive status */ - while (*ptr == ' ') ptr++; - ptr2 = ptr; - res = f_getfree(ptr, (DWORD*)&p2, &fs); - if (res) { put_rc(res); break; } - xprintf(PSTR("FAT type = %u\nBytes/Cluster = %lu\nNumber of FATs = %u\n" - "Root DIR entries = %u\nSectors/FAT = %lu\nNumber of clusters = %lu\n" - "FAT start (lba) = %lu\nDIR start (lba,clustor) = %lu\nData start (lba) = %lu\n\n"), - fs->fs_type, (DWORD)fs->csize * 512, fs->n_fats, - fs->n_rootdir, fs->fsize, fs->n_fatent - 2, - fs->fatbase, fs->dirbase, fs->database - ); -#if _USE_LABEL - res = f_getlabel(ptr2, (char*)Buff, (DWORD*)&p1); - if (res) { put_rc(res); break; } - xprintf(Buff[0] ? PSTR("Volume name is %s\n") : PSTR("No volume label\n"), Buff); - xprintf(PSTR("Volume S/N is %04X-%04X\n"), (WORD)((DWORD)p1 >> 16), (WORD)(p1 & 0xFFFF)); -#endif - xputs(PSTR("...")); - AccSize = AccFiles = AccDirs = 0; - strcpy((char*)Buff, ptr); - res = scan_files((char*)Buff); - if (res) { put_rc(res); break; } - xprintf(PSTR("\r%u files, %lu bytes.\n%u folders.\n" - "%lu KB total disk space.\n%lu KB available.\n"), - AccFiles, AccSize, AccDirs, - (fs->n_fatent - 2) * (fs->csize / 2), p2 * (fs->csize / 2) - ); - break; - - //fl - case 'l' : /* fl [] - Directory listing */ - while (*ptr == ' ') ptr++; - res = f_opendir(&Dir, ptr); - if (res) { put_rc(res); break; } - p1 = s1 = s2 = 0; - for(;;) { - res = f_readdir(&Dir, &Finfo); - if ((res != FR_OK) || !Finfo.fname[0]) break; - if (Finfo.fattrib & AM_DIR) { - s2++; - } else { - s1++; p1 += Finfo.fsize; - } - xprintf(PSTR("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu %s"), - (Finfo.fattrib & AM_DIR) ? 'D' : '-', - (Finfo.fattrib & AM_RDO) ? 'R' : '-', - (Finfo.fattrib & AM_HID) ? 'H' : '-', - (Finfo.fattrib & AM_SYS) ? 'S' : '-', - (Finfo.fattrib & AM_ARC) ? 'A' : '-', - (Finfo.fdate >> 9) + 1980, (Finfo.fdate >> 5) & 15, Finfo.fdate & 31, - (Finfo.ftime >> 11), (Finfo.ftime >> 5) & 63, - Finfo.fsize, &(Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\n"), Lfname); -#else - xputc('\n'); -#endif - } - if (res == FR_OK) { - xprintf(PSTR("%4u File(s),%10lu bytes total\n%4u Dir(s)"), s1, p1, s2); - if (f_getfree(ptr, (DWORD*)&p1, &fs) == FR_OK) - xprintf(PSTR(", %10luK bytes free\n"), p1 * fs->csize / 2); - } - if (res) put_rc(res); - break; - - // - Открываем для чтения(FA_OPEN_READ = 0x1) файл "123.txt" - case 'o' : /* fo - Open a file */ - if (!xatoi(&ptr, &p1)) break; - while (*ptr == ' ') ptr++; - put_rc(f_open(&File[0], ptr, (BYTE)p1)); - break; - - case 'c' : /* fc - Close a file */ - put_rc(f_close(&File[0])); - break; - - case 'e' : /* fe - Seek file pointer */ - if (!xatoi(&ptr, &p1)) break; - res = f_lseek(&File[0], p1); - put_rc(res); - if (res == FR_OK) - xprintf(PSTR("fptr = %lu(0x%lX)\n"), File[0].fptr, File[0].fptr); - break; - - case 'r' : /* fr - read file */ - if (!xatoi(&ptr, &p1)) break; - p2 = 0; - cli(); Timer = 0; sei(); - while (p1) { - if (p1 >= sizeof Buff) { cnt = sizeof Buff; p1 -= sizeof Buff; } - else { cnt = (WORD)p1; p1 = 0; } - res = f_read(&File[0], Buff, cnt, &s2); - if (res != FR_OK) { put_rc(res); break; } - p2 += s2; - if (cnt != s2) break; - } - cli(); s2 = Timer; sei(); - xprintf(PSTR("%lu bytes read with %lu bytes/sec.\n"), p2, s2 ? (p2 * 100 / s2) : 0); - break; - - case 'd' : /* fd - read and dump file from current fp */ - if (!xatoi(&ptr, &p1)) break; - ofs = File[0].fptr; - while (p1) { - if (p1 >= 16) { cnt = 16; p1 -= 16; } - else { cnt = (WORD)p1; p1 = 0; } - res = f_read(&File[0], Buff, cnt, &cnt); - if (res != FR_OK) { put_rc(res); break; } - if (!cnt) break; - put_dump(Buff, ofs, cnt); - ofs += 16; - } - break; - - case 'w' : /* fw - write file */ - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2)) break; - memset(Buff, (BYTE)p2, sizeof Buff); - p2 = 0; - cli(); Timer = 0; sei(); - while (p1) { - if (p1 >= sizeof Buff) { cnt = sizeof Buff; p1 -= sizeof Buff; } - else { cnt = (WORD)p1; p1 = 0; } - res = f_write(&File[0], Buff, cnt, &s2); - if (res != FR_OK) { put_rc(res); break; } - p2 += s2; - if (cnt != s2) break; - } - cli(); s2 = Timer; sei(); - xprintf(PSTR("%lu bytes written with %lu bytes/sec.\n"), p2, s2 ? (p2 * 100 / s2) : 0); - break; - - case 'v' : /* fv - Truncate file */ - put_rc(f_truncate(&File[0])); - break; - - case 'n' : /* fn - Change file/dir name */ - while (*ptr == ' ') ptr++; - ptr2 = strchr(ptr, ' '); - if (!ptr2) break; - *ptr2++ = 0; - while (*ptr2 == ' ') ptr2++; - put_rc(f_rename(ptr, ptr2)); - break; - - case 'u' : /* fu - Unlink a file or dir */ - while (*ptr == ' ') ptr++; - put_rc(f_unlink(ptr)); - break; - - case 'k' : /* fk - Create a directory */ - while (*ptr == ' ') ptr++; - put_rc(f_mkdir(ptr)); - break; - - case 'a' : /* fa - Change file/dir attribute */ - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2)) break; - while (*ptr == ' ') ptr++; - put_rc(f_chmod(ptr, p1, p2)); - break; - - case 't' : /* ft */ - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break; - Finfo.fdate = ((p1 - 1980) << 9) | ((p2 & 15) << 5) | (p3 & 31); - if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break; - Finfo.ftime = ((p1 & 31) << 11) | ((p2 & 63) << 5) | ((p3 >> 1) & 31); - while (*ptr == ' ') ptr++; - put_rc(f_utime(ptr, &Finfo)); - break; - - case 'x' : /* fx - Copy file */ - while (*ptr == ' ') ptr++; - ptr2 = strchr(ptr, ' '); - if (!ptr2) break; - *ptr2++ = 0; - while (*ptr2 == ' ') ptr2++; - xprintf(PSTR("Opening \"%s\""), ptr); - res = f_open(&File[0], ptr, FA_OPEN_EXISTING | FA_READ); - if (res) { - put_rc(res); - break; - } - xprintf(PSTR("\nCreating \"%s\""), ptr2); - res = f_open(&File[1], ptr2, FA_CREATE_ALWAYS | FA_WRITE); - if (res) { - put_rc(res); - f_close(&File[0]); - break; - } - xprintf(PSTR("\nCopying...")); - cli(); Timer = 0; sei(); - p1 = 0; - for (;;) { - res = f_read(&File[0], Buff, sizeof Buff, &s1); - if (res || s1 == 0) break; /* error or eof */ - res = f_write(&File[1], Buff, s1, &s2); - p1 += s2; - if (res || s2 < s1) break; /* error or disk full */ - } - if (res) put_rc(res); - cli(); s2 = Timer; sei(); - xprintf(PSTR("\n%lu bytes copied with %lu bytes/sec.\n"), p1, p1 * 100 / s2); - f_close(&File[0]); - f_close(&File[1]); - break; -#if _FS_RPATH - case 'g' : /* fg - Change current directory */ - while (*ptr == ' ') ptr++; - put_rc(f_chdir(ptr)); - break; -#if _VOLUMES >= 2 - case 'j' : /* fj - Change current drive */ - while (*ptr == ' ') ptr++; - put_rc(f_chdrive(ptr)); - break; -#endif -#if _FS_RPATH >= 2 - case 'q' : /* fq - Show current dir path */ - res = f_getcwd(Line, sizeof Line); - if (res) - put_rc(res); - else - xprintf(PSTR("%s\n"), Line); - break; -#endif -#endif -#if _USE_LABEL - case 'b' : /* fb - Set volume label */ - while (*ptr == ' ') ptr++; - put_rc(f_setlabel(ptr)); - break; -#endif -#if _USE_MKFS - case 'm' : /* fm - Create file system */ - if (!xatoi(&ptr, &p1) || (UINT)p1 > 9 || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break; - xprintf(PSTR("The drive %u will be formatted. Are you sure? (Y/n)="), (WORD)p1); - get_line(Line, sizeof Line); - if (*ptr == 'Y') { - xsprintf(Line, PSTR("%u:"), (UINT)p1); - put_rc(f_mkfs(Line, (BYTE)p2, (WORD)p3)); - } - break; -#endif - } - break; -#ifdef SOUND_DEFINED - case 'p' : /* p - Play RIFF-WAV file (upto data rate of 48kB/sec) */ - while (*ptr == ' ') ptr++; - res = f_open(&File[0], ptr, FA_READ); - if (res) { - put_rc(res); - } else { - load_wav(&File[0], "**** WAV PLAYER ****", Buff, sizeof Buff); - f_close(&File[0]); - } - break; -#endif -//!! RTC not released yet -/* - case 't' : // t [ ] - if (!RtcOk) break; - if (xatoi(&ptr, &p1)) { - rtc.year = (WORD)p1; - xatoi(&ptr, &p1); rtc.month = (BYTE)p1; - xatoi(&ptr, &p1); rtc.mday = (BYTE)p1; - xatoi(&ptr, &p1); rtc.hour = (BYTE)p1; - xatoi(&ptr, &p1); rtc.min = (BYTE)p1; - if (!xatoi(&ptr, &p1)) break; - rtc.sec = (BYTE)p1; - rtc_settime(&rtc); - } - rtc_gettime(&rtc); - xprintf(PSTR("%u/%u/%u %02u:%02u:%02u\n"), rtc.year, rtc.month, rtc.mday, rtc.hour, rtc.min, rtc.sec); - break; -*/ - case '?' : /* Show Command List */ - xputs(PSTR( - "[Disk contorls]\n" - " di - Initialize disk\n" - " dd [ ] - Dump a secrtor\n" - " ds - Show disk status\n" - " dcs - ioctl(CTRL_SYNC)\n" - "[Buffer controls]\n" - " bd - Dump working buffer\n" - " be [] ... - Edit working buffer\n" - " br [] - Read disk into working buffer\n" - " bw [] - Write working buffer into disk\n" - " bf - Fill working buffer\n" - "[File system controls]\n" - " fi [] - Force initialized the volume\n" - " fs [] - Show volume status\n" - " fl [] - Show a directory\n" - " fo - Open a file\n" - " fc - Close the file\n" - " fe - Move fp in normal seek\n" - " fd - Read and dump the file\n" - " fr - Read the file\n" - " fw - Write to the file\n" - " fn - Rename an object\n" - " fu - Unlink an object\n" - " fv - Truncate the file at current fp\n" - " fk - Create a directory\n" - " fa - Change object attribute\n" - " ft - Change timestamp of an object\n" - " fx - Copy a file\n" - " fg - Change current directory\n" - " fj - Change current drive\n" - " fq - Show current directory\n" - " fm - Create file system\n" - "[Misc commands]\n" - " p - Play RIFF-WAVE file\n" - " t [ ] - Set/Show current time\n" - "\n")); - break; - - } - } -} -#endif -//***************** ChaN FATFS related functions: END - - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - fatfs_tst(); //Quick self-test FATFS -#if EN_FS_MONITOR - fatfs_monitor(); //FATFS monitor terminal -#endif - while(1) - { - ; - } - - unsigned long prev_millis = 0; - unsigned long rx_millis = 0; - unsigned long uptime = 0; - uint16_t CharIn; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - if((millis()-prev_millis)>TICK_PER_SEC) - { - //Here every 1sec - wdt_reset(); // WDT reset at least every sec - prev_millis = millis(); - led1_tgl(); - PRINTF("Uptime %lu sec\r\n", uptime++); - //PRINTF("ADC5: %d\r\n", adc_read(5)); - - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - //PRINTF("SW1 is pressed\r\n"); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - }//if((millis()-prev_millis)>TICK_PER_SEC) - - if((millis()-rx_millis)>0) - { - // Here every 1 msec, to check UART RX - rx_millis = millis(); - - // GET UART RX Symbol - CharIn = uart_getc(); - - // Check if char exist - // Read until data in RX buffer present - while (( CharIn & UART_NO_DATA ) == 0) - { - wdt_reset(); // WDT reset at least every sec - //!! Debug only - //Read data from UART0 RX ring buffer & send back echo - uart_putc(CharIn+1); - // GET UART RX Symbol - CharIn = uart_getc(); - } - }//if((millis()-rx_millis)>0) - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< Chan lib - // Should not used here, because Chan xprintf redirect via stdout - //xfunc_out = uart1_putc; - //xfunc_out = uart_putc; - - //ADC init - adc_init(); - adc_read(0); //Dummy read - - - led1_conf(); - led1_low();// LED1 is OFF - - - sw1_conf();//SW1 internal pull-up - - sei(); //re-enable global interrupts - - return; -} - diff --git a/02_m1284p_FATFS_LFN_Chang_tst/mmc_avr.c b/02_m1284p_FATFS_LFN_Chang_tst/mmc_avr.c deleted file mode 100644 index 2d59360..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/mmc_avr.c +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Slightly modified for M128 using - * maxx_ir 28.05.2015 - * - * PS. SPI Speed (4/8Mhz on F_CPU=16Mhz) set-up at: - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/02_m1284p_FATFS_LFN_Chang_tst/uart_extd.c b/02_m1284p_FATFS_LFN_Chang_tst/uart_extd.c deleted file mode 100644 index f4ad484..0000000 --- a/02_m1284p_FATFS_LFN_Chang_tst/uart_extd.c +++ /dev/null @@ -1,706 +0,0 @@ -/* - * Modified for different BUFFER_SIZE for UART0 && UART1 - * see below: UART0_RX_BUFFER_SIZE/UART1_RX_BUFFER_SIZE && UART0_TX_BUFFER_SIZE/UART1_TX_BUFFER_SIZE - * Ibragimov M. 7/03/2015 -*/ -/************************************************************************* -Title: Interrupt UART library with receive/transmit circular buffers -Author: Peter Fleury http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/.cproject b/03_m1284p_WIZNET_loopback_FATFS_template/.cproject deleted file mode 100644 index fac9f0c..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/.cproject +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/.project b/03_m1284p_WIZNET_loopback_FATFS_template/.project deleted file mode 100644 index cb5b146..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 03_m1284p_WIZNET_loopback_FATFS_template - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Application/loopback/loopback.c b/03_m1284p_WIZNET_loopback_FATFS_template/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Application/loopback/loopback.h b/03_m1284p_WIZNET_loopback_FATFS_template/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/W5500/w5500.c b/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/W5500/w5500.h b/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/socket.c b/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/socket.h b/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/wizchip_conf.c b/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/wizchip_conf.h b/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ccsbcs.c.unicode b/03_m1284p_WIZNET_loopback_FATFS_template/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/ff/diskio.h b/03_m1284p_WIZNET_loopback_FATFS_template/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ff.c b/03_m1284p_WIZNET_loopback_FATFS_template/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ff.h b/03_m1284p_WIZNET_loopback_FATFS_template/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ffconf.h b/03_m1284p_WIZNET_loopback_FATFS_template/ff/ffconf.h deleted file mode 100644 index bcaba72..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_READONLY 1 -/* 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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/ff/integer.h b/03_m1284p_WIZNET_loopback_FATFS_template/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/globals.h b/03_m1284p_WIZNET_loopback_FATFS_template/globals.h deleted file mode 100644 index 3fabed6..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/globals.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -//#include "Internet/httpServer_avr/httpParser.h" -static FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - - -//Should not use here -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" - -#define _MAIN_DEBUG_ - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -/* - * History: - * - * (3) WIZNET loopback + FATFS (as template) - * + Added FATFS init (from <02_m1284p_FATFS_Chang_tst>), - * Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.0 Static IP Loop-back && FATFS SDCARD template WIZNET_5500 ETHERNET 20/12/2018\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -/* -void spi_speed_tst(void) -{ - // Here on SPI pins: MOSI 400Khz freq out, on SCLK 3.2MhzOUT - while(1) - { - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - } -} -*/ - -int main() -{ - //uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - //spi_speed_tst(); / Here on SPI pins: MOSI 400Khz freq out, on SCLK 3.2MhzOUT (Witk SPI CLK 4Mhz) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } - - //Check ETHERNET PHY link - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/03_m1284p_WIZNET_loopback_FATFS_template/spi.c b/03_m1284p_WIZNET_loopback_FATFS_template/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/03_m1284p_WIZNET_loopback_FATFS_template/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/.cproject b/03_m1284p_WIZNET_loopback_STATIC_IP/.cproject deleted file mode 100644 index b5431c1..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/.cproject +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/.project b/03_m1284p_WIZNET_loopback_STATIC_IP/.project deleted file mode 100644 index b4c35e6..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 03_m1284p_WIZNET_loopback_STATIC_IP - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Application/loopback/loopback.c b/03_m1284p_WIZNET_loopback_STATIC_IP/Application/loopback/loopback.c deleted file mode 100644 index 8396cf7..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - PRINTF("%d:Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > LOOPBACK_DATA_BUF_SIZE) size = LOOPBACK_DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Listen, TCP server loopback, port [%u]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Connected to - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > LOOPBACK_DATA_BUF_SIZE) size = LOOPBACK_DATA_BUF_SIZE; // LOOPBACK_DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Try to connect to the %d.%d.%d.%d : %u\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > LOOPBACK_DATA_BUF_SIZE) size = LOOPBACK_DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Opened, UDP loopback, port [%u]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Application/loopback/loopback.h b/03_m1284p_WIZNET_loopback_STATIC_IP/Application/loopback/loopback.h deleted file mode 100644 index 5df3cff..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Application/loopback/loopback.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "../../globals.h" - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef LOOPBACK_DATA_BUF_SIZE - #define LOOPBACK_DATA_BUF_SIZE 512 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/W5500/w5500.c b/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/W5500/w5500.h b/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/socket.c b/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/socket.h b/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/wizchip_conf.c b/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/wizchip_conf.h b/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/globals.c b/03_m1284p_WIZNET_loopback_STATIC_IP/globals.c deleted file mode 100644 index 6b51aa0..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/globals.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - diff --git a/03_m1284p_WIZNET_loopback_STATIC_IP/globals.h b/03_m1284p_WIZNET_loopback_STATIC_IP/globals.h deleted file mode 100644 index 25410eb..0000000 --- a/03_m1284p_WIZNET_loopback_STATIC_IP/globals.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" - -//******************************* Fat FS declare related: BEGIN -/* -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -#include "Internet/httpServer_avr/httpParser.h" -static FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -*/ -//******************************* Fat FS declare related: END - - -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -#define LOOPBACK_DATA_BUF_SIZE 512 - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" - -#define _MAIN_DEBUG_ - -/* - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.0 Static IP Loop-back WIZNET_5500 ETHERNET 25/11/2018\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - uint32_t timer_uptime_60sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/04_m1284p_WIZNET_loopback_DHCP/.cproject b/04_m1284p_WIZNET_loopback_DHCP/.cproject deleted file mode 100644 index 08ae71f..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/.cproject +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/04_m1284p_WIZNET_loopback_DHCP/.project b/04_m1284p_WIZNET_loopback_DHCP/.project deleted file mode 100644 index 2e2dbf8..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 04_m1284p_WIZNET_loopback_DHCP - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/04_m1284p_WIZNET_loopback_DHCP/Application/loopback/loopback.c b/04_m1284p_WIZNET_loopback_DHCP/Application/loopback/loopback.c deleted file mode 100644 index 8396cf7..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - PRINTF("%d:Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > LOOPBACK_DATA_BUF_SIZE) size = LOOPBACK_DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Listen, TCP server loopback, port [%u]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Connected to - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > LOOPBACK_DATA_BUF_SIZE) size = LOOPBACK_DATA_BUF_SIZE; // LOOPBACK_DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Try to connect to the %d.%d.%d.%d : %u\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > LOOPBACK_DATA_BUF_SIZE) size = LOOPBACK_DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Opened, UDP loopback, port [%u]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/04_m1284p_WIZNET_loopback_DHCP/Application/loopback/loopback.h b/04_m1284p_WIZNET_loopback_DHCP/Application/loopback/loopback.h deleted file mode 100644 index 5df3cff..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Application/loopback/loopback.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "../../globals.h" - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef LOOPBACK_DATA_BUF_SIZE - #define LOOPBACK_DATA_BUF_SIZE 512 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/W5500/w5500.c b/04_m1284p_WIZNET_loopback_DHCP/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/W5500/w5500.h b/04_m1284p_WIZNET_loopback_DHCP/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/socket.c b/04_m1284p_WIZNET_loopback_DHCP/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/socket.h b/04_m1284p_WIZNET_loopback_DHCP/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/wizchip_conf.c b/04_m1284p_WIZNET_loopback_DHCP/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/wizchip_conf.h b/04_m1284p_WIZNET_loopback_DHCP/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/04_m1284p_WIZNET_loopback_DHCP/Internet/DHCP/dhcp.c b/04_m1284p_WIZNET_loopback_DHCP/Internet/DHCP/dhcp.c deleted file mode 100644 index 0741eaf..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Internet/DHCP/dhcp.c +++ /dev/null @@ -1,992 +0,0 @@ -//***************************************************************************** -// -//! \file dhcp.c -//! \brief DHCP APIs implement file. -//! \details Processing DHCP protocol as DISCOVER, OFFER, REQUEST, ACK, NACK and DECLINE. -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/11/18> 1st Release -//! <2012/12/20> V1.1.0 -//! 1. Optimize code -//! 2. Add reg_dhcp_cbfunc() -//! 3. Add DHCP_stop() -//! 4. Integrate check_DHCP_state() & DHCP_run() to DHCP_run() -//! 5. Don't care system endian -//! 6. Add comments -//! <2012/12/26> V1.1.1 -//! 1. Modify variable declaration: dhcp_tick_1s is declared volatile for code optimization -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#include "socket.h" -#include "dhcp.h" - -/* If you want to display debug & processing message, Define _DHCP_DEBUG_ in dhcp.h */ - -#ifdef _DHCP_DEBUG_ - #include -#endif - -/* DHCP state machine. */ -#define STATE_DHCP_INIT 0 ///< Initialize -#define STATE_DHCP_DISCOVER 1 ///< send DISCOVER and wait OFFER -#define STATE_DHCP_REQUEST 2 ///< send REQEUST and wait ACK or NACK -#define STATE_DHCP_LEASED 3 ///< ReceiveD ACK and IP leased -#define STATE_DHCP_REREQUEST 4 ///< send REQUEST for maintaining leased IP -#define STATE_DHCP_RELEASE 5 ///< No use -#define STATE_DHCP_STOP 6 ///< Stop processing DHCP - -#define DHCP_FLAGSBROADCAST 0x8000 ///< The broadcast value of flags in @ref RIP_MSG -#define DHCP_FLAGSUNICAST 0x0000 ///< The unicast value of flags in @ref RIP_MSG - -/* DHCP message OP code */ -#define DHCP_BOOTREQUEST 1 ///< Request Message used in op of @ref RIP_MSG -#define DHCP_BOOTREPLY 2 ///< Reply Message used i op of @ref RIP_MSG - -/* DHCP message type */ -#define DHCP_DISCOVER 1 ///< DISCOVER message in OPT of @ref RIP_MSG -#define DHCP_OFFER 2 ///< OFFER message in OPT of @ref RIP_MSG -#define DHCP_REQUEST 3 ///< REQUEST message in OPT of @ref RIP_MSG -#define DHCP_DECLINE 4 ///< DECLINE message in OPT of @ref RIP_MSG -#define DHCP_ACK 5 ///< ACK message in OPT of @ref RIP_MSG -#define DHCP_NAK 6 ///< NACK message in OPT of @ref RIP_MSG -#define DHCP_RELEASE 7 ///< RELEASE message in OPT of @ref RIP_MSG. No use -#define DHCP_INFORM 8 ///< INFORM message in OPT of @ref RIP_MSG. No use - -#define DHCP_HTYPE10MB 1 ///< Used in type of @ref RIP_MSG -#define DHCP_HTYPE100MB 2 ///< Used in type of @ref RIP_MSG - -#define DHCP_HLENETHERNET 6 ///< Used in hlen of @ref RIP_MSG -#define DHCP_HOPS 0 ///< Used in hops of @ref RIP_MSG -#define DHCP_SECS 0 ///< Used in secs of @ref RIP_MSG - -#define INFINITE_LEASETIME 0xffffffff ///< Infinite lease time - -#define OPT_SIZE 312 /// Max OPT size of @ref RIP_MSG -#define RIP_MSG_SIZE (236+OPT_SIZE) /// Max size of @ref RIP_MSG - -/* - * @brief DHCP option and value (cf. RFC1533) - */ -enum -{ - padOption = 0, - subnetMask = 1, - timerOffset = 2, - routersOnSubnet = 3, - timeServer = 4, - nameServer = 5, - dns = 6, - logServer = 7, - cookieServer = 8, - lprServer = 9, - impressServer = 10, - resourceLocationServer = 11, - hostName = 12, - bootFileSize = 13, - meritDumpFile = 14, - domainName = 15, - swapServer = 16, - rootPath = 17, - extentionsPath = 18, - IPforwarding = 19, - nonLocalSourceRouting = 20, - policyFilter = 21, - maxDgramReasmSize = 22, - defaultIPTTL = 23, - pathMTUagingTimeout = 24, - pathMTUplateauTable = 25, - ifMTU = 26, - allSubnetsLocal = 27, - broadcastAddr = 28, - performMaskDiscovery = 29, - maskSupplier = 30, - performRouterDiscovery = 31, - routerSolicitationAddr = 32, - staticRoute = 33, - trailerEncapsulation = 34, - arpCacheTimeout = 35, - ethernetEncapsulation = 36, - tcpDefaultTTL = 37, - tcpKeepaliveInterval = 38, - tcpKeepaliveGarbage = 39, - nisDomainName = 40, - nisServers = 41, - ntpServers = 42, - vendorSpecificInfo = 43, - netBIOSnameServer = 44, - netBIOSdgramDistServer = 45, - netBIOSnodeType = 46, - netBIOSscope = 47, - xFontServer = 48, - xDisplayManager = 49, - dhcpRequestedIPaddr = 50, - dhcpIPaddrLeaseTime = 51, - dhcpOptionOverload = 52, - dhcpMessageType = 53, - dhcpServerIdentifier = 54, - dhcpParamRequest = 55, - dhcpMsg = 56, - dhcpMaxMsgSize = 57, - dhcpT1value = 58, - dhcpT2value = 59, - dhcpClassIdentifier = 60, - dhcpClientIdentifier = 61, - endOption = 255 -}; - -/* - * @brief DHCP message format - */ -typedef struct { - uint8_t op; ///< @ref DHCP_BOOTREQUEST or @ref DHCP_BOOTREPLY - uint8_t htype; ///< @ref DHCP_HTYPE10MB or @ref DHCP_HTYPE100MB - uint8_t hlen; ///< @ref DHCP_HLENETHERNET - uint8_t hops; ///< @ref DHCP_HOPS - uint32_t xid; ///< @ref DHCP_XID This increase one every DHCP transaction. - uint16_t secs; ///< @ref DHCP_SECS - uint16_t flags; ///< @ref DHCP_FLAGSBROADCAST or @ref DHCP_FLAGSUNICAST - uint8_t ciaddr[4]; ///< @ref Request IP to DHCP sever - uint8_t yiaddr[4]; ///< @ref Offered IP from DHCP server - uint8_t siaddr[4]; ///< No use - uint8_t giaddr[4]; ///< No use - uint8_t chaddr[16]; ///< DHCP client 6bytes MAC address. Others is filled to zero - uint8_t sname[64]; ///< No use - uint8_t file[128]; ///< No use - uint8_t OPT[OPT_SIZE]; ///< Option -} RIP_MSG; - - - -uint8_t DHCP_SOCKET; // Socket number for DHCP - -uint8_t DHCP_SIP[4]; // DHCP Server IP address - -// Network information from DHCP Server -uint8_t OLD_allocated_ip[4] = {0, }; // Previous IP address -uint8_t DHCP_allocated_ip[4] = {0, }; // IP address from DHCP -uint8_t DHCP_allocated_gw[4] = {0, }; // Gateway address from DHCP -uint8_t DHCP_allocated_sn[4] = {0, }; // Subnet mask from DHCP -uint8_t DHCP_allocated_dns[4] = {0, }; // DNS address from DHCP - - -int8_t dhcp_state = STATE_DHCP_INIT; // DHCP state -int8_t dhcp_retry_count = 0; - -uint32_t dhcp_lease_time = INFINITE_LEASETIME; -volatile uint32_t dhcp_tick_1s = 0; // unit 1 second -uint32_t dhcp_tick_next = DHCP_WAIT_TIME ; - -uint32_t DHCP_XID; // Any number - -RIP_MSG* pDHCPMSG; // Buffer pointer for DHCP processing - -uint8_t HOST_NAME[] = DCHP_HOST_NAME; - -uint8_t DHCP_CHADDR[6]; // DHCP Client MAC address. - -/* The default callback function */ -void default_ip_assign(void); -void default_ip_update(void); -void default_ip_conflict(void); - -/* Callback handler */ -void (*dhcp_ip_assign)(void) = default_ip_assign; /* handler to be called when the IP address from DHCP server is first assigned */ -void (*dhcp_ip_update)(void) = default_ip_update; /* handler to be called when the IP address from DHCP server is updated */ -void (*dhcp_ip_conflict)(void) = default_ip_conflict; /* handler to be called when the IP address from DHCP server is conflict */ - -void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void)); - -char NibbleToHex(uint8_t nibble); - -/* send DISCOVER message to DHCP server */ -void send_DHCP_DISCOVER(void); - -/* send REQEUST message to DHCP server */ -void send_DHCP_REQUEST(void); - -/* send DECLINE message to DHCP server */ -void send_DHCP_DECLINE(void); - -/* IP conflict check by sending ARP-request to leased IP and wait ARP-response. */ -int8_t check_DHCP_leasedIP(void); - -/* check the timeout in DHCP process */ -uint8_t check_DHCP_timeout(void); - -/* Initialize to timeout process. */ -void reset_DHCP_timeout(void); - -/* Parse message as OFFER and ACK and NACK from DHCP server.*/ -int8_t parseDHCPCMSG(void); - -/* The default handler of ip assign first */ -void default_ip_assign(void) -{ - setSIPR(DHCP_allocated_ip); - setSUBR(DHCP_allocated_sn); - setGAR (DHCP_allocated_gw); -} - -/* The default handler of ip changed */ -void default_ip_update(void) -{ - /* WIZchip Software Reset */ - setMR(MR_RST); - getMR(); // for delay - default_ip_assign(); - setSHAR(DHCP_CHADDR); -} - -/* The default handler of ip changed */ -void default_ip_conflict(void) -{ - // WIZchip Software Reset - setMR(MR_RST); - getMR(); // for delay - setSHAR(DHCP_CHADDR); -} - -/* register the call back func. */ -void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void)) -{ - dhcp_ip_assign = default_ip_assign; - dhcp_ip_update = default_ip_update; - dhcp_ip_conflict = default_ip_conflict; - if(ip_assign) dhcp_ip_assign = ip_assign; - if(ip_update) dhcp_ip_update = ip_update; - if(ip_conflict) dhcp_ip_conflict = ip_conflict; -} - -/* make the common DHCP message */ -void makeDHCPMSG(void) -{ - uint8_t bk_mac[6]; - uint8_t* ptmp; - uint8_t i; - getSHAR(bk_mac); - pDHCPMSG->op = DHCP_BOOTREQUEST; - pDHCPMSG->htype = DHCP_HTYPE10MB; - pDHCPMSG->hlen = DHCP_HLENETHERNET; - pDHCPMSG->hops = DHCP_HOPS; - ptmp = (uint8_t*)(&pDHCPMSG->xid); - *(ptmp+0) = (uint8_t)((DHCP_XID & 0xFF000000) >> 24); - *(ptmp+1) = (uint8_t)((DHCP_XID & 0x00FF0000) >> 16); - *(ptmp+2) = (uint8_t)((DHCP_XID & 0x0000FF00) >> 8); - *(ptmp+3) = (uint8_t)((DHCP_XID & 0x000000FF) >> 0); - pDHCPMSG->secs = DHCP_SECS; - ptmp = (uint8_t*)(&pDHCPMSG->flags); - *(ptmp+0) = (uint8_t)((DHCP_FLAGSBROADCAST & 0xFF00) >> 8); - *(ptmp+1) = (uint8_t)((DHCP_FLAGSBROADCAST & 0x00FF) >> 0); - - pDHCPMSG->ciaddr[0] = 0; - pDHCPMSG->ciaddr[1] = 0; - pDHCPMSG->ciaddr[2] = 0; - pDHCPMSG->ciaddr[3] = 0; - - pDHCPMSG->yiaddr[0] = 0; - pDHCPMSG->yiaddr[1] = 0; - pDHCPMSG->yiaddr[2] = 0; - pDHCPMSG->yiaddr[3] = 0; - - pDHCPMSG->siaddr[0] = 0; - pDHCPMSG->siaddr[1] = 0; - pDHCPMSG->siaddr[2] = 0; - pDHCPMSG->siaddr[3] = 0; - - pDHCPMSG->giaddr[0] = 0; - pDHCPMSG->giaddr[1] = 0; - pDHCPMSG->giaddr[2] = 0; - pDHCPMSG->giaddr[3] = 0; - - pDHCPMSG->chaddr[0] = DHCP_CHADDR[0]; - pDHCPMSG->chaddr[1] = DHCP_CHADDR[1]; - pDHCPMSG->chaddr[2] = DHCP_CHADDR[2]; - pDHCPMSG->chaddr[3] = DHCP_CHADDR[3]; - pDHCPMSG->chaddr[4] = DHCP_CHADDR[4]; - pDHCPMSG->chaddr[5] = DHCP_CHADDR[5]; - - for (i = 6; i < 16; i++) pDHCPMSG->chaddr[i] = 0; - for (i = 0; i < 64; i++) pDHCPMSG->sname[i] = 0; - for (i = 0; i < 128; i++) pDHCPMSG->file[i] = 0; - - // MAGIC_COOKIE - pDHCPMSG->OPT[0] = (uint8_t)((MAGIC_COOKIE & 0xFF000000) >> 24); - pDHCPMSG->OPT[1] = (uint8_t)((MAGIC_COOKIE & 0x00FF0000) >> 16); - pDHCPMSG->OPT[2] = (uint8_t)((MAGIC_COOKIE & 0x0000FF00) >> 8); - pDHCPMSG->OPT[3] = (uint8_t) (MAGIC_COOKIE & 0x000000FF) >> 0; -} - -/* SEND DHCP DISCOVER */ -void send_DHCP_DISCOVER(void) -{ - uint16_t i; - uint8_t ip[4]; - uint16_t k = 0; - - makeDHCPMSG(); - - k = 4; // because MAGIC_COOKIE already made by makeDHCPMSG() - - // Option Request Param - pDHCPMSG->OPT[k++] = dhcpMessageType; - pDHCPMSG->OPT[k++] = 0x01; - pDHCPMSG->OPT[k++] = DHCP_DISCOVER; - - // Client identifier - pDHCPMSG->OPT[k++] = dhcpClientIdentifier; - pDHCPMSG->OPT[k++] = 0x07; - pDHCPMSG->OPT[k++] = 0x01; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[0]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[1]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[2]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[3]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[4]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[5]; - - // host name - pDHCPMSG->OPT[k++] = hostName; - pDHCPMSG->OPT[k++] = 0; // fill zero length of hostname - for(i = 0 ; HOST_NAME[i] != 0; i++) - pDHCPMSG->OPT[k++] = HOST_NAME[i]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[3]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[4]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[5]; - pDHCPMSG->OPT[k - (i+3+1)] = i+3; // length of hostname - - pDHCPMSG->OPT[k++] = dhcpParamRequest; - pDHCPMSG->OPT[k++] = 0x06; // length of request - pDHCPMSG->OPT[k++] = subnetMask; - pDHCPMSG->OPT[k++] = routersOnSubnet; - pDHCPMSG->OPT[k++] = dns; - pDHCPMSG->OPT[k++] = domainName; - pDHCPMSG->OPT[k++] = dhcpT1value; - pDHCPMSG->OPT[k++] = dhcpT2value; - pDHCPMSG->OPT[k++] = endOption; - - for (i = k; i < OPT_SIZE; i++) pDHCPMSG->OPT[i] = 0; - - // send broadcasting packet - ip[0] = 255; - ip[1] = 255; - ip[2] = 255; - ip[3] = 255; - -#ifdef _DHCP_DEBUG_ - printf("> Send DHCP_DISCOVER\r\n"); -#endif - - sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT); -} - -/* SEND DHCP REQUEST */ -void send_DHCP_REQUEST(void) -{ - int i; - uint8_t ip[4]; - uint16_t k = 0; - - makeDHCPMSG(); - - if(dhcp_state == STATE_DHCP_LEASED || dhcp_state == STATE_DHCP_REREQUEST) - { - *((uint8_t*)(&pDHCPMSG->flags)) = ((DHCP_FLAGSUNICAST & 0xFF00)>> 8); - *((uint8_t*)(&pDHCPMSG->flags)+1) = (DHCP_FLAGSUNICAST & 0x00FF); - pDHCPMSG->ciaddr[0] = DHCP_allocated_ip[0]; - pDHCPMSG->ciaddr[1] = DHCP_allocated_ip[1]; - pDHCPMSG->ciaddr[2] = DHCP_allocated_ip[2]; - pDHCPMSG->ciaddr[3] = DHCP_allocated_ip[3]; - ip[0] = DHCP_SIP[0]; - ip[1] = DHCP_SIP[1]; - ip[2] = DHCP_SIP[2]; - ip[3] = DHCP_SIP[3]; - } - else - { - ip[0] = 255; - ip[1] = 255; - ip[2] = 255; - ip[3] = 255; - } - - k = 4; // because MAGIC_COOKIE already made by makeDHCPMSG() - - // Option Request Param. - pDHCPMSG->OPT[k++] = dhcpMessageType; - pDHCPMSG->OPT[k++] = 0x01; - pDHCPMSG->OPT[k++] = DHCP_REQUEST; - - pDHCPMSG->OPT[k++] = dhcpClientIdentifier; - pDHCPMSG->OPT[k++] = 0x07; - pDHCPMSG->OPT[k++] = 0x01; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[0]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[1]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[2]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[3]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[4]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[5]; - - if(ip[3] == 255) // if(dchp_state == STATE_DHCP_LEASED || dchp_state == DHCP_REREQUEST_STATE) - { - pDHCPMSG->OPT[k++] = dhcpRequestedIPaddr; - pDHCPMSG->OPT[k++] = 0x04; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[0]; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[1]; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[2]; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[3]; - - pDHCPMSG->OPT[k++] = dhcpServerIdentifier; - pDHCPMSG->OPT[k++] = 0x04; - pDHCPMSG->OPT[k++] = DHCP_SIP[0]; - pDHCPMSG->OPT[k++] = DHCP_SIP[1]; - pDHCPMSG->OPT[k++] = DHCP_SIP[2]; - pDHCPMSG->OPT[k++] = DHCP_SIP[3]; - } - - // host name - pDHCPMSG->OPT[k++] = hostName; - pDHCPMSG->OPT[k++] = 0; // length of hostname - for(i = 0 ; HOST_NAME[i] != 0; i++) - pDHCPMSG->OPT[k++] = HOST_NAME[i]; - pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[3] >> 4); - pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[3]); - pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[4] >> 4); - pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[4]); - pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[5] >> 4); - pDHCPMSG->OPT[k++] = NibbleToHex(DHCP_CHADDR[5]); - pDHCPMSG->OPT[k - (i+6+1)] = i+6; // length of hostname - - pDHCPMSG->OPT[k++] = dhcpParamRequest; - pDHCPMSG->OPT[k++] = 0x08; - pDHCPMSG->OPT[k++] = subnetMask; - pDHCPMSG->OPT[k++] = routersOnSubnet; - pDHCPMSG->OPT[k++] = dns; - pDHCPMSG->OPT[k++] = domainName; - pDHCPMSG->OPT[k++] = dhcpT1value; - pDHCPMSG->OPT[k++] = dhcpT2value; - pDHCPMSG->OPT[k++] = performRouterDiscovery; - pDHCPMSG->OPT[k++] = staticRoute; - pDHCPMSG->OPT[k++] = endOption; - - for (i = k; i < OPT_SIZE; i++) pDHCPMSG->OPT[i] = 0; - -#ifdef _DHCP_DEBUG_ - printf("> Send DHCP_REQUEST\r\n"); -#endif - - sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT); - -} - -/* SEND DHCP DHCPDECLINE */ -void send_DHCP_DECLINE(void) -{ - int i; - uint8_t ip[4]; - uint16_t k = 0; - - makeDHCPMSG(); - - k = 4; // because MAGIC_COOKIE already made by makeDHCPMSG() - - *((uint8_t*)(&pDHCPMSG->flags)) = ((DHCP_FLAGSUNICAST & 0xFF00)>> 8); - *((uint8_t*)(&pDHCPMSG->flags)+1) = (DHCP_FLAGSUNICAST & 0x00FF); - - // Option Request Param. - pDHCPMSG->OPT[k++] = dhcpMessageType; - pDHCPMSG->OPT[k++] = 0x01; - pDHCPMSG->OPT[k++] = DHCP_DECLINE; - - pDHCPMSG->OPT[k++] = dhcpClientIdentifier; - pDHCPMSG->OPT[k++] = 0x07; - pDHCPMSG->OPT[k++] = 0x01; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[0]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[1]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[2]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[3]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[4]; - pDHCPMSG->OPT[k++] = DHCP_CHADDR[5]; - - pDHCPMSG->OPT[k++] = dhcpRequestedIPaddr; - pDHCPMSG->OPT[k++] = 0x04; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[0]; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[1]; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[2]; - pDHCPMSG->OPT[k++] = DHCP_allocated_ip[3]; - - pDHCPMSG->OPT[k++] = dhcpServerIdentifier; - pDHCPMSG->OPT[k++] = 0x04; - pDHCPMSG->OPT[k++] = DHCP_SIP[0]; - pDHCPMSG->OPT[k++] = DHCP_SIP[1]; - pDHCPMSG->OPT[k++] = DHCP_SIP[2]; - pDHCPMSG->OPT[k++] = DHCP_SIP[3]; - - pDHCPMSG->OPT[k++] = endOption; - - for (i = k; i < OPT_SIZE; i++) pDHCPMSG->OPT[i] = 0; - - //send broadcasting packet - ip[0] = 0xFF; - ip[1] = 0xFF; - ip[2] = 0xFF; - ip[3] = 0xFF; - -#ifdef _DHCP_DEBUG_ - printf("\r\n> Send DHCP_DECLINE\r\n"); -#endif - - sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT); -} - -/* PARSE REPLY pDHCPMSG */ -int8_t parseDHCPMSG(void) -{ - uint8_t svr_addr[6]; - uint16_t svr_port; - uint16_t len; - - uint8_t * p; - uint8_t * e; - uint8_t type = 0; - uint8_t opt_len; - - if((len = getSn_RX_RSR(DHCP_SOCKET)) > 0) - { - len = recvfrom(DHCP_SOCKET, (uint8_t *)pDHCPMSG, len, svr_addr, &svr_port); - #ifdef _DHCP_DEBUG_ - printf("DHCP message : %d.%d.%d.%d(%d) %d received. \r\n",svr_addr[0],svr_addr[1],svr_addr[2], svr_addr[3],svr_port, len); - #endif - } - else return 0; - if (svr_port == DHCP_SERVER_PORT) { - // compare mac address - if ( (pDHCPMSG->chaddr[0] != DHCP_CHADDR[0]) || (pDHCPMSG->chaddr[1] != DHCP_CHADDR[1]) || - (pDHCPMSG->chaddr[2] != DHCP_CHADDR[2]) || (pDHCPMSG->chaddr[3] != DHCP_CHADDR[3]) || - (pDHCPMSG->chaddr[4] != DHCP_CHADDR[4]) || (pDHCPMSG->chaddr[5] != DHCP_CHADDR[5]) ) - return 0; - p = (uint8_t *)(&pDHCPMSG->op); - p = p + 240; // 240 = sizeof(RIP_MSG) + MAGIC_COOKIE size in RIP_MSG.opt - sizeof(RIP_MSG.opt) - e = p + (len - 240); - - while ( p < e ) { - - switch ( *p ) { - - case endOption : - p = e; // for break while(p < e) - break; - case padOption : - p++; - break; - case dhcpMessageType : - p++; - p++; - type = *p++; - break; - case subnetMask : - p++; - p++; - DHCP_allocated_sn[0] = *p++; - DHCP_allocated_sn[1] = *p++; - DHCP_allocated_sn[2] = *p++; - DHCP_allocated_sn[3] = *p++; - break; - case routersOnSubnet : - p++; - opt_len = *p++; - DHCP_allocated_gw[0] = *p++; - DHCP_allocated_gw[1] = *p++; - DHCP_allocated_gw[2] = *p++; - DHCP_allocated_gw[3] = *p++; - p = p + (opt_len - 4); - break; - case dns : - p++; - opt_len = *p++; - DHCP_allocated_dns[0] = *p++; - DHCP_allocated_dns[1] = *p++; - DHCP_allocated_dns[2] = *p++; - DHCP_allocated_dns[3] = *p++; - p = p + (opt_len - 4); - break; - case dhcpIPaddrLeaseTime : - p++; - opt_len = *p++; - dhcp_lease_time = *p++; - dhcp_lease_time = (dhcp_lease_time << 8) + *p++; - dhcp_lease_time = (dhcp_lease_time << 8) + *p++; - dhcp_lease_time = (dhcp_lease_time << 8) + *p++; - #ifdef _DHCP_DEBUG_ - dhcp_lease_time = 10; - #endif - break; - case dhcpServerIdentifier : - p++; - opt_len = *p++; - DHCP_SIP[0] = *p++; - DHCP_SIP[1] = *p++; - DHCP_SIP[2] = *p++; - DHCP_SIP[3] = *p++; - break; - default : - p++; - opt_len = *p++; - p += opt_len; - break; - } // switch - } // while - } // if - return type; -} - -uint8_t DHCP_run(void) -{ - uint8_t type; - uint8_t ret; - - if(dhcp_state == STATE_DHCP_STOP) return DHCP_STOPPED; - - if(getSn_SR(DHCP_SOCKET) != SOCK_UDP) - socket(DHCP_SOCKET, Sn_MR_UDP, DHCP_CLIENT_PORT, 0x00); - - ret = DHCP_RUNNING; - type = parseDHCPMSG(); - - switch ( dhcp_state ) { - case STATE_DHCP_INIT : - DHCP_allocated_ip[0] = 0; - DHCP_allocated_ip[1] = 0; - DHCP_allocated_ip[2] = 0; - DHCP_allocated_ip[3] = 0; - send_DHCP_DISCOVER(); - dhcp_state = STATE_DHCP_DISCOVER; - break; - case STATE_DHCP_DISCOVER : - if (type == DHCP_OFFER){ -#ifdef _DHCP_DEBUG_ - printf("> Receive DHCP_OFFER\r\n"); -#endif - DHCP_allocated_ip[0] = pDHCPMSG->yiaddr[0]; - DHCP_allocated_ip[1] = pDHCPMSG->yiaddr[1]; - DHCP_allocated_ip[2] = pDHCPMSG->yiaddr[2]; - DHCP_allocated_ip[3] = pDHCPMSG->yiaddr[3]; - - send_DHCP_REQUEST(); - dhcp_state = STATE_DHCP_REQUEST; - } else ret = check_DHCP_timeout(); - break; - - case STATE_DHCP_REQUEST : - if (type == DHCP_ACK) { - -#ifdef _DHCP_DEBUG_ - printf("> Receive DHCP_ACK\r\n"); -#endif - if (check_DHCP_leasedIP()) { - // Network info assignment from DHCP - dhcp_ip_assign(); - reset_DHCP_timeout(); - - dhcp_state = STATE_DHCP_LEASED; - } else { - // IP address conflict occurred - reset_DHCP_timeout(); - dhcp_ip_conflict(); - dhcp_state = STATE_DHCP_INIT; - } - } else if (type == DHCP_NAK) { - -#ifdef _DHCP_DEBUG_ - printf("> Receive DHCP_NACK\r\n"); -#endif - - reset_DHCP_timeout(); - - dhcp_state = STATE_DHCP_DISCOVER; - } else ret = check_DHCP_timeout(); - break; - - case STATE_DHCP_LEASED : - ret = DHCP_IP_LEASED; - if ((dhcp_lease_time != INFINITE_LEASETIME) && ((dhcp_lease_time/2) < dhcp_tick_1s)) { -#ifdef _DHCP_DEBUG_EXTD_ - printf("> dhcp_lease_time: %lu\r\n", dhcp_lease_time); - printf("> dhcp_tick_1s: %lu\r\n", dhcp_tick_1s); - printf("> EXEC send_DHCP_REQUEST()\r\n"); -#endif - -#ifdef _DHCP_DEBUG_ - printf("> Maintains the IP address \r\n"); - printf("> dhcp_lease_time: %lu\r\n", dhcp_lease_time); - printf("> dhcp_tick_1s: %lu\r\n", dhcp_tick_1s); -#endif - - type = 0; - OLD_allocated_ip[0] = DHCP_allocated_ip[0]; - OLD_allocated_ip[1] = DHCP_allocated_ip[1]; - OLD_allocated_ip[2] = DHCP_allocated_ip[2]; - OLD_allocated_ip[3] = DHCP_allocated_ip[3]; - - DHCP_XID++; - - send_DHCP_REQUEST(); - - reset_DHCP_timeout(); - - dhcp_state = STATE_DHCP_REREQUEST; - } - break; - - case STATE_DHCP_REREQUEST : - ret = DHCP_IP_LEASED; - if (type == DHCP_ACK) { - dhcp_retry_count = 0; - if (OLD_allocated_ip[0] != DHCP_allocated_ip[0] || - OLD_allocated_ip[1] != DHCP_allocated_ip[1] || - OLD_allocated_ip[2] != DHCP_allocated_ip[2] || - OLD_allocated_ip[3] != DHCP_allocated_ip[3]) - { - ret = DHCP_IP_CHANGED; - dhcp_ip_update(); - #ifdef _DHCP_DEBUG_ - printf(">IP changed.\r\n"); - #endif - - } - #ifdef _DHCP_DEBUG_ - else printf(">IP is continued.\r\n"); - #endif - reset_DHCP_timeout(); - dhcp_state = STATE_DHCP_LEASED; - } else if (type == DHCP_NAK) { - -#ifdef _DHCP_DEBUG_ - printf("> Receive DHCP_NACK, Failed to maintain ip\r\n"); -#endif - - reset_DHCP_timeout(); - - dhcp_state = STATE_DHCP_DISCOVER; - } else ret = check_DHCP_timeout(); - break; - default : - break; - } - - return ret; -} - -void DHCP_stop(void) -{ - close(DHCP_SOCKET); - dhcp_state = STATE_DHCP_STOP; -} - -uint8_t check_DHCP_timeout(void) -{ - uint8_t ret = DHCP_RUNNING; - - if (dhcp_retry_count < MAX_DHCP_RETRY) { - if (dhcp_tick_next < dhcp_tick_1s) { - - switch ( dhcp_state ) { - case STATE_DHCP_DISCOVER : -// printf("<> state : STATE_DHCP_DISCOVER\r\n"); - send_DHCP_DISCOVER(); - break; - - case STATE_DHCP_REQUEST : -// printf("<> state : STATE_DHCP_REQUEST\r\n"); - - send_DHCP_REQUEST(); - break; - - case STATE_DHCP_REREQUEST : -// printf("<> state : STATE_DHCP_REREQUEST\r\n"); - - send_DHCP_REQUEST(); - break; - - default : - break; - } - - dhcp_tick_1s = 0; - dhcp_tick_next = dhcp_tick_1s + DHCP_WAIT_TIME; - dhcp_retry_count++; - } - } else { // timeout occurred - - switch(dhcp_state) { - case STATE_DHCP_DISCOVER: - dhcp_state = STATE_DHCP_INIT; - ret = DHCP_FAILED; - break; - case STATE_DHCP_REQUEST: - case STATE_DHCP_REREQUEST: - send_DHCP_DISCOVER(); - dhcp_state = STATE_DHCP_DISCOVER; - break; - default : - break; - } - reset_DHCP_timeout(); - } - return ret; -} - -int8_t check_DHCP_leasedIP(void) -{ - uint8_t tmp; - int32_t ret; - - //WIZchip RCR value changed for ARP Timeout count control - tmp = getRCR(); - setRCR(0x03); - - // IP conflict detection : ARP request - ARP reply - // Broadcasting ARP Request for check the IP conflict using UDP sendto() function - ret = sendto(DHCP_SOCKET, (uint8_t *)"CHECK_IP_CONFLICT", 17, DHCP_allocated_ip, 5000); - - // RCR value restore - setRCR(tmp); - - if(ret == SOCKERR_TIMEOUT) { - // UDP send Timeout occurred : allocated IP address is unique, DHCP Success - -#ifdef _DHCP_DEBUG_ - printf("\r\n> Check leased IP - OK\r\n"); -#endif - - return 1; - } else { - // Received ARP reply or etc : IP address conflict occur, DHCP Failed - send_DHCP_DECLINE(); - - ret = dhcp_tick_1s; - while((dhcp_tick_1s - ret) < 2) ; // wait for 1s over; wait to complete to send DECLINE message; - - return 0; - } -} - -void DHCP_init(uint8_t s, uint8_t * buf) -{ - uint8_t zeroip[4] = {0,0,0,0}; - getSHAR(DHCP_CHADDR); - if((DHCP_CHADDR[0] | DHCP_CHADDR[1] | DHCP_CHADDR[2] | DHCP_CHADDR[3] | DHCP_CHADDR[4] | DHCP_CHADDR[5]) == 0x00) - { - // assigning temporary mac address, you should be set SHAR before call this function. - DHCP_CHADDR[0] = 0x00; - DHCP_CHADDR[1] = 0x08; - DHCP_CHADDR[2] = 0xdc; - DHCP_CHADDR[3] = 0x00; - DHCP_CHADDR[4] = 0x00; - DHCP_CHADDR[5] = 0x00; - setSHAR(DHCP_CHADDR); - } - - DHCP_SOCKET = s; // SOCK_DHCP - pDHCPMSG = (RIP_MSG*)buf; - DHCP_XID = 0x12345678; - - // WIZchip Netinfo Clear - setSIPR(zeroip); - setGAR(zeroip); - - reset_DHCP_timeout(); - dhcp_state = STATE_DHCP_INIT; -} - - -/* Reset the DHCP timeout count and retry count. */ -void reset_DHCP_timeout(void) -{ - dhcp_tick_1s = 0; - dhcp_tick_next = DHCP_WAIT_TIME; - dhcp_retry_count = 0; -} - -void DHCP_time_handler(void) -{ - dhcp_tick_1s++; -} - -void getIPfromDHCP(uint8_t* ip) -{ - ip[0] = DHCP_allocated_ip[0]; - ip[1] = DHCP_allocated_ip[1]; - ip[2] = DHCP_allocated_ip[2]; - ip[3] = DHCP_allocated_ip[3]; -} - -void getGWfromDHCP(uint8_t* ip) -{ - ip[0] =DHCP_allocated_gw[0]; - ip[1] =DHCP_allocated_gw[1]; - ip[2] =DHCP_allocated_gw[2]; - ip[3] =DHCP_allocated_gw[3]; -} - -void getSNfromDHCP(uint8_t* ip) -{ - ip[0] = DHCP_allocated_sn[0]; - ip[1] = DHCP_allocated_sn[1]; - ip[2] = DHCP_allocated_sn[2]; - ip[3] = DHCP_allocated_sn[3]; -} - -void getDNSfromDHCP(uint8_t* ip) -{ - ip[0] = DHCP_allocated_dns[0]; - ip[1] = DHCP_allocated_dns[1]; - ip[2] = DHCP_allocated_dns[2]; - ip[3] = DHCP_allocated_dns[3]; -} - -uint32_t getDHCPLeasetime(void) -{ - return dhcp_lease_time; -} - -char NibbleToHex(uint8_t nibble) -{ - nibble &= 0x0F; - if (nibble <= 9) - return nibble + '0'; - else - return nibble + ('A'-0x0A); -} - - diff --git a/04_m1284p_WIZNET_loopback_DHCP/Internet/DHCP/dhcp.h b/04_m1284p_WIZNET_loopback_DHCP/Internet/DHCP/dhcp.h deleted file mode 100644 index 9f8854c..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/Internet/DHCP/dhcp.h +++ /dev/null @@ -1,160 +0,0 @@ -//***************************************************************************** -// -//! \file dhcp.h -//! \brief DHCP APIs Header file. -//! \details Processig DHCP protocol as DISCOVER, OFFER, REQUEST, ACK, NACK and DECLINE. -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/11/18> 1st Release -//! <2012/12/20> V1.1.0 -//! 1. Move unreferenced DEFINE to dhcp.c -//! <2012/12/26> V1.1.1 -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#ifndef _DHCP_H_ -#define _DHCP_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * @brief - * @details If you want to display debug & processing message, Define _DHCP_DEBUG_ - * @note If defined, it depends on - */ -//#define _DHCP_DEBUG_ -//#define _DHCP_DEBUG_EXTD_ - -/* Retry to processing DHCP */ -#define MAX_DHCP_RETRY 2 ///< Maximum retry count -#define DHCP_WAIT_TIME 10 ///< Wait Time 10s - - -/* UDP port numbers for DHCP */ -#define DHCP_SERVER_PORT 67 ///< DHCP server port number -#define DHCP_CLIENT_PORT 68 ///< DHCP client port number - - -#define MAGIC_COOKIE 0x63825363 ///< You should not modify it number. - -#define DCHP_HOST_NAME "WIZnet\0" - -/* - * @brief return value of @ref DHCP_run() - */ -enum -{ - DHCP_FAILED = 0, ///< Processing Fail - DHCP_RUNNING, ///< Processing DHCP protocol - DHCP_IP_ASSIGN, ///< First Occupy IP from DHPC server (if cbfunc == null, act as default default_ip_assign) - DHCP_IP_CHANGED, ///< Change IP address by new ip from DHCP (if cbfunc == null, act as default default_ip_update) - DHCP_IP_LEASED, ///< Stand by - DHCP_STOPPED ///< Stop processing DHCP protocol -}; - -/* - * @brief DHCP client initialization (outside of the main loop) - * @param s - socket number - * @param buf - buffer for processing DHCP message - */ -void DHCP_init(uint8_t s, uint8_t * buf); - -/* - * @brief DHCP 1s Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void DHCP_time_handler(void); - -/* - * @brief Register call back function - * @param ip_assign - callback func when IP is assigned from DHCP server first - * @param ip_update - callback func when IP is changed - * @param ip_conflict - callback func when the assigned IP is conflict with others. - */ -void reg_dhcp_cbfunc(void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void)); - -/* - * @brief DHCP client in the main loop - * @return The value is as the follow \n - * @ref DHCP_FAILED \n - * @ref DHCP_RUNNING \n - * @ref DHCP_IP_ASSIGN \n - * @ref DHCP_IP_CHANGED \n - * @ref DHCP_IP_LEASED \n - * @ref DHCP_STOPPED \n - * - * @note This function is always called by you main task. - */ -uint8_t DHCP_run(void); - -/* - * @brief Stop DHCP processing - * @note If you want to restart. call DHCP_init() and DHCP_run() - */ -void DHCP_stop(void); - -/* Get Network information assigned from DHCP server */ -/* - * @brief Get IP address - * @param ip - IP address to be returned - */ -void getIPfromDHCP(uint8_t* ip); -/* - * @brief Get Gateway address - * @param ip - Gateway address to be returned - */ -void getGWfromDHCP(uint8_t* ip); -/* - * @brief Get Subnet mask value - * @param ip - Subnet mask to be returned - */ -void getSNfromDHCP(uint8_t* ip); -/* - * @brief Get DNS address - * @param ip - DNS address to be returned - */ -void getDNSfromDHCP(uint8_t* ip); - -/* - * @brief Get the leased time by DHCP sever - * @return unit 1s - */ -uint32_t getDHCPLeasetime(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCP_H_ */ diff --git a/04_m1284p_WIZNET_loopback_DHCP/globals.c b/04_m1284p_WIZNET_loopback_DHCP/globals.c deleted file mode 100644 index da3992e..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/globals.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_DHCP}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_DHCP}; //Static IP configuration -#endif - diff --git a/04_m1284p_WIZNET_loopback_DHCP/globals.h b/04_m1284p_WIZNET_loopback_DHCP/globals.h deleted file mode 100644 index c8e2fe4..0000000 --- a/04_m1284p_WIZNET_loopback_DHCP/globals.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" - -//******************************* Fat FS declare related: BEGIN -/* -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -#include "Internet/httpServer_avr/httpParser.h" -static FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -*/ -//******************************* Fat FS declare related: END - - -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -#define LOOPBACK_DATA_BUF_SIZE 512 - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Internet/DHCP/dhcp.h" -#include "Application/loopback/loopback.h" - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//#include // itoa etc.. -/* - * (4) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, on DHCP client (3 times), if failure assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.2 DHCP IP Loop-back WIZNET_5500 ETHERNET 26/11/2018\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; -} - -inline unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1< 236+312=548 Bytes - * - */ -#define SOCK_DHCPC 7 -#define DATA_BUF_SIZE_DHCP 550 -uint8_t gDATABUF_DHCP[DATA_BUF_SIZE_DHCP]; - -#define MY_MAX_DHCP_RETRY 3 -uint8_t my_dhcp_retry = 0; - - -/******************************************************* - * @ brief Call back for ip assing & ip update from DHCP - *******************************************************/ -void my_ip_assign(void) -{ - getIPfromDHCP(netInfo.ip); - getGWfromDHCP(netInfo.gw); - getSNfromDHCP(netInfo.sn); - getDNSfromDHCP(netInfo.dns); - netInfo.dhcp = NETINFO_DHCP; - /* Network initialization */ - //Net_Conf(); // apply from DHCP - wizchip_setnetinfo(&netInfo);// apply from DHCP -//#ifdef _MAIN_DEBUG_ -// Display_Net_Conf(); - print_network_information(); -#if 1 - PRINTF("DHCP LEASED TIME : %ld Sec.\r\n", getDHCPLeasetime()); - PRINTF("\r\n"); -#endif -} - -/************************************ - * @ brief Call back for ip Conflict - ************************************/ -void my_ip_conflict(void) -{ -#ifdef _MAIN_DEBUG_ - printf("CONFLICT IP from DHCP\r\n"); -#endif - //halt or reset or any... - while(1); // this example is halt. -} -//*************************DHCP-callback: END - -//***************** WIZCHIP INIT: END - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - uint8_t run_user_applications = 0; - - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - - /* DHCP client Initialization */ - if(netInfo.dhcp == NETINFO_DHCP) - { - //DHCP IP - DHCP_init(SOCK_DHCPC, gDATABUF_DHCP); - // if you want different action instead default ip assign, update, conflict. - // if cbfunc == 0, act as default. - reg_dhcp_cbfunc(my_ip_assign, my_ip_assign, my_ip_conflict); - - run_user_applications = 0; // flag for running user's code - } - else - { - // Static IP - print_network_information(); - run_user_applications = 1; // flag for running user's code - } - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - - //Set-up virtual timers - uint32_t timer_link_1sec = millis(); - uint32_t timer_dhcp_1sec = millis(); - uint32_t timer_dhcp_1sec_count = 0; - uint32_t timer_uptime_60sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* DHCP */ - /*DHCP timer 1 sec interval tick*/ - if((millis()-timer_dhcp_1sec)> 1000) - { - //here every 1 sec - timer_dhcp_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added DHCP Timer Handler your 1s tick timer - DHCP_time_handler(); // for DHCP timeout counter - //////////////////////////////////////////////////////// - if (timer_dhcp_1sec_count++ % 60 == 0) - { - //Every 1min print-out DHCP leased time elapse -#ifdef _DHCP_LEASED_TIME_DEBUG_ - PRINTF("DHCP LEASED TIME elapse: %lu Sec.\r\n", timer_dhcp_1sec_count ); - PRINTF("DHCP LEASED TIME : %ld Sec.\r\n", getDHCPLeasetime()); -#endif - } - } -/* DHCP IP allocation and check the DHCP lease time (for IP renewal) */ - if(netInfo.dhcp == NETINFO_DHCP) - { - switch(DHCP_run()) - { - case DHCP_IP_ASSIGN: - case DHCP_IP_CHANGED: - /* If this block empty, act with default_ip_assign & default_ip_update */ - // - // This example calls my_ip_assign in the two case. - // - // Add to ... - // - break; - case DHCP_IP_LEASED: - // - // TODO: insert user's code here - run_user_applications = 1; - // - break; - case DHCP_FAILED: - /* ===== Example pseudo code ===== */ - // The below code can be replaced your code or omitted. - // if omitted, retry to process DHCP - my_dhcp_retry++; - if(my_dhcp_retry > MY_MAX_DHCP_RETRY) - { - netInfo.dhcp = NETINFO_STATIC; - DHCP_stop(); // if restart, recall DHCP_init() -//#ifdef _MAIN_DEBUG_ -#if 1 - printf(">> DHCP %d Failed\r\n", my_dhcp_retry); - //Net_Conf(); - //Display_Net_Conf(); // print out static netinfo to serial - - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); -#endif - my_dhcp_retry = 0; - - run_user_applications = 1; - } - break; - default: - break; - } - } - - /*PHY LINK DETECT*/ - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - - /*TCP-IP & UDP user's applications*/ - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - if(run_user_applications) - { - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - } - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/05_m1284p_WIZNET_DNS_client/.cproject b/05_m1284p_WIZNET_DNS_client/.cproject deleted file mode 100644 index b5431c1..0000000 --- a/05_m1284p_WIZNET_DNS_client/.cproject +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/05_m1284p_WIZNET_DNS_client/.project b/05_m1284p_WIZNET_DNS_client/.project deleted file mode 100644 index 5454382..0000000 --- a/05_m1284p_WIZNET_DNS_client/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 05_m1284p_WIZNET_DNS_client - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/05_m1284p_WIZNET_DNS_client/Application/loopback/loopback.c b/05_m1284p_WIZNET_DNS_client/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/05_m1284p_WIZNET_DNS_client/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/05_m1284p_WIZNET_DNS_client/Application/loopback/loopback.h b/05_m1284p_WIZNET_DNS_client/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/05_m1284p_WIZNET_DNS_client/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/05_m1284p_WIZNET_DNS_client/Ethernet/W5500/w5500.c b/05_m1284p_WIZNET_DNS_client/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/05_m1284p_WIZNET_DNS_client/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/05_m1284p_WIZNET_DNS_client/Ethernet/W5500/w5500.h b/05_m1284p_WIZNET_DNS_client/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/05_m1284p_WIZNET_DNS_client/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/05_m1284p_WIZNET_DNS_client/Ethernet/socket.c b/05_m1284p_WIZNET_DNS_client/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/05_m1284p_WIZNET_DNS_client/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/05_m1284p_WIZNET_DNS_client/Ethernet/socket.h b/05_m1284p_WIZNET_DNS_client/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/05_m1284p_WIZNET_DNS_client/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/05_m1284p_WIZNET_DNS_client/Ethernet/wizchip_conf.c b/05_m1284p_WIZNET_DNS_client/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/05_m1284p_WIZNET_DNS_client/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/05_m1284p_WIZNET_DNS_client/Ethernet/wizchip_conf.h b/05_m1284p_WIZNET_DNS_client/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/05_m1284p_WIZNET_DNS_client/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/05_m1284p_WIZNET_DNS_client/Internet/DNS/dns.c b/05_m1284p_WIZNET_DNS_client/Internet/DNS/dns.c deleted file mode 100644 index 9f7107b..0000000 --- a/05_m1284p_WIZNET_DNS_client/Internet/DNS/dns.c +++ /dev/null @@ -1,566 +0,0 @@ -//***************************************************************************** -// -//! \file dns.c -//! \brief DNS APIs Implement file. -//! \details Send DNS query & Receive DNS reponse. \n -//! It depends on stdlib.h & string.h in ansi-c library -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Remove the unused define -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#include -#include - -#include "socket.h" -#include "dns.h" - -#ifdef _DNS_DEBUG_ - #include -#endif - -#define INITRTT 2000L /* Initial smoothed response time */ -#define MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */ - -#define TYPE_A 1 /* Host address */ -#define TYPE_NS 2 /* Name server */ -#define TYPE_MD 3 /* Mail destination (obsolete) */ -#define TYPE_MF 4 /* Mail forwarder (obsolete) */ -#define TYPE_CNAME 5 /* Canonical name */ -#define TYPE_SOA 6 /* Start of Authority */ -#define TYPE_MB 7 /* Mailbox name (experimental) */ -#define TYPE_MG 8 /* Mail group member (experimental) */ -#define TYPE_MR 9 /* Mail rename name (experimental) */ -#define TYPE_NULL 10 /* Null (experimental) */ -#define TYPE_WKS 11 /* Well-known sockets */ -#define TYPE_PTR 12 /* Pointer record */ -#define TYPE_HINFO 13 /* Host information */ -#define TYPE_MINFO 14 /* Mailbox information (experimental)*/ -#define TYPE_MX 15 /* Mail exchanger */ -#define TYPE_TXT 16 /* Text strings */ -#define TYPE_ANY 255 /* Matches any type */ - -#define CLASS_IN 1 /* The ARPA Internet */ - -/* Round trip timing parameters */ -#define AGAIN 8 /* Average RTT gain = 1/8 */ -#define LAGAIN 3 /* Log2(AGAIN) */ -#define DGAIN 4 /* Mean deviation gain = 1/4 */ -#define LDGAIN 2 /* log2(DGAIN) */ - -/* Header for all domain messages */ -struct dhdr -{ - uint16_t id; /* Identification */ - uint8_t qr; /* Query/Response */ -#define QUERY 0 -#define RESPONSE 1 - uint8_t opcode; -#define IQUERY 1 - uint8_t aa; /* Authoratative answer */ - uint8_t tc; /* Truncation */ - uint8_t rd; /* Recursion desired */ - uint8_t ra; /* Recursion available */ - uint8_t rcode; /* Response code */ -#define NO_ERROR 0 -#define FORMAT_ERROR 1 -#define SERVER_FAIL 2 -#define NAME_ERROR 3 -#define NOT_IMPL 4 -#define REFUSED 5 - uint16_t qdcount; /* Question count */ - uint16_t ancount; /* Answer count */ - uint16_t nscount; /* Authority (name server) count */ - uint16_t arcount; /* Additional record count */ -}; - - -uint8_t* pDNSMSG; // DNS message buffer -uint8_t DNS_SOCKET; // SOCKET number for DNS -uint16_t DNS_MSGID; // DNS message ID - -uint32_t dns_1s_tick; // for timout of DNS processing -static uint8_t retry_count; - -/* converts uint16_t from network buffer to a host byte order integer. */ -uint16_t get16(uint8_t * s) -{ - uint16_t i; - i = *s++ << 8; - i = i + *s; - return i; -} - -/* copies uint16_t to the network buffer with network byte order. */ -uint8_t * put16(uint8_t * s, uint16_t i) -{ - *s++ = i >> 8; - *s++ = i; - return s; -} - - -/* - * CONVERT A DOMAIN NAME TO THE HUMAN-READABLE FORM - * - * Description : This function converts a compressed domain name to the human-readable form - * Arguments : msg - is a pointer to the reply message - * compressed - is a pointer to the domain name in reply message. - * buf - is a pointer to the buffer for the human-readable form name. - * len - is the MAX. size of buffer. - * Returns : the length of compressed message - */ -int parse_name(uint8_t * msg, uint8_t * compressed, char * buf, int16_t len) -{ - uint16_t slen; /* Length of current segment */ - uint8_t * cp; - int clen = 0; /* Total length of compressed name */ - int indirect = 0; /* Set if indirection encountered */ - int nseg = 0; /* Total number of segments in name */ - - cp = compressed; - - for (;;) - { - slen = *cp++; /* Length of this segment */ - - if (!indirect) clen++; - - if ((slen & 0xc0) == 0xc0) - { - if (!indirect) - clen++; - indirect = 1; - /* Follow indirection */ - cp = &msg[((slen & 0x3f)<<8) + *cp]; - slen = *cp++; - } - - if (slen == 0) /* zero length == all done */ - break; - - len -= slen + 1; - - if (len < 0) return -1; - - if (!indirect) clen += slen; - - while (slen-- != 0) *buf++ = (char)*cp++; - *buf++ = '.'; - nseg++; - } - - if (nseg == 0) - { - /* Root name; represent as single dot */ - *buf++ = '.'; - len--; - } - - *buf++ = '\0'; - len--; - - return clen; /* Length of compressed message */ -} - -/* - * PARSE QUESTION SECTION - * - * Description : This function parses the qeustion record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the qeustion record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_question(uint8_t * msg, uint8_t * cp) -{ - int len; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - - if (len == -1) return 0; - - cp += len; - cp += 2; /* type */ - cp += 2; /* class */ - - return cp; -} - - -/* - * PARSE ANSER SECTION - * - * Description : This function parses the answer record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the answer record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_answer(uint8_t * msg, uint8_t * cp, uint8_t * ip_from_dns) -{ - int len, type; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - if (len == -1) return 0; - - cp += len; - type = get16(cp); - cp += 2; /* type */ - cp += 2; /* class */ - cp += 4; /* ttl */ - cp += 2; /* len */ - - - switch (type) - { - case TYPE_A: - /* Just read the address directly into the structure */ - ip_from_dns[0] = *cp++; - ip_from_dns[1] = *cp++; - ip_from_dns[2] = *cp++; - ip_from_dns[3] = *cp++; - break; - case TYPE_CNAME: - case TYPE_MB: - case TYPE_MG: - case TYPE_MR: - case TYPE_NS: - case TYPE_PTR: - /* These types all consist of a single domain name */ - /* convert it to ascii format */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_HINFO: - len = *cp++; - cp += len; - - len = *cp++; - cp += len; - break; - case TYPE_MX: - cp += 2; - /* Get domain name of exchanger */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_SOA: - /* Get domain name of name server */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - /* Get domain name of responsible person */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - cp += 4; - cp += 4; - cp += 4; - cp += 4; - cp += 4; - break; - case TYPE_TXT: - /* Just stash */ - break; - default: - /* Ignore */ - break; - } - - return cp; -} - -/* - * PARSE THE DNS REPLY - * - * Description : This function parses the reply message from DNS server. - * Arguments : dhdr - is a pointer to the header for DNS message - * buf - is a pointer to the reply message. - * len - is the size of reply message. - * Returns : -1 - Domain name lenght is too big - * 0 - Fail (Timout or parse error) - * 1 - Success, - */ -int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns) -{ - uint16_t tmp; - uint16_t i; - uint8_t * msg; - uint8_t * cp; - - msg = pbuf; - memset(pdhdr, 0, sizeof(*pdhdr)); - - pdhdr->id = get16(&msg[0]); - tmp = get16(&msg[2]); - if (tmp & 0x8000) pdhdr->qr = 1; - - pdhdr->opcode = (tmp >> 11) & 0xf; - - if (tmp & 0x0400) pdhdr->aa = 1; - if (tmp & 0x0200) pdhdr->tc = 1; - if (tmp & 0x0100) pdhdr->rd = 1; - if (tmp & 0x0080) pdhdr->ra = 1; - - pdhdr->rcode = tmp & 0xf; - pdhdr->qdcount = get16(&msg[4]); - pdhdr->ancount = get16(&msg[6]); - pdhdr->nscount = get16(&msg[8]); - pdhdr->arcount = get16(&msg[10]); - - - /* Now parse the variable length sections */ - cp = &msg[12]; - - /* Question section */ - for (i = 0; i < pdhdr->qdcount; i++) - { - cp = dns_question(msg, cp); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Answer section */ - for (i = 0; i < pdhdr->ancount; i++) - { - cp = dns_answer(msg, cp, ip_from_dns); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Name server (authority) section */ - for (i = 0; i < pdhdr->nscount; i++) - { - ; - } - - /* Additional section */ - for (i = 0; i < pdhdr->arcount; i++) - { - ; - } - - if(pdhdr->rcode == 0) return 1; // No error - else return 0; -} - - -/* - * MAKE DNS QUERY MESSAGE - * - * Description : This function makes DNS query message. - * Arguments : op - Recursion desired - * name - is a pointer to the domain name. - * buf - is a pointer to the buffer for DNS message. - * len - is the MAX. size of buffer. - * Returns : the pointer to the DNS message. - */ -int16_t dns_makequery(uint16_t op, char * name, uint8_t * buf, uint16_t len) -{ - uint8_t *cp; - char *cp1; - char sname[MAXCNAME]; - char *dname; - uint16_t p; - uint16_t dlen; - - cp = buf; - - DNS_MSGID++; - cp = put16(cp, DNS_MSGID); - p = (op << 11) | 0x0100; /* Recursion desired */ - cp = put16(cp, p); - cp = put16(cp, 1); - cp = put16(cp, 0); - cp = put16(cp, 0); - cp = put16(cp, 0); - - strcpy(sname, name); - dname = sname; - dlen = strlen(dname); - for (;;) - { - /* Look for next dot */ - cp1 = strchr(dname, '.'); - - if (cp1 != NULL) len = cp1 - dname; /* More to come */ - else len = dlen; /* Last component */ - - *cp++ = len; /* Write length of component */ - if (len == 0) break; - - /* Copy component up to (but not including) dot */ - strncpy((char *)cp, dname, len); - cp += len; - if (cp1 == NULL) - { - *cp++ = 0; /* Last one; write null and finish */ - break; - } - dname += len+1; - dlen -= len+1; - } - - cp = put16(cp, 0x0001); /* type */ - cp = put16(cp, 0x0001); /* class */ - - return ((int16_t)((uint32_t)(cp) - (uint32_t)(buf))); -} - -/* - * CHECK DNS TIMEOUT - * - * Description : This function check the DNS timeout - * Arguments : None. - * Returns : -1 - timeout occurred, 0 - timer over, but no timeout, 1 - no timer over, no timeout occur - * Note : timeout : retry count and timer both over. - */ - -int8_t check_DNS_timeout(void) -{ - - if(dns_1s_tick >= DNS_WAIT_TIME) - { - dns_1s_tick = 0; - if(retry_count >= MAX_DNS_RETRY) { - retry_count = 0; - return -1; // timeout occurred - } - retry_count++; - return 0; // timer over, but no timeout - } - - return 1; // no timer over, no timeout occur -} - - - -/* DNS CLIENT INIT */ -void DNS_init(uint8_t s, uint8_t * buf) -{ - DNS_SOCKET = s; // SOCK_DNS - pDNSMSG = buf; // User's shared buffer - DNS_MSGID = DNS_MSG_ID; -} - -/* DNS CLIENT RUN */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns) -{ - int8_t ret; - struct dhdr dhp; - uint8_t ip[4]; - uint16_t len, port; - int8_t ret_check_timeout; - - retry_count = 0; - dns_1s_tick = 0; - - // Socket open - socket(DNS_SOCKET, Sn_MR_UDP, 0, 0); - -#ifdef _DNS_DEBUG_ - printf("> DNS Query to DNS Server : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - - len = dns_makequery(0, (char *)name, pDNSMSG, MAX_DNS_BUF_SIZE); - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - - while (1) - { - if ((len = getSn_RX_RSR(DNS_SOCKET)) > 0) - { - if (len > MAX_DNS_BUF_SIZE) len = MAX_DNS_BUF_SIZE; - len = recvfrom(DNS_SOCKET, pDNSMSG, len, ip, &port); - #ifdef _DNS_DEBUG_ - printf("> Receive DNS message from %d.%d.%d.%d(%d). len = %d\r\n", ip[0], ip[1], ip[2], ip[3],port,len); - #endif - ret = parseDNSMSG(&dhp, pDNSMSG, ip_from_dns); - break; - } - // Check Timeout - ret_check_timeout = check_DNS_timeout(); - if (ret_check_timeout < 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Server is not responding : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - return 0; // timeout occurred - } - else if (ret_check_timeout == 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Timeout\r\n"); -#endif - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - } - } - close(DNS_SOCKET); - // Return value - // 0 > : failed / 1 - success - return ret; -} - - -/* DNS TIMER HANDLER */ -void DNS_time_handler(void) -{ - dns_1s_tick++; -} - - - diff --git a/05_m1284p_WIZNET_DNS_client/Internet/DNS/dns.h b/05_m1284p_WIZNET_DNS_client/Internet/DNS/dns.h deleted file mode 100644 index 6f6aa6b..0000000 --- a/05_m1284p_WIZNET_DNS_client/Internet/DNS/dns.h +++ /dev/null @@ -1,109 +0,0 @@ -//***************************************************************************** -// -//! \file dns.h -//! \brief DNS APIs Header file. -//! \details Send DNS query & Receive DNS reponse. -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Move the no reference define to dns.c -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#ifndef _DNS_H_ -#define _DNS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/* - * @brief Define it for Debug & Monitor DNS processing. - * @note If defined, it dependens on - */ -//#define _DNS_DEBUG_ - -#define MAX_DNS_BUF_SIZE 256 ///< maximum size of DNS buffer. */ -/* - * @brief Maxium length of your queried Domain name - * @todo SHOULD BE defined it equal as or greater than your Domain name lenght + null character(1) - * @note SHOULD BE careful to stack overflow because it is allocated 1.5 times as MAX_DOMAIN_NAME in stack. - */ -#define MAX_DOMAIN_NAME 16 // for example "www.google.com" - -#define MAX_DNS_RETRY 2 ///< Requery Count -#define DNS_WAIT_TIME 3 ///< Wait response time. unit 1s. - -#define IPPORT_DOMAIN 53 ///< DNS server port number - -#define DNS_MSG_ID 0x1122 ///< ID for DNS message. You can be modifyed it any number -/* - * @brief DNS process initialize - * @param s : Socket number for DNS - * @param buf : Buffer for DNS message - */ -void DNS_init(uint8_t s, uint8_t * buf); - -/* - * @brief DNS process - * @details Send DNS query and receive DNS response - * @param dns_ip : DNS server ip - * @param name : Domain name to be queryed - * @param ip_from_dns : IP address from DNS server - * @return -1 : failed. @ref MAX_DOMIN_NAME is too small \n - * 0 : failed (Timeout or Parse error)\n - * 1 : success - * @note This funtion blocks until success or fail. max time = @ref MAX_DNS_RETRY * @ref DNS_WAIT_TIME - */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns); - -/* - * @brief DNS 1s Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void DNS_time_handler(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _DNS_H_ */ diff --git a/05_m1284p_WIZNET_DNS_client/main.c b/05_m1284p_WIZNET_DNS_client/main.c deleted file mode 100644 index 487b679..0000000 --- a/05_m1284p_WIZNET_DNS_client/main.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/DNS/dns.h" - -//#include // itoa etc.. -/* - * (5) Added DNS Lookup example on start-up device - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ -#define _MAIN_DEBUG_ - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -#ifdef _MAIN_DEBUG_ - printf("\r\n===== DNS Servers =====\r\n"); - printf("> DNS 1st : %d.%d.%d.%d\r\n", netInfo.dns[0], netInfo.dns[1], netInfo.dns[2], netInfo.dns[3]); - printf("> DNS 2nd : %d.%d.%d.%d\r\n", DNS_2nd[0], DNS_2nd[1], DNS_2nd[2], DNS_2nd[3]); - printf("=======================================\r\n"); - printf("> [Example] Target Domain Name : %s\r\n", Domain_name); -#endif - - /* DNS client Initialization */ - DNS_init(SOCK_DNS, gDATABUF_DNS); - - /* DNS processing */ - int32_t ret; - if ((ret = DNS_run(netInfo.dns, Domain_name, Domain_IP)) > 0) // try to 1st DNS - { -#ifdef _MAIN_DEBUG_ - printf("> 1st DNS Respond\r\n"); -#endif - } - else if ((ret != -1) && ((ret = DNS_run(DNS_2nd, Domain_name, Domain_IP))>0)) // retry to 2nd DNS - { -#ifdef _MAIN_DEBUG_ - printf("> 2nd DNS Respond\r\n"); -#endif - } - else if(ret == -1) - { -#ifdef _MAIN_DEBUG_ - printf("> MAX_DOMAIN_NAME is too small. Should be redefined it.\r\n"); -#endif - ; - } - else - { -#ifdef _MAIN_DEBUG_ - printf("> DNS Failed\r\n"); -#endif - ; - } - - if(ret > 0) - { -#ifdef _MAIN_DEBUG_ - printf("> Translated %s to [%d.%d.%d.%d]\r\n\r\n",Domain_name,Domain_IP[0],Domain_IP[1],Domain_IP[2],Domain_IP[3]); -#endif - // - // TODO: To be executed User's code after a successful DNS process - // - } - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - - - - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/.cproject b/06_m1284p_WIZNET_DNS_SNTP_client/.cproject deleted file mode 100644 index b5431c1..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/.cproject +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/.project b/06_m1284p_WIZNET_DNS_SNTP_client/.project deleted file mode 100644 index c557799..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 06_m1284p_WIZNET_DNS_SNTP_client - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Application/loopback/loopback.c b/06_m1284p_WIZNET_DNS_SNTP_client/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Application/loopback/loopback.h b/06_m1284p_WIZNET_DNS_SNTP_client/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/W5500/w5500.c b/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/W5500/w5500.h b/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/socket.c b/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/socket.h b/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/wizchip_conf.c b/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/wizchip_conf.h b/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Internet/DNS/dns.c b/06_m1284p_WIZNET_DNS_SNTP_client/Internet/DNS/dns.c deleted file mode 100644 index 9f7107b..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Internet/DNS/dns.c +++ /dev/null @@ -1,566 +0,0 @@ -//***************************************************************************** -// -//! \file dns.c -//! \brief DNS APIs Implement file. -//! \details Send DNS query & Receive DNS reponse. \n -//! It depends on stdlib.h & string.h in ansi-c library -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Remove the unused define -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#include -#include - -#include "socket.h" -#include "dns.h" - -#ifdef _DNS_DEBUG_ - #include -#endif - -#define INITRTT 2000L /* Initial smoothed response time */ -#define MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */ - -#define TYPE_A 1 /* Host address */ -#define TYPE_NS 2 /* Name server */ -#define TYPE_MD 3 /* Mail destination (obsolete) */ -#define TYPE_MF 4 /* Mail forwarder (obsolete) */ -#define TYPE_CNAME 5 /* Canonical name */ -#define TYPE_SOA 6 /* Start of Authority */ -#define TYPE_MB 7 /* Mailbox name (experimental) */ -#define TYPE_MG 8 /* Mail group member (experimental) */ -#define TYPE_MR 9 /* Mail rename name (experimental) */ -#define TYPE_NULL 10 /* Null (experimental) */ -#define TYPE_WKS 11 /* Well-known sockets */ -#define TYPE_PTR 12 /* Pointer record */ -#define TYPE_HINFO 13 /* Host information */ -#define TYPE_MINFO 14 /* Mailbox information (experimental)*/ -#define TYPE_MX 15 /* Mail exchanger */ -#define TYPE_TXT 16 /* Text strings */ -#define TYPE_ANY 255 /* Matches any type */ - -#define CLASS_IN 1 /* The ARPA Internet */ - -/* Round trip timing parameters */ -#define AGAIN 8 /* Average RTT gain = 1/8 */ -#define LAGAIN 3 /* Log2(AGAIN) */ -#define DGAIN 4 /* Mean deviation gain = 1/4 */ -#define LDGAIN 2 /* log2(DGAIN) */ - -/* Header for all domain messages */ -struct dhdr -{ - uint16_t id; /* Identification */ - uint8_t qr; /* Query/Response */ -#define QUERY 0 -#define RESPONSE 1 - uint8_t opcode; -#define IQUERY 1 - uint8_t aa; /* Authoratative answer */ - uint8_t tc; /* Truncation */ - uint8_t rd; /* Recursion desired */ - uint8_t ra; /* Recursion available */ - uint8_t rcode; /* Response code */ -#define NO_ERROR 0 -#define FORMAT_ERROR 1 -#define SERVER_FAIL 2 -#define NAME_ERROR 3 -#define NOT_IMPL 4 -#define REFUSED 5 - uint16_t qdcount; /* Question count */ - uint16_t ancount; /* Answer count */ - uint16_t nscount; /* Authority (name server) count */ - uint16_t arcount; /* Additional record count */ -}; - - -uint8_t* pDNSMSG; // DNS message buffer -uint8_t DNS_SOCKET; // SOCKET number for DNS -uint16_t DNS_MSGID; // DNS message ID - -uint32_t dns_1s_tick; // for timout of DNS processing -static uint8_t retry_count; - -/* converts uint16_t from network buffer to a host byte order integer. */ -uint16_t get16(uint8_t * s) -{ - uint16_t i; - i = *s++ << 8; - i = i + *s; - return i; -} - -/* copies uint16_t to the network buffer with network byte order. */ -uint8_t * put16(uint8_t * s, uint16_t i) -{ - *s++ = i >> 8; - *s++ = i; - return s; -} - - -/* - * CONVERT A DOMAIN NAME TO THE HUMAN-READABLE FORM - * - * Description : This function converts a compressed domain name to the human-readable form - * Arguments : msg - is a pointer to the reply message - * compressed - is a pointer to the domain name in reply message. - * buf - is a pointer to the buffer for the human-readable form name. - * len - is the MAX. size of buffer. - * Returns : the length of compressed message - */ -int parse_name(uint8_t * msg, uint8_t * compressed, char * buf, int16_t len) -{ - uint16_t slen; /* Length of current segment */ - uint8_t * cp; - int clen = 0; /* Total length of compressed name */ - int indirect = 0; /* Set if indirection encountered */ - int nseg = 0; /* Total number of segments in name */ - - cp = compressed; - - for (;;) - { - slen = *cp++; /* Length of this segment */ - - if (!indirect) clen++; - - if ((slen & 0xc0) == 0xc0) - { - if (!indirect) - clen++; - indirect = 1; - /* Follow indirection */ - cp = &msg[((slen & 0x3f)<<8) + *cp]; - slen = *cp++; - } - - if (slen == 0) /* zero length == all done */ - break; - - len -= slen + 1; - - if (len < 0) return -1; - - if (!indirect) clen += slen; - - while (slen-- != 0) *buf++ = (char)*cp++; - *buf++ = '.'; - nseg++; - } - - if (nseg == 0) - { - /* Root name; represent as single dot */ - *buf++ = '.'; - len--; - } - - *buf++ = '\0'; - len--; - - return clen; /* Length of compressed message */ -} - -/* - * PARSE QUESTION SECTION - * - * Description : This function parses the qeustion record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the qeustion record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_question(uint8_t * msg, uint8_t * cp) -{ - int len; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - - if (len == -1) return 0; - - cp += len; - cp += 2; /* type */ - cp += 2; /* class */ - - return cp; -} - - -/* - * PARSE ANSER SECTION - * - * Description : This function parses the answer record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the answer record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_answer(uint8_t * msg, uint8_t * cp, uint8_t * ip_from_dns) -{ - int len, type; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - if (len == -1) return 0; - - cp += len; - type = get16(cp); - cp += 2; /* type */ - cp += 2; /* class */ - cp += 4; /* ttl */ - cp += 2; /* len */ - - - switch (type) - { - case TYPE_A: - /* Just read the address directly into the structure */ - ip_from_dns[0] = *cp++; - ip_from_dns[1] = *cp++; - ip_from_dns[2] = *cp++; - ip_from_dns[3] = *cp++; - break; - case TYPE_CNAME: - case TYPE_MB: - case TYPE_MG: - case TYPE_MR: - case TYPE_NS: - case TYPE_PTR: - /* These types all consist of a single domain name */ - /* convert it to ascii format */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_HINFO: - len = *cp++; - cp += len; - - len = *cp++; - cp += len; - break; - case TYPE_MX: - cp += 2; - /* Get domain name of exchanger */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_SOA: - /* Get domain name of name server */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - /* Get domain name of responsible person */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - cp += 4; - cp += 4; - cp += 4; - cp += 4; - cp += 4; - break; - case TYPE_TXT: - /* Just stash */ - break; - default: - /* Ignore */ - break; - } - - return cp; -} - -/* - * PARSE THE DNS REPLY - * - * Description : This function parses the reply message from DNS server. - * Arguments : dhdr - is a pointer to the header for DNS message - * buf - is a pointer to the reply message. - * len - is the size of reply message. - * Returns : -1 - Domain name lenght is too big - * 0 - Fail (Timout or parse error) - * 1 - Success, - */ -int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns) -{ - uint16_t tmp; - uint16_t i; - uint8_t * msg; - uint8_t * cp; - - msg = pbuf; - memset(pdhdr, 0, sizeof(*pdhdr)); - - pdhdr->id = get16(&msg[0]); - tmp = get16(&msg[2]); - if (tmp & 0x8000) pdhdr->qr = 1; - - pdhdr->opcode = (tmp >> 11) & 0xf; - - if (tmp & 0x0400) pdhdr->aa = 1; - if (tmp & 0x0200) pdhdr->tc = 1; - if (tmp & 0x0100) pdhdr->rd = 1; - if (tmp & 0x0080) pdhdr->ra = 1; - - pdhdr->rcode = tmp & 0xf; - pdhdr->qdcount = get16(&msg[4]); - pdhdr->ancount = get16(&msg[6]); - pdhdr->nscount = get16(&msg[8]); - pdhdr->arcount = get16(&msg[10]); - - - /* Now parse the variable length sections */ - cp = &msg[12]; - - /* Question section */ - for (i = 0; i < pdhdr->qdcount; i++) - { - cp = dns_question(msg, cp); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Answer section */ - for (i = 0; i < pdhdr->ancount; i++) - { - cp = dns_answer(msg, cp, ip_from_dns); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Name server (authority) section */ - for (i = 0; i < pdhdr->nscount; i++) - { - ; - } - - /* Additional section */ - for (i = 0; i < pdhdr->arcount; i++) - { - ; - } - - if(pdhdr->rcode == 0) return 1; // No error - else return 0; -} - - -/* - * MAKE DNS QUERY MESSAGE - * - * Description : This function makes DNS query message. - * Arguments : op - Recursion desired - * name - is a pointer to the domain name. - * buf - is a pointer to the buffer for DNS message. - * len - is the MAX. size of buffer. - * Returns : the pointer to the DNS message. - */ -int16_t dns_makequery(uint16_t op, char * name, uint8_t * buf, uint16_t len) -{ - uint8_t *cp; - char *cp1; - char sname[MAXCNAME]; - char *dname; - uint16_t p; - uint16_t dlen; - - cp = buf; - - DNS_MSGID++; - cp = put16(cp, DNS_MSGID); - p = (op << 11) | 0x0100; /* Recursion desired */ - cp = put16(cp, p); - cp = put16(cp, 1); - cp = put16(cp, 0); - cp = put16(cp, 0); - cp = put16(cp, 0); - - strcpy(sname, name); - dname = sname; - dlen = strlen(dname); - for (;;) - { - /* Look for next dot */ - cp1 = strchr(dname, '.'); - - if (cp1 != NULL) len = cp1 - dname; /* More to come */ - else len = dlen; /* Last component */ - - *cp++ = len; /* Write length of component */ - if (len == 0) break; - - /* Copy component up to (but not including) dot */ - strncpy((char *)cp, dname, len); - cp += len; - if (cp1 == NULL) - { - *cp++ = 0; /* Last one; write null and finish */ - break; - } - dname += len+1; - dlen -= len+1; - } - - cp = put16(cp, 0x0001); /* type */ - cp = put16(cp, 0x0001); /* class */ - - return ((int16_t)((uint32_t)(cp) - (uint32_t)(buf))); -} - -/* - * CHECK DNS TIMEOUT - * - * Description : This function check the DNS timeout - * Arguments : None. - * Returns : -1 - timeout occurred, 0 - timer over, but no timeout, 1 - no timer over, no timeout occur - * Note : timeout : retry count and timer both over. - */ - -int8_t check_DNS_timeout(void) -{ - - if(dns_1s_tick >= DNS_WAIT_TIME) - { - dns_1s_tick = 0; - if(retry_count >= MAX_DNS_RETRY) { - retry_count = 0; - return -1; // timeout occurred - } - retry_count++; - return 0; // timer over, but no timeout - } - - return 1; // no timer over, no timeout occur -} - - - -/* DNS CLIENT INIT */ -void DNS_init(uint8_t s, uint8_t * buf) -{ - DNS_SOCKET = s; // SOCK_DNS - pDNSMSG = buf; // User's shared buffer - DNS_MSGID = DNS_MSG_ID; -} - -/* DNS CLIENT RUN */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns) -{ - int8_t ret; - struct dhdr dhp; - uint8_t ip[4]; - uint16_t len, port; - int8_t ret_check_timeout; - - retry_count = 0; - dns_1s_tick = 0; - - // Socket open - socket(DNS_SOCKET, Sn_MR_UDP, 0, 0); - -#ifdef _DNS_DEBUG_ - printf("> DNS Query to DNS Server : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - - len = dns_makequery(0, (char *)name, pDNSMSG, MAX_DNS_BUF_SIZE); - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - - while (1) - { - if ((len = getSn_RX_RSR(DNS_SOCKET)) > 0) - { - if (len > MAX_DNS_BUF_SIZE) len = MAX_DNS_BUF_SIZE; - len = recvfrom(DNS_SOCKET, pDNSMSG, len, ip, &port); - #ifdef _DNS_DEBUG_ - printf("> Receive DNS message from %d.%d.%d.%d(%d). len = %d\r\n", ip[0], ip[1], ip[2], ip[3],port,len); - #endif - ret = parseDNSMSG(&dhp, pDNSMSG, ip_from_dns); - break; - } - // Check Timeout - ret_check_timeout = check_DNS_timeout(); - if (ret_check_timeout < 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Server is not responding : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - return 0; // timeout occurred - } - else if (ret_check_timeout == 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Timeout\r\n"); -#endif - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - } - } - close(DNS_SOCKET); - // Return value - // 0 > : failed / 1 - success - return ret; -} - - -/* DNS TIMER HANDLER */ -void DNS_time_handler(void) -{ - dns_1s_tick++; -} - - - diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Internet/DNS/dns.h b/06_m1284p_WIZNET_DNS_SNTP_client/Internet/DNS/dns.h deleted file mode 100644 index 6f6aa6b..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Internet/DNS/dns.h +++ /dev/null @@ -1,109 +0,0 @@ -//***************************************************************************** -// -//! \file dns.h -//! \brief DNS APIs Header file. -//! \details Send DNS query & Receive DNS reponse. -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Move the no reference define to dns.c -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#ifndef _DNS_H_ -#define _DNS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/* - * @brief Define it for Debug & Monitor DNS processing. - * @note If defined, it dependens on - */ -//#define _DNS_DEBUG_ - -#define MAX_DNS_BUF_SIZE 256 ///< maximum size of DNS buffer. */ -/* - * @brief Maxium length of your queried Domain name - * @todo SHOULD BE defined it equal as or greater than your Domain name lenght + null character(1) - * @note SHOULD BE careful to stack overflow because it is allocated 1.5 times as MAX_DOMAIN_NAME in stack. - */ -#define MAX_DOMAIN_NAME 16 // for example "www.google.com" - -#define MAX_DNS_RETRY 2 ///< Requery Count -#define DNS_WAIT_TIME 3 ///< Wait response time. unit 1s. - -#define IPPORT_DOMAIN 53 ///< DNS server port number - -#define DNS_MSG_ID 0x1122 ///< ID for DNS message. You can be modifyed it any number -/* - * @brief DNS process initialize - * @param s : Socket number for DNS - * @param buf : Buffer for DNS message - */ -void DNS_init(uint8_t s, uint8_t * buf); - -/* - * @brief DNS process - * @details Send DNS query and receive DNS response - * @param dns_ip : DNS server ip - * @param name : Domain name to be queryed - * @param ip_from_dns : IP address from DNS server - * @return -1 : failed. @ref MAX_DOMIN_NAME is too small \n - * 0 : failed (Timeout or Parse error)\n - * 1 : success - * @note This funtion blocks until success or fail. max time = @ref MAX_DNS_RETRY * @ref DNS_WAIT_TIME - */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns); - -/* - * @brief DNS 1s Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void DNS_time_handler(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _DNS_H_ */ diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/Internet/SNTP/sntp.c b/06_m1284p_WIZNET_DNS_SNTP_client/Internet/SNTP/sntp.c deleted file mode 100644 index 5b9c463..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/Internet/SNTP/sntp.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * sntp.c - * - * Created on: 2014. 12. 15. - * Author: Administrator - */ - - -#include - -#include "sntp.h" -#include "socket.h" - -ntpformat NTPformat; -datetime Nowdatetime; -uint8_t ntpmessage[48]; -uint8_t *data_buf; -uint8_t NTP_SOCKET; -uint8_t time_zone; -uint16_t ntp_retry_cnt=0; //counting the ntp retry number - -/* -00)UTC-12:00 Baker Island, Howland Island (both uninhabited) -01) UTC-11:00 American Samoa, Samoa -02) UTC-10:00 (Summer)French Polynesia (most), United States (Aleutian Islands, Hawaii) -03) UTC-09:30 Marquesas Islands -04) UTC-09:00 Gambier Islands;(Summer)United States (most of Alaska) -05) UTC-08:00 (Summer)Canada (most of British Columbia), Mexico (Baja California) -06) UTC-08:00 United States (California, most of Nevada, most of Oregon, Washington (state)) -07) UTC-07:00 Mexico (Sonora), United States (Arizona); (Summer)Canada (Alberta) -08) UTC-07:00 Mexico (Chihuahua), United States (Colorado) -09) UTC-06:00 Costa Rica, El Salvador, Ecuador (Galapagos Islands), Guatemala, Honduras -10) UTC-06:00 Mexico (most), Nicaragua;(Summer)Canada (Manitoba, Saskatchewan), United States (Illinois, most of Texas) -11) UTC-05:00 Colombia, Cuba, Ecuador (continental), Haiti, Jamaica, Panama, Peru -12) UTC-05:00 (Summer)Canada (most of Ontario, most of Quebec) -13) UTC-05:00 United States (most of Florida, Georgia, Massachusetts, most of Michigan, New York, North Carolina, Ohio, Washington D.C.) -14) UTC-04:30 Venezuela -15) UTC-04:00 Bolivia, Brazil (Amazonas), Chile (continental), Dominican Republic, Canada (Nova Scotia), Paraguay, -16) UTC-04:00 Puerto Rico, Trinidad and Tobago -17) UTC-03:30 Canada (Newfoundland) -18) UTC-03:00 Argentina; (Summer) Brazil (Brasilia, Rio de Janeiro, Sao Paulo), most of Greenland, Uruguay -19) UTC-02:00 Brazil (Fernando de Noronha), South Georgia and the South Sandwich Islands -20) UTC-01:00 Portugal (Azores), Cape Verde -21) UTC±00:00 Cote d'Ivoire, Faroe Islands, Ghana, Iceland, Senegal; (Summer) Ireland, Portugal (continental and Madeira) -22) UTC±00:00 Spain (Canary Islands), Morocco, United Kingdom -23) UTC+01:00 Angola, Cameroon, Nigeria, Tunisia; (Summer)Albania, Algeria, Austria, Belgium, Bosnia and Herzegovina, -24) UTC+01:00 Spain (continental), Croatia, Czech Republic, Denmark, Germany, Hungary, Italy, Kinshasa, Kosovo, -25) UTC+01:00 Macedonia, France (metropolitan), the Netherlands, Norway, Poland, Serbia, Slovakia, Slovenia, Sweden, Switzerland -26) UTC+02:00 Libya, Egypt, Malawi, Mozambique, South Africa, Zambia, Zimbabwe, (Summer)Bulgaria, Cyprus, Estonia, -27) UTC+02:00 Finland, Greece, Israel, Jordan, Latvia, Lebanon, Lithuania, Moldova, Palestine, Romania, Syria, Turkey, Ukraine -28) UTC+03:00 Belarus, Djibouti, Eritrea, Ethiopia, Iraq, Kenya, Madagascar, Russia (Kaliningrad Oblast), Saudi Arabia, -29) UTC+03:00 South Sudan, Sudan, Somalia, South Sudan, Tanzania, Uganda, Yemen -30) UTC+03:30 (Summer)Iran -31) UTC+04:00 Armenia, Azerbaijan, Georgia, Mauritius, Oman, Russia (European), Seychelles, United Arab Emirates -32) UTC+04:30 Afghanistan -33) UTC+05:00 Kazakhstan (West), Maldives, Pakistan, Uzbekistan -34) UTC+05:30 India, Sri Lanka -35) UTC+05:45 Nepal -36) UTC+06:00 Kazakhstan (most), Bangladesh, Russia (Ural: Sverdlovsk Oblast, Chelyabinsk Oblast) -37) UTC+06:30 Cocos Islands, Myanmar -38) UTC+07:00 Jakarta, Russia (Novosibirsk Oblast), Thailand, Vietnam -39) UTC+08:00 China, Hong Kong, Russia (Krasnoyarsk Krai), Malaysia, Philippines, Singapore, Taiwan, most of Mongolia, Western Australia -40) UTC+09:00 Korea, East Timor, Russia (Irkutsk Oblast), Japan -41) UTC+09:30 Australia (Northern Territory);(Summer)Australia (South Australia)) -42) UTC+10:00 Russia (Zabaykalsky Krai); (Summer)Australia (New South Wales, Queensland, Tasmania, Victoria) -43) UTC+10:30 Lord Howe Island -44) UTC+11:00 New Caledonia, Russia (Primorsky Krai), Solomon Islands -45) UTC+11:30 Norfolk Island -46) UTC+12:00 Fiji, Russia (Kamchatka Krai);(Summer)New Zealand -47) UTC+12:45 (Summer)New Zealand -48) UTC+13:00 Tonga -49) UTC+14:00 Kiribati (Line Islands) -*/ -void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx) -{ - tstamp seconds = 0; - uint8_t i=0; - for (i = 0; i < 4; i++) - { - seconds = (seconds << 8) | buf[idx + i]; - } - switch (time_zone) - { - case 0: - seconds -= 12*3600; - break; - case 1: - seconds -= 11*3600; - break; - case 2: - seconds -= 10*3600; - break; - case 3: - seconds -= (9*3600+30*60); - break; - case 4: - seconds -= 9*3600; - break; - case 5: - case 6: - seconds -= 8*3600; - break; - case 7: - case 8: - seconds -= 7*3600; - break; - case 9: - case 10: - seconds -= 6*3600; - break; - case 11: - case 12: - case 13: - seconds -= 5*3600; - break; - case 14: - seconds -= (4*3600+30*60); - break; - case 15: - case 16: - seconds -= 4*3600; - break; - case 17: - seconds -= (3*3600+30*60); - break; - case 18: - seconds -= 3*3600; - break; - case 19: - seconds -= 2*3600; - break; - case 20: - seconds -= 1*3600; - break; - case 21: //? - case 22: - break; - case 23: - case 24: - case 25: - seconds += 1*3600; - break; - case 26: - case 27: - seconds += 2*3600; - break; - case 28: - case 29: - seconds += 3*3600; - break; - case 30: - seconds += (3*3600+30*60); - break; - case 31: - seconds += 4*3600; - break; - case 32: - seconds += (4*3600+30*60); - break; - case 33: - seconds += 5*3600; - break; - case 34: - seconds += (5*3600+30*60); - break; - case 35: - seconds += (5*3600+45*60); - break; - case 36: - seconds += 6*3600; - break; - case 37: - seconds += (6*3600+30*60); - break; - case 38: - seconds += 7*3600; - break; - case 39: - seconds += 8*3600; - break; - case 40: - seconds += 9*3600; - break; - case 41: - seconds += (9*3600+30*60); - break; - case 42: - seconds += 10*3600; - break; - case 43: - seconds += (10*3600+30*60); - break; - case 44: - seconds += 11*3600; - break; - case 45: - seconds += (11*3600+30*60); - break; - case 46: - seconds += 12*3600; - break; - case 47: - seconds += (12*3600+45*60); - break; - case 48: - seconds += 13*3600; - break; - case 49: - seconds += 14*3600; - break; - - } - - //calculation for date - calcdatetime(seconds); -} - -void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf) -{ - NTP_SOCKET = s; - - NTPformat.dstaddr[0] = ntp_server[0]; - NTPformat.dstaddr[1] = ntp_server[1]; - NTPformat.dstaddr[2] = ntp_server[2]; - NTPformat.dstaddr[3] = ntp_server[3]; - - time_zone = tz; - - data_buf = buf; - - uint8_t Flag; - NTPformat.leap = 0; /* leap indicator */ - NTPformat.version = 4; /* version number */ - NTPformat.mode = 3; /* mode */ - NTPformat.stratum = 0; /* stratum */ - NTPformat.poll = 0; /* poll interval */ - NTPformat.precision = 0; /* precision */ - NTPformat.rootdelay = 0; /* root delay */ - NTPformat.rootdisp = 0; /* root dispersion */ - NTPformat.refid = 0; /* reference ID */ - NTPformat.reftime = 0; /* reference time */ - NTPformat.org = 0; /* origin timestamp */ - NTPformat.rec = 0; /* receive timestamp */ - NTPformat.xmt = 1; /* transmit timestamp */ - - Flag = (NTPformat.leap<<6)+(NTPformat.version<<3)+NTPformat.mode; //one byte Flag - memcpy(ntpmessage,(void const*)(&Flag),1); -} - -int8_t SNTP_run(datetime *time) -{ - uint16_t RSR_len; - uint32_t destip = 0; - uint16_t destport; - uint16_t startindex = 40; //last 8-byte of data_buf[size is 48 byte] is xmt, so the startindex should be 40 - - switch(getSn_SR(NTP_SOCKET)) - { - case SOCK_UDP: - if ((RSR_len = getSn_RX_RSR(NTP_SOCKET)) > 0) - { - if (RSR_len > MAX_SNTP_BUF_SIZE) RSR_len = MAX_SNTP_BUF_SIZE; // if Rx data size is lager than TX_RX_MAX_BUF_SIZE - recvfrom(NTP_SOCKET, data_buf, RSR_len, (uint8_t *)&destip, &destport); - - get_seconds_from_ntp_server(data_buf,startindex); - time->yy = Nowdatetime.yy; - time->mo = Nowdatetime.mo; - time->dd = Nowdatetime.dd; - time->hh = Nowdatetime.hh; - time->mm = Nowdatetime.mm; - time->ss = Nowdatetime.ss; - - ntp_retry_cnt=0; - close(NTP_SOCKET); - - return 1; - } - - if(ntp_retry_cnt<0xFFFF) - { - if(ntp_retry_cnt==0)//first send request, no need to wait - { - sendto(NTP_SOCKET,ntpmessage,sizeof(ntpmessage),NTPformat.dstaddr,ntp_port); - ntp_retry_cnt++; - } - else // send request again? it should wait for a while - { - if((ntp_retry_cnt % 0xFFF) == 0) //wait time - { - sendto(NTP_SOCKET,ntpmessage,sizeof(ntpmessage),NTPformat.dstaddr,ntp_port); -#ifdef _SNTP_DEBUG_ - printf("ntp retry: %d\r\n", ntp_retry_cnt); -#endif - ntp_retry_cnt++; - } - } - } - else //ntp retry fail - { - ntp_retry_cnt=0; -#ifdef _SNTP_DEBUG_ - printf("ntp retry failed!\r\n"); -#endif - close(NTP_SOCKET); - } - break; - case SOCK_CLOSED: - socket(NTP_SOCKET,Sn_MR_UDP,ntp_port,0); - break; - } - // Return value - // 0 - failed / 1 - success - return 0; -} - -void calcdatetime(tstamp seconds) -{ - uint8_t yf=0; - tstamp n=0,d=0,total_d=0,rz=0; - uint16_t y=0,r=0,yr=0; - signed long long yd=0; - - n = seconds; - total_d = seconds/(SECS_PERDAY); - d=0; - uint32_t p_year_total_sec=SECS_PERDAY*365; - uint32_t r_year_total_sec=SECS_PERDAY*366; - while(n>=p_year_total_sec) - { - if((EPOCH+r)%400==0 || ((EPOCH+r)%100!=0 && (EPOCH+r)%4==0)) - { - n = n -(r_year_total_sec); - d = d + 366; - } - else - { - n = n - (p_year_total_sec); - d = d + 365; - } - r+=1; - y+=1; - - } - - y += EPOCH; - - Nowdatetime.yy = y; - - yd=0; - yd = total_d - d; - - yf=1; - while(yd>=28) - { - - if(yf==1 || yf==3 || yf==5 || yf==7 || yf==8 || yf==10 || yf==12) - { - yd -= 31; - if(yd<0)break; - rz += 31; - } - - if (yf==2) - { - if (y%400==0 || (y%100!=0 && y%4==0)) - { - yd -= 29; - if(yd<0)break; - rz += 29; - } - else - { - yd -= 28; - if(yd<0)break; - rz += 28; - } - } - if(yf==4 || yf==6 || yf==9 || yf==11 ) - { - yd -= 30; - if(yd<0)break; - rz += 30; - } - yf += 1; - - } - Nowdatetime.mo=yf; - yr = total_d-d-rz; - - yr += 1; - - Nowdatetime.dd=yr; - - //calculation for time - seconds = seconds%SECS_PERDAY; - Nowdatetime.hh = seconds/3600; - Nowdatetime.mm = (seconds%3600)/60; - Nowdatetime.ss = (seconds%3600)%60; - -} - -tstamp changedatetime_to_seconds(void) -{ - tstamp seconds=0; - uint32_t total_day=0; - uint16_t i=0,run_year_cnt=0,l=0; - - l = Nowdatetime.yy;//low - - - for(i=EPOCH;i - -/* - * @brief Define it for Debug & Monitor DNS processing. - * @note If defined, it dependens on - */ -//#define _SNTP_DEBUG_ - -#define MAX_SNTP_BUF_SIZE sizeof(ntpformat) ///< maximum size of DNS buffer. */ - -/* for ntpclient */ -typedef signed char s_char; -typedef unsigned long long tstamp; -typedef unsigned int tdist; - -typedef struct _ntpformat -{ - - uint8_t dstaddr[4]; /* destination (local) address */ - char version; /* version number */ - char leap; /* leap indicator */ - char mode; /* mode */ - char stratum; /* stratum */ - char poll; /* poll interval */ - s_char precision; /* precision */ - tdist rootdelay; /* root delay */ - tdist rootdisp; /* root dispersion */ - char refid; /* reference ID */ - tstamp reftime; /* reference time */ - tstamp org; /* origin timestamp */ - tstamp rec; /* receive timestamp */ - tstamp xmt; /* transmit timestamp */ - - -} ntpformat; - -typedef struct _datetime -{ - uint16_t yy; - uint8_t mo; - uint8_t dd; - uint8_t hh; - uint8_t mm; - uint8_t ss; -} datetime; - -#define ntp_port 123 //ntp server port number -#define SECS_PERDAY 86400UL // seconds in a day = 60*60*24 -#define UTC_ADJ_HRS 9 // SEOUL : GMT+9 -#define EPOCH 1900 // NTP start year - -void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx); -void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf); -int8_t SNTP_run(datetime *time); -tstamp changedatetime_to_seconds(void); -void calcdatetime(tstamp seconds); - -#ifdef __cplusplus -} -#endif - -#endif /* SNTP_H_ */ diff --git a/06_m1284p_WIZNET_DNS_SNTP_client/main.c b/06_m1284p_WIZNET_DNS_SNTP_client/main.c deleted file mode 100644 index d81fd31..0000000 --- a/06_m1284p_WIZNET_DNS_SNTP_client/main.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/DNS/dns.h" -#include "Internet/SNTP/sntp.h" - -//#include // itoa etc.. -/* - * (06)Added SNTP Client example for russian public ntp server: - * (05)Added DNS Lookup example on start-up device - * (03)Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ -#define _MAIN_DEBUG_ - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -#ifdef _MAIN_DEBUG_ - printf("\r\n===== DNS Servers =====\r\n"); - printf("> DNS 1st : %d.%d.%d.%d\r\n", netInfo.dns[0], netInfo.dns[1], netInfo.dns[2], netInfo.dns[3]); - printf("> DNS 2nd : %d.%d.%d.%d\r\n", DNS_2nd[0], DNS_2nd[1], DNS_2nd[2], DNS_2nd[3]); - printf("=======================================\r\n"); - printf("> [NTP] Target Domain Name : %s\r\n", Domain_name); -#endif - - /* DNS client Initialization */ - DNS_init(SOCK_DNS, gDATABUF_DNS); - - /* DNS processing */ - int32_t ret; - if ((ret = DNS_run(netInfo.dns, Domain_name, Domain_IP)) > 0) // try to 1st DNS - { -#ifdef _MAIN_DEBUG_ - printf("> 1st DNS Respond\r\n"); -#endif - } - else if ((ret != -1) && ((ret = DNS_run(DNS_2nd, Domain_name, Domain_IP))>0)) // retry to 2nd DNS - { -#ifdef _MAIN_DEBUG_ - printf("> 2nd DNS Respond\r\n"); -#endif - } - else if(ret == -1) - { -#ifdef _MAIN_DEBUG_ - printf("> MAX_DOMAIN_NAME is too small. Should be redefined it.\r\n"); -#endif - ; - } - else - { -#ifdef _MAIN_DEBUG_ - printf("> DNS Failed\r\n"); -#endif - ; - } - - if(ret > 0) - { -#ifdef _MAIN_DEBUG_ - printf("> Translated %s to [%d.%d.%d.%d]\r\n\r\n",Domain_name,Domain_IP[0],Domain_IP[1],Domain_IP[2],Domain_IP[3]); -#endif - // - // TODO: To be executed User's code after a successful DNS process - // sntp server ip resolved, so init SNTP client - SNTP_init(SOCK_SNTP, Domain_IP, SNTP_TIMESONE, gDATABUF_SNTP); // timezone: Korea, Republic of - //Query SNTP time - do {} - while (SNTP_run(&time) != 1); - sntp_client_enabled = 1; - PRINTF(">SNTP TIME from: %s\r\n", Domain_name); - PRINTF(">%02d/%02d/%d, %02d:%02d:%02d\r\n\r\n", time.dd, time.mo, time.yy, time.hh, time.mm, time.ss); - - } - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - - - - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - uint32_t timer_sntpc_60sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //SNTP every 1min query - if(sntp_client_enabled) - { - if((millis()-timer_sntpc_60sec)> 60000) - { - //here every 60 sec - timer_sntpc_60sec = millis(); - //TODO: this is ugly method (because blocking query), better rewrite with FSM method/protothreads (or use RTOS delay) - do {} - while (SNTP_run(&time) != 1); - sntp_client_enabled = 1; - PRINTF(">SNTP TIME from: %s\r\n", Domain_name); - PRINTF(">%02d/%02d/%d, %02d:%02d:%02d\r\n\r\n", time.dd, time.mo, time.yy, time.hh, time.mm, time.ss); - } - } - - - //PHY Link detect - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/07_m1284p_WIZNET_telnets_basic/.cproject b/07_m1284p_WIZNET_telnets_basic/.cproject deleted file mode 100644 index 0bc291c..0000000 --- a/07_m1284p_WIZNET_telnets_basic/.cproject +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/07_m1284p_WIZNET_telnets_basic/.project b/07_m1284p_WIZNET_telnets_basic/.project deleted file mode 100644 index 69d92eb..0000000 --- a/07_m1284p_WIZNET_telnets_basic/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 07_m1284p_WIZNET_telnets_basic - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/07_m1284p_WIZNET_telnets_basic/Application/loopback/loopback.c b/07_m1284p_WIZNET_telnets_basic/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/07_m1284p_WIZNET_telnets_basic/Application/loopback/loopback.h b/07_m1284p_WIZNET_telnets_basic/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/07_m1284p_WIZNET_telnets_basic/Application/telnet/telnet.c b/07_m1284p_WIZNET_telnets_basic/Application/telnet/telnet.c deleted file mode 100644 index dcf6f09..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Application/telnet/telnet.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - * telnet.c - * - * Created on: 30 . 2018 . - * Author: maxx - */ -#include -#include "telnet.h" -#include "socket.h" -#include "wizchip_conf.h" - -#define GREETING_MSG "Well done guys! Welcome to the IoT world.\r\nType or to exit.\r\n" -#define PASS_MSG "\r\n> pass: " -#define BYE_MSG "\r\nBye-bye!\r\n" - -#define _passcode "1234" //Pass for authorization telnet session - -//Command processor exec command from telnet server -void processCommand(char *command, char *answer) -{ - //Loopback mode - //sprintf_P(answer,PSTR("\r\n> %s\r\n"), command); - - if((strcasestr_P(command, PSTR("HELP")) != 0) ||\ - (strncmp_P(command, PSTR("?"), 1) == 0) ) - { - sprintf_P(answer,PSTR("\r\nAvailable commands:\r\n"\ - "Help/Echo xyz/FreeRAM/Uptime/LED_(ON/OFF/TGL)\r\n")); - - } - else if(strcasestr_P(command, PSTR("ECHO ")) != 0) - { - sprintf_P(answer,PSTR("\r\n> %s\r\n"), (char *)(command+5)); - } - else if(strcasestr_P(command, PSTR("Uptime")) != 0) - { - sprintf_P(answer,PSTR("\r\nServer uptime: %lu sec\r\n"), millis()/1000); - } - else if(strcasestr_P(command, PSTR("FreeRAM")) != 0) - { - sprintf_P(answer,PSTR("\r\nRAM free: %u bytes\r\n"), freeRam()); - } - else if(strcasestr_P(command, PSTR("LED_ON")) != 0) - { - led1_high(); - sprintf_P(answer,PSTR("\r\n> LED: %s\r\n"), (led1_read()? "ON": "OFF")); - } - else if(strcasestr_P(command, PSTR("LED_OFF")) != 0) - { - led1_low(); - sprintf_P(answer,PSTR("\r\n> LED: %s\r\n"), (led1_read()? "ON": "OFF")); - } - else if(strcasestr_P(command, PSTR("LED_TGL")) != 0) - { - led1_tgl(); - sprintf_P(answer,PSTR("\r\n> LED: %s\r\n"), (led1_read()? "ON": "OFF")); - } - else - { - sprintf_P(answer,PSTR("\r\n??Unknown command: <%s>\r\nTry \r\n"), command); - } -} - -int32_t telnet_srv(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0; - - static char cmd_buffer[TELNET_BUF_SIZE] = "\0"; - static uint8_t cmd_buffer_len; - static char msg_answer[128] = "\0"; - -#ifdef _TELNET_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { - //Open connection -#ifdef _TELNET_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d telnet:Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - cmd_buffer_len = 0; - //Send welcome message to client - ret = send(sn, GREETING_MSG, strlen(GREETING_MSG)); - if(ret < 0) - { - close(sn); - return ret; - } - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - //Here when receive message from client - if(size > TELNET_BUF_SIZE) size = TELNET_BUF_SIZE; - ret = recv(sn, buf, size); //receive message - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - - //Parse to quit session - if(buf[0] == 'Q') - { - //Send welcome message to client - ret = send(sn, BYE_MSG, strlen(BYE_MSG)); - //Disconnect - disconnect(sn); - close(sn); - return ret; - } - else - { - //Loop-back received back, just for test!!! - /* - ret = send(sn, buf, size); - if(ret < 0) - { - close(sn); - return ret; - } - */ - - //Parse received message from telnet client - buf[size] = 0x0; //Insert null-terminate symbol (for string parse) - - //Print out command from telnet client - //PRINTF(">> %s\r\n", msg_receive); - - //Fill cmd_buffer until '\n' (NEW LINE) received - //some bulletproof for overflow protection - if(size > TELNET_BUF_SIZE) size = TELNET_BUF_SIZE; - for(int32_t i = 0; i < size; i++) - { - if(buf[i] == '\n') //PARSE '\n'(0x0A NEW LINE) - { - cmd_buffer[cmd_buffer_len++] = 0x0; //Received EOL,so process command - //Clear commnad buffe - cmd_buffer_len = 0; - //Exec process command - processCommand(cmd_buffer, msg_answer); - //Send answer to telnet client - send(sn, msg_answer, strlen(msg_answer)); - - } - else if(buf[i] == '\r') //PARSE '\r'(0x0D RETURN LINE) - { - //Suppress CR symbol - } - else - { - // Any other symbol, fill input buffer - cmd_buffer[cmd_buffer_len++] = buf[i]; - } - - } - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _TELNET_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _TELNET_DEBUG_ - printf("%d telnet:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _TELNET_DEBUG_ - printf("%d telnet:Listen, TELNET server, port [%u]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _TELNET_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _TELNET_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - -//Command processor authorization -uint8_t processAuth(char * pass) -{ - if(strstr_P(pass, PSTR(_passcode)) != 0) - { - //PASS OK - return 1; - } - else - { - //PASS ERROR - return 0; - } -} - -#define TELNET_STATE_BEGIN 0 -#define TELNET_STATE_AUTH 1 -#define TELNET_STATE_PROCESS 2 - -int32_t telnet_auth_srv(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0; - static uint8_t tel_st = TELNET_STATE_BEGIN; - static char cmd_buffer[TELNET_BUF_SIZE] = "\0"; - static uint8_t cmd_buffer_len; - static char msg_answer[128] = "\0"; - -#ifdef _TELNET_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { - //Open connection -#ifdef _TELNET_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d telnet_auth:Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - cmd_buffer_len = 0; - //Send pass message to client - ret = send(sn, PASS_MSG, strlen(PASS_MSG)); - if(ret < 0) - { - close(sn); - return ret; - } - tel_st = TELNET_STATE_AUTH; - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - //Here when receive message from client - if(size > TELNET_BUF_SIZE) size = TELNET_BUF_SIZE; - ret = recv(sn, buf, size); //receive message - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - - //Parse to quit session - if(buf[0] == 'Q') - { - //Send welcome message to client - ret = send(sn, BYE_MSG, strlen(BYE_MSG)); - //Disconnect - disconnect(sn); - close(sn); - return ret; - } - else - { - //Loop-back received back, just for test - /* - ret = send(sn, buf, size); - if(ret < 0) - { - close(sn); - return ret; - } - */ - - //Parse received message from telnet client - buf[size] = 0x0; //Insert null-terminate symbol (for string parse) - - //Print out command from telnet client - //PRINTF(">> %s\r\n", msg_receive); - - //Fill cmd_buffer until '\n' (NEW LINE) received - //some bulletproof for overflow protection - if(size > TELNET_BUF_SIZE) size = TELNET_BUF_SIZE; - for(int32_t i = 0; i < size; i++) - { - if(buf[i] == '\n') //PARSE '\n'(0x0A NEW LINE) - { - cmd_buffer[cmd_buffer_len++] = 0x0; //Received EOL,so process command - //Clear commnad buffe - cmd_buffer_len = 0; - //String to command done - //Check state session (authorization done or not) - if(tel_st == TELNET_STATE_AUTH) - { - //Authorization required - if (processAuth(cmd_buffer)) - { - //Authorization OK - tel_st = TELNET_STATE_PROCESS; - //Send greetings message to client - ret = send(sn, GREETING_MSG, strlen(GREETING_MSG)); - } - else - { - //Authorization ERROR - tel_st = TELNET_STATE_BEGIN; - //Send bye message to client - ret = send(sn, BYE_MSG, strlen(BYE_MSG)); - //Disconnect - disconnect(sn); - close(sn); - return ret; - } - } - else - { - //Authorization done - //Exec process command - processCommand(cmd_buffer, msg_answer); - //Send answer to telnet client - send(sn, msg_answer, strlen(msg_answer)); - } - } - else if(buf[i] == '\r') //PARSE '\r'(0x0D RETURN LINE) - { - //Suppress CR symbol - } - else - { - // Any other symbol, fill input buffer - cmd_buffer[cmd_buffer_len++] = buf[i]; - } - - } - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _TELNET_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - tel_st = TELNET_STATE_BEGIN; - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _TELNET_DEBUG_ - printf("%d telnet_auth:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _TELNET_DEBUG_ - printf("%d telnet_auth:Listen, TELNET_AUTH server, port [%u]\r\n", sn, port); -#endif - tel_st = TELNET_STATE_BEGIN; - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _TELNET_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _TELNET_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - tel_st = TELNET_STATE_BEGIN; - break; - default: - break; - } - return 1; -} - - diff --git a/07_m1284p_WIZNET_telnets_basic/Application/telnet/telnet.h b/07_m1284p_WIZNET_telnets_basic/Application/telnet/telnet.h deleted file mode 100644 index 10177dd..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Application/telnet/telnet.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * telnet.h - * - * Created on: 30 . 2018 . - * Author: maxx - */ - -#ifndef TELNET_H_ -#define TELNET_H_ - -#include "stdint.h" -#include "../../globals.h" - -#define TELNET_PORT 23 -#define TELNET_AUTH_PORT 24 - -int32_t telnet_srv(uint8_t sn, uint8_t* buf, uint16_t port); - -int32_t telnet_auth_srv(uint8_t sn, uint8_t* buf, uint16_t port); - -/*Telnet test debug message printout enable */ -#define _TELNET_DEBUG_ - -/* TELNET_BUF_SIZE define for TELNET example */ -#ifndef TELNET_BUF_SIZE - #define TELNET_BUF_SIZE 64 -#endif - -#endif /* TELNET_H_ */ diff --git a/07_m1284p_WIZNET_telnets_basic/Ethernet/W5500/w5500.c b/07_m1284p_WIZNET_telnets_basic/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/07_m1284p_WIZNET_telnets_basic/Ethernet/W5500/w5500.h b/07_m1284p_WIZNET_telnets_basic/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/07_m1284p_WIZNET_telnets_basic/Ethernet/socket.c b/07_m1284p_WIZNET_telnets_basic/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/07_m1284p_WIZNET_telnets_basic/Ethernet/socket.h b/07_m1284p_WIZNET_telnets_basic/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/07_m1284p_WIZNET_telnets_basic/Ethernet/wizchip_conf.c b/07_m1284p_WIZNET_telnets_basic/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/07_m1284p_WIZNET_telnets_basic/Ethernet/wizchip_conf.h b/07_m1284p_WIZNET_telnets_basic/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/07_m1284p_WIZNET_telnets_basic/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/07_m1284p_WIZNET_telnets_basic/globals.h b/07_m1284p_WIZNET_telnets_basic/globals.h deleted file mode 100644 index 5196aa5..0000000 --- a/07_m1284p_WIZNET_telnets_basic/globals.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Application/telnet/telnet.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif -//#include // itoa etc.. -/* - * (7)Add Telnet simple server (23) - unblocking type via telnet_srv(..) (v2.0) - * (7)Add Telnet authorization (v2.1) (24) - unblocking type via telnet_auth_srv(..) (v2.1) - * Use telnet to connect to defined IP and port. In this example, connect to 192.168.1.192 port 23. The telnet client will receive a message and port closed. - * XP/Windows_7 - * > telnet 192.168.1.192 23 - * - * Windows 10 - * run telnet client - * open 192.168.1.192 23 - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ -/* - * m1284p minimum template, with one button & one led - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v2.1 Static IP Telnet server WIZNET_5500 ETHERNET 01/12/2018\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - /* - *To run blocking telnet server (deprecated) - while(1) - { - _telnet_srv(TELNET_PORT); - } - */ - PRINTF("> Telnet server is running on port %u\r\n", TELNET_PORT); - PRINTF("> Telnet AUTH server is running on port %u\r\n", TELNET_AUTH_PORT); - - - //Telnet SERVER (23) + Loopback Test: TCP Server (5000) and UDP (3000) - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - - /* - * https://www.hw-group.com/software/hercules-setup-utility - * - */ - telnet_srv(3, ethBut3_TELNET, TELNET_PORT); - telnet_auth_srv(4, ethBut4_TELNET, TELNET_AUTH_PORT); - loopback_tcps(0,ethBuf0,5000); - loopback_udps(1, ethBuf0, 3000); - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //Shouldn't use LED for ethernet link here, because it used on telnet command processor - /* - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - */ - - } - - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/.cproject b/08_m1284p_WIZNET_ICMP_aka_ping/.cproject deleted file mode 100644 index 44380b6..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/.cproject +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/.project b/08_m1284p_WIZNET_ICMP_aka_ping/.project deleted file mode 100644 index a1049df..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 08_m1284p_WIZNET_ICMP_aka_ping - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Application/PING/ping.c b/08_m1284p_WIZNET_ICMP_aka_ping/Application/PING/ping.c deleted file mode 100644 index 88b9a3c..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Application/PING/ping.c +++ /dev/null @@ -1,370 +0,0 @@ -#include -#include "ping.h" -#include "socket.h" -#include - -#ifndef Sn_PROTO -#define Sn_PROTO(N) (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -#endif - -PINGMSGR PingRequest; // Variable for Ping Request -PINGMSGR PingReply; // Variable for Ping Reply -static uint16_t RandomID = 0x1234; -static uint16_t RandomSeqNum = 0x4321; - -void wait_1ms(unsigned int cnt); - - - - -uint8_t ping_request(uint8_t s, uint8_t *addr){ - uint16_t i; - - /* make header of the ping-request */ - PingRequest.Type = PING_REQUEST; // Ping-Request - PingRequest.Code = CODE_ZERO; // Always '0' - PingRequest.ID = htons(RandomID++); // set ping-request's ID to random integer value - PingRequest.SeqNum =htons(RandomSeqNum++);// set ping-request's sequence number to ramdom integer value - //size = 32; // set Data size - - /* Fill in Data[] as size of BIF_LEN (Default = 32)*/ - for(i = 0 ; i < PING_BUF_LEN; i++){ - PingRequest.Data[i] = (i) % 8; //'0'~'8' number into ping-request's data - } - /* Do checksum of Ping Request */ - PingRequest.CheckSum = 0; // value of checksum before calucating checksum of ping-request packet - PingRequest.CheckSum = htons(checksum((uint8_t*)&PingRequest,(uint16_t)(sizeof(PingRequest)-PING_BUF_LEN))); // Calculate checksum - - /* sendto ping_request to destination */ - if(sendto(s,(uint8_t *)&PingRequest,(uint16_t)(sizeof(PingRequest)-PING_BUF_LEN),addr,3000)==0){ // Send Ping-Request to the specified peer. -#ifdef PING_DEBUG - printf( "\r\n Fail to send ping-request packet r\n"); - -#endif - }else{ -#ifdef PING_DEBUG - printf( "Send Ping Request to Destination ("); - printf( "%d.%d.%d.%d )", - (int16_t) addr[0], - (int16_t) addr[1], - (int16_t) addr[2], - (int16_t) addr[3]); - printf( " ID:%x SeqNum:%x CheckSum:%x\r\n", - htons(PingRequest.ID), - htons(PingRequest.SeqNum), - htons(PingRequest.CheckSum)) ; -#endif - } - return 0; -} // ping request - - -uint16_t checksum(uint8_t * data_buf, uint16_t len) -{ - uint16_t sum, tsum, i, j; - uint32_t lsum; - - j = len >> 1; - lsum = 0; - tsum = 0; - for (i = 0; i < j; i++) - { - tsum = data_buf[i * 2]; - tsum = tsum << 8; - tsum += data_buf[i * 2 + 1]; - lsum += tsum; - } - if (len % 2) - { - tsum = data_buf[i * 2]; - lsum += (tsum << 8); - } - sum = (uint16_t)lsum; - sum = ~(sum + (lsum >> 16)); - return sum; - -} - -//!!Comment this line for STM8 -#define LITTLE_ENDIAN // for STM32, ATMEGA - -uint16_t htons( uint16_t hostshort) -{ -#ifdef LITTLE_ENDIAN - uint16_t netshort=0; - netshort = (hostshort & 0xFF) << 8; - - netshort |= ((hostshort >> 8)& 0xFF); - return netshort; -#else - return hostshort; -#endif -} - - -/***************************************************************************************** - Function name: wait_1us - Input : cnt; Delay duration = cnt * 1u seconds - Output : non - Description - : A delay function for waiting cnt*1u second. - *****************************************************************************************/ -void wait_1us(unsigned int cnt) -{ - unsigned int i; - - for(i = 0; i>rlen: %u, len: %u\r\n", rlen, len); - if(data_buf[0] == PING_REPLY) - { - PingReply.Type = data_buf[0]; - PingReply.Code = data_buf[1]; - PingReply.CheckSum = (data_buf[3]<<8) + data_buf[2]; - PingReply.ID = (data_buf[5]<<8) + data_buf[4]; - PingReply.SeqNum = (data_buf[7]<<8) + data_buf[6]; - - for(i=0; i 0) - { - //Yes, RX data is present - ping_read(s, dest_ip, len); - } - break; - default: - break; - - } -} diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Application/PING/ping.h b/08_m1284p_WIZNET_ICMP_aka_ping/Application/PING/ping.h deleted file mode 100644 index 4a02373..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Application/PING/ping.h +++ /dev/null @@ -1,47 +0,0 @@ -#include "wizchip_conf.h" - -#define PING_BUF_LEN 32 -#define PING_REQUEST 8 -#define PING_REPLY 0 -#define CODE_ZERO 0 - -#define SOCKET_ERROR 1 -#define TIMEOUT_ERROR 2 -#define SUCCESS 3 -#define REPLY_ERROR 4 - - -//#define PING_DEBUG - - -typedef struct pingmsg -{ - uint8_t Type; // 0 - Ping Reply, 8 - Ping Request - uint8_t Code; // Always 0 - int16_t CheckSum; // Check sum - int16_t ID; // Identification - int16_t SeqNum; // Sequence Number - int8_t Data[PING_BUF_LEN*2];// Ping Data : 1452 = IP RAW MTU - sizeof(Type+Code+CheckSum+ID+SeqNum) -} PINGMSGR; - -void ping_srv(uint8_t s); -uint8_t ping_request(uint8_t s, uint8_t *addr); -uint8_t ping_reply(uint8_t s, uint8_t *addr, uint16_t len); -uint16_t checksum(uint8_t * data_buf, uint16_t len); -uint16_t htons( uint16_t hostshort); /* htons function converts a unsigned short from host to TCP/IP network byte order (which is big-endian).*/ - -//ICMP callback (fire on ICMP request/reply from ping_srv), must be realize somewhere on main.c etc.. -/* - * socket - socket number - * ip_query - IP from which ICMP query (like 192.168.0.x) - * type_query - ICMP query type: PING_REQUEST or PING_REPLY - * id_query - ICMP query Identificator: ID ICMP [0..0xFFFF] - * seq_query - ICMP query Sequence Number : ID Seq num [0..0xFFFF] - * len_query - ICMP query length of the data - */ -extern void icmp_cb(uint8_t socket,\ - uint8_t* ip_query,\ - uint8_t type_query,\ - uint16_t id_query,\ - uint16_t seq_query,\ - uint16_t len_query); diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Application/loopback/loopback.c b/08_m1284p_WIZNET_ICMP_aka_ping/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Application/loopback/loopback.h b/08_m1284p_WIZNET_ICMP_aka_ping/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/W5500/w5500.c b/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/W5500/w5500.h b/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/W5500/w5500.h deleted file mode 100644 index a98d38b..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2164 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_PROTO(N) (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/socket.c b/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/socket.h b/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/wizchip_conf.c b/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/wizchip_conf.h b/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/08_m1284p_WIZNET_ICMP_aka_ping/main.c b/08_m1284p_WIZNET_ICMP_aka_ping/main.c deleted file mode 100644 index 587d109..0000000 --- a/08_m1284p_WIZNET_ICMP_aka_ping/main.c +++ /dev/null @@ -1,504 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Application/PING/ping.h" - -//#include // itoa etc.. -/* - * - * (8) ICMP PING Client-Server unblocking via IPRAW mode - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - uint32_t timer_ping1 = millis(); - uint32_t timer_ping2 = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(0,ethBuf0,5000); - loopback_udps(1, ethBuf0, 3000); - - /* - * run ICMP (ping) server - */ - ping_srv(2); - - /*ICM Ping client example #1 - ping GW/myPC every 10 sec*/ - if((millis()-timer_ping1)> 10000) - { - timer_ping1 = millis(); - //PRINTF("\r\n>> PING GW\r\n"); - //ping_request(2, netInfo.gw); - - PRINTF("\r\n>> PING my PC\r\n"); - ping_request(2, ping_ip); //DEVELOPER PC IP - } - - /*ICM Ping client example #2 - ping DNS google every 15 sec*/ - if((millis()-timer_ping2)> 15000) - { - timer_ping2 = millis(); - PRINTF("\r\n>>> PING DNS\r\n"); - ping_request(2, netInfo.dns); - } - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 128 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/09_m1284p_WIZNET_simple_webserver/.cproject b/09_m1284p_WIZNET_simple_webserver/.cproject deleted file mode 100644 index 075c5bb..0000000 --- a/09_m1284p_WIZNET_simple_webserver/.cproject +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/09_m1284p_WIZNET_simple_webserver/.project b/09_m1284p_WIZNET_simple_webserver/.project deleted file mode 100644 index 740c08d..0000000 --- a/09_m1284p_WIZNET_simple_webserver/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 09_m1284p_WIZNET_simple_webserver - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/09_m1284p_WIZNET_simple_webserver/Application/loopback/loopback.c b/09_m1284p_WIZNET_simple_webserver/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/09_m1284p_WIZNET_simple_webserver/Application/loopback/loopback.h b/09_m1284p_WIZNET_simple_webserver/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webpages.h b/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webpages.h deleted file mode 100644 index 47f7c72..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webpages.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * webpages.h - * - * Created on: 05 . 2018 . - * Author: maxx - */ - -#ifndef WEBPAGES_H_ -#define WEBPAGES_H_ - -#define index_page \ -"\n"\ -"

W5500 Simple Web Server


\n"\ -"

AVR Mega1284p and WIZ5500


\n"\ -"

\n"\ -"Uptime: sec\n"\ -"

LED1 OFF\n"\ -"
LED1 ON\n"\ -"

\n"\ -"\n"\ -"

\n" - -#define page_404 \ -"HTTP/1.0 404 Not Found\r\n"\ -"Content-Type: text/html\r\n"\ -"\r\n"\ -"

404 Not Found

" - -#endif /* WEBPAGES_H_ */ diff --git a/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webserver_simple.c b/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webserver_simple.c deleted file mode 100644 index 8879627..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webserver_simple.c +++ /dev/null @@ -1,257 +0,0 @@ -#include -#include -#include "webserver_simple.h" -#include "socket.h" -#include "wizchip_conf.h" - - -int strindex(char *s,char *t) -{ - uint16_t i,n; - - n=strlen(t); - for(i=0; *(s+i); i++) - { - if (strncmp(s+i,t,n) == 0) - return i; - } - return -1; -} -void SetAutoKeepAlive(sn, time) // time > 0 -{ - setSn_KPALVTR(sn, time); - printf("Sn:%d - kpalvtime: %u sec\r\n",sn, 5*getSn_KPALVTR(sn)); -} - -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0; - int getidx, postidx, getidx_htm, postidx_htm; - char radiostat0[10],radiostat1[10],temp[12]; - - static uint32_t httpd_active_millis; - -#ifdef _WEBSRV_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _WEBSRV_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:WEB Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - //Get timetick to open socket - httpd_active_millis = millis(); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > WEBSRV_DATA_BUF_SIZE) size = WEBSRV_DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - - //Get timetick to read data from socket - httpd_active_millis = millis(); - - size = (uint16_t) ret; - buf[size] = 0x0;// insert null-terminate symbol to correct parse data - -#ifdef _WEBSRV_DEBUG_ - PRINTF("\r\n>>HTTP REQUEST %u bytes:\r\n%s\rn\n",size, buf); -#endif - - // Check the HTTP Request Header - getidx=strindex((char *)buf,"GET / "); - getidx_htm=strindex((char *)buf,"GET /index.htm"); - postidx=strindex((char *)buf,"POST / "); - postidx_htm=strindex((char *)buf,"POST /index.htm"); - - if (getidx >= 0 || postidx >= 0 || getidx_htm >= 0 || postidx_htm >= 0) - { -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. ROOT check!\n"); -#endif - // Now check the Radio Button for POST request - if (postidx >= 0 || postidx_htm >= 0) - { - if (strindex((char *)buf,"radio=0") > 0) - { - //ledmode=0; - //PRINTF("++LED=0\r\n"); - led1_low(); - } - - if (strindex((char *)buf,"radio=1") > 0) - { - //ledmode=1; - //PRINTF("++LED=1\r\n"); - led1_high(); - } - - } -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. Send!\n"); -#endif - //Old method with every string fill - /* - // Create the HTTP Response Header - strcpy_P((char *)buf,PSTR("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n")); - strcat_P((char *)buf,PSTR(""\ - ""\ - )); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

W5500 Simple Web Server


\r\n")); - strcat_P((char *)buf,PSTR("

AVR Mega1284p and WIZ5500


\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - - // Now Send the HTTP Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - // Create the HTTP Temperature Response - sprintf((char *)temp,"%lu",(millis()/1000)); // Convert temperature value to string - - strcpy_P((char *)buf,PSTR("Uptime: OC\r\n")); // for celsius - strcat_P((char *)buf,PSTR("\"> sec\r\n")); // for seconds - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - // Create the HTTP Radio Button 0 Response - strcat_P((char *)buf,PSTR("

LED1 OFF\r\n")); - strcat_P((char *)buf,PSTR("
LED1 ON\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - */ - - //New method, send page at once, (no more then ~1500 bytes content!!) - //Prepare additional data to send - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - //copy page to buffer and send to http client, without additional data - //strcpy_P((char *)buf,PSTR(index_page)); - - //copy page to buffer and send to http client, with additional data - sprintf_P((char *)buf,PSTR(index_page), millis()/1000, radiostat0, radiostat1); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - } - else - { - //Page not found - /* - strcpy_P((char *)buf,PSTR(\ - "HTTP/1.0 404 Not Found\r\n" - "Content-Type: text/html\r\n" - "\r\n" - //" " // Redirect 5 - "

404 Not Found

"\ - )); - */ - - //copy page to buffer and send to http client, without additional data - strcpy_P((char *)buf,PSTR(page_404)); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - } - // Disconnect the socket - disconnect(sn); - } - else - { - //here when opened socket connection but no data received - if((millis()-httpd_active_millis) > HTTPD_OPEN_TIMEOUT) - { - //Force close socket, after 3 sec idle (To beat Chrome "persistent connection") -#ifdef _WEBSRV_DEBUG_ - PRINTF("!!HTTPD timeout, Force close socket\r\n"); -#endif - close(sn); - } - } - break; - /* - case SOCK_FIN_WAIT: - case SOCK_CLOSING: - case SOCK_TIME_WAIT: - case SOCK_LAST_ACK: - //case SOCK_CLOSE_WAIT: - //Force close socket - close(sn); - */ - - break; - case SOCK_CLOSE_WAIT : -#ifdef _WEBSRV_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _WEBSRV_DEBUG_ - printf("%d:WEB Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _WEBSRV_DEBUG_ - printf("%d:Listen, WEB server, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _WEBSRV_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; - //This is not helped with Chrome keep-alive sessions - //SetAutoKeepAlive(sn, 1); // set Auto keepalive 5sec(1*5) (This is for TCP IP only!) -#ifdef _WEBSRV_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} diff --git a/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webserver_simple.h b/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webserver_simple.h deleted file mode 100644 index b851fbc..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Application/webserver_simple/webserver_simple.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _WEBSERVER_SIMPLE_H_ -#define _WEBSERVER_SIMPLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../../globals.h" -#include "webpages.h" - -/* Loopback test debug message printout enable */ -#define _WEBSRV_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef WEBSRV_DATA_BUF_SIZE - #define WEBSRV_DATA_BUF_SIZE 2048 -#endif - -//Timeout (ms) to close too long opened socket (Help from freeze with work with Chrome browser (keep persistent connection on WIN7 ~ 120 sec)) -#define HTTPD_OPEN_TIMEOUT 3000 - -/* WEB SERVER test example */ -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port); - -int strindex(char *s,char *t); - - -#ifdef __cplusplus -} -#endif - -#endif //_WEBSERVER_SIMPLE_H_ diff --git a/09_m1284p_WIZNET_simple_webserver/Ethernet/W5500/w5500.c b/09_m1284p_WIZNET_simple_webserver/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/09_m1284p_WIZNET_simple_webserver/Ethernet/W5500/w5500.h b/09_m1284p_WIZNET_simple_webserver/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/09_m1284p_WIZNET_simple_webserver/Ethernet/socket.c b/09_m1284p_WIZNET_simple_webserver/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/09_m1284p_WIZNET_simple_webserver/Ethernet/socket.h b/09_m1284p_WIZNET_simple_webserver/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/09_m1284p_WIZNET_simple_webserver/Ethernet/wizchip_conf.c b/09_m1284p_WIZNET_simple_webserver/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/09_m1284p_WIZNET_simple_webserver/Ethernet/wizchip_conf.h b/09_m1284p_WIZNET_simple_webserver/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/09_m1284p_WIZNET_simple_webserver/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/09_m1284p_WIZNET_simple_webserver/globals.h b/09_m1284p_WIZNET_simple_webserver/globals.h deleted file mode 100644 index 5196aa5..0000000 --- a/09_m1284p_WIZNET_simple_webserver/globals.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< - - - - -

W5500 Simple Web Server


-

AVR_maxxir Mega1284p and WIZ5500


-
- -Uptime: sec -

LED1 OFF -
LED1 ON -

- - -

-
- - - \ No newline at end of file diff --git a/09_m1284p_WIZNET_simple_webserver/main.c b/09_m1284p_WIZNET_simple_webserver/main.c deleted file mode 100644 index 7e811d2..0000000 --- a/09_m1284p_WIZNET_simple_webserver/main.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Application/webserver_simple/webserver_simple.h" - -//#include // itoa etc.. -/* - * (9) Simple webserver, based on code from: - * http://www.ermicro.com/blog/?p=1773 - * Article: Integrating Wiznet W5100, WIZ811MJ network module with Atmel AVR Microcontroller - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - //uint32_t timer_link_1sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(0,ethBuf0,5000); - loopback_udps(1, ethBuf1, 3000); - - //Use WEBbrowser to connect to webserver: http://192.168.0.199/index.html - websrv_simple(2, ethBuf2_WEBSRV, 80); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //Not used here, because led1 handle via websrv_simple - /* - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - */ - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/.cproject b/10_m1284p_WIZNET_HTTPServer_RAM_pages/.cproject deleted file mode 100644 index 841372e..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/.cproject +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/.project b/10_m1284p_WIZNET_HTTPServer_RAM_pages/.project deleted file mode 100644 index 137b4b0..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 10_m1284p_WIZNET_HTTPServer_RAM_pages - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/loopback/loopback.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/loopback/loopback.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webpages.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webpages.h deleted file mode 100644 index 47f7c72..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webpages.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * webpages.h - * - * Created on: 05 . 2018 . - * Author: maxx - */ - -#ifndef WEBPAGES_H_ -#define WEBPAGES_H_ - -#define index_page \ -"\n"\ -"

W5500 Simple Web Server


\n"\ -"

AVR Mega1284p and WIZ5500


\n"\ -"

\n"\ -"Uptime: sec\n"\ -"

LED1 OFF\n"\ -"
LED1 ON\n"\ -"

\n"\ -"\n"\ -"

\n" - -#define page_404 \ -"HTTP/1.0 404 Not Found\r\n"\ -"Content-Type: text/html\r\n"\ -"\r\n"\ -"

404 Not Found

" - -#endif /* WEBPAGES_H_ */ diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webserver_simple.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webserver_simple.c deleted file mode 100644 index 8879627..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webserver_simple.c +++ /dev/null @@ -1,257 +0,0 @@ -#include -#include -#include "webserver_simple.h" -#include "socket.h" -#include "wizchip_conf.h" - - -int strindex(char *s,char *t) -{ - uint16_t i,n; - - n=strlen(t); - for(i=0; *(s+i); i++) - { - if (strncmp(s+i,t,n) == 0) - return i; - } - return -1; -} -void SetAutoKeepAlive(sn, time) // time > 0 -{ - setSn_KPALVTR(sn, time); - printf("Sn:%d - kpalvtime: %u sec\r\n",sn, 5*getSn_KPALVTR(sn)); -} - -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0; - int getidx, postidx, getidx_htm, postidx_htm; - char radiostat0[10],radiostat1[10],temp[12]; - - static uint32_t httpd_active_millis; - -#ifdef _WEBSRV_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _WEBSRV_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:WEB Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - //Get timetick to open socket - httpd_active_millis = millis(); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > WEBSRV_DATA_BUF_SIZE) size = WEBSRV_DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - - //Get timetick to read data from socket - httpd_active_millis = millis(); - - size = (uint16_t) ret; - buf[size] = 0x0;// insert null-terminate symbol to correct parse data - -#ifdef _WEBSRV_DEBUG_ - PRINTF("\r\n>>HTTP REQUEST %u bytes:\r\n%s\rn\n",size, buf); -#endif - - // Check the HTTP Request Header - getidx=strindex((char *)buf,"GET / "); - getidx_htm=strindex((char *)buf,"GET /index.htm"); - postidx=strindex((char *)buf,"POST / "); - postidx_htm=strindex((char *)buf,"POST /index.htm"); - - if (getidx >= 0 || postidx >= 0 || getidx_htm >= 0 || postidx_htm >= 0) - { -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. ROOT check!\n"); -#endif - // Now check the Radio Button for POST request - if (postidx >= 0 || postidx_htm >= 0) - { - if (strindex((char *)buf,"radio=0") > 0) - { - //ledmode=0; - //PRINTF("++LED=0\r\n"); - led1_low(); - } - - if (strindex((char *)buf,"radio=1") > 0) - { - //ledmode=1; - //PRINTF("++LED=1\r\n"); - led1_high(); - } - - } -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. Send!\n"); -#endif - //Old method with every string fill - /* - // Create the HTTP Response Header - strcpy_P((char *)buf,PSTR("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n")); - strcat_P((char *)buf,PSTR(""\ - ""\ - )); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

W5500 Simple Web Server


\r\n")); - strcat_P((char *)buf,PSTR("

AVR Mega1284p and WIZ5500


\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - - // Now Send the HTTP Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - // Create the HTTP Temperature Response - sprintf((char *)temp,"%lu",(millis()/1000)); // Convert temperature value to string - - strcpy_P((char *)buf,PSTR("Uptime: OC\r\n")); // for celsius - strcat_P((char *)buf,PSTR("\"> sec\r\n")); // for seconds - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - // Create the HTTP Radio Button 0 Response - strcat_P((char *)buf,PSTR("

LED1 OFF\r\n")); - strcat_P((char *)buf,PSTR("
LED1 ON\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - */ - - //New method, send page at once, (no more then ~1500 bytes content!!) - //Prepare additional data to send - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - //copy page to buffer and send to http client, without additional data - //strcpy_P((char *)buf,PSTR(index_page)); - - //copy page to buffer and send to http client, with additional data - sprintf_P((char *)buf,PSTR(index_page), millis()/1000, radiostat0, radiostat1); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - } - else - { - //Page not found - /* - strcpy_P((char *)buf,PSTR(\ - "HTTP/1.0 404 Not Found\r\n" - "Content-Type: text/html\r\n" - "\r\n" - //" " // Redirect 5 - "

404 Not Found

"\ - )); - */ - - //copy page to buffer and send to http client, without additional data - strcpy_P((char *)buf,PSTR(page_404)); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - } - // Disconnect the socket - disconnect(sn); - } - else - { - //here when opened socket connection but no data received - if((millis()-httpd_active_millis) > HTTPD_OPEN_TIMEOUT) - { - //Force close socket, after 3 sec idle (To beat Chrome "persistent connection") -#ifdef _WEBSRV_DEBUG_ - PRINTF("!!HTTPD timeout, Force close socket\r\n"); -#endif - close(sn); - } - } - break; - /* - case SOCK_FIN_WAIT: - case SOCK_CLOSING: - case SOCK_TIME_WAIT: - case SOCK_LAST_ACK: - //case SOCK_CLOSE_WAIT: - //Force close socket - close(sn); - */ - - break; - case SOCK_CLOSE_WAIT : -#ifdef _WEBSRV_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _WEBSRV_DEBUG_ - printf("%d:WEB Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _WEBSRV_DEBUG_ - printf("%d:Listen, WEB server, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _WEBSRV_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; - //This is not helped with Chrome keep-alive sessions - //SetAutoKeepAlive(sn, 1); // set Auto keepalive 5sec(1*5) (This is for TCP IP only!) -#ifdef _WEBSRV_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webserver_simple.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webserver_simple.h deleted file mode 100644 index b851fbc..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Application/webserver_simple/webserver_simple.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _WEBSERVER_SIMPLE_H_ -#define _WEBSERVER_SIMPLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../../globals.h" -#include "webpages.h" - -/* Loopback test debug message printout enable */ -#define _WEBSRV_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef WEBSRV_DATA_BUF_SIZE - #define WEBSRV_DATA_BUF_SIZE 2048 -#endif - -//Timeout (ms) to close too long opened socket (Help from freeze with work with Chrome browser (keep persistent connection on WIN7 ~ 120 sec)) -#define HTTPD_OPEN_TIMEOUT 3000 - -/* WEB SERVER test example */ -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port); - -int strindex(char *s,char *t); - - -#ifdef __cplusplus -} -#endif - -#endif //_WEBSERVER_SIMPLE_H_ diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/W5500/w5500.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/W5500/w5500.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/socket.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/socket.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/wizchip_conf.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/wizchip_conf.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpParser.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpParser.c deleted file mode 100644 index 3d353e3..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpParser.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - @file httpd.c - @brief functions associated http processing - */ - -#include -#include -#include "socket.h" -#include "httpParser.h" - -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -//uint8_t BUFPUB[2048]; -uint8_t BUFPUB[256]; - -/***************************************************************************** - * Private functions - ****************************************************************************/ -static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */ -static uint8_t C2D(uint8_t c); /* Convert a character to HEX */ - -/** - @brief convert escape characters(%XX) to ASCII character - */ -void unescape_http_url( - char * url /**< pointer to be converted ( escape characters )*/ - ) -{ - int x, y; - - for (x = 0, y = 0; url[y]; ++x, ++y) { - if ((url[x] = url[y]) == '%') { - url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]); - y+=2; - } - } - url[x] = '\0'; -} - - -/** - @brief make response header such as html, gif, jpeg,etc. - */ -void make_http_response_head( - char * buf, /**< pointer to response header to be made */ - char type, /**< response type */ - uint32_t len /**< size of response header */ - ) -{ - char * head; - char tmp[10]; - - /* file type*/ - if (type == PTYPE_HTML) head = RES_HTMLHEAD_OK; - else if (type == PTYPE_GIF) head = RES_GIFHEAD_OK; - else if (type == PTYPE_TEXT) head = RES_TEXTHEAD_OK; - else if (type == PTYPE_JPEG) head = RES_JPEGHEAD_OK; - else if (type == PTYPE_FLASH) head = RES_FLASHHEAD_OK; - else if (type == PTYPE_XML) head = RES_XMLHEAD_OK; - else if (type == PTYPE_CSS) head = RES_CSSHEAD_OK; - else if (type == PTYPE_JSON) head = RES_JSONHEAD_OK; - else if (type == PTYPE_JS) head = RES_JSHEAD_OK; - else if (type == PTYPE_CGI) head = RES_CGIHEAD_OK; - else if (type == PTYPE_PNG) head = RES_PNGHEAD_OK; - else if (type == PTYPE_ICO) head = RES_ICOHEAD_OK; - else if (type == PTYPE_TTF) head = RES_TTFHEAD_OK; - else if (type == PTYPE_OTF) head = RES_OTFHEAD_OK; - else if (type == PTYPE_WOFF) head = RES_WOFFHEAD_OK; - else if (type == PTYPE_EOT) head = RES_EOTHEAD_OK; - else if (type == PTYPE_SVG) head = RES_SVGHEAD_OK; -#ifdef _HTTPPARSER_DEBUG_ - else - { - head = NULL; - printf("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n"); - } -#else - else head = NULL; -#endif - - sprintf(tmp, "%ld", len); - strcpy(buf, head); - strcat(buf, tmp); - strcat(buf, "\r\n\r\n"); -} - - -/** - @brief find MIME type of a file - */ -void find_http_uri_type( - uint8_t * type, /**< type to be returned */ - uint8_t * buff /**< file name */ - ) -{ - /* Decide type according to extension*/ - - char * buf; - buf = (char *)buff; - - if (strstr(buf, ".htm") || strstr(buf, ".html")) *type = PTYPE_HTML; - else if (strstr(buf, ".gif")) *type = PTYPE_GIF; - else if (strstr(buf, ".text") || strstr(buf,".txt")) *type = PTYPE_TEXT; - else if (strstr(buf, ".jpeg") || strstr(buf,".jpg")) *type = PTYPE_JPEG; - else if (strstr(buf, ".swf")) *type = PTYPE_FLASH; - else if (strstr(buf, ".cgi") || strstr(buf,".CGI")) *type = PTYPE_CGI; - else if (strstr(buf, ".json") || strstr(buf,".JSON")) *type = PTYPE_JSON; - else if (strstr(buf, ".js") || strstr(buf,".JS")) *type = PTYPE_JS; - else if (strstr(buf, ".CGI") || strstr(buf,".cgi")) *type = PTYPE_CGI; - else if (strstr(buf, ".xml") || strstr(buf,".XML")) *type = PTYPE_XML; - else if (strstr(buf, ".css") || strstr(buf,".CSS")) *type = PTYPE_CSS; - else if (strstr(buf, ".png") || strstr(buf,".PNG")) *type = PTYPE_PNG; - else if (strstr(buf, ".ico") || strstr(buf,".ICO")) *type = PTYPE_ICO; - else if (strstr(buf, ".ttf") || strstr(buf,".TTF")) *type = PTYPE_TTF; - else if (strstr(buf, ".otf") || strstr(buf,".OTF")) *type = PTYPE_OTF; - else if (strstr(buf, ".woff") || strstr(buf,".WOFF")) *type = PTYPE_WOFF; - else if (strstr(buf, ".eot") || strstr(buf,".EOT")) *type = PTYPE_EOT; - else if (strstr(buf, ".svg") || strstr(buf,".SVG")) *type = PTYPE_SVG; - else *type = PTYPE_ERR; -} - - -/** - @brief parse http request from a peer - */ -void parse_http_request( - st_http_request * request, /**< request to be returned */ - uint8_t * buf /**< pointer to be parsed */ - ) -{ - char * nexttok; - nexttok = strtok((char*)buf," "); - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - if(!strcmp(nexttok, "GET") || !strcmp(nexttok,"get")) - { - request->METHOD = METHOD_GET; - nexttok = strtok(NULL," "); - - } - else if (!strcmp(nexttok, "HEAD") || !strcmp(nexttok,"head")) - { - request->METHOD = METHOD_HEAD; - nexttok = strtok(NULL," "); - - } - else if (!strcmp(nexttok, "POST") || !strcmp(nexttok,"post")) - { - nexttok = strtok(NULL,"\0"); - request->METHOD = METHOD_POST; - } - else - { - request->METHOD = METHOD_ERR; - } - - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - strcpy((char *)request->URI, nexttok); -} - -#ifdef _OLD_ -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value( - char* uri, - char* param_name - ) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * name = 0; - - - if(!uri || !param_name) return 0; - - strcpy((char*)tempURI,uri); - if((name = (uint8_t*)strstr(tempURI, param_name))) - { - name += strlen(param_name) + 1; // strlen(para_name) + strlen("=") - if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0"))) - { - unescape_http_url((char *)name); - replacetochar(name, '+', ' '); - } - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s",param_name,name); -#endif - - return name; -} -#else -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value(char* uri, char* param_name) -{ - - uint8_t * name = 0; - uint8_t * ret = BUFPUB; - uint8_t * pos2; - uint16_t len = 0, content_len = 0; - uint8_t tmp_buf[10]={0x00, }; - - if(!uri || !param_name) return 0; - - /***************/ - mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf); - content_len = ATOI(tmp_buf, 10); - uri = strstr(uri, "\r\n\r\n"); - uri += 4; - uri[content_len] = 0; - /***************/ - - if((name = (uint8_t *)strstr(uri, param_name))) - { - name += strlen(param_name) + 1; - pos2 = (uint8_t*)strstr((char*)name, "&"); - if(!pos2) - { - pos2 = name + strlen((char*)name); - } - len = pos2 - name; - - if(len) - { - ret[len] = 0; - strncpy((char*)ret,(char*)name, len); - unescape_http_url((char *)ret); - replacetochar(ret, '+' ,' '); - //ret[len] = 0; - //ret[strlen((int8*)ret)] = 0; - //printf("len=%d\r\n",len); - } - else - { - ret[0] = 0; - } - } - else - { - return 0; - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s\r\n", param_name, ret); -#endif - return ret; -} -#endif - -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * uri_name; - - if(!uri) return 0; - - strcpy(tempURI, (char *)uri); - - uri_name = (uint8_t *)strtok(tempURI, " ?"); - - if(strcmp((char *)uri_name,"/")) uri_name++; - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_name); -#endif - - return uri_name; -} -#else - -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf) -{ - uint8_t * uri_ptr; - if(!uri) return 0; - - strcpy((char *)uri_buf, (char *)uri); - - uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?"); - - if(strcmp((char *)uri_ptr,"/")) uri_ptr++; - strcpy((char *)uri_buf, (char *)uri_ptr); - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_buf); -#endif - - return 1; -} - -#endif - -void inet_addr_(uint8_t * addr, uint8_t *ip) -{ - uint8_t i; - uint8_t taddr[30]; - uint8_t * nexttok; - uint8_t num; - - strcpy((char *)taddr, (char *)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (uint8_t *)strtok((char *)nexttok, "."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10); - else num = ATOI(nexttok,10); - ip[i] = num; - nexttok = NULL; - } -} - - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; -// debug_2013_11_25 -// while (*str !=0) - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -/** - * @brief Check strings and then execute callback function by each string. - * @param src The information of URI - * @param s1 The start string to be researched - * @param s2 The end string to be researched - * @param sub The string between s1 and s2 - * @return The length value atfer working - */ -void mid(char* src, char* s1, char* s2, char* sub) -{ - char* sub1; - char* sub2; - uint16_t n; - - sub1=strstr((char*)src,(char*)s1); - sub1+=strlen((char*)s1); - sub2=strstr((char*)sub1,(char*)s2); - - n=sub2-sub1; - strncpy((char*)sub,(char*)sub1,n); - sub[n]='\0'; -} - -//////////////////////////////////////////////////////////////////// -// Static functions -//////////////////////////////////////////////////////////////////// - -/** -@brief replace the specified character in a string with new character -*/ -static void replacetochar( - uint8_t * str, /**< pointer to be replaced */ - uint8_t oldchar, /**< old character */ - uint8_t newchar /**< new character */ - ) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == oldchar) str[x] = newchar; -} - -/** -@brief CONVERT CHAR INTO HEX -@return HEX - -This function converts HEX(0-F) to a character -*/ -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - - - diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpParser.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpParser.h deleted file mode 100644 index b64be68..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpParser.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - @file httpd.h - @brief Define Constants and fucntions associated with HTTP protocol. - */ - -#include - -#ifndef __HTTPPARSER_H__ -#define __HTTPPARSER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#define _HTTPPARSER_DEBUG_ - -#define HTTP_SERVER_PORT 80 /**< HTTP server well-known port number */ - -/* HTTP Method */ -#define METHOD_ERR 0 /**< Error Method. */ -#define METHOD_GET 1 /**< GET Method. */ -#define METHOD_HEAD 2 /**< HEAD Method. */ -#define METHOD_POST 3 /**< POST Method. */ - -/* HTTP GET Method */ -#define PTYPE_ERR 0 /**< Error file. */ -#define PTYPE_HTML 1 /**< HTML file. */ -#define PTYPE_GIF 2 /**< GIF file. */ -#define PTYPE_TEXT 3 /**< TEXT file. */ -#define PTYPE_JPEG 4 /**< JPEG file. */ -#define PTYPE_FLASH 5 /**< FLASH file. */ -#define PTYPE_MPEG 6 /**< MPEG file. */ -#define PTYPE_PDF 7 /**< PDF file. */ -#define PTYPE_CGI 8 /**< CGI file. */ -#define PTYPE_XML 9 /**< XML file. */ -#define PTYPE_CSS 10 /**< CSS file. */ -#define PTYPE_JS 11 /**< JavaScript file. */ -#define PTYPE_JSON 12 /**< JSON (JavaScript Standard Object Notation) file. */ -#define PTYPE_PNG 13 /**< PNG file. */ -#define PTYPE_ICO 14 /**< ICON file. */ - -#define PTYPE_TTF 20 /**< Font type: TTF file. */ -#define PTYPE_OTF 21 /**< Font type: OTF file. */ -#define PTYPE_WOFF 22 /**< Font type: WOFF file. */ -#define PTYPE_EOT 23 /**< Font type: EOT file. */ -#define PTYPE_SVG 24 /**< Font type: SVG file. */ - - -/* HTTP response */ -#define STATUS_OK 200 -#define STATUS_CREATED 201 -#define STATUS_ACCEPTED 202 -#define STATUS_NO_CONTENT 204 -#define STATUS_MV_PERM 301 -#define STATUS_MV_TEMP 302 -#define STATUS_NOT_MODIF 304 -#define STATUS_BAD_REQ 400 -#define STATUS_UNAUTH 401 -#define STATUS_FORBIDDEN 403 -#define STATUS_NOT_FOUND 404 -#define STATUS_INT_SERR 500 -#define STATUS_NOT_IMPL 501 -#define STATUS_BAD_GATEWAY 502 -#define STATUS_SERV_UNAVAIL 503 - -/* HTML Doc. for ERROR */ -static const char ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n\r\n\r\nSorry, the page you requested was not found.\r\n\r\n\r\n\0"; -static const char ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n\r\n\r\nInvalid request.\r\n\r\n\r\n\0"; - -/* HTML Doc. for CGI result */ -#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response header for HTML*/ -#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for TEXT */ -#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " - -/* Response head for GIF */ -#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: " - -/* Response head for JPEG */ -#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: " - -/* Response head for PNG */ -#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: " - -/* Response head for FLASH */ -#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: " - -/* Response head for XML */ -#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for CSS */ -#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: " - -/* Response head for JavaScript */ -#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: " - -/* Response head for JSON */ -#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " - -/* Response head for ICO */ -#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: " - -/* Response head for CGI */ -#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response head for TTF, Font */ -#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: " - -/* Response head for OTF, Font */ -#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: " - -/* Response head for WOFF, Font */ -#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: " - -/* Response head for EOT, Font */ -#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: " - -/* Response head for SVG, Font */ -#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: " - -/** - @brief Structure of HTTP REQUEST - */ - -//#define MAX_URI_SIZE 1461 -#define MAX_URI_SIZE 512 - -typedef struct _st_http_request -{ - uint8_t METHOD; /**< request method(METHOD_GET...). */ - uint8_t TYPE; /**< request type(PTYPE_HTML...). */ - uint8_t URI[MAX_URI_SIZE]; /**< request file name. */ -}st_http_request; - -// HTTP Parsing functions -void unescape_http_url(char * url); /* convert escape character to ascii */ -void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */ -void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */ -void make_http_response_head(char *, char, uint32_t); /* make response header */ -uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */ -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */ -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri); -#endif - -// Utility functions -uint16_t ATOI(uint8_t * str, uint8_t base); -void mid(char* src, char* s1, char* s2, char* sub); -void inet_addr_(uint8_t * addr, uint8_t * ip); - -#ifdef __cplusplus -} -#endif - -#endif /* end of __HTTPPARSER_H__ */ diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpServer.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpServer.c deleted file mode 100644 index dbbead8..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpServer.c +++ /dev/null @@ -1,759 +0,0 @@ -#include -#include -#include - -#include "socket.h" -#include "wizchip_conf.h" - -#include "httpServer.h" -#include "httpParser.h" -#include "httpUtil.h" - -#ifdef _USE_SDCARD_ -#include "ff.h" // header file for FatFs library (FAT file system) -#endif - -#ifndef DATA_BUF_SIZE - //#define DATA_BUF_SIZE 2048 //This is for maximum throughput -/* -!!Don't forget also set size HTTPD_MAX_BUF_SIZE in like: -#define HTTPD_MAX_BUF_SIZE 2048 //This is for maximum throughput -*/ - - #define DATA_BUF_SIZE 512 //This is for save RAM resources -/* -!!Don't forget also set size HTTPD_MAX_BUF_SIZE in like: -#define HTTPD_MAX_BUF_SIZE 512 //This is for save RAM resources -*/ -#endif - -/***************************************************************************** - * Private types/enumerations/variables - ****************************************************************************/ -static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, }; -static st_http_request * http_request; /**< Pointer to received HTTP request */ -static st_http_request * parsed_http_request; /**< Pointer to parsed HTTP request */ -static uint8_t * http_response; /**< Pointer to HTTP response */ - -// ## For Debugging -//static uint8_t uri_buf[128]; - -// Number of registered web content in code flash memory -static uint16_t total_content_cnt = 0; -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -uint8_t * pHTTP_TX; -uint8_t * pHTTP_RX; - -volatile uint32_t httpServer_tick_1s = 0; -st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }; -httpServer_webContent web_content[MAX_CONTENT_CALLBACK]; - -#ifdef _USE_SDCARD_ -FIL fs; // FatFs: File object -FRESULT fr; // FatFs: File function return code -#endif - -/***************************************************************************** - * Private functions - ****************************************************************************/ -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist); -static uint8_t getHTTPSocketNum(uint8_t seqnum); -static int8_t getHTTPSequenceNum(uint8_t socket); -static int8_t http_disconnect(uint8_t sn); - -static void http_process_handler(uint8_t s, st_http_request * p_http_request); -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status); -static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len); - -/***************************************************************************** - * Public functions - ****************************************************************************/ -// Callback functions definition: MCU Reset / WDT Reset -void default_mcu_reset(void) {;} -void default_wdt_reset(void) {;} -void (*HTTPServer_ReStart)(void) = default_mcu_reset; -void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset; - -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist) -{ - uint8_t i; - - for(i = 0; i < cnt; i++) - { - // Mapping the H/W socket numbers to the sequential index numbers - HTTPSock_Num[i] = socklist[i]; - } -} - -static uint8_t getHTTPSocketNum(uint8_t seqnum) -{ - // Return the 'H/W socket number' corresponding to the index number - return HTTPSock_Num[seqnum]; -} - -static int8_t getHTTPSequenceNum(uint8_t socket) -{ - uint8_t i; - - for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++) - if(HTTPSock_Num[i] == socket) return i; - - return -1; -} - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist) -{ - // User's shared buffer - pHTTP_TX = tx_buf; - pHTTP_RX = rx_buf; - - // H/W Socket number mapping - httpServer_Sockinit(cnt, socklist); -} - - -/* Register the call back functions for HTTP Server */ -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)) -{ - // Callback: HW Reset and WDT reset function for each MCU platforms - if(mcu_reset) HTTPServer_ReStart = mcu_reset; - if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset; -} - - -void httpServer_run(uint8_t seqnum) -{ - uint8_t s; // socket number - uint16_t len; - uint32_t gettime = 0; - -#ifdef _HTTPSERVER_DEBUG_ - uint8_t destip[4] = {0, }; - uint16_t destport = 0; -#endif - - http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request - parsed_http_request = (st_http_request *)pHTTP_TX; - - // Get the H/W socket number - s = getHTTPSocketNum(seqnum); - - /* HTTP Service Start */ - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - } - - // HTTP Process states - switch(HTTPSock_Status[seqnum].sock_status) - { - - case STATE_HTTP_IDLE : - if ((len = getSn_RX_RSR(s)) > 0) - { - if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; - len = recv(s, (uint8_t *)http_request, len); - - *(((uint8_t *)http_request) + len) = '\0'; - - parse_http_request(parsed_http_request, (uint8_t *)http_request); -#ifdef _HTTPSERVER_DEBUG_ - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - printf("\r\n"); - printf("> HTTPSocket[%d] : HTTP Request received ", s); - printf("from %d.%d.%d.%d : %d\r\n", destip[0], destip[1], destip[2], destip[3], destport); -#endif -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -#endif - // HTTP 'response' handler; includes send_http_response_header / body function - http_process_handler(s, parsed_http_request); - - gettime = get_httpServer_timecount(); - // Check the TX socket buffer for End of HTTP response sends - while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) - { - if((get_httpServer_timecount() - gettime) > 3) - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -#endif - break; - } - } - - if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; - else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end - } - break; - - case STATE_HTTP_RES_INPROC : - /* Repeat: Send the remain parts of HTTP responses */ -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); -#endif - // Repeatedly send remaining data to client - send_http_response_body(s, 0, http_response, 0, 0); - - if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - - case STATE_HTTP_RES_DONE : -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -#endif - // Socket file info structure re-initialize - HTTPSock_Status[seqnum].file_len = 0; - HTTPSock_Status[seqnum].file_offset = 0; - HTTPSock_Status[seqnum].file_start = 0; - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; - -//#ifdef _USE_SDCARD_ -// f_close(&fs); -//#endif -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif - http_disconnect(s); - break; - - default : - break; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : CLOSED\r\n", s); -#endif - if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: - listen(s); - break; - - case SOCK_LISTEN: - break; - - default : - break; - - } // end of switch - -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif -} - -//////////////////////////////////////////// -// Private Functions -//////////////////////////////////////////// -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status) -{ - switch(http_status) - { - case STATUS_OK: // HTTP/1.1 200 OK - if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s); -#endif - make_http_response_head((char*)http_response, content_type, body_len); - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s); -#endif - // CGI/XML type request does not respond HTTP header to client - http_status = 0; - } - break; - case STATUS_BAD_REQ: // HTTP/1.1 400 OK -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s); -#endif - memcpy(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE)); - break; - case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s); -#endif - memcpy(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE)); - break; - default: - break; - } - - // Send the HTTP Response 'header' - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response)); -#endif - send(s, http_response, strlen((char *)http_response)); - } -} - -static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -{ - int8_t get_seqnum; - uint32_t send_len; - - uint8_t flag_datasend_end = 0; - -#ifdef _USE_SDCARD_ - uint16_t blocklen; -#endif -#ifdef _USE_FLASH_ - uint32_t addr = 0; -#endif - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - // Send the HTTP Response 'body'; requested file - if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### - { - if (file_len > DATA_BUF_SIZE - 1) - { - HTTPSock_Status[get_seqnum].file_start = start_addr; - HTTPSock_Status[get_seqnum].file_len = file_len; - send_len = DATA_BUF_SIZE - 1; - -///////////////////////////////////////////////////////////////////////////////////////////////// -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) - memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); - strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -#endif -///////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -#endif - } - else - { - // Send process end - send_len = file_len; - -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -#endif - } -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -#endif - } - else // remained parts - { -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; - } -#endif - send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; - - if(send_len > DATA_BUF_SIZE - 1) - { - send_len = DATA_BUF_SIZE - 1; - //HTTPSock_Status[get_seqnum]->file_offset += send_len; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -#endif - // Send process end - flag_datasend_end = 1; - } -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -#endif - } - -/*****************************************************/ - //HTTPSock_Status[get_seqnum]->storage_type == NONE - //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH - //HTTPSock_Status[get_seqnum]->storage_type == SDCARD - //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -/*****************************************************/ - - if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) - { - if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; - read_userReg_webContent(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); - } -#ifdef _USE_SDCARD_ - else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) - { - // Data read from SD Card - fr = f_read(&fs, &buf[0], send_len, (void *)&blocklen); - if(fr != FR_OK) - { - send_len = 0; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -#endif - } - else - { - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } - } -#endif - -#ifdef _USE_FLASH_ - else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - // Data read from external data flash memory - read_from_flashbuf(addr, &buf[0], send_len); - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } -#endif - else - { - send_len = 0; - } - // Requested content send to HTTP client -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -#endif - - if(send_len) send(s, buf, send_len); - else flag_datasend_end = 1; - - if(flag_datasend_end) - { - HTTPSock_Status[get_seqnum].file_start = 0; - HTTPSock_Status[get_seqnum].file_len = 0; - HTTPSock_Status[get_seqnum].file_offset = 0; - flag_datasend_end = 0; - } - else - { - HTTPSock_Status[get_seqnum].file_offset += send_len; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -#endif - } - -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -#ifdef _USE_SDCARD_ - f_close(&fs); -#endif -// ## 20141219 added end -} - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len) -{ - uint16_t send_len = 0; - -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s); -#endif - send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body); -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len); -#endif - - send(s, buf, send_len); -} - - -static int8_t http_disconnect(uint8_t sn) -{ - setSn_CR(sn,Sn_CR_DISCON); - /* wait to process the command... */ - while(getSn_CR(sn)); - - return SOCK_OK; -} - - -static void http_process_handler(uint8_t s, st_http_request * p_http_request) -{ - uint8_t * uri_name; - uint32_t content_addr = 0; - uint16_t content_num = 0; - uint32_t file_len = 0; - - uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; - - uint16_t http_status; - int8_t get_seqnum; - uint8_t content_found; - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - http_status = 0; - http_response = pHTTP_RX; - file_len = 0; - - //method Analyze - switch (p_http_request->METHOD) - { - case METHOD_ERR : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - - case METHOD_HEAD : - case METHOD_GET : - get_http_uri_name(p_http_request->URI, uri_buf); - uri_name = uri_buf; - - if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html - if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); - if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); - find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) - -#ifdef _HTTPSERVER_DEBUG_ - printf("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); - printf("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); - printf("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) - { - content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else - { - // Find the User registered index for web content - if(find_userReg_webContent(uri_buf, &content_num, &file_len)) - { - content_found = 1; // Web content found in code flash memory - content_addr = (uint32_t)content_num; - HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; - } - // Not CGI request, Web content in 'SD card' or 'Data flash' requested -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - printf("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); -#endif - if((fr = f_open(&fs, (const char *)uri_name, FA_READ)) == 0) - { - content_found = 1; // file open succeed - - file_len = fs.fsize; - content_addr = fs.sclust; - HTTPSock_Status[get_seqnum].storage_type = SDCARD; - } -#elif _USE_FLASH_ - else if(/* Read content from Dataflash */) - { - content_found = 1; - HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; - ; // To do - } -#endif - else - { - content_found = 0; // fail to find content - } - - if(!content_found) - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -#endif - http_status = STATUS_NOT_FOUND; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -#endif - http_status = STATUS_OK; - } - - // Send HTTP header - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -#endif - send_http_response_header(s, p_http_request->TYPE, file_len, http_status); - } - - // Send HTTP body (content) - if(http_status == STATUS_OK) - { - send_http_response_body(s, uri_name, http_response, content_addr, file_len); - } - } - break; - - case METHOD_POST : - mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); - uri_name = uri_buf; - find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) - -#ifdef _HTTPSERVER_DEBUG_ - printf("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); - printf("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); - printf("Type = %d\r\n", p_http_request->TYPE); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process - { - content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -#endif - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); - - // Reset the H/W for apply to the change configuration information - if(content_found == HTTP_RESET) HTTPServer_ReStart(); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else // HTTP POST Method; Content not found - { - send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); - } - break; - - default : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - } -} - -void httpServer_time_handler(void) -{ - httpServer_tick_1s++; -} - -uint32_t get_httpServer_timecount(void) -{ - return httpServer_tick_1s; -} - -void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content) -{ - uint16_t name_len; - uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen((char *)content_name); - content_len = strlen((char *)content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -uint8_t display_reg_webContent_list(void) -{ - uint16_t i; - uint8_t ret; - - if(total_content_cnt == 0) - { - printf(">> Web content file not found\r\n"); - ret = 0; - } - else - { - printf("\r\n=== List of Web content in code flash ===\r\n"); - for(i = 0; i < total_content_cnt; i++) - { - printf(" [%d] ", i+1); - printf("%s, ", web_content[i].content_name); - printf("%ld byte, ", web_content[i].content_len); - - if(web_content[i].content_len < 30) printf("[%s]\r\n", web_content[i].content); - else printf("[ ... ]\r\n"); - } - printf("=========================================\r\n\r\n"); - ret = 1; - } - - return ret; -} - -uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -{ - uint16_t i; - uint8_t ret = 0; // '0' means 'File Not Found' - - for(i = 0; i < total_content_cnt; i++) - { - if(!strcmp((char *)content_name, (char *)web_content[i].content_name)) - { - *file_len = web_content[i].content_len; - *content_num = i; - ret = 1; // If the requested content found, ret set to '1' (Found) - break; - } - } - return ret; -} - - -uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -{ - uint16_t ret = 0; - uint8_t * ptr; - - if(content_num > total_content_cnt) return 0; - - ptr = web_content[content_num].content; - if(offset) ptr += offset; - - strncpy((char *)buf, (char *)ptr, size); - *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - - ret = strlen((void *)buf); - return ret; -} diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpServer.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpServer.h deleted file mode 100644 index dcd0b00..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpServer.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - @file httpServer.h - @brief Define constants and functions related HTTP Web server. - */ - -#include - -#ifndef __HTTPSERVER_H__ -#define __HTTPSERVER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -// HTTP Server debug message enable -#define _HTTPSERVER_DEBUG_ - -#define INITIAL_WEBPAGE "index.html" -#define M_INITIAL_WEBPAGE "m/index.html" -#define MOBILE_INITIAL_WEBPAGE "mobile/index.html" - -/* Web Server Content Storage Select */ -//#define _USE_SDCARD_ -#ifndef _USE_SDCARD_ -//#define _USE_FLASH_ -#endif - -#if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_) -#define _NOTUSED_STORAGE_ -#endif - - -/* Watchdog timer */ -//#define _USE_WATCHDOG_ - -/********************************************* -* HTTP Process states list -*********************************************/ -#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */ -#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */ -#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */ -#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */ -#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */ - -/********************************************* -* HTTP Simple Return Value -*********************************************/ -#define HTTP_FAILED 0 -#define HTTP_OK 1 -#define HTTP_RESET 2 - -/********************************************* -* HTTP Content NAME length -*********************************************/ -#define MAX_CONTENT_NAME_LEN 128 - -/********************************************* -* HTTP Timeout -*********************************************/ -#define HTTP_MAX_TIMEOUT_SEC 3 // Sec. - -typedef enum -{ - NONE, ///< Web storage none - CODEFLASH, ///< Code flash memory - SDCARD, ///< SD card - DATAFLASH ///< External data flash memory -}StorageType; - -typedef struct _st_http_socket -{ - uint8_t sock_status; - uint8_t file_name[MAX_CONTENT_NAME_LEN]; - uint32_t file_start; - uint32_t file_len; - uint32_t file_offset; // (start addr + sent size...) - uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ... -}st_http_socket; - -// Web content structure for file in code flash memory -#define MAX_CONTENT_CALLBACK 20 - -typedef struct _httpServer_webContent -{ - uint8_t * content_name; - uint32_t content_len; - uint8_t * content; -}httpServer_webContent; - - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist); -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)); -void httpServer_run(uint8_t seqnum); - -void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content); -uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); -uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); -uint8_t display_reg_webContent_list(void); - -/* - * @brief HTTP Server 1sec Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void httpServer_time_handler(void); -uint32_t get_httpServer_timecount(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpUtil.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpUtil.c deleted file mode 100644 index 77c9a9d..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpUtil.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file httpUtil.c - * @brief HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -#include "httpUtil.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - - if(predefined_get_cgi_processor(uri_name, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - ; - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} - -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - uint8_t val = 0; - - if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - val = 1; - len = sprintf((char *)buf, "%d", val); - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpUtil.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpUtil.h deleted file mode 100644 index f2c384a..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/Internet/httpServer/httpUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file httpUtil.h - * @brief Header File for HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __HTTPUTIL_H__ -#define __HTTPUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "httpServer.h" -#include "httpParser.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len); -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/globals.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/globals.h deleted file mode 100644 index f5f850c..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/globals.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Internet/httpServer/httpServer.h" -#include "webpage.h" - -//#include "Application/loopback/loopback.h" -//#include "Application/webserver_simple/webserver_simple.h" - -//#include // itoa etc.. -/* (10) Try repeat example HTTPServer_LPC11E36_LPCXpresso on AVR Mega1284p (All pages still in RAM) - * Here used to WEB-server handle cgi-like requests, with AJAX + JSON - * Description here: - * http://wiznetmuseum.com/portfolio-items/w5500-evb-web-server/ - * - * To better undestand AJAX look here (actually here used AJAX + XHTML): - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-automatically-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/AJAX-read-switches-analog/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-XML-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-gauge/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-IO/ - * - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example: - * https://tomeko.net/online_tools/file_to_hex.php?lang=en - * - * (9) Simple webserver, based on code from: - * http://www.ermicro.com/blog/?p=1773 - * Article: Integrating Wiznet W5100, WIZ811MJ network module with Atmel AVR Microcontroller - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.0 Static IP HTTPServer_LPC11E36->AtMega1284p WIZNET_5500 ETHERNET 06/12/2018\r\n"; // Program name - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1< like: -#define DATA_BUF_SIZE 512 //This is for save RAM resources -*/ - -//#define HTTPD_MAX_BUF_SIZE 2048 //This is for maximum throughput -/* -!!Don't forget also set size DATA_BUF_SIZE in like: -#define DATA_BUF_SIZE 2048 //This is for maximum throughput -*/ - -uint8_t RX_BUF[HTTPD_MAX_BUF_SIZE]; -uint8_t TX_BUF[HTTPD_MAX_BUF_SIZE]; - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - if(1) - { - /* Web content registration (web content in webpage.h, Example web pages) */ - - // Index page and netinfo / base64 image demo - reg_httpServer_webContent((uint8_t *)"index.html", (uint8_t *)index_page); // index.html : Main page example - reg_httpServer_webContent((uint8_t *)"netinfo.html", (uint8_t *)netinfo_page); // netinfo.html : Network information example page - reg_httpServer_webContent((uint8_t *)"netinfo.js", (uint8_t *)wiz550web_netinfo_js); // netinfo.js : JavaScript for Read Network configuration (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"img.html", (uint8_t *)img_page); // img.html : Base64 Image data example page - - // Example #1 - reg_httpServer_webContent((uint8_t *)"dio.html", (uint8_t *)dio_page); // dio.html : Digital I/O control example page - reg_httpServer_webContent((uint8_t *)"dio.js", (uint8_t *)wiz550web_dio_js); // dio.js : JavaScript for digital I/O control (+ ajax.js) - - // Example #2 - reg_httpServer_webContent((uint8_t *)"ain.html", (uint8_t *)ain_page); // ain.html : Analog input monitor example page - reg_httpServer_webContent((uint8_t *)"ain.js", (uint8_t *)wiz550web_ain_js); // ain.js : JavaScript for Analog input monitor (+ ajax.js) - - // Example #3 - //reg_httpServer_webContent((uint8_t *)"ain_gauge.html", (uint8_t *)ain_gauge_page); // ain_gauge.html : Analog input monitor example page; using Google Gauge chart - //reg_httpServer_webContent((uint8_t *)"ain_gauge.js", (uint8_t *)ain_gauge_js); // ain_gauge.js : JavaScript for Google Gauge chart (+ ajax.js) - - // AJAX JavaScript functions - reg_httpServer_webContent((uint8_t *)"ajax.js", (uint8_t *)wiz550web_ajax_js); // ajax.js : JavaScript for AJAX request transfer - - //Device info page && related ajax script - reg_httpServer_webContent((uint8_t *)"info.html", (uint8_t *)info_page); //info.html - reg_httpServer_webContent((uint8_t *)"info.js", (uint8_t *)wiz550web_info_js); // info.js : JavaScript for Device information (+ ajax.js) - -#ifdef _MAIN_DEBUG_ - display_reg_webContent_list(); -#endif - } -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - //uint32_t timer_link_1sec = millis(); - uint32_t timer_httpd_1sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } - } - - // TODO: insert user's code here - if(run_user_applications) - { - for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - } // End of user's code - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - //loopback_tcps(0,ethBuf0,5000); - //loopback_udps(1, ethBuf1, 3000); - - //Use WEBbrowser to connect to webserver: http://192.168.0.199/index.html - //websrv_simple(2, ethBuf2_WEBSRV, 80); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //Not used here, because led1 handle via websrv_simple - /* - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - */ - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/userHandler.c b/10_m1284p_WIZNET_HTTPServer_RAM_pages/userHandler.c deleted file mode 100644 index d9799e2..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/userHandler.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file userHandler.c - * @brief User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -//#include "board.h" -#include "httpUtil.h" -#include "userHandler.h" -//#include "adcHandler.h" -#include "wizchip_conf.h" -#include "globals.h" - -/* Unavailable Pins (W5500-EVB component preempted) */ -// >> UART Rx/Tx : D0 (Rx), D1 (Tx) -// >> W5500 SPI(SPI0) : D11 (MOSI), D12 (MISO), D13 (SCK) - -/* On-board Devices */ -// >> Input : D14 (SW1) / D15 (SW2) -// >> Input : AIN (Potentiometer / TEMP.Sensor) -// >> Output : D8 (LED R) / D9 (LED G) / D10 (LED B) - -/* NXP LPC11Exx GPIO functions */ -// GPIO: Pin state -//Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); - -// GPIO: Pin direction -//Chip_GPIO_GetPinDIR((LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); - -// Pre-defined Get CGI functions -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_netinfo(uint8_t * buf, uint16_t * len); -void make_json_led1(uint8_t * buf, uint16_t * len); -void make_info(uint8_t * buf, uint16_t * len); - -// Pre-defined Set CGI functions -int8_t set_diodir(uint8_t * uri); -int8_t set_diostate(uint8_t * uri); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len) -{ - //return 0; //Just a stub, not used yet.. - //uint8_t ret = 1; // ret = 1 means 'uri_name' matched - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched - uint8_t cgibuf[14] = {0, }; - int8_t cgi_dio = -1; - int8_t cgi_ain = -1; - - uint8_t i; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { -// // to do -// ;//make_json_todo(buf, len); - } - else if(strcmp_P((const char *)uri_name,PSTR("get_netinfo.cgi")) == 0) - { - make_json_netinfo(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_led1.cgi")) == 0) - { - make_json_led1(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_info.cgi")) == 0) - { - make_info(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else - { -// // get_dio0.cgi ~ get_dio15.cgi -// for(i = 0; i < DIOn; i++) -// { -// memset(cgibuf, 0x00, 14); -// sprintf((char *)cgibuf, "get_dio%d.cgi", i); -// if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) -// { -// make_json_dio(buf, len, i); -// cgi_dio = i; -// break; -// } -// } -// -// if(cgi_dio < 0) - //Analog Ins reading get_ain0.cgi ~ get_ain7.cgi - if(1) - { - // get_ain0.cgi ~ get_ain5.cgi (A0 - A5), get_ain6.cgi for on-board potentiometer / Temp.Sensor - LPC11Exx - //for(i = 0; i < AINn; i++) //for LPC11xx - for(i = 0; i < 8; i++) //for AVR Mega1284p, available AIN0..AIN7 - { - memset(cgibuf, 0x00, 14); - sprintf((char *)cgibuf, "get_ain%d.cgi", i); - if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) - { - make_json_ain(buf, len, i); - cgi_ain = i; - ret = 1; - break; - } - } - } - -// if((cgi_dio < 0) && (cgi_ain < 0)) ret = 0; - } - - return ret; -} - - -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len) -{ -// return 0; //Just a stub, not used yet.. - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched -// uint8_t ret = 1; // ret = '1' means 'uri_name' matched - uint8_t val = 0; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { - // to do - ;//val = todo(uri); - //*len = sprintf((char *)buf, "%d", val); - } -// // Digital I/O; dio_s, dio_d -// else if(strcmp_P((const char *)uri_name,PSTR("set_diodir.cgi")) == 0) -// { -// //val = set_diodir(uri); -// //printf_P(PSTR("+++set_diodir.cgi uri_name: %s; uri: %s;\r\n")); -// *len = sprintf_P((char *)buf, PSTR("%d"), val); -// ret = 1; -// } - else if(strcmp((const char *)uri_name, "set_diostate.cgi") == 0) - { - //When uri_name=set_diostate.cgi, and uri HTTP POST request which contains something like: - //pin=8&val=1; or pin=8&val=1; (look && ) - - /* - This is LPC11xx handler - val = set_diostate(uri); - len = sprintf((char *)buf, "%d", val); - len ret = 1; - */ - - - //!!Just for debug - printf_P(PSTR("\r\n+++set_diostate.cgi uri_name: %s\r\nuri: %s\r\n"), uri_name, uri); - - //Parse URI (Very dirty!!) - if(strstr_P(uri,PSTR("pin=LED1&val=0"))) - { - led1_low(); - *len = sprintf_P((char *)buf, PSTR("LED1: OFF")); - ret = 1; - } - else if(strstr_P(uri,PSTR("pin=LED1&val=1"))) - { - led1_high(); - *len = sprintf_P((char *)buf, PSTR("LED1: ON")); - ret = 1; - } - else - { - //*len = sprintf_P((char *)buf, PSTR("%d"), -1); - *len = sprintf_P((char *)buf, PSTR("???")); - ret = 1; - } - } -// else -// { -// ret = 0; -// } -// - return ret; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Get CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin) -//{ -// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// -// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\ -// \"dio_s\":\"%d\",\ -// \"dio_d\":\"%d\"\ -// });", -// pin, // Digital io pin number -// pin_state, // Digital io status -// pin_dir // Digital io directions -// ); -//} -// -void make_json_led1(uint8_t * buf, uint16_t * len) -{ - if(led1_read()) - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: ON\"});")); //Send back LED1 state via call-back function - } - else - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: OFF\"});")); //Send back LED1 state via call-back function - } - -} - -void make_info(uint8_t * buf, uint16_t * len) -{ - /* - * Send program metrics: - * Program name - * time-date compile - * MCU info - * free ram info - * uptime device - */ - *len = sprintf_P((char *)buf,PSTR(\ - "
%S"\
-			"Compiled at: %S %S\r\n"\
-			"MCU is: %S; CLK is: %luHz\r\n"\
-			"Free RAM: %dbytes\r\n"\
-			"Uptime: %lusec\r\n
"),\ - str_prog_name,\ - compile_time, compile_date,\ - str_mcu, F_CPU,\ - freeRam(),\ - millis()/1000); -} - -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin) -{ - *len = sprintf_P((char *)buf,PSTR( "AinCallback({\"ain_p\":\"%d\",\ - \"ain_v\":\"%d\"\ - });"), - pin, // ADC input pin number - //get_ADC_val(pin) // ADC input value for LPC11xx - adc_read(pin) // ADC input value for AVR - ); -} - -void make_json_netinfo(uint8_t * buf, uint16_t * len) -{ - wiz_NetInfo netinfo; - ctlnetwork(CN_GET_NETINFO, (void*) &netinfo); - - // DHCP: 1 - Static, 2 - DHCP - *len = sprintf_P((char *)buf,PSTR( "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\ - \"ip\":\"%d.%d.%d.%d\",\ - \"gw\":\"%d.%d.%d.%d\",\ - \"sn\":\"%d.%d.%d.%d\",\ - \"dns\":\"%d.%d.%d.%d\",\ - \"dhcp\":\"%d\"\ - });"), - netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5], - netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3], - netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3], - netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3], - netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3], - netinfo.dhcp - ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Set CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//int8_t set_diodir(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // Direction; NotUsed/Input/Output -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > Output) val = Output; -// } -// } -// -// if(val == Input) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input -// else Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -// -// return pin; -//} -// -//int8_t set_diostate(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // State; high(on)/low(off) -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > On) val = On; -// } -// -// if(val == On) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High -// else Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -// } -// -// return pin; -//} diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/userHandler.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/userHandler.h deleted file mode 100644 index 1f9af30..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/userHandler.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file userHandler.h - * @brief Header File for User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __USERHANDLER_H -#define __USERHANDLER_H - -#include -//#define _WEB_DEBUG_ - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Public Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined CGI Interface Functions Handler -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP GET Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP POST Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - - -#endif - diff --git a/10_m1284p_WIZNET_HTTPServer_RAM_pages/webpage.h b/10_m1284p_WIZNET_HTTPServer_RAM_pages/webpage.h deleted file mode 100644 index 8722edc..0000000 --- a/10_m1284p_WIZNET_HTTPServer_RAM_pages/webpage.h +++ /dev/null @@ -1,358 +0,0 @@ -#ifndef _WEBPAGE_H_ -#define _WEBPAGE_H_ -/* - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example: - * https://tomeko.net/online_tools/file_to_hex.php?lang=en -*/ - -/************************************************************************************* - * JavaScript Functions - *************************************************************************************/ - -#define wiz550web_ajax_js "function AJAX(a,e){var c=d();c.onreadystatechange=b;function d(){if(window.XMLHttpRequest){return new XMLHttpRequest()}else{if(window.ActiveXObject){return new ActiveXObject(\"Microsoft.XMLHTTP\")}}}function b(){if(c.readyState==4){if(c.status==200){if(e){e(c.responseText)}}}}this.doGet=function(){c.open(\"GET\",a,true);c.send(null)};this.doPost=function(f){c.open(\"POST\",a,true);c.setRequestHeader(\"Content-Type\",\"application/x-www-form-urlencoded\");c.setRequestHeader(\"ISAJAX\",\"yes\");c.send(f)}}function $(a){return document.getElementById(a)}function $$(a){return document.getElementsByName(a)}function $$_ie(a,c){if(!a){a=\"*\"}var b=document.getElementsByTagName(a);var e=[];for(var d=0;d\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server\n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Web Server Demopage\n"\ -"

\n"\ -" Network Information
\n"\ -" Base64 Image Data
\n"\ -"
\n"\ -" Ex1> Digital I/O
\n"\ -" Ex2> Analog Input
\n"\ -" Ex3> Analog Input: Google Gauge Chart
\n"\ -"
\n"\ -" Device Information
\n"\ -"\n"\ -"\n"\ -"" -#define wiz550web_info_js \ -"function getInfo()\n"\ -"{\n"\ -" var oUpdate;\n"\ -" setTimeout(function()\n"\ -" {\n"\ -" oUpdate = new AJAX('get_info.cgi', function(t)\n"\ -" {\n"\ -" try\n"\ -" {\n"\ -" //*eval(t);\n"\ -" document.getElementById('info_txt').innerHTML = t;\n"\ -" }\n"\ -" catch(e)\n"\ -" {\n"\ -" alert(e);\n"\ -" }\n"\ -" }\n"\ -" ); oUpdate.doGet();\n"\ -" }\n"\ -" , 300); setTimeout('getInfo()', 3000);\n"\ -"}\n"\ -"" - - -#define netinfo_page ""\ - ""\ - ""\ - "W5500-AtMEGA1284p Web Server Network Info"\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - "
"\ - "W5500-AtMEGA1284p Web Server Network Information"\ - "
"\ - "
"\ - "
    "\ - "
  • "\ - "
  • "\ - "
  • "\ - "
  • "\ - "
  • "\ - "
"\ - ""\ - "" - - -#define dio_page ""\ - ""\ - ""\ - "W5500-AtMEGA1284p Web Server Digital I/O v1.1"\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - "

LED1: unknown..

"\ - "
"\ - " "\ - ""\ - "
"\ - "
"\ - ""\ - ""\ - "" - - -#define ain_page ""\ - ""\ - ""\ - "W5500-AtMEGA1284p Web Server Analog Input"\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - "
"\ - " "\ - " "\ - " "\ - "
"\ - "
"\ - "
"\ - ""\ - ""\ - "" -#define info_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Device Info\n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Device Information\n"\ -"

\n"\ -"

..

\n"\ -"\n"\ -"\n"\ -"" - - -//!! No space at RAM in AtMega1284p (16kb only..) -//!! Need replace all pages into FLASH memory (PROGMEM) - Shame AVR-8bit HARVARD Architecture!! -/* -#define ain_gauge_page ""\ - ""\ - ""\ - "W5500-AtMEGA1284p Web Server Analog Input Gauge"\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - "
"\ - " "\ - " "\ - " "\ - "
"\ - ""\ - "
"\ - "
"\ - ""\ - "" -*/ - -/* Base64 Image converter: http://base64.wutils.com/encoding-online/ */ -/* -#define img_page ""\ - ""\ - ""\ - "W5500-AtMEGA1284p Web Server Image"\ - ""\ - ""\ - ""\ - ""\ - ""\ - "
"\ - "wizwebserver.png"\ - "
"\ - ""\ - "" -*/ -#endif diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/.cproject b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/.cproject deleted file mode 100644 index a9150f2..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/.cproject +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/.project b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/.project deleted file mode 100644 index 47fb963..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 11_m1284p_WIZNET_HTTPServer_FLASH_pages - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webpages.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webpages.h deleted file mode 100644 index 47f7c72..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webpages.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * webpages.h - * - * Created on: 05 . 2018 . - * Author: maxx - */ - -#ifndef WEBPAGES_H_ -#define WEBPAGES_H_ - -#define index_page \ -"\n"\ -"

W5500 Simple Web Server


\n"\ -"

AVR Mega1284p and WIZ5500


\n"\ -"

\n"\ -"Uptime: sec\n"\ -"

LED1 OFF\n"\ -"
LED1 ON\n"\ -"

\n"\ -"\n"\ -"

\n" - -#define page_404 \ -"HTTP/1.0 404 Not Found\r\n"\ -"Content-Type: text/html\r\n"\ -"\r\n"\ -"

404 Not Found

" - -#endif /* WEBPAGES_H_ */ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.c deleted file mode 100644 index 8879627..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.c +++ /dev/null @@ -1,257 +0,0 @@ -#include -#include -#include "webserver_simple.h" -#include "socket.h" -#include "wizchip_conf.h" - - -int strindex(char *s,char *t) -{ - uint16_t i,n; - - n=strlen(t); - for(i=0; *(s+i); i++) - { - if (strncmp(s+i,t,n) == 0) - return i; - } - return -1; -} -void SetAutoKeepAlive(sn, time) // time > 0 -{ - setSn_KPALVTR(sn, time); - printf("Sn:%d - kpalvtime: %u sec\r\n",sn, 5*getSn_KPALVTR(sn)); -} - -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0; - int getidx, postidx, getidx_htm, postidx_htm; - char radiostat0[10],radiostat1[10],temp[12]; - - static uint32_t httpd_active_millis; - -#ifdef _WEBSRV_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _WEBSRV_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:WEB Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - //Get timetick to open socket - httpd_active_millis = millis(); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > WEBSRV_DATA_BUF_SIZE) size = WEBSRV_DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - - //Get timetick to read data from socket - httpd_active_millis = millis(); - - size = (uint16_t) ret; - buf[size] = 0x0;// insert null-terminate symbol to correct parse data - -#ifdef _WEBSRV_DEBUG_ - PRINTF("\r\n>>HTTP REQUEST %u bytes:\r\n%s\rn\n",size, buf); -#endif - - // Check the HTTP Request Header - getidx=strindex((char *)buf,"GET / "); - getidx_htm=strindex((char *)buf,"GET /index.htm"); - postidx=strindex((char *)buf,"POST / "); - postidx_htm=strindex((char *)buf,"POST /index.htm"); - - if (getidx >= 0 || postidx >= 0 || getidx_htm >= 0 || postidx_htm >= 0) - { -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. ROOT check!\n"); -#endif - // Now check the Radio Button for POST request - if (postidx >= 0 || postidx_htm >= 0) - { - if (strindex((char *)buf,"radio=0") > 0) - { - //ledmode=0; - //PRINTF("++LED=0\r\n"); - led1_low(); - } - - if (strindex((char *)buf,"radio=1") > 0) - { - //ledmode=1; - //PRINTF("++LED=1\r\n"); - led1_high(); - } - - } -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. Send!\n"); -#endif - //Old method with every string fill - /* - // Create the HTTP Response Header - strcpy_P((char *)buf,PSTR("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n")); - strcat_P((char *)buf,PSTR(""\ - ""\ - )); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

W5500 Simple Web Server


\r\n")); - strcat_P((char *)buf,PSTR("

AVR Mega1284p and WIZ5500


\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - - // Now Send the HTTP Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - // Create the HTTP Temperature Response - sprintf((char *)temp,"%lu",(millis()/1000)); // Convert temperature value to string - - strcpy_P((char *)buf,PSTR("Uptime: OC\r\n")); // for celsius - strcat_P((char *)buf,PSTR("\"> sec\r\n")); // for seconds - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - // Create the HTTP Radio Button 0 Response - strcat_P((char *)buf,PSTR("

LED1 OFF\r\n")); - strcat_P((char *)buf,PSTR("
LED1 ON\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - */ - - //New method, send page at once, (no more then ~1500 bytes content!!) - //Prepare additional data to send - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - //copy page to buffer and send to http client, without additional data - //strcpy_P((char *)buf,PSTR(index_page)); - - //copy page to buffer and send to http client, with additional data - sprintf_P((char *)buf,PSTR(index_page), millis()/1000, radiostat0, radiostat1); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - } - else - { - //Page not found - /* - strcpy_P((char *)buf,PSTR(\ - "HTTP/1.0 404 Not Found\r\n" - "Content-Type: text/html\r\n" - "\r\n" - //" " // Redirect 5 - "

404 Not Found

"\ - )); - */ - - //copy page to buffer and send to http client, without additional data - strcpy_P((char *)buf,PSTR(page_404)); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - } - // Disconnect the socket - disconnect(sn); - } - else - { - //here when opened socket connection but no data received - if((millis()-httpd_active_millis) > HTTPD_OPEN_TIMEOUT) - { - //Force close socket, after 3 sec idle (To beat Chrome "persistent connection") -#ifdef _WEBSRV_DEBUG_ - PRINTF("!!HTTPD timeout, Force close socket\r\n"); -#endif - close(sn); - } - } - break; - /* - case SOCK_FIN_WAIT: - case SOCK_CLOSING: - case SOCK_TIME_WAIT: - case SOCK_LAST_ACK: - //case SOCK_CLOSE_WAIT: - //Force close socket - close(sn); - */ - - break; - case SOCK_CLOSE_WAIT : -#ifdef _WEBSRV_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _WEBSRV_DEBUG_ - printf("%d:WEB Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _WEBSRV_DEBUG_ - printf("%d:Listen, WEB server, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _WEBSRV_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; - //This is not helped with Chrome keep-alive sessions - //SetAutoKeepAlive(sn, 1); // set Auto keepalive 5sec(1*5) (This is for TCP IP only!) -#ifdef _WEBSRV_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.h deleted file mode 100644 index b851fbc..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _WEBSERVER_SIMPLE_H_ -#define _WEBSERVER_SIMPLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../../globals.h" -#include "webpages.h" - -/* Loopback test debug message printout enable */ -#define _WEBSRV_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef WEBSRV_DATA_BUF_SIZE - #define WEBSRV_DATA_BUF_SIZE 2048 -#endif - -//Timeout (ms) to close too long opened socket (Help from freeze with work with Chrome browser (keep persistent connection on WIN7 ~ 120 sec)) -#define HTTPD_OPEN_TIMEOUT 3000 - -/* WEB SERVER test example */ -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port); - -int strindex(char *s,char *t); - - -#ifdef __cplusplus -} -#endif - -#endif //_WEBSERVER_SIMPLE_H_ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.c deleted file mode 100644 index 0aead49..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - @file httpd.c - @brief functions associated http processing - */ - -#include -#include -#include "socket.h" -#include "httpParser.h" - -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -//uint8_t BUFPUB[2048]; -uint8_t BUFPUB[256]; - -/***************************************************************************** - * Private functions - ****************************************************************************/ -static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */ -static uint8_t C2D(uint8_t c); /* Convert a character to HEX */ - -/** - @brief convert escape characters(%XX) to ASCII character - */ -void unescape_http_url( - char * url /**< pointer to be converted ( escape characters )*/ - ) -{ - int x, y; - - for (x = 0, y = 0; url[y]; ++x, ++y) { - if ((url[x] = url[y]) == '%') { - url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]); - y+=2; - } - } - url[x] = '\0'; -} - - -/** - @brief make response header such as html, gif, jpeg,etc. - */ -void make_http_response_head( - char * buf, /**< pointer to response header to be made */ - char type, /**< response type */ - uint32_t len /**< size of response header */ - ) -{ - const char * head; - char tmp[10]; - - /* file type*/ - if (type == PTYPE_HTML) head = PSTR(RES_HTMLHEAD_OK); - else if (type == PTYPE_GIF) head = PSTR(RES_GIFHEAD_OK); - else if (type == PTYPE_TEXT) head = PSTR(RES_TEXTHEAD_OK); - else if (type == PTYPE_JPEG) head = PSTR(RES_JPEGHEAD_OK); - else if (type == PTYPE_FLASH) head = PSTR(RES_FLASHHEAD_OK); - else if (type == PTYPE_XML) head = PSTR(RES_XMLHEAD_OK); - else if (type == PTYPE_CSS) head = PSTR(RES_CSSHEAD_OK); - else if (type == PTYPE_JSON) head = PSTR(RES_JSONHEAD_OK); - else if (type == PTYPE_JS) head = PSTR(RES_JSHEAD_OK); - else if (type == PTYPE_CGI) head = PSTR(RES_CGIHEAD_OK); - else if (type == PTYPE_PNG) head = PSTR(RES_PNGHEAD_OK); - else if (type == PTYPE_ICO) head = PSTR(RES_ICOHEAD_OK); - else if (type == PTYPE_TTF) head = PSTR(RES_TTFHEAD_OK); - else if (type == PTYPE_OTF) head = PSTR(RES_OTFHEAD_OK); - else if (type == PTYPE_WOFF) head = PSTR(RES_WOFFHEAD_OK); - else if (type == PTYPE_EOT) head = PSTR(RES_EOTHEAD_OK); - else if (type == PTYPE_SVG) head = PSTR(RES_SVGHEAD_OK); -#ifdef _HTTPPARSER_DEBUG_ - else - { - head = NULL; - PRINTF("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n"); - } -#else - else head = NULL; -#endif - - sprintf(tmp, "%ld", len); - strcpy_P(buf, head); - strcat(buf, tmp); - strcat(buf, "\r\n\r\n"); -} - - -/** - @brief find MIME type of a file - */ -void find_http_uri_type( - uint8_t * type, /**< type to be returned */ - uint8_t * buff /**< file name */ - ) -{ - /* Decide type according to extension*/ - - char * buf; - buf = (char *)buff; - - if (strstr_P(buf, PSTR(".htm")) || strstr_P(buf, PSTR(".html"))) *type = PTYPE_HTML; - else if (strstr_P(buf, PSTR(".gif"))) *type = PTYPE_GIF; - else if (strstr_P(buf, PSTR(".text")) || strstr_P(buf,PSTR(".txt"))) *type = PTYPE_TEXT; - else if (strstr_P(buf, PSTR(".jpeg")) || strstr_P(buf,PSTR(".jpg"))) *type = PTYPE_JPEG; - else if (strstr_P(buf, PSTR(".swf"))) *type = PTYPE_FLASH; - else if (strstr_P(buf, PSTR(".cgi")) || strstr_P(buf,PSTR(".CGI"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".json")) || strstr_P(buf,PSTR(".JSON"))) *type = PTYPE_JSON; - else if (strstr_P(buf, PSTR(".js")) || strstr_P(buf,PSTR(".JS"))) *type = PTYPE_JS; - else if (strstr_P(buf, PSTR(".CGI")) || strstr_P(buf,PSTR(".cgi"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".xml")) || strstr_P(buf,PSTR(".XML"))) *type = PTYPE_XML; - else if (strstr_P(buf, PSTR(".css")) || strstr_P(buf,PSTR(".CSS"))) *type = PTYPE_CSS; - else if (strstr_P(buf, PSTR(".png")) || strstr_P(buf,PSTR(".PNG"))) *type = PTYPE_PNG; - else if (strstr_P(buf, PSTR(".ico")) || strstr_P(buf,PSTR(".ICO"))) *type = PTYPE_ICO; - else if (strstr_P(buf, PSTR(".ttf")) || strstr_P(buf,PSTR(".TTF"))) *type = PTYPE_TTF; - else if (strstr_P(buf, PSTR(".otf")) || strstr_P(buf,PSTR(".OTF"))) *type = PTYPE_OTF; - else if (strstr_P(buf, PSTR(".woff")) || strstr_P(buf,PSTR(".WOFF"))) *type = PTYPE_WOFF; - else if (strstr_P(buf, PSTR(".eot")) || strstr_P(buf,PSTR(".EOT"))) *type = PTYPE_EOT; - else if (strstr_P(buf, PSTR(".svg")) || strstr_P(buf,PSTR(".SVG"))) *type = PTYPE_SVG; - else *type = PTYPE_ERR; -} - - -/** - @brief parse http request from a peer - */ -void parse_http_request( - st_http_request * request, /**< request to be returned */ - uint8_t * buf /**< pointer to be parsed */ - ) -{ - char * nexttok; - nexttok = strtok((char*)buf," "); - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - if(!strcmp_P(nexttok, PSTR("GET")) || !strcmp_P(nexttok,PSTR("get"))) - { - request->METHOD = METHOD_GET; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("HEAD")) || !strcmp_P(nexttok,PSTR("head"))) - { - request->METHOD = METHOD_HEAD; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("POST")) || !strcmp_P(nexttok,PSTR("post"))) - { - nexttok = strtok(NULL,"\0"); - request->METHOD = METHOD_POST; - } - else - { - request->METHOD = METHOD_ERR; - } - - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - strcpy((char *)request->URI, nexttok); -} - -#ifdef _OLD_ -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value( - char* uri, - char* param_name - ) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * name = 0; - - - if(!uri || !param_name) return 0; - - strcpy((char*)tempURI,uri); - if((name = (uint8_t*)strstr(tempURI, param_name))) - { - name += strlen(param_name) + 1; // strlen(para_name) + strlen("=") - if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0"))) - { - unescape_http_url((char *)name); - replacetochar(name, '+', ' '); - } - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s",param_name,name); -#endif - - return name; -} -#else -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value(char* uri, char* param_name) -{ - - uint8_t * name = 0; - uint8_t * ret = BUFPUB; - uint8_t * pos2; - uint16_t len = 0, content_len = 0; - uint8_t tmp_buf[10]={0x00, }; - - if(!uri || !param_name) return 0; - - /***************/ - mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf); - content_len = ATOI(tmp_buf, 10); - uri = strstr(uri, "\r\n\r\n"); - uri += 4; - uri[content_len] = 0; - /***************/ - - if((name = (uint8_t *)strstr(uri, param_name))) - { - name += strlen(param_name) + 1; - pos2 = (uint8_t*)strstr((char*)name, "&"); - if(!pos2) - { - pos2 = name + strlen((char*)name); - } - len = pos2 - name; - - if(len) - { - ret[len] = 0; - strncpy((char*)ret,(char*)name, len); - unescape_http_url((char *)ret); - replacetochar(ret, '+' ,' '); - //ret[len] = 0; - //ret[strlen((int8*)ret)] = 0; - //printf("len=%d\r\n",len); - } - else - { - ret[0] = 0; - } - } - else - { - return 0; - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s\r\n", param_name, ret); -#endif - return ret; -} -#endif - -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * uri_name; - - if(!uri) return 0; - - strcpy(tempURI, (char *)uri); - - uri_name = (uint8_t *)strtok(tempURI, " ?"); - - if(strcmp((char *)uri_name,"/")) uri_name++; - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_name); -#endif - - return uri_name; -} -#else - -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf) -{ - uint8_t * uri_ptr; - if(!uri) return 0; - - strcpy((char *)uri_buf, (char *)uri); - - uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?"); - - if(strcmp((char *)uri_ptr,"/")) uri_ptr++; - strcpy((char *)uri_buf, (char *)uri_ptr); - -#ifdef _HTTPPARSER_DEBUG_ - PRINTF(" uri_name = %s\r\n", uri_buf); -#endif - - return 1; -} - -#endif - -void inet_addr_(uint8_t * addr, uint8_t *ip) -{ - uint8_t i; - uint8_t taddr[30]; - uint8_t * nexttok; - uint8_t num; - - strcpy((char *)taddr, (char *)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (uint8_t *)strtok((char *)nexttok, "."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10); - else num = ATOI(nexttok,10); - ip[i] = num; - nexttok = NULL; - } -} - - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; -// debug_2013_11_25 -// while (*str !=0) - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -/** - * @brief Check strings and then execute callback function by each string. - * @param src The information of URI - * @param s1 The start string to be researched - * @param s2 The end string to be researched - * @param sub The string between s1 and s2 - * @return The length value atfer working - */ -void mid(char* src, char* s1, char* s2, char* sub) -{ - char* sub1; - char* sub2; - uint16_t n; - - sub1=strstr((char*)src,(char*)s1); - sub1+=strlen((char*)s1); - sub2=strstr((char*)sub1,(char*)s2); - - n=sub2-sub1; - strncpy((char*)sub,(char*)sub1,n); - sub[n]='\0'; -} - -//////////////////////////////////////////////////////////////////// -// Static functions -//////////////////////////////////////////////////////////////////// - -/** -@brief replace the specified character in a string with new character -*/ -static void replacetochar( - uint8_t * str, /**< pointer to be replaced */ - uint8_t oldchar, /**< old character */ - uint8_t newchar /**< new character */ - ) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == oldchar) str[x] = newchar; -} - -/** -@brief CONVERT CHAR INTO HEX -@return HEX - -This function converts HEX(0-F) to a character -*/ -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - - - diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.h deleted file mode 100644 index c289c2e..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - @file httpd.h - @brief Define Constants and fucntions associated with HTTP protocol. - */ - -#include -#include "../../globals.h" - -#ifndef __HTTPPARSER_H__ -#define __HTTPPARSER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#define _HTTPPARSER_DEBUG_ - -#define HTTP_SERVER_PORT 80 /**< HTTP server well-known port number */ - -/* HTTP Method */ -#define METHOD_ERR 0 /**< Error Method. */ -#define METHOD_GET 1 /**< GET Method. */ -#define METHOD_HEAD 2 /**< HEAD Method. */ -#define METHOD_POST 3 /**< POST Method. */ - -/* HTTP GET Method */ -#define PTYPE_ERR 0 /**< Error file. */ -#define PTYPE_HTML 1 /**< HTML file. */ -#define PTYPE_GIF 2 /**< GIF file. */ -#define PTYPE_TEXT 3 /**< TEXT file. */ -#define PTYPE_JPEG 4 /**< JPEG file. */ -#define PTYPE_FLASH 5 /**< FLASH file. */ -#define PTYPE_MPEG 6 /**< MPEG file. */ -#define PTYPE_PDF 7 /**< PDF file. */ -#define PTYPE_CGI 8 /**< CGI file. */ -#define PTYPE_XML 9 /**< XML file. */ -#define PTYPE_CSS 10 /**< CSS file. */ -#define PTYPE_JS 11 /**< JavaScript file. */ -#define PTYPE_JSON 12 /**< JSON (JavaScript Standard Object Notation) file. */ -#define PTYPE_PNG 13 /**< PNG file. */ -#define PTYPE_ICO 14 /**< ICON file. */ - -#define PTYPE_TTF 20 /**< Font type: TTF file. */ -#define PTYPE_OTF 21 /**< Font type: OTF file. */ -#define PTYPE_WOFF 22 /**< Font type: WOFF file. */ -#define PTYPE_EOT 23 /**< Font type: EOT file. */ -#define PTYPE_SVG 24 /**< Font type: SVG file. */ - - -/* HTTP response */ -#define STATUS_OK 200 -#define STATUS_CREATED 201 -#define STATUS_ACCEPTED 202 -#define STATUS_NO_CONTENT 204 -#define STATUS_MV_PERM 301 -#define STATUS_MV_TEMP 302 -#define STATUS_NOT_MODIF 304 -#define STATUS_BAD_REQ 400 -#define STATUS_UNAUTH 401 -#define STATUS_FORBIDDEN 403 -#define STATUS_NOT_FOUND 404 -#define STATUS_INT_SERR 500 -#define STATUS_NOT_IMPL 501 -#define STATUS_BAD_GATEWAY 502 -#define STATUS_SERV_UNAVAIL 503 - -/* HTML Doc. for ERROR */ -static const char PROGMEM ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n\r\n\r\nSorry, the page you requested was not found.\r\n\r\n\r\n\0"; -static const char PROGMEM ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n\r\n\r\nInvalid request.\r\n\r\n\r\n\0"; - -/* HTML Doc. for CGI result */ -#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response header for HTML*/ -#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for TEXT */ -#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " - -/* Response head for GIF */ -#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: " - -/* Response head for JPEG */ -#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: " - -/* Response head for PNG */ -#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: " - -/* Response head for FLASH */ -#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: " - -/* Response head for XML */ -#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for CSS */ -#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: " - -/* Response head for JavaScript */ -#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: " - -/* Response head for JSON */ -#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " - -/* Response head for ICO */ -#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: " - -/* Response head for CGI */ -#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response head for TTF, Font */ -#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: " - -/* Response head for OTF, Font */ -#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: " - -/* Response head for WOFF, Font */ -#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: " - -/* Response head for EOT, Font */ -#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: " - -/* Response head for SVG, Font */ -#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: " - -/** - @brief Structure of HTTP REQUEST - */ - -//#define MAX_URI_SIZE 1461 -#define MAX_URI_SIZE 512 - -typedef struct _st_http_request -{ - uint8_t METHOD; /**< request method(METHOD_GET...). */ - uint8_t TYPE; /**< request type(PTYPE_HTML...). */ - uint8_t URI[MAX_URI_SIZE]; /**< request file name. */ -}st_http_request; - -// HTTP Parsing functions -void unescape_http_url(char * url); /* convert escape character to ascii */ -void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */ -void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */ -void make_http_response_head(char *, char, uint32_t); /* make response header */ -uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */ -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */ -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri); -#endif - -// Utility functions -uint16_t ATOI(uint8_t * str, uint8_t base); -void mid(char* src, char* s1, char* s2, char* sub); -void inet_addr_(uint8_t * addr, uint8_t * ip); - -#ifdef __cplusplus -} -#endif - -#endif /* end of __HTTPPARSER_H__ */ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.c deleted file mode 100644 index 8df7015..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.c +++ /dev/null @@ -1,1399 +0,0 @@ -#include -#include -#include - -#include "socket.h" -#include "wizchip_conf.h" - -#include "httpServer.h" -#include "httpParser.h" -#include "httpUtil.h" -//Find Content -/* -#include -#include -#include "avr/wdt.h" // WatchDog -#ifndef PRINTF - #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#endif -*/ -#include "../../globals.h" //add AVR specific useful headers - -#ifdef _USE_SDCARD_ -#include "ff.h" // header file for FatFs library (FAT file system) -#endif - -/* -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif -*/ -#define DATA_BUF_SIZE HTTPD_MAX_BUF_SIZE -/***************************************************************************** - * Private types/enumerations/variables - ****************************************************************************/ -static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, }; -static st_http_request * http_request; /**< Pointer to received HTTP request */ -static st_http_request * parsed_http_request; /**< Pointer to parsed HTTP request */ -static uint8_t * http_response; /**< Pointer to HTTP response */ - -// ## For Debugging -//static uint8_t uri_buf[128]; - -// Number of registered web content in code flash memory -static uint16_t total_content_cnt = 0; -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -uint8_t * pHTTP_TX; -uint8_t * pHTTP_RX; - -volatile uint32_t httpServer_tick_1s = 0; -st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }; -httpServer_webContent web_content[MAX_CONTENT_CALLBACK]; - -#ifdef _USE_SDCARD_ -FIL fs; // FatFs: File object -FRESULT fr; // FatFs: File function return code -#endif - -/***************************************************************************** - * Private functions - ****************************************************************************/ -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist); -static uint8_t getHTTPSocketNum(uint8_t seqnum); -static int8_t getHTTPSequenceNum(uint8_t socket); -static int8_t http_disconnect(uint8_t sn); - -//static void http_process_handler(uint8_t s, st_http_request * p_http_request); -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request); - -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status); - -//static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len); - -/***************************************************************************** - * Public functions - ****************************************************************************/ -// Callback functions definition: MCU Reset / WDT Reset -void default_mcu_reset(void) {;} -void default_wdt_reset(void) {;} -void (*HTTPServer_ReStart)(void) = default_mcu_reset; -void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset; - -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist) -{ - uint8_t i; - - for(i = 0; i < cnt; i++) - { - // Mapping the H/W socket numbers to the sequential index numbers - HTTPSock_Num[i] = socklist[i]; - } -} - -static uint8_t getHTTPSocketNum(uint8_t seqnum) -{ - // Return the 'H/W socket number' corresponding to the index number - return HTTPSock_Num[seqnum]; -} - -static int8_t getHTTPSequenceNum(uint8_t socket) -{ - uint8_t i; - - for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++) - if(HTTPSock_Num[i] == socket) return i; - - return -1; -} - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist) -{ - // User's shared buffer - pHTTP_TX = tx_buf; - pHTTP_RX = rx_buf; - - // H/W Socket number mapping - httpServer_Sockinit(cnt, socklist); -} - - -/* Register the call back functions for HTTP Server */ -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)) -{ - // Callback: HW Reset and WDT reset function for each MCU platforms - if(mcu_reset) HTTPServer_ReStart = mcu_reset; - if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset; -} - - -//void httpServer_run(uint8_t seqnum) -//{ -// uint8_t s; // socket number -// uint16_t len; -// uint32_t gettime = 0; -// -//#ifdef _HTTPSERVER_DEBUG_ -// uint8_t destip[4] = {0, }; -// uint16_t destport = 0; -//#endif -// -// http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request -// parsed_http_request = (st_http_request *)pHTTP_TX; -// -// // Get the H/W socket number -// s = getHTTPSocketNum(seqnum); -// -// /* HTTP Service Start */ -// switch(getSn_SR(s)) -// { -// case SOCK_ESTABLISHED: -// // Interrupt clear -// if(getSn_IR(s) & Sn_IR_CON) -// { -// setSn_IR(s, Sn_IR_CON); -// } -// -// // HTTP Process states -// switch(HTTPSock_Status[seqnum].sock_status) -// { -// -// case STATE_HTTP_IDLE : -// if ((len = getSn_RX_RSR(s)) > 0) -// { -// if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; -// len = recv(s, (uint8_t *)http_request, len); -// -// *(((uint8_t *)http_request) + len) = '\0'; -// -// parse_http_request(parsed_http_request, (uint8_t *)http_request); -//#ifdef _HTTPSERVER_DEBUG_ -// getSn_DIPR(s, destip); -// destport = getSn_DPORT(s); -// printf("\r\n"); -// printf("> HTTPSocket[%d] : HTTP Request received ", s); -// printf("from %d.%d.%d.%d : %d\r\n", destip[0], destip[1], destip[2], destip[3], destport); -//#endif -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -//#endif -// // HTTP 'response' handler; includes send_http_response_header / body function -// http_process_handler(s, parsed_http_request); -// -// gettime = get_httpServer_timecount(); -// // Check the TX socket buffer for End of HTTP response sends -// while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) -// { -// if((get_httpServer_timecount() - gettime) > 3) -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -//#endif -// break; -// } -// } -// -// if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; -// else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end -// } -// break; -// -// case STATE_HTTP_RES_INPROC : -// /* Repeat: Send the remain parts of HTTP responses */ -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); -//#endif -// // Repeatedly send remaining data to client -// send_http_response_body(s, 0, http_response, 0, 0); -// -// if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; -// break; -// -// case STATE_HTTP_RES_DONE : -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -//#endif -// // Socket file info structure re-initialize -// HTTPSock_Status[seqnum].file_len = 0; -// HTTPSock_Status[seqnum].file_offset = 0; -// HTTPSock_Status[seqnum].file_start = 0; -// HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; -// -////#ifdef _USE_SDCARD_ -//// f_close(&fs); -////#endif -//#ifdef _USE_WATCHDOG_ -// HTTPServer_WDT_Reset(); -//#endif -// http_disconnect(s); -// break; -// -// default : -// break; -// } -// break; -// -// case SOCK_CLOSE_WAIT: -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -//#endif -// disconnect(s); -// break; -// -// case SOCK_CLOSED: -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : CLOSED\r\n", s); -//#endif -// if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : OPEN\r\n", s); -//#endif -// } -// break; -// -// case SOCK_INIT: -// listen(s); -// break; -// -// case SOCK_LISTEN: -// break; -// -// default : -// break; -// -// } // end of switch -// -//#ifdef _USE_WATCHDOG_ -// HTTPServer_WDT_Reset(); -//#endif -//} - -void httpServer_run_avr(uint8_t seqnum) -{ - uint8_t s; // socket number - uint16_t len; - uint32_t gettime = 0; - -#ifdef _HTTPSERVER_DEBUG_ - uint8_t destip[4] = {0, }; - uint16_t destport = 0; -#endif - - http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request - parsed_http_request = (st_http_request *)pHTTP_TX; - - // Get the H/W socket number - s = getHTTPSocketNum(seqnum); - - /* HTTP Service Start */ - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - } - - // HTTP Process states - switch(HTTPSock_Status[seqnum].sock_status) - { - - case STATE_HTTP_IDLE : - if ((len = getSn_RX_RSR(s)) > 0) - { - if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; - len = recv(s, (uint8_t *)http_request, len); - - *(((uint8_t *)http_request) + len) = '\0'; - - parse_http_request(parsed_http_request, (uint8_t *)http_request); -#ifdef _HTTPSERVER_DEBUG_ - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("\r\n"); - PRINTF("> HTTPSocket[%d] : HTTP Request received ", s); - PRINTF("from %d.%d.%d.%d : %u\r\n", destip[0], destip[1], destip[2], destip[3], destport); -#endif -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -#endif - // HTTP 'response' handler; includes send_http_response_header / body function - http_process_handler_avr(s, parsed_http_request); - - gettime = get_httpServer_timecount(); - // Check the TX socket buffer for End of HTTP response sends - while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) - { - if((get_httpServer_timecount() - gettime) > 3) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -#endif - break; - } - } - - if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; - else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end - } - break; - - case STATE_HTTP_RES_INPROC : - /* Repeat: Send the remain parts of HTTP responses */ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); -#endif - // Repeatedly send remaining data to client - send_http_response_body_avr(s, 0, http_response, 0, 0); - - if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - - case STATE_HTTP_RES_DONE : -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -#endif - // Socket file info structure re-initialize - HTTPSock_Status[seqnum].file_len = 0; - HTTPSock_Status[seqnum].file_offset = 0; - HTTPSock_Status[seqnum].file_start = 0; - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; - -//#ifdef _USE_SDCARD_ -// f_close(&fs); -//#endif -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif - http_disconnect(s); - break; - - default : - break; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : CLOSED\r\n", s); -#endif - if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: - listen(s); - break; - - case SOCK_LISTEN: - break; - - default : - break; - - } // end of switch - -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif -} - -//////////////////////////////////////////// -// Private Functions -//////////////////////////////////////////// -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status) -{ - switch(http_status) - { - case STATUS_OK: // HTTP/1.1 200 OK - if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s); -#endif - make_http_response_head((char*)http_response, content_type, body_len); - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s); -#endif - // CGI/XML type request does not respond HTTP header to client - http_status = 0; - } - break; - case STATUS_BAD_REQ: // HTTP/1.1 400 OK -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s); -#endif - memcpy_P(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE)); - break; - case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s); -#endif - memcpy_P(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE)); - break; - default: - break; - } - - // Send the HTTP Response 'header' - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response)); -#endif - send(s, http_response, strlen((char *)http_response)); - } -} - - -//static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -//{ -// int8_t get_seqnum; -// uint32_t send_len; -// -// uint8_t flag_datasend_end = 0; -// -//#ifdef _USE_SDCARD_ -// uint16_t blocklen; -//#endif -//#ifdef _USE_FLASH_ -// uint32_t addr = 0; -//#endif -// -// if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number -// -// // Send the HTTP Response 'body'; requested file -// if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### -// { -// if (file_len > DATA_BUF_SIZE - 1) -// { -// HTTPSock_Status[get_seqnum].file_start = start_addr; -// HTTPSock_Status[get_seqnum].file_len = file_len; -// send_len = DATA_BUF_SIZE - 1; -// -/////////////////////////////////////////////////////////////////////////////////////////////////// -//// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -// memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); -// strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -//#endif -/////////////////////////////////////////////////////////////////////////////////////////////////// -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -//#endif -// } -// else -// { -// // Send process end -// send_len = file_len; -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -//#endif -// } -//#ifdef _USE_FLASH_ -// if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -//#endif -// } -// else // remained parts -// { -//#ifdef _USE_FLASH_ -// if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) -// { -// addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; -// } -//#endif -// send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; -// -// if(send_len > DATA_BUF_SIZE - 1) -// { -// send_len = DATA_BUF_SIZE - 1; -// //HTTPSock_Status[get_seqnum]->file_offset += send_len; -// } -// else -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -//#endif -// // Send process end -// flag_datasend_end = 1; -// } -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -//#endif -// } -// -///*****************************************************/ -// //HTTPSock_Status[get_seqnum]->storage_type == NONE -// //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH -// //HTTPSock_Status[get_seqnum]->storage_type == SDCARD -// //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -///*****************************************************/ -// -// if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) -// { -// if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; -// read_userReg_webContent(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); -// } -//#ifdef _USE_SDCARD_ -// else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) -// { -// // Data read from SD Card -// fr = f_read(&fs, &buf[0], send_len, (void *)&blocklen); -// if(fr != FR_OK) -// { -// send_len = 0; -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -//#endif -// } -// else -// { -// *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) -// } -// } -//#endif -// -//#ifdef _USE_FLASH_ -// else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) -// { -// // Data read from external data flash memory -// read_from_flashbuf(addr, &buf[0], send_len); -// *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) -// } -//#endif -// else -// { -// send_len = 0; -// } -// // Requested content send to HTTP client -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -//#endif -// -// if(send_len) send(s, buf, send_len); -// else flag_datasend_end = 1; -// -// if(flag_datasend_end) -// { -// HTTPSock_Status[get_seqnum].file_start = 0; -// HTTPSock_Status[get_seqnum].file_len = 0; -// HTTPSock_Status[get_seqnum].file_offset = 0; -// flag_datasend_end = 0; -// } -// else -// { -// HTTPSock_Status[get_seqnum].file_offset += send_len; -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -//#endif -// } -// -//// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -//#ifdef _USE_SDCARD_ -// f_close(&fs); -//#endif -//// ## 20141219 added end -//} - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -{ - int8_t get_seqnum; - uint32_t send_len; - - uint8_t flag_datasend_end = 0; - -#ifdef _USE_SDCARD_ - uint16_t blocklen; -#endif -#ifdef _USE_FLASH_ - uint32_t addr = 0; -#endif - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - // Send the HTTP Response 'body'; requested file - if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### - { - if (file_len > DATA_BUF_SIZE - 1) - { - HTTPSock_Status[get_seqnum].file_start = start_addr; - HTTPSock_Status[get_seqnum].file_len = file_len; - send_len = DATA_BUF_SIZE - 1; - -///////////////////////////////////////////////////////////////////////////////////////////////// -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) - memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); - strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -#endif -///////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -#endif - } - else - { - // Send process end - send_len = file_len; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -#endif - } -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -#endif - } - else // remained parts - { -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; - } -#endif - send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; - - if(send_len > DATA_BUF_SIZE - 1) - { - send_len = DATA_BUF_SIZE - 1; - //HTTPSock_Status[get_seqnum]->file_offset += send_len; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -#endif - // Send process end - flag_datasend_end = 1; - } -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -#endif - } - -/*****************************************************/ - //HTTPSock_Status[get_seqnum]->storage_type == NONE - //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH - //HTTPSock_Status[get_seqnum]->storage_type == SDCARD - //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -/*****************************************************/ - - if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) - { - if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; - read_userReg_webContent_avr(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); - } -#ifdef _USE_SDCARD_ - else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) - { - // Data read from SD Card - fr = f_read(&fs, &buf[0], send_len, (void *)&blocklen); - if(fr != FR_OK) - { - send_len = 0; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -#endif - } - else - { - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } - } -#endif - -#ifdef _USE_FLASH_ - else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - // Data read from external data flash memory - read_from_flashbuf(addr, &buf[0], send_len); - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } -#endif - else - { - send_len = 0; - } - // Requested content send to HTTP client -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -#endif - - if(send_len) send(s, buf, send_len); - else flag_datasend_end = 1; - - if(flag_datasend_end) - { - HTTPSock_Status[get_seqnum].file_start = 0; - HTTPSock_Status[get_seqnum].file_len = 0; - HTTPSock_Status[get_seqnum].file_offset = 0; - flag_datasend_end = 0; - } - else - { - HTTPSock_Status[get_seqnum].file_offset += send_len; -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -#endif - } - -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -#ifdef _USE_SDCARD_ - f_close(&fs); -#endif -// ## 20141219 added end -} - - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len) -{ - uint16_t send_len = 0; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s); -#endif - //send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body); - send_len = sprintf_P((char *)buf, PSTR("%S%d\r\n\r\n%s"), PSTR(RES_CGIHEAD_OK), file_len, http_body); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len); -#endif - - send(s, buf, send_len); -} - - -static int8_t http_disconnect(uint8_t sn) -{ - setSn_CR(sn,Sn_CR_DISCON); - /* wait to process the command... */ - while(getSn_CR(sn)); - - return SOCK_OK; -} - - -//static void http_process_handler(uint8_t s, st_http_request * p_http_request) -//{ -// uint8_t * uri_name; -// uint32_t content_addr = 0; -// uint16_t content_num = 0; -// uint32_t file_len = 0; -// -// uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; -// -// uint16_t http_status; -// int8_t get_seqnum; -// uint8_t content_found; -// -// if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number -// -// http_status = 0; -// http_response = pHTTP_RX; -// file_len = 0; -// -// //method Analyze -// switch (p_http_request->METHOD) -// { -// case METHOD_ERR : -// http_status = STATUS_BAD_REQ; -// send_http_response_header(s, 0, 0, http_status); -// break; -// -// case METHOD_HEAD : -// case METHOD_GET : -// get_http_uri_name(p_http_request->URI, uri_buf); -// uri_name = uri_buf; -// -// if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html -// if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); -// if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); -// find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); -// printf("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); -// printf("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -//#endif -// -// if(p_http_request->TYPE == PTYPE_CGI) -// { -// content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); -// if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) -// { -// send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); -// } -// else -// { -// send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); -// } -// } -// else -// { -// // Find the User registered index for web content -// if(find_userReg_webContent(uri_buf, &content_num, &file_len)) -// { -// content_found = 1; // Web content found in code flash memory -// content_addr = (uint32_t)content_num; -// HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; -// } -// // Not CGI request, Web content in 'SD card' or 'Data flash' requested -//#ifdef _USE_SDCARD_ -//#ifdef _HTTPSERVER_DEBUG_ -// printf("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); -//#endif -// if((fr = f_open(&fs, (const char *)uri_name, FA_READ)) == 0) -// { -// content_found = 1; // file open succeed -// -// file_len = fs.fsize; -// content_addr = fs.sclust; -// HTTPSock_Status[get_seqnum].storage_type = SDCARD; -// } -//#elif _USE_FLASH_ -// else if(/* Read content from Dataflash */) -// { -// content_found = 1; -// HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; -// ; // To do -// } -//#endif -// else -// { -// content_found = 0; // fail to find content -// } -// -// if(!content_found) -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -//#endif -// http_status = STATUS_NOT_FOUND; -// } -// else -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -//#endif -// http_status = STATUS_OK; -// } -// -// // Send HTTP header -// if(http_status) -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -//#endif -// send_http_response_header(s, p_http_request->TYPE, file_len, http_status); -// } -// -// // Send HTTP body (content) -// if(http_status == STATUS_OK) -// { -// send_http_response_body(s, uri_name, http_response, content_addr, file_len); -// } -// } -// break; -// -// case METHOD_POST : -// mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); -// uri_name = uri_buf; -// find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); -// printf("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); -// printf("Type = %d\r\n", p_http_request->TYPE); -//#endif -// -// if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process -// { -// content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -//#endif -// if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) -// { -// send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); -// -// // Reset the H/W for apply to the change configuration information -// if(content_found == HTTP_RESET) HTTPServer_ReStart(); -// } -// else -// { -// send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); -// } -// } -// else // HTTP POST Method; Content not found -// { -// send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); -// } -// break; -// -// default : -// http_status = STATUS_BAD_REQ; -// send_http_response_header(s, 0, 0, http_status); -// break; -// } -//} - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request) -{ - uint8_t * uri_name; - uint32_t content_addr = 0; - uint16_t content_num = 0; - uint32_t file_len = 0; - - uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; - - uint16_t http_status; - int8_t get_seqnum; - uint8_t content_found; - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - http_status = 0; - http_response = pHTTP_RX; - file_len = 0; - - //method Analyze - switch (p_http_request->METHOD) - { - case METHOD_ERR : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - - case METHOD_HEAD : - case METHOD_GET : - get_http_uri_name(p_http_request->URI, uri_buf); - uri_name = uri_buf; - - if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html - if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); - if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); - find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); - PRINTF("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); - PRINTF("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) - { - content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else - { - // Find the User registered index for web content - if(find_userReg_webContent_avr(uri_buf, &content_num, &file_len)) - { - content_found = 1; // Web content found in code flash memory - content_addr = (uint32_t)content_num; - HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; - } - // Not CGI request, Web content in 'SD card' or 'Data flash' requested -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - printf("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); -#endif - if((fr = f_open(&fs, (const char *)uri_name, FA_READ)) == 0) - { - content_found = 1; // file open succeed - - file_len = fs.fsize; - content_addr = fs.sclust; - HTTPSock_Status[get_seqnum].storage_type = SDCARD; - } -#elif _USE_FLASH_ - else if(/* Read content from Dataflash */) - { - content_found = 1; - HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; - ; // To do - } -#endif - else - { - content_found = 0; // fail to find content - } - - if(!content_found) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -#endif - http_status = STATUS_NOT_FOUND; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -#endif - http_status = STATUS_OK; - } - - // Send HTTP header - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -#endif - send_http_response_header(s, p_http_request->TYPE, file_len, http_status); - } - - // Send HTTP body (content) - if(http_status == STATUS_OK) - { - send_http_response_body_avr(s, uri_name, http_response, content_addr, file_len); - } - } - break; - - case METHOD_POST : - mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); - uri_name = uri_buf; - find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); - PRINTF("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); - PRINTF("Type = %d\r\n", p_http_request->TYPE); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process - { - content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -#endif - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); - - // Reset the H/W for apply to the change configuration information - if(content_found == HTTP_RESET) HTTPServer_ReStart(); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else // HTTP POST Method; Content not found - { - send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); - } - break; - - default : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - } -} - - -void httpServer_time_handler(void) -{ - httpServer_tick_1s++; -} - -uint32_t get_httpServer_timecount(void) -{ - return httpServer_tick_1s; -} -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content) -{ - uint16_t name_len; - uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - content_len = strlen_P((const char *)content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len) -{ - uint16_t name_len; - //uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - //content_len = (uint32_t) sizeof(content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -//void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content) -//{ -// uint16_t name_len; -// uint32_t content_len; -// -// if(content_name == NULL || content == NULL) -// { -// return; -// } -// else if(total_content_cnt >= MAX_CONTENT_CALLBACK) -// { -// return; -// } -// -// name_len = strlen((char *)content_name); -// content_len = strlen((char *)content); -// -// web_content[total_content_cnt].content_name = malloc(name_len+1); -// strcpy((char *)web_content[total_content_cnt].content_name, (const char *)content_name); -// web_content[total_content_cnt].content_len = content_len; -// web_content[total_content_cnt].content = content; -// -// total_content_cnt++; -//} - -//uint8_t display_reg_webContent_list(void) -//{ -// uint16_t i; -// uint8_t ret; -// -// if(total_content_cnt == 0) -// { -// printf(">> Web content file not found\r\n"); -// ret = 0; -// } -// else -// { -// printf("\r\n=== List of Web content in code flash ===\r\n"); -// for(i = 0; i < total_content_cnt; i++) -// { -// printf(" [%d] ", i+1); -// printf("%s, ", web_content[i].content_name); -// printf("%ld byte, ", web_content[i].content_len); -// -// if(web_content[i].content_len < 30) printf("[%s]\r\n", web_content[i].content); -// else printf("[ ... ]\r\n"); -// } -// printf("=========================================\r\n\r\n"); -// ret = 1; -// } -// -// return ret; -//} - -uint8_t display_reg_webContent_list_avr(void) -{ - uint16_t i; - uint8_t ret; - - if(total_content_cnt == 0) - { - PRINTF(">> Web content file not found\r\n"); - ret = 0; - } - else - { - PRINTF("\r\n=== List of Web content in code flash ===\r\n"); - for(i = 0; i < total_content_cnt; i++) - { - PRINTF(" [%d] ", i+1); - PRINTF("%s, ", web_content[i].content_name); - PRINTF("%ld byte\r\n", web_content[i].content_len); - - - if(web_content[i].content_len < 30) - { - PRINTF("[%s]\r\n", web_content[i].content); - } - else - { - PRINTF("[ ... ]\r\n"); - } - //Dump head 16 bytes every file.. - /* - else - { - const char PROGMEM * tst_char = web_content[i].content; - if(strstr_P(web_content[i].content_name,PSTR("favicon.ico"))==NULL) - { - //ASCII Dump first 0x10 symbols, for all files without - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - else - { - //HEX dump first 0x10 symbols, for - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - } - */ - wdt_reset(); // WDT reset at least every sec - - } - PRINTF("=========================================\r\n\r\n"); - ret = 1; - } - - return ret; -} - -//uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -//{ -// uint16_t i; -// uint8_t ret = 0; // '0' means 'File Not Found' -// -// for(i = 0; i < total_content_cnt; i++) -// { -// if(!strcmp((char *)content_name, (char *)web_content[i].content_name)) -// { -// *file_len = web_content[i].content_len; -// *content_num = i; -// ret = 1; // If the requested content found, ret set to '1' (Found) -// break; -// } -// } -// return ret; -//} - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -{ - uint16_t i; - uint8_t ret = 0; // '0' means 'File Not Found' - - for(i = 0; i < total_content_cnt; i++) - { - if(!strcmp((const char *)content_name, (const char *)web_content[i].content_name)) - { - *file_len = web_content[i].content_len; - *content_num = i; - ret = 1; // If the requested content found, ret set to '1' (Found) - break; - } - } - return ret; -} - - -//uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -//{ -// uint16_t ret = 0; -// uint8_t * ptr; -// -// if(content_num > total_content_cnt) return 0; -// -// ptr = web_content[content_num].content; -// if(offset) ptr += offset; -// -// strncpy((char *)buf, (char *)ptr, size); -// *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) -// -// ret = strlen((void *)buf); -// return ret; -//} - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -{ - uint16_t ret = 0; - uint8_t * ptr; - - if(content_num > total_content_cnt) return 0; - - ptr = web_content[content_num].content; - if(offset) ptr += offset; - - //strncpy_P((char *)buf, (const char *)ptr, size); //not suit for case binary data - memcpy_P((char *)buf, (const char *)ptr, size); - *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - - //ret = strlen((void *)buf); //Useless for memcpy_P - ret = 0; //All ok - return ret; -} diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.h deleted file mode 100644 index 0ca80c2..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - @file httpServer.h - @brief Define constants and functions related HTTP Web server. - */ - -#include - -#ifndef __HTTPSERVER_H__ -#define __HTTPSERVER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -// HTTP Server debug message enable -#define _HTTPSERVER_DEBUG_ - -#define INITIAL_WEBPAGE "index.html" -#define M_INITIAL_WEBPAGE "m/index.html" -#define MOBILE_INITIAL_WEBPAGE "mobile/index.html" - -/* Web Server Content Storage Select */ -//#define _USE_SDCARD_ -#ifndef _USE_SDCARD_ -//#define _USE_FLASH_ -#endif - -#if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_) -#define _NOTUSED_STORAGE_ -#endif - - -/* Watchdog timer */ -//#define _USE_WATCHDOG_ - -/********************************************* -* HTTP Process states list -*********************************************/ -#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */ -#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */ -#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */ -#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */ -#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */ - -/********************************************* -* HTTP Simple Return Value -*********************************************/ -#define HTTP_FAILED 0 -#define HTTP_OK 1 -#define HTTP_RESET 2 - -/********************************************* -* HTTP Content NAME length -*********************************************/ -//#define MAX_CONTENT_NAME_LEN 128 ? Wastefull -#define MAX_CONTENT_NAME_LEN 16 - -/********************************************* -* HTTP Timeout -*********************************************/ -#define HTTP_MAX_TIMEOUT_SEC 3 // Sec. - -typedef enum -{ - NONE, ///< Web storage none - CODEFLASH, ///< Code flash memory - SDCARD, ///< SD card - DATAFLASH ///< External data flash memory -}StorageType; - -typedef struct _st_http_socket -{ - uint8_t sock_status; - uint8_t file_name[MAX_CONTENT_NAME_LEN]; - uint32_t file_start; - uint32_t file_len; - uint32_t file_offset; // (start addr + sent size...) - uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ... -}st_http_socket; - -// Web content structure for file in code flash memory -#define MAX_CONTENT_CALLBACK 20 - -typedef struct _httpServer_webContent -{ - uint8_t * content_name; - uint32_t content_len; - uint8_t * content; -}httpServer_webContent; - - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist); -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)); - -//void httpServer_run(uint8_t seqnum); -void httpServer_run_avr(uint8_t seqnum); - -//void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content); -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content); - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len); - -//uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); - -//uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); - -//uint8_t display_reg_webContent_list(void); -uint8_t display_reg_webContent_list_avr(void); - -/* - * @brief HTTP Server 1sec Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void httpServer_time_handler(void); -uint32_t get_httpServer_timecount(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.c deleted file mode 100644 index 77c9a9d..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file httpUtil.c - * @brief HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -#include "httpUtil.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - - if(predefined_get_cgi_processor(uri_name, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - ; - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} - -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - uint8_t val = 0; - - if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - val = 1; - len = sprintf((char *)buf, "%d", val); - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.h deleted file mode 100644 index f2c384a..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file httpUtil.h - * @brief Header File for HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __HTTPUTIL_H__ -#define __HTTPUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "httpServer.h" -#include "httpParser.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len); -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/bin2hex_v2.py b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/bin2hex_v2.py deleted file mode 100644 index cfd3991..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/bin2hex_v2.py +++ /dev/null @@ -1,52 +0,0 @@ -# -- coding: utf-8 -- -#Reading file in binary & print in HEX AVR PROGCHAR ARRAY every symbol & to ***.h -#Ethercard helper utilites for something like: -#(c) Ibragimov M. Russia Togliatty 19/08/2014 -# .PS used for build <***.h> from images(*.gif, *.jpg), *.css, static htm(l) pages, javascript etc.. -import sys, os -if len(sys.argv) < 2: - sys.exit('Usage: %s file-name' % sys.argv[0]) - -file_name = sys.argv[1] -if not os.path.exists(sys.argv[1]): - sys.exit('ERROR: Filename %s was not found!' % file_name) -else: - print('File %s is OK!' % file_name) -file_out = file_name.replace(".", "_") + ".h" -print('File_to_write is: %s' % file_out) -fhex = open(file_out, "w") -fhex_str = 'const char %s[] PROGMEM = {' % file_name.replace(".", "_") -print(fhex_str) -fhex.write(fhex_str + '\n') -with open(file_name, "rb") as f: - byte = f.read(1) - i = 0 - fhex_size = 0 - _str = "" - while byte != "": - # Do stuff with byte. - _byte = f.read(1) - fhex_size = fhex_size + 1 - if _byte != "": - #print ('%s, ' % hex(ord(byte))) - _str = _str + "%s," % hex(ord(byte)) - else: - #Last byte wo <,> - #print hex(ord(byte)) - _str = _str + "%s" % hex(ord(byte)) - if i < 15: - print _str - fhex.write(_str + '\n') - byte = _byte; - i = i + 1; - if i > 15: - i = 0; - print _str - fhex.write(_str + '\n') - _str = "" -print'};' -fhex.write('};\n') -_str = '%s: %d bytes' % (file_name, fhex_size) -print(_str); -fhex.write('//' + _str + '\n'); -fhex.close() diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet.png b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet.png deleted file mode 100644 index 90d075a..0000000 Binary files a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet.png and /dev/null differ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet_png.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet_png.h deleted file mode 100644 index a316c18..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet_png.h +++ /dev/null @@ -1,860 +0,0 @@ -const char brd_wiznet_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x3,0x7f,0x0,0x0,0x3,0x91,0x1,0x3,0x0,0x0,0x0,0x78,0x37,0x89, -0x3e,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54,0x78,0xda,0xed,0x9d,0x4f, -0x88,0x24,0x47,0xbe,0xdf,0x33,0x95,0x62,0x72,0x17,0x86,0x49,0x2d,0xef,0xd2,0x82, -0x66,0x52,0x8b,0x6c,0xf6,0x62,0xcc,0xc,0xc2,0xb8,0x5,0xed,0x4e,0x3d,0x16,0x2c, -0x1e,0x6,0xeb,0x6c,0xf0,0x61,0x16,0xc1,0xd3,0xc1,0x97,0x1a,0xe6,0xe0,0x16,0x2e, -0x3a,0xab,0xdd,0x8b,0xda,0x7,0xa1,0x32,0xf8,0x22,0xc1,0xb0,0x7d,0xf4,0xd5,0xe0, -0xcb,0x33,0x98,0x37,0x59,0x2e,0x31,0xe5,0x83,0x50,0xfb,0xea,0x93,0xb2,0xb6,0x96, -0xad,0x8b,0xb0,0xb2,0xdc,0x87,0x8d,0xf6,0x8b,0xcd,0x78,0xbf,0x5f,0x44,0x64,0x66, -0x44,0x66,0x56,0x66,0x64,0x56,0x56,0xeb,0x8f,0xa7,0x44,0xcd,0x1f,0x4d,0x77,0x7d, -0x3a,0x33,0xe2,0xf7,0xe7,0xfb,0x8b,0x5f,0x44,0x5a,0xec,0x6e,0x5f,0xa9,0xf5,0xa, -0xf8,0xa,0xf8,0xa,0xf8,0xe3,0x6,0xde,0x5e,0xde,0x31,0x70,0x73,0x71,0xc7,0xc0, -0xd5,0xe3,0x3b,0x6,0xae,0xdf,0xfd,0xa9,0x3,0xff,0xf8,0xf1,0x5d,0x3,0x9f,0xde, -0x31,0x30,0xf9,0xf0,0x8e,0x81,0x64,0xfd,0x3d,0x7b,0x1a,0x3a,0xb6,0x1e,0x1c,0x38, -0x71,0xe8,0xaf,0x67,0xcb,0x74,0xe4,0x3d,0xf,0xae,0xbe,0xb6,0xf7,0xa,0x24,0x1c, -0x38,0x39,0xf1,0xd7,0x93,0x88,0x8e,0xdc,0xbf,0xf1,0xfd,0xcf,0xac,0x61,0x5d,0xdb, -0x77,0x25,0x60,0x70,0xfd,0xe0,0x4d,0xf6,0xd9,0x43,0xef,0xf2,0xf9,0x57,0xe3,0x67, -0x8b,0x77,0x0,0x78,0x3a,0xac,0x6b,0x9b,0x97,0x7e,0x80,0xe0,0xfa,0x1f,0xbf,0xc9, -0xfc,0x93,0xf,0xdc,0xe7,0x5f,0x9f,0x3e,0x5b,0xbf,0x93,0xfa,0xf,0xc6,0xc3,0xba, -0xb6,0x55,0xe9,0x7,0x8,0xae,0xff,0xd1,0x17,0x2c,0xa0,0x1f,0x7c,0x44,0xbf,0x1a, -0x3d,0x5b,0x3c,0x3a,0x7e,0xf8,0x60,0xd8,0x2b,0x5c,0x6f,0xf4,0xbf,0xdf,0xf8,0xd7, -0xff,0xe0,0x73,0x37,0xa0,0x8b,0x35,0x89,0xff,0xef,0xc8,0x1d,0x1d,0xfe,0xee,0x5f, -0xe,0x3b,0x86,0xeb,0xdb,0x12,0xf0,0xa,0x81,0xc7,0x87,0xeb,0xf5,0x26,0xfe,0xe3, -0xe8,0xe1,0xb3,0x37,0x9f,0x7f,0xed,0xec,0x15,0x18,0xfb,0xd7,0xff,0xf0,0xb,0x76, -0x7c,0xe0,0xae,0x57,0x5f,0xfd,0xf5,0xb3,0xf4,0xd9,0x17,0xcf,0xbf,0xe,0xf7,0x7a, -0x4b,0x63,0xef,0xfa,0x9f,0x7c,0xc1,0xfc,0x3,0x67,0xbd,0xf8,0xfa,0xbd,0xbf,0x48, -0x9f,0xfd,0x47,0xeb,0xb5,0x61,0x81,0x37,0xa5,0x49,0xb3,0xbe,0xbe,0x7e,0xfc,0x5, -0x9b,0xbe,0x79,0xb3,0x9e,0x7e,0x5,0xc0,0xcd,0x1b,0x43,0x3,0x89,0xab,0xff,0x7d, -0x1,0xc0,0xcf,0x9d,0xc9,0xe3,0x1b,0x30,0xfc,0xb3,0x67,0x94,0x80,0xa7,0x19,0x16, -0x48,0xbd,0x12,0x70,0x81,0xc0,0xf8,0xe9,0x66,0x6d,0xc5,0xe9,0x33,0x4a,0xc3,0x3e, -0x40,0x7a,0xcf,0x83,0xf,0x5e,0xe0,0xc7,0xb1,0xc4,0xa,0xf6,0x9f,0xb5,0x11,0xcb, -0x85,0x5b,0x27,0x80,0xb1,0xe5,0x97,0xfe,0xf5,0xc5,0xf0,0xc0,0xc4,0x72,0x58,0x22, -0x81,0x91,0xe5,0xdd,0x1,0xf0,0xc9,0x9c,0x25,0x73,0x9,0xf4,0x3d,0x96,0xfe,0x66, -0xdf,0xc0,0xcd,0x8a,0x6d,0x96,0x2,0xf8,0xa5,0x37,0x65,0xf4,0xc9,0x5d,0x0,0x13, -0x1c,0x3f,0x97,0xbd,0x74,0xa7,0x8c,0x7c,0x15,0xde,0x1,0x90,0xbc,0xcf,0x81,0xb, -0x67,0xca,0x6e,0xbf,0xbe,0xb,0x20,0x75,0x5,0x70,0xd6,0xa,0x4c,0xc0,0x5b,0xa7, -0x87,0x60,0x3d,0xdf,0xf4,0x6,0x32,0x0,0xa6,0x2e,0x4b,0xc2,0x5,0x5b,0xc4,0x0, -0xfc,0x9d,0x19,0xf0,0x6a,0x30,0xe0,0xf3,0xe6,0x5b,0x1a,0xec,0xc,0xc,0xc1,0x2c, -0x18,0x18,0x7f,0xb0,0x60,0xf3,0x4,0xbc,0xce,0x81,0xe2,0xac,0x6b,0xbe,0x3e,0xf0, -0x7e,0x99,0xfe,0xeb,0xe3,0xe3,0x4f,0xee,0x79,0x3f,0x9f,0xf7,0xf3,0x34,0xc1,0x25, -0x23,0xe1,0x25,0xa3,0xbe,0xf0,0x34,0xe9,0xbb,0xcd,0xc0,0x13,0xd7,0x4a,0xff,0xd5, -0xd1,0xe1,0x6b,0xaf,0xdf,0xb3,0xcf,0x7b,0x1,0x69,0x0,0xb6,0x7,0xc0,0xd4,0xaf, -0xfa,0xd2,0x3a,0xe0,0xf1,0x87,0x7,0xe9,0x5f,0x3d,0xfe,0xf4,0xc3,0xe7,0x2f,0x1f, -0x3f,0xdf,0x1,0x8,0x86,0x6f,0xa,0xbc,0x39,0x4e,0xff,0xea,0x9d,0xaf,0x6e,0xae, -0x3e,0xf9,0xd8,0x1a,0x24,0xf3,0x4e,0xff,0x9d,0x12,0xe1,0xed,0x7a,0xe0,0xbf,0x0, -0xe0,0xf3,0x7b,0x3,0x1,0xe9,0xa8,0x1d,0xf8,0x6f,0x10,0xf8,0xf2,0x63,0xbf,0x1f, -0x30,0x2,0xcb,0x9a,0x40,0x68,0x7,0xc3,0x4f,0x21,0x5a,0x10,0xa2,0xdf,0xd2,0xe9, -0x45,0x75,0xc,0x3f,0x7c,0xfc,0xe9,0xcd,0xe7,0x7d,0xc7,0x90,0x4d,0x1c,0x9,0x73, -0x19,0x5,0xe0,0x2d,0xd,0x75,0x60,0x29,0x11,0x3c,0x86,0x59,0xfa,0xe1,0xa3,0xc3, -0x9b,0xdf,0xf6,0x9d,0xa5,0xc,0xe2,0xa1,0x80,0x81,0x2d,0x22,0x30,0xd5,0x81,0xf, -0xec,0xb2,0x1d,0xbe,0x9d,0x7e,0x78,0x7c,0x7c,0xf3,0xdb,0x5f,0xf5,0xb4,0x43,0xa, -0x1f,0x48,0x1d,0x91,0x30,0x25,0xf0,0x2e,0x1,0xd3,0xc3,0x37,0x6a,0x7c,0x8d,0x48, -0xfc,0x7b,0xa6,0x18,0xbf,0x80,0xf7,0xdb,0x0,0x7b,0x1f,0x26,0x9,0x58,0x87,0x7a, -0x4b,0xf1,0x3,0x8e,0x8f,0xb6,0x0,0x53,0xa7,0xa7,0x6b,0x7b,0x2c,0xa4,0x35,0xc2, -0x66,0xf0,0xa6,0x44,0xab,0x62,0xa4,0xc7,0xa7,0xdb,0xae,0xd0,0xed,0x9,0x7c,0xa, -0x6f,0x48,0x78,0x31,0xe8,0x63,0xa6,0x91,0xda,0x6d,0xc0,0x5d,0xe3,0x61,0xe9,0xa, -0x99,0xb3,0x67,0x60,0x79,0xc,0x4b,0x85,0xa1,0xe1,0x81,0xe5,0x59,0xca,0xd8,0x77, -0x1a,0xf0,0x60,0x34,0x74,0x15,0xa3,0x64,0x87,0x65,0xa0,0xf5,0x64,0x68,0x60,0xc9, -0xd3,0x94,0x80,0xcc,0x5a,0xe,0xd,0x2c,0xf9,0x52,0x15,0x88,0xce,0xfb,0x7c,0xb5, -0xf7,0xc2,0xd0,0x77,0x8d,0xd1,0x62,0xaf,0xc0,0xbd,0xa8,0xa7,0x3b,0x7,0x26,0xd2, -0xd,0xaf,0xb8,0xba,0xa8,0xde,0xd2,0xe9,0xc5,0xd0,0xc0,0x50,0x40,0x71,0x32,0xce, -0x6b,0x80,0x9e,0xbd,0x77,0xa0,0xf2,0x5a,0xee,0x3,0x18,0x8,0x68,0xc,0x7f,0x9e, -0x31,0xdd,0x97,0x32,0xc8,0x1e,0xef,0x5b,0x43,0xbb,0x36,0x30,0x3d,0xea,0x63,0x42, -0x2c,0xe0,0x54,0xfd,0xe,0xd0,0xa7,0x87,0x8f,0x86,0x9e,0xa5,0x60,0xf3,0x69,0x6, -0xc5,0x37,0x55,0x73,0xd6,0x3d,0x38,0x6f,0x7e,0x1f,0x2f,0x24,0xb8,0x94,0x62,0x90, -0x70,0x1f,0xc0,0x58,0x81,0x3a,0x3a,0x70,0xc9,0xf6,0x1,0x54,0x67,0xcc,0x4c,0x7, -0x82,0x59,0xec,0x1,0xa8,0xce,0x18,0x80,0xef,0x1f,0xa8,0xcd,0x98,0x40,0x3,0xe2, -0xbf,0xe,0x1f,0x80,0xd5,0x19,0x3,0x70,0x62,0xe9,0xe5,0xb3,0xe1,0xe3,0x21,0xf7, -0x2f,0x97,0x32,0xed,0xd3,0x81,0xab,0xdb,0xbd,0xc4,0xc3,0xcc,0x6d,0xe3,0x7b,0xaa, -0x7b,0xb6,0xdb,0x3b,0x9,0xc0,0x8a,0xc5,0xdc,0xde,0x41,0x3c,0x54,0x6b,0x6d,0xf1, -0x3e,0x96,0xf3,0x78,0xbd,0xd4,0xf2,0x61,0xec,0x7c,0x7e,0x4b,0xd5,0x5a,0xdb,0x1f, -0xdf,0x64,0x69,0x30,0x38,0xf0,0x75,0x1d,0xa8,0xd6,0xda,0xd6,0x3f,0x67,0xa9,0x3f, -0x34,0x90,0xc8,0x7c,0x34,0xe1,0x19,0x9b,0x5e,0xfa,0x5a,0x9f,0x73,0x2b,0x1d,0xba, -0x5e,0xfa,0x6b,0x10,0x33,0x97,0x2c,0xf6,0xdd,0x2a,0x70,0x29,0xac,0x74,0x58,0x20, -0x48,0xa7,0xcd,0x6a,0xc1,0x7e,0xef,0x9,0xb3,0xd0,0x6a,0x6d,0x1b,0x19,0x94,0x7, -0xaf,0x26,0x2,0x70,0xe5,0x8a,0x12,0xb4,0x5e,0x6b,0x13,0xbe,0x7d,0x3f,0xc0,0xb, -0x1,0x54,0x6b,0x6d,0xa2,0x34,0xb6,0x2f,0xe0,0x4c,0x0,0xd5,0x5a,0x1b,0x66,0x6d, -0xd4,0xdf,0x17,0x10,0xc4,0x61,0x5c,0x72,0x6d,0x3c,0xd5,0x77,0x7,0x9f,0xa5,0x58, -0xd5,0xbf,0x64,0x4b,0x10,0x87,0x49,0x30,0xad,0xd6,0xda,0x2e,0xee,0x10,0x18,0x87, -0xfb,0x0,0xe2,0x42,0x89,0x23,0x6a,0xde,0xc4,0x2f,0x1,0x3d,0x99,0xf3,0xc,0xee, -0x69,0x5c,0xe1,0x69,0x68,0x9,0xc8,0x2b,0x1a,0x89,0x2e,0x5f,0xad,0x86,0x97,0x6d, -0xbe,0xd8,0x25,0x7c,0x69,0x5a,0x2,0xf2,0xfc,0x9f,0xe8,0x9,0x40,0xe3,0x6b,0xe7, -0xc6,0x81,0xaa,0xae,0xd8,0x2f,0x90,0x54,0x3d,0x77,0xa3,0x55,0x92,0x9d,0x23,0x7e, -0xb8,0x7,0x20,0x75,0x57,0x7c,0xc1,0x92,0x1c,0xf8,0x2c,0x39,0xc8,0xa,0x77,0x3e, -0x8b,0x20,0xf4,0x62,0x3a,0xa3,0xd7,0xfa,0x6,0x0,0x12,0x67,0xc5,0x17,0x2c,0x71, -0x96,0xe6,0xb,0x96,0x0,0x9c,0x9c,0x5,0xfc,0xa,0x7,0x7,0x26,0xf6,0xa,0xec, -0x50,0xac,0xae,0xe5,0xb,0x96,0x0,0xb4,0x4e,0x2,0x1c,0xc3,0xd4,0xb2,0x86,0x6, -0x3e,0x1,0x20,0x38,0xee,0xe5,0x85,0xcb,0xe6,0x4e,0x1,0xbc,0xff,0x20,0xc0,0x59, -0xba,0x7,0x60,0xf2,0x21,0xdb,0x80,0xe3,0x5e,0x2d,0x16,0x6c,0xb1,0x98,0xe6,0xc0, -0x87,0xf7,0x2,0xb4,0xc3,0x3d,0x0,0xc9,0xdb,0x6c,0x93,0xbc,0xaf,0x1,0x27,0x30, -0x96,0xfe,0x6b,0x1,0xf7,0x34,0xaf,0x6b,0x63,0x18,0x5b,0x2c,0xdc,0x15,0x48,0x1d, -0xb6,0x21,0x6e,0x15,0x38,0x81,0x49,0x3,0xa1,0x69,0x52,0x2,0x36,0x5,0x64,0x33, -0x60,0xea,0xf0,0x5,0xcb,0xa,0x30,0x12,0xb3,0x34,0x2a,0x1,0xa3,0x9d,0xaf,0x30, -0x84,0x68,0x1,0xca,0x69,0x9,0x91,0x76,0xce,0xc4,0xa4,0x59,0xc2,0x18,0x7a,0xa0, -0x17,0xd7,0x15,0xe3,0x5f,0x95,0xc5,0x55,0xf,0x60,0x70,0x1,0x50,0x8,0x4f,0x0, -0x9d,0xc9,0x2c,0x34,0x39,0xf3,0x99,0x2b,0xef,0x5d,0x52,0x2,0xfe,0x97,0x5d,0x81, -0x24,0x98,0xf3,0xf5,0xc3,0x4,0x60,0x4b,0x99,0x67,0x13,0x0,0x5e,0xd2,0x20,0x2b, -0x2c,0x68,0xc0,0x78,0x67,0xd7,0x16,0xac,0xf8,0x72,0x1e,0x1,0xd8,0x46,0x2a,0x9, -0xa,0xc0,0x45,0xf6,0xe7,0x12,0xf0,0xcb,0x7d,0x3a,0xef,0x1a,0x2d,0x49,0x3e,0xbd, -0x13,0x20,0xe8,0x80,0x8,0x26,0xee,0x1c,0x80,0x6f,0xde,0xd,0xf0,0x81,0x1d,0xf9, -0xa9,0x7f,0x1,0xc0,0x7f,0xb6,0xb3,0xa7,0x29,0xd5,0x4b,0x33,0xe1,0xd,0xd3,0x7, -0x47,0x51,0x8c,0xe4,0xfa,0xd3,0x8f,0x29,0x8,0xa9,0x77,0x1,0x18,0xee,0xc,0x2c, -0x95,0x2f,0xb3,0x12,0x83,0x27,0xa,0x2a,0x62,0xde,0xae,0xbf,0xa2,0x0,0xfc,0x0, -0x22,0x24,0x61,0x77,0x3,0xfc,0x14,0x80,0xf4,0x3,0xf0,0x47,0xc9,0xee,0xc0,0xa0, -0x52,0xfd,0x2a,0x55,0x6e,0x70,0xc,0xef,0x23,0x70,0x61,0x83,0x20,0xd8,0x3d,0xc5, -0xf0,0x2a,0xd5,0xaf,0x1c,0x7e,0x9e,0x25,0xde,0xf1,0x31,0x2,0xd7,0x30,0x86,0xd1, -0xee,0x49,0x94,0x5b,0xa9,0x7e,0xe5,0xd0,0x28,0xab,0x12,0xaf,0x29,0x0,0x89,0xb, -0xc0,0xff,0xb0,0x3b,0xb0,0xe6,0x1e,0x66,0x57,0x9c,0xc1,0x1,0x48,0x0,0xe8,0x0, -0xf0,0x60,0x77,0x60,0xa9,0x5e,0x9a,0x5f,0xb1,0x2,0x6,0x20,0x98,0xc5,0xed,0xcd, -0xbb,0xec,0xf7,0x47,0xbb,0x3,0x5b,0x66,0xc,0x17,0xa4,0xeb,0xd4,0xa6,0x6c,0x73, -0x73,0xc1,0xe2,0xd3,0xdd,0x81,0x6d,0x33,0xc6,0xe5,0x42,0xd1,0xa5,0xec,0x66,0x3, -0xb9,0xdd,0xee,0x76,0xd8,0x3a,0x63,0x34,0x7d,0xb8,0x1c,0x0,0x58,0x3b,0x63,0x4a, -0xf0,0x5c,0x2c,0xae,0x86,0x0,0xea,0xf5,0x52,0xee,0x5b,0x10,0x8a,0x1,0x98,0x84, -0x85,0x3e,0xe4,0xc0,0xf9,0x10,0xc0,0x3a,0xb7,0x2d,0x5d,0x37,0x46,0x5f,0xd,0x71, -0x31,0x4,0xb0,0xcb,0xcb,0xb9,0x63,0x60,0xfa,0xf6,0x1d,0x3,0xe9,0x87,0xbb,0x3, -0xcb,0xd,0xad,0x9,0x26,0x9e,0x52,0x1f,0x4e,0x66,0xa5,0x24,0x8a,0xc,0x30,0x4b, -0xcb,0xd,0xad,0x31,0x36,0x62,0x49,0x7d,0x88,0x42,0x46,0x3,0x6e,0x86,0x8,0xc0, -0xbc,0x4e,0x53,0x34,0xb4,0x46,0x96,0x9f,0xe9,0x43,0x50,0x4e,0xa1,0xae,0x9e,0x56, -0xb1,0x35,0x80,0x3e,0x9c,0x73,0x7d,0x98,0x35,0xb4,0x46,0x27,0x7e,0xa6,0xf,0xd3, -0xfb,0x7,0x39,0x50,0xd4,0x67,0xdc,0x21,0x80,0x58,0xdc,0x8b,0x5,0xf0,0xa5,0x37, -0x65,0x2f,0x7d,0x3f,0xd3,0x87,0xe9,0xc9,0x71,0xe,0xbc,0xe2,0xbf,0x7e,0x37,0x14, -0x30,0x91,0xfd,0xa5,0xee,0x94,0x2d,0x3c,0x3f,0xd3,0x87,0x8,0xcc,0xf4,0xe1,0xd5, -0x70,0x82,0x94,0x37,0xb4,0xca,0xfe,0xd2,0x39,0x0,0x2f,0xfd,0x4c,0x1f,0x72,0xe0, -0x64,0x2f,0xc0,0xac,0xa1,0x75,0x9,0xc0,0xb9,0x9f,0xe9,0x43,0xe,0x8c,0x6,0x7, -0x62,0xbb,0x27,0x44,0xa,0x12,0x8a,0x76,0xcf,0x79,0xec,0x67,0xfa,0x30,0xf5,0xc0, -0x79,0xc7,0x3f,0x7e,0xa0,0x14,0xa4,0xd8,0x5f,0x9a,0xd9,0xa1,0x14,0xa4,0xa9,0xb, -0xf1,0x30,0x19,0x1a,0x98,0x35,0xb4,0xa6,0x7e,0xe1,0x69,0x32,0x41,0xea,0x26,0xb9, -0x20,0x1d,0xe,0x58,0xee,0x2f,0x45,0x5f,0x9a,0x9,0xd2,0xcb,0x4d,0xee,0xda,0x86, -0x3,0x1a,0xbe,0x5e,0x1,0x3b,0x0,0x4b,0x4d,0x58,0xc9,0x23,0x30,0x85,0x27,0xf0, -0xbf,0x21,0x4d,0xc4,0x78,0x78,0x7e,0x31,0x34,0xb0,0xd4,0x66,0x96,0xbc,0x5,0xc0, -0xf7,0x0,0x38,0x81,0x7f,0x82,0x64,0xf8,0xdc,0x19,0x1a,0x58,0x6a,0xa4,0x43,0xb3, -0x88,0x60,0xa6,0x4e,0xe0,0x8d,0x91,0xc2,0xb2,0x87,0x36,0x8b,0x52,0xab,0xe0,0xfc, -0x35,0x9f,0x7d,0xf2,0x3a,0xc4,0xc3,0xd7,0x21,0x1e,0xfe,0x2c,0x4c,0xf,0xde,0x18, -0xda,0xf0,0x4b,0xcd,0x90,0x18,0x2d,0xa6,0xf,0x20,0x1e,0x42,0x0,0x3e,0x39,0xc, -0xb3,0x86,0xd6,0x1,0x5d,0x5b,0xa9,0xdd,0x73,0x31,0x5,0xe0,0x43,0x0,0x9e,0x88, -0x0,0x2c,0x9b,0x3f,0x6,0x4,0x96,0x1a,0x5a,0xf7,0xf,0xbc,0xeb,0x2b,0xac,0x8c, -0xe1,0xbe,0x81,0xe5,0x59,0xba,0x77,0x60,0xd9,0xe,0x31,0x1e,0x62,0x8a,0x61,0x59, -0x5a,0x5e,0xba,0x3f,0x4f,0xb3,0x7f,0x60,0xc9,0x97,0xee,0x1f,0xf8,0x2a,0x1e,0xb2, -0x3d,0x9b,0x5,0x64,0x8a,0xc,0x32,0x45,0x16,0x81,0x6a,0x9b,0x4,0x6c,0xf8,0xcc, -0xfb,0xce,0x81,0x4,0xbe,0x82,0xd8,0x62,0x8f,0x58,0x8c,0x6f,0x80,0x46,0x0,0x9d, -0xc0,0x1b,0xa5,0xa2,0xdc,0x28,0x34,0xa0,0x2f,0x95,0xa9,0x21,0xa,0xb1,0x8,0xdf, -0xb6,0x34,0x4d,0xe1,0xf,0x52,0xb9,0x86,0x39,0x20,0x70,0xc,0x40,0xc8,0x76,0x97, -0x90,0xf4,0xce,0xf1,0xbd,0x64,0xec,0x72,0xce,0x98,0x77,0xc1,0x52,0xf,0xf3,0xe3, -0xc1,0x81,0x90,0xf0,0x6e,0x20,0xdb,0x45,0xf5,0xbe,0xc0,0x37,0x24,0xbf,0x53,0x8, -0x57,0xfe,0x9c,0xa5,0xc1,0x2,0xde,0xd3,0x57,0xc0,0x9f,0x8,0xf0,0x7a,0x40,0xb3, -0x70,0xe0,0xed,0xe6,0xeb,0xf8,0x5b,0xa2,0xc5,0x2b,0xe0,0xe0,0xd1,0xe2,0x15,0xf0, -0x15,0xf0,0xa7,0xe,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0x21,0x6,0x77,0x2c,0xf0,0xee, -0x7e,0x85,0x44,0xf6,0xb3,0xf1,0x6d,0xe6,0x4d,0x40,0x5e,0x52,0x76,0x76,0x7,0x26, -0x1c,0x18,0xb6,0x3,0xb3,0x5e,0xc2,0x5d,0x81,0x71,0x76,0x3f,0x5b,0x80,0x69,0xd6, -0xda,0xb7,0x2b,0x90,0xf,0xd,0x66,0x77,0x2d,0x40,0x6a,0x65,0xb7,0x62,0x47,0xa0, -0xa8,0xf6,0x7b,0x3f,0x3c,0x20,0x29,0xe6,0xf2,0x6e,0x40,0xf1,0x39,0x6e,0x2b,0x50, -0x4c,0x2e,0xcb,0xdf,0x15,0x28,0xe7,0x82,0xd3,0xa,0x14,0x93,0xcb,0xf2,0x76,0x5, -0xd2,0xbc,0x75,0xb6,0x5,0x18,0xe5,0xb7,0x62,0x37,0x20,0xc9,0x3b,0x59,0x5b,0x80, -0x93,0xfc,0x56,0xec,0x6,0x94,0x43,0x3,0xb3,0xaf,0xa,0x4c,0x8b,0x11,0xb,0x59, -0xd1,0x63,0xbb,0x1b,0x30,0xce,0x3d,0x69,0x33,0x30,0xb5,0xac,0x8e,0x76,0xb1,0x5, -0x28,0x87,0x6,0x3e,0xba,0xf9,0x96,0x52,0xd5,0xc7,0x77,0x2,0x2a,0xf1,0xc1,0x67, -0x45,0x17,0xb6,0xd7,0x2,0x24,0xea,0x37,0xf5,0x5,0x7a,0xb9,0x55,0xe0,0xec,0xab, -0x1,0x16,0xc7,0x3c,0x86,0x89,0xf2,0x4d,0xdd,0x80,0x13,0xd,0x98,0xdf,0x29,0xa7, -0x6e,0xc,0x8b,0x29,0x19,0xc6,0xc5,0x4f,0xd6,0x11,0xa8,0xbc,0xa6,0x85,0x55,0x80, -0x21,0xd6,0x0,0xdf,0x29,0x80,0x51,0xf1,0x93,0xed,0x4,0x4c,0x8a,0x96,0xf2,0x1a, -0xe0,0xb3,0x2,0x38,0x51,0xba,0xeb,0x77,0x1,0xc6,0x45,0x86,0xd1,0xc,0x54,0x9b, -0xdd,0x77,0x1,0x46,0xc5,0x94,0x6d,0x4,0x9e,0x15,0xc0,0x70,0x27,0x60,0x31,0x85, -0xbc,0x46,0xe0,0xa9,0x9e,0x6c,0xf5,0x7,0x16,0x9f,0xe3,0x36,0x7a,0x9a,0x91,0x6e, -0xbd,0xbd,0x81,0x69,0xf1,0x39,0x4e,0x23,0xf0,0x89,0x66,0x4c,0xfd,0x81,0x54,0xd9, -0xdb,0xd1,0xe8,0x69,0xde,0x53,0x6e,0xc5,0x2e,0x40,0xa2,0xf8,0x9d,0x17,0x86,0x99, -0xb7,0xb3,0xb,0x30,0x69,0xce,0xbc,0x3f,0xf,0x6b,0x80,0xf6,0x2e,0xc0,0xb8,0x19, -0x78,0x10,0x68,0x40,0x3f,0x19,0x6,0xe8,0xa4,0x5b,0x80,0xe9,0x3b,0xbe,0x6,0x14, -0xbf,0xed,0xe,0xf4,0x85,0xf9,0xd7,0x0,0x9f,0x5d,0x7d,0xaf,0x40,0x47,0x75,0x4c, -0x6d,0x7b,0x7d,0x9a,0x80,0x32,0xe7,0xac,0x1,0x7e,0xa4,0x1,0x5d,0xa6,0x8d,0x79, -0xd3,0x2b,0x6c,0x2,0xda,0x32,0x48,0xd5,0x1,0xb5,0x31,0xf4,0xc5,0x17,0x1a,0xdc, -0xd2,0xb4,0x11,0xe8,0xca,0xb8,0x5f,0x33,0x4b,0xef,0x69,0xb3,0x34,0x10,0xf1,0x7a, -0x67,0xa0,0x57,0x7c,0x5e,0x19,0xf8,0x99,0x66,0x87,0xa1,0xf8,0xc9,0x76,0x6,0xfa, -0x32,0x77,0xb,0xda,0x3c,0x4d,0xe,0x94,0xe5,0x7b,0x74,0xb5,0x14,0xbe,0x8d,0x5a, -0x21,0xaf,0xf4,0x27,0xf8,0xb6,0xb1,0xd2,0xdf,0x1f,0xf8,0x77,0x2a,0x50,0xfe,0x6e, -0x67,0x8b,0x5c,0xb8,0xb2,0x46,0xf8,0x6,0xe4,0xac,0xca,0x1f,0xca,0x2a,0x7f,0x33, -0x30,0x90,0xe9,0x70,0x1b,0xd0,0x96,0x29,0x98,0x4d,0xc1,0x40,0xc4,0xda,0xa1,0xcb, -0x37,0x5b,0x25,0xbc,0xc5,0x5,0x8d,0x2b,0xe0,0x6b,0xf9,0x13,0xab,0x19,0x18,0xca, -0x84,0xdf,0x18,0x48,0xe0,0x8f,0x84,0x97,0x30,0x1d,0x5e,0xc2,0x8c,0x79,0x9,0xd3, -0xcb,0x4a,0x98,0xf0,0x3e,0x1b,0x4,0xe8,0xca,0x44,0xdd,0x86,0x2f,0x86,0x6f,0xb0, -0xe1,0x9b,0x6d,0xf8,0xbb,0x3,0x6f,0x17,0x60,0x2e,0x7c,0x8d,0x7,0x63,0xec,0xc3, -0xfb,0xa4,0x11,0x98,0x69,0x28,0x63,0x20,0x7c,0x13,0xa6,0xa9,0x98,0x39,0x2,0x8, -0x86,0x14,0xa0,0xc2,0x23,0xbb,0x60,0x36,0x1e,0xbc,0x1f,0xe,0xb,0x8c,0xbc,0x49, -0x10,0xf9,0x56,0x30,0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0x9d,0x5a,0xc4,0xa6, -0x36,0x71,0x88,0x9d,0xb8,0xc4,0x89,0xef,0xd,0x2,0xf4,0xa4,0xd8,0xb2,0x23,0x3f, -0xa,0xa2,0x60,0x12,0x4c,0x42,0x0,0x32,0x0,0xa6,0x76,0xa,0x38,0xea,0x50,0x7, -0x90,0x2e,0x71,0x93,0x46,0xa0,0x9d,0xe9,0x60,0x73,0x60,0x10,0x7,0x51,0x8,0x48, -0x16,0x85,0x60,0x94,0xa9,0xcd,0xec,0xd4,0x1,0xa4,0x9b,0x2,0x8e,0xba,0xc4,0x23, -0x43,0x3,0xc3,0x24,0x88,0x58,0x1c,0x9c,0xb3,0x38,0x84,0x29,0x3,0xa,0xe4,0x3c, -0x75,0x99,0x4d,0x3d,0xe6,0x10,0x2f,0x75,0x89,0x4f,0xfb,0x3,0xd9,0x4e,0xc0,0x54, -0x8b,0x20,0x9e,0x1,0x30,0xda,0xd,0x48,0x35,0xa0,0x6b,0x0,0xb4,0x82,0xdd,0x80, -0xda,0x4d,0x5a,0xb7,0x3,0xd3,0xe0,0xae,0x81,0xe1,0xd5,0x4e,0xb3,0x74,0x30,0xa0, -0xa9,0x1d,0xee,0x8,0xec,0xee,0x69,0xea,0x81,0xd,0x9e,0x66,0xb,0xd0,0xd8,0x97, -0xfe,0x8,0x80,0x96,0xbf,0x53,0x78,0xda,0x11,0xd8,0x3d,0x0,0x6f,0x1,0x36,0x5, -0x60,0xb6,0x53,0x8a,0xb1,0x23,0xb0,0x7b,0x12,0xb5,0x5,0xd8,0x90,0x44,0x7d,0x1e, -0xee,0x94,0x26,0x6e,0x1,0x36,0xa4,0x89,0xba,0x3e,0xec,0x9c,0x8,0x53,0x55,0x8b, -0x84,0x6,0xc0,0x92,0x3e,0xec,0x9c,0xea,0x53,0xf5,0x6c,0xbc,0x2,0xb8,0x3d,0xd5, -0x2f,0xc9,0x35,0x9f,0x69,0x35,0x81,0x76,0xf5,0x44,0xd9,0xff,0x29,0x82,0x53,0x18, -0xb7,0x8b,0x99,0x12,0xb0,0xb3,0x5c,0xa3,0xec,0xdb,0xa2,0x14,0x11,0xc6,0xa1,0x81, -0x5c,0xab,0x13,0xa4,0xe6,0xa,0x18,0x80,0xf9,0xdf,0x6e,0x42,0x1a,0x1a,0x8,0xd2, -0xdd,0x34,0xfe,0x36,0xe0,0x56,0xc9,0x5d,0xd2,0x87,0x9d,0xab,0x18,0xdb,0x80,0x5b, -0xab,0x18,0x25,0x7d,0xd8,0xb9,0x4e,0xb3,0xd,0x68,0xb2,0x24,0xdb,0xab,0x12,0x55, -0x3,0xac,0xaf,0x44,0x25,0x76,0xe2,0xe0,0xb6,0x7d,0x30,0xa7,0xf4,0x71,0x7a,0x2, -0xbe,0x8c,0x58,0x7d,0x6a,0x6d,0x35,0xc0,0xfa,0x5a,0x5b,0x62,0x25,0x36,0x7,0x82, -0xcf,0x7c,0x44,0x8f,0x21,0xa6,0x9f,0x5a,0x7d,0xaa,0x89,0x35,0xc0,0xfa,0x6a,0x62, -0x62,0x8d,0x0,0x11,0xfe,0x19,0x92,0x24,0xfa,0x68,0x74,0x64,0x3d,0xb2,0x8e,0xac, -0x3e,0xf5,0xd2,0x1a,0x60,0x7d,0xbd,0x74,0x43,0x9e,0x92,0x53,0xc6,0x6e,0x19,0xf5, -0xc9,0xe8,0xad,0xa3,0xf1,0xa3,0xf1,0xc9,0x51,0x9f,0x8a,0x70,0xd,0xb0,0xbe,0x22, -0xbc,0xa1,0x4f,0xe9,0x29,0xdf,0xab,0xfd,0x4d,0x92,0x58,0x47,0xe9,0xa3,0xf4,0xe4, -0xa4,0x4f,0xcd,0xbb,0xe,0x58,0x5b,0xf3,0xe6,0xc0,0x73,0xb6,0x84,0x49,0xb3,0xe1, -0x40,0x48,0x89,0xfb,0x54,0xf5,0xeb,0x80,0xb5,0x55,0x7d,0x0,0x92,0x53,0x8b,0xcd, -0x0,0xb8,0xdc,0xbc,0x6,0xc0,0x30,0xd,0xfa,0xac,0x5b,0xd4,0x1,0x6b,0xd7,0x2d, -0x36,0x94,0x4f,0x9a,0xb,0x0,0xae,0x36,0x9f,0x1,0xd0,0x4a,0x83,0x3e,0x2b,0x33, -0x75,0xc0,0xda,0x95,0x19,0x0,0xda,0xe4,0x28,0xbc,0x4,0xe0,0x7a,0x93,0x1e,0xa5, -0x90,0xec,0x6,0x13,0x93,0x20,0xe1,0x37,0x1,0x93,0x70,0xeb,0xda,0x53,0xe,0xb4, -0xfc,0x3b,0x2,0x92,0x91,0x45,0x68,0xe8,0x66,0xc0,0xc0,0x3a,0xb,0x8c,0xc2,0xa0, -0xd7,0x4,0xe4,0xf1,0xb0,0x7e,0x39,0x2f,0xb1,0x36,0x49,0x48,0xcf,0x7c,0xb8,0xa5, -0xdf,0x71,0x20,0x3d,0x9,0x8c,0x16,0x2c,0xe7,0x5b,0x80,0xde,0x1a,0x80,0x3c,0xc5, -0xa8,0x5f,0xb0,0x4c,0xec,0xd,0x9,0xe9,0x38,0xc0,0xd4,0x84,0x3,0xd3,0x93,0xc0, -0x68,0x49,0x76,0x53,0xf,0x4c,0x9d,0x2,0x58,0xbb,0x24,0xb,0x40,0x7a,0x4a,0xc7, -0x61,0x6,0x4,0xc3,0xf,0x8c,0x16,0x9d,0xb5,0x13,0x29,0xa,0x20,0x79,0xaa,0x0, -0xeb,0x16,0x9d,0x37,0x30,0x8a,0xa7,0xa7,0xa7,0x19,0x10,0x5d,0x5b,0x60,0xb4,0xac, -0xae,0x1d,0x99,0x28,0x80,0x98,0xa6,0x13,0xaa,0x0,0xeb,0x96,0xd5,0x37,0x30,0x8a, -0xa7,0x96,0x38,0x14,0x14,0x80,0xe8,0xbc,0x5d,0xb3,0xc6,0x1,0xaf,0x1e,0x98,0x7e, -0x54,0x0,0xeb,0x1a,0x7,0x0,0x8,0x2,0x62,0xc3,0xb3,0xb6,0x4d,0xca,0xc3,0x93, -0x6b,0xd6,0x1a,0xb1,0xa8,0xde,0x52,0xb8,0x68,0xd,0x58,0xd7,0x1a,0x1,0x40,0xd0, -0xec,0x19,0x90,0x7,0x60,0xd7,0xac,0xf9,0x63,0x59,0xf,0x64,0xbf,0x2a,0x80,0x4d, -0xcd,0x1f,0x4a,0x5e,0x6a,0xd8,0xde,0x42,0xaa,0xc0,0x2b,0xc6,0x37,0x2b,0xe6,0xc0, -0xa6,0xf6,0x16,0xd,0x68,0xd4,0xc0,0x43,0x83,0xa,0xf0,0x1b,0xc6,0x1b,0x79,0x73, -0x60,0x53,0x3,0x8f,0x6,0x34,0x6b,0x51,0xf2,0x6a,0xd,0x3f,0x50,0x66,0x69,0x53, -0x8b,0x92,0x6,0x34,0xeb,0xfa,0xba,0xd8,0xee,0xda,0x32,0x60,0x43,0xd7,0x97,0x6, -0x34,0xeb,0x6b,0xdb,0xb4,0x3,0x1b,0xfa,0xda,0xb4,0x7e,0x1a,0xb3,0xce,0x3d,0xc5, -0xd7,0x6c,0x3,0x36,0x74,0xee,0xe9,0x40,0xa3,0xde,0x44,0xc5,0xd7,0x6c,0x3,0x1a, -0xf7,0x26,0xc6,0x46,0x49,0xa9,0xa7,0x2,0xc3,0x12,0xf0,0x32,0xab,0x7a,0xf1,0xa1, -0x69,0x3,0x9a,0xbd,0x16,0xa,0x30,0x2d,0x3,0xf5,0x53,0xbf,0xda,0x6e,0xa9,0xd9, -0x6b,0xd9,0x4,0xd4,0xcf,0x1c,0x1c,0x6,0x48,0x9a,0x80,0xec,0xbc,0x19,0xa8,0x1c, -0x98,0x6b,0xc,0x2c,0x7c,0x4d,0x1d,0x30,0x9,0x9a,0x81,0xc5,0x24,0x37,0x6,0x16, -0x3f,0xa3,0x0,0x62,0x15,0x10,0xf7,0xa,0x9,0xa0,0xf6,0x94,0x92,0x17,0x9a,0x5c, -0xe3,0x3b,0xb2,0x13,0x94,0x6b,0x47,0x2e,0xd6,0x63,0xcb,0x1f,0x1c,0x1b,0x64,0x54, -0x39,0x10,0x86,0x46,0x0,0xb5,0x69,0xa3,0xcb,0x35,0xbe,0xab,0x7e,0x8e,0x72,0xed, -0xc8,0x9d,0xf8,0x13,0x9f,0x31,0x56,0x5a,0x16,0x30,0x7,0x62,0x9d,0x4c,0x2,0xd5, -0x47,0xdd,0xd5,0x0,0x2f,0xb7,0x3,0x7d,0x83,0xcc,0xad,0x6,0xc8,0x26,0xf5,0xc0, -0x91,0x15,0x4e,0xc2,0x3f,0xc3,0x78,0xa0,0x3e,0xbc,0x67,0xb9,0xc2,0xe0,0x53,0x93, -0x91,0x4c,0xaa,0x40,0x2c,0x3b,0x66,0xc0,0xc4,0xaf,0x1,0xa2,0x3e,0xc,0xcf,0xd9, -0x2d,0x98,0x5,0xe8,0xc3,0x93,0x13,0xff,0xd2,0x33,0x7,0x2a,0xde,0x34,0x3,0x62, -0x61,0x35,0x3,0x2a,0x8f,0x19,0xd0,0xe5,0x5a,0x88,0xc7,0xdb,0x59,0x3e,0xe8,0xc3, -0x93,0x93,0x60,0xe1,0x9b,0x3,0x95,0xb3,0xa7,0x33,0xa0,0x28,0x1d,0xcb,0xd9,0x1f, -0x7,0xf5,0xc0,0x33,0x9f,0x3b,0x8d,0xd,0x7,0xb2,0xe,0x40,0xe5,0x50,0x5f,0xe, -0xf4,0x27,0x61,0xe4,0x5b,0x5,0x90,0xba,0xb5,0x40,0x32,0xe,0xf8,0x81,0x48,0xa0, -0xf,0xe1,0x96,0x76,0x2,0xce,0x75,0x60,0xb6,0xa6,0x92,0xc7,0xee,0xa8,0xe,0x8, -0xfa,0xd0,0x66,0x17,0x69,0x70,0x5,0xfa,0x10,0xe4,0x76,0xd0,0x5,0x18,0xeb,0x40, -0x10,0x31,0x80,0x54,0x80,0xc4,0xaf,0x3,0xda,0xc4,0x66,0x97,0xa9,0x7f,0x5,0xea, -0xe9,0x24,0x98,0xf8,0xbe,0x67,0x2e,0xd7,0x28,0x36,0xbf,0xf2,0x8d,0xf2,0xf5,0xc0, -0xfc,0x98,0xda,0x92,0x5c,0xb3,0x98,0x9b,0x7a,0x2,0x18,0x79,0xbe,0x67,0x2e,0xd7, -0x52,0x5c,0x48,0xe0,0xfb,0x83,0x68,0x3d,0x30,0x9b,0x36,0xba,0x5c,0x3b,0x25,0x20, -0xd7,0xdc,0xab,0xef,0x10,0xc8,0x5c,0xc3,0x5b,0x2a,0x82,0xe1,0x14,0xae,0xd1,0xa7, -0x21,0xa8,0x3c,0x56,0xb,0x4c,0xdd,0xaa,0x2f,0x5,0x31,0x83,0x72,0xed,0x37,0x3c, -0xf3,0xe,0xd8,0xa5,0x21,0x50,0x1c,0xa8,0x8f,0x47,0x51,0x4d,0xe1,0xed,0x6f,0x1, -0x66,0xe,0xb5,0x46,0xae,0x8d,0x38,0xd0,0xdc,0xe,0x45,0xce,0xb6,0x81,0xdf,0xae, -0xc1,0xa6,0xae,0x38,0xb0,0x32,0x4b,0xf3,0x38,0x5c,0x23,0xd7,0x4e,0x7d,0xe,0x34, -0xf0,0x34,0xc4,0x2a,0xa2,0x2f,0xf9,0x30,0x72,0xd6,0xf3,0xc8,0xbd,0xe6,0x40,0x69, -0x87,0xf3,0x50,0x39,0x7b,0xef,0x9c,0xaf,0x37,0x54,0xe5,0x5a,0x7a,0x86,0x40,0x23, -0x5f,0xca,0x8f,0x6e,0x92,0x39,0x5b,0xea,0x4e,0xec,0x9b,0xcb,0x89,0xb3,0xc2,0x74, -0x29,0xf3,0x34,0x1a,0x10,0xe2,0x70,0x6c,0xd5,0xc8,0x35,0x6c,0x99,0x6,0x60,0x11, -0x2d,0xb6,0x3,0xe5,0xf1,0xbe,0xc2,0xc4,0x60,0x4a,0x6f,0x7c,0xcb,0x5e,0x22,0xf0, -0x89,0xf4,0xa5,0x1a,0x30,0xc5,0x15,0xb2,0xa0,0x2a,0xd7,0xa4,0x20,0xcd,0x3,0x70, -0x3,0x50,0x1e,0xef,0x2b,0x76,0x1e,0xde,0xb3,0xac,0xd3,0x13,0xcb,0x4a,0x28,0x7c, -0xcb,0x13,0x19,0x2d,0x34,0x20,0x4c,0x9b,0x49,0x5d,0x43,0x6b,0x39,0x4d,0x6c,0x0, -0x4e,0x44,0x8a,0xcc,0xed,0x22,0x7d,0xcb,0xb2,0x8e,0xc7,0x96,0x35,0xce,0x80,0x18, -0xf,0x75,0x20,0xf5,0xea,0x1b,0x5a,0x4b,0x59,0x5b,0x3,0x50,0x8a,0x0,0x6e,0x17, -0xe9,0xa9,0x65,0x1d,0x42,0x7e,0x7d,0x9c,0x1,0x31,0xc5,0xd0,0x81,0xa8,0x1b,0xdc, -0x5d,0x80,0xa9,0x94,0x39,0x7c,0x18,0xd2,0x91,0x13,0xdf,0x8f,0xdd,0xe8,0x30,0x7, -0x42,0x12,0x55,0x2,0x26,0xf5,0xd,0xad,0x21,0xeb,0x8,0x24,0x2,0xe8,0x26,0xf7, -0x63,0x2f,0xe6,0xc0,0xec,0x5b,0x4a,0x40,0xa,0x79,0x5a,0xd,0xd0,0x35,0x7,0x8e, -0x6c,0xe9,0xb8,0xf9,0x15,0x92,0xfb,0xb1,0x9f,0x34,0x2,0xad,0xd3,0xda,0x96,0x5d, -0x73,0x20,0xb1,0x73,0x2d,0x93,0x8e,0x7e,0x49,0xef,0xc7,0x1,0x69,0x4,0xbe,0x7e, -0x5c,0x3,0xe4,0x9b,0xde,0xcd,0x80,0x36,0x15,0xc0,0x4b,0xe,0x3c,0x1a,0xb7,0x2, -0x5d,0xea,0xe0,0x36,0xfa,0xe6,0x54,0xdf,0x0,0x38,0xe7,0xc0,0x13,0x23,0xa0,0x15, -0x54,0x80,0x49,0x67,0xe0,0x86,0x3,0x3,0x6a,0x2,0x7c,0x51,0x5,0x4e,0xd8,0xdd, -0x2,0xbb,0xcc,0x52,0x39,0x69,0xc8,0x6e,0xc0,0xa0,0xab,0x59,0x70,0xbb,0x48,0x47, -0x7e,0xbb,0x59,0x38,0x64,0xc7,0x2b,0x94,0x5,0x15,0x7e,0xae,0xaf,0xa9,0xe1,0xef, -0x32,0x86,0x79,0x5,0xc7,0x2f,0xb9,0xb6,0x10,0x23,0x5b,0xd5,0xb5,0x51,0x74,0x6d, -0x41,0x79,0x39,0xf,0x66,0x29,0x56,0xf4,0xed,0x24,0xd,0xc,0x9d,0xb7,0x28,0x6b, -0xab,0xce,0x3b,0xb4,0x44,0x97,0x41,0x9,0x88,0xad,0x29,0xa,0x50,0x2e,0xe7,0x61, -0xc6,0x77,0x6c,0x8d,0x21,0xb0,0x5,0x86,0xe1,0x89,0xc7,0x8b,0x74,0x8c,0x30,0x19, -0x9e,0xce,0x64,0x1f,0x45,0x9,0x88,0xad,0x29,0x2a,0x50,0x2e,0xe7,0xc5,0x3e,0xc5, -0xa5,0xbc,0x47,0xa4,0x15,0x98,0x9f,0xaf,0xf,0x76,0x1,0x77,0xc5,0x1a,0x9f,0x59, -0x16,0xa5,0x1c,0xee,0x30,0x19,0x80,0x43,0xfd,0x27,0xf4,0xb,0x20,0x97,0x6b,0x24, -0x4,0xb9,0x16,0x92,0x11,0x3d,0x1a,0x3f,0x4a,0xc2,0x36,0x60,0xfe,0x4,0x1,0xb4, -0xb,0xdf,0xb2,0x48,0x60,0xd9,0x3c,0xe2,0x9f,0xc2,0xe0,0x8a,0x14,0x43,0x3f,0x13, -0x1a,0x53,0x8c,0x40,0x93,0x6b,0x24,0x5c,0xe2,0x73,0x9b,0x79,0x55,0x3f,0x6e,0xd, -0xc0,0x49,0x56,0xd7,0x44,0xbb,0x98,0x4e,0xec,0x8d,0x3f,0x71,0x96,0x8,0x1c,0x41, -0x7a,0x28,0x92,0x28,0x1d,0x88,0x49,0x94,0xe,0x4c,0xc4,0x72,0xde,0x6,0xfe,0x5f, -0x32,0x6b,0x5,0x12,0x4b,0xb1,0xdd,0x45,0xe4,0xac,0x2e,0x23,0x77,0xce,0x3,0x70, -0x9e,0x26,0xea,0x40,0x4c,0x13,0x55,0x20,0x5c,0x9f,0x90,0x6b,0x9,0x2,0x2f,0x5a, -0x81,0xc5,0xcb,0xe7,0xe3,0xb8,0x58,0x62,0xca,0x7f,0x1b,0xa5,0x4f,0x8a,0x44,0xb8, -0xfc,0xdd,0x2a,0x10,0x34,0xfe,0x9c,0x17,0x5b,0x57,0x89,0x45,0xf0,0x88,0x16,0x73, -0xe0,0x94,0x7f,0x8a,0x48,0xf5,0x37,0x93,0x93,0x27,0x45,0xaa,0xdf,0x8,0x4,0xb1, -0xc6,0x63,0xdb,0x9a,0x22,0xd0,0x53,0x36,0x5a,0xb5,0xc9,0xb5,0x5,0xb7,0x6a,0x1f, -0xde,0x1,0x5d,0xf9,0x86,0x40,0x90,0x6b,0x10,0xbb,0xf9,0xf9,0xc3,0xa9,0x75,0xca, -0xaf,0xd0,0x58,0xae,0xdd,0x70,0xab,0x16,0x72,0x6d,0x1d,0xfc,0xce,0x8,0x88,0x72, -0xd,0xc4,0x1a,0xfe,0xbc,0xdf,0x31,0x7a,0x84,0x7,0xd1,0x98,0xdd,0xd2,0x85,0xbe, -0x92,0x60,0xe,0x4,0xb9,0x36,0xe,0x64,0x99,0x2e,0x5,0xe0,0x5f,0x1a,0x2,0x4b, -0xf,0xc,0xe9,0x2,0xa4,0xa7,0xa1,0xf8,0x4e,0x43,0x3b,0x2c,0xe4,0x9a,0x12,0xd3, -0xe8,0xfa,0xc5,0xef,0xcc,0x66,0x29,0xca,0x35,0x69,0x37,0x49,0xe1,0x69,0xd2,0x86, -0x65,0x12,0xe1,0x4b,0x6f,0xb,0x41,0xc3,0x81,0x9b,0xab,0x93,0x27,0x45,0xd9,0x24, -0xa4,0xca,0xf7,0x73,0x3b,0x8c,0x1c,0x45,0xae,0xc9,0x1a,0x56,0x52,0xf8,0xd2,0xb4, -0x61,0x99,0x44,0x0,0x69,0x96,0xb8,0x49,0x20,0xb1,0xce,0x32,0x4f,0x13,0x71,0x51, -0xe3,0xeb,0x9e,0x26,0xb2,0xb,0xb9,0x46,0xa4,0x9c,0xa5,0x4a,0xb4,0x68,0x5,0xf2, -0x7b,0x5e,0xd4,0x69,0x68,0x6a,0xe5,0xbe,0x14,0x97,0xd5,0x13,0xa5,0x46,0xcf,0x7d, -0x69,0x64,0x15,0x72,0x2d,0x3,0xa6,0x4a,0x3c,0x6c,0x58,0x97,0x91,0xc0,0x40,0xab, -0x7a,0xab,0xd1,0x2,0x57,0xb9,0x63,0x65,0x15,0x42,0x44,0xb,0x6c,0xf9,0x68,0x90, -0x6b,0x93,0x36,0x20,0x1f,0x3f,0xa2,0x1,0xb3,0x78,0x88,0xab,0xdc,0x91,0xb2,0xce, -0x22,0xe2,0x21,0x3e,0xee,0xab,0x9,0x68,0xb7,0x1,0xa7,0xda,0x34,0x55,0x23,0x3e, -0x56,0x13,0x27,0xc5,0x4a,0x92,0x8c,0xf8,0x69,0x33,0x30,0xba,0x73,0xa0,0x63,0xa4, -0x80,0x7d,0xd,0x28,0x93,0x28,0x4,0x2a,0x8b,0x73,0x32,0x89,0x6a,0xb9,0xa5,0x71, -0x2b,0x70,0x55,0x8,0xfd,0xc,0xa8,0x2c,0x23,0xa8,0x40,0x91,0x26,0x92,0xa3,0x66, -0xa0,0xdb,0x6,0xdc,0x68,0xab,0x41,0x15,0xe0,0x91,0x55,0x4a,0x84,0x93,0xd3,0xbe, -0xc0,0x2b,0x71,0x5d,0xb7,0x45,0x1,0xac,0xe,0x38,0xb6,0xf4,0x54,0x3f,0xb3,0xc3, -0x2d,0xc0,0xa6,0xf5,0x4a,0x9,0xa4,0xe2,0x32,0x65,0xf9,0xb2,0x2,0x64,0x1a,0x70, -0x92,0x7b,0x9a,0x7a,0x60,0xda,0xb4,0x22,0x2b,0x81,0xfc,0xf3,0x49,0x1e,0xf,0x9b, -0x81,0x56,0xee,0x4b,0xb7,0x0,0x43,0xe2,0xd1,0x36,0x20,0x9a,0x4,0x1d,0xe7,0xe5, -0xcb,0x46,0x60,0x8d,0xb6,0x28,0x3,0xfd,0x36,0xa0,0xd0,0xf8,0x47,0x79,0xf9,0xb2, -0x65,0xc,0xdb,0x80,0xb4,0x1d,0x78,0x29,0x8b,0x85,0xb2,0x7c,0xd9,0x36,0x4b,0x5b, -0x80,0x91,0xdb,0xa,0xe4,0xa1,0x62,0x9e,0x97,0x2f,0x5b,0xec,0x70,0x31,0x39,0x6d, -0x4,0x4e,0x9c,0x56,0x20,0x37,0xc4,0x79,0x56,0xbe,0x6c,0xf3,0x34,0xb,0xeb,0x54, -0xa6,0x18,0xd8,0xb6,0x18,0xaa,0xdd,0x31,0x1c,0x8,0xfa,0xa4,0x4d,0x3d,0xf1,0x50, -0x71,0x9e,0x95,0x2f,0xdb,0x7c,0xe9,0x4b,0xeb,0x48,0x66,0x6d,0x90,0x22,0xc6,0x15, -0x20,0x8,0xa2,0x71,0x1b,0x90,0xff,0x44,0x7,0x4a,0xf9,0xb2,0x8,0x4f,0x6b,0x56, -0x9,0x4f,0x5f,0x3e,0x3c,0x90,0xc0,0x33,0x87,0x4d,0x42,0x7a,0x2,0x60,0x7c,0xa2, -0x70,0xb0,0xe4,0x40,0x94,0x7d,0x6d,0x40,0x1c,0x33,0xd0,0x94,0xb2,0x7c,0x9,0xf7, -0xb0,0x8,0xc0,0x6b,0x56,0x9,0xc0,0x5f,0x6,0x7,0x32,0x11,0x1e,0xdb,0x30,0xd5, -0xc8,0x99,0x35,0xb6,0x1,0x48,0x21,0xe9,0xa,0xa5,0xb0,0x6d,0x15,0xa4,0x81,0xaa, -0x80,0x1,0x58,0xa4,0x18,0x6b,0x56,0x49,0x31,0xbe,0xc,0x25,0x90,0x9e,0xbe,0x5, -0x16,0x15,0xa7,0x30,0x8f,0x11,0xe8,0x3f,0xf,0x79,0x71,0xc2,0x8d,0xee,0xb7,0x2, -0x75,0x8d,0xff,0x2d,0xd6,0x29,0x79,0x12,0x85,0xc0,0x4a,0x12,0x55,0x0,0x47,0x23, -0x5c,0x5d,0x4b,0x4f,0x1e,0x11,0xf8,0x4,0xea,0xfb,0xfc,0xa,0x47,0x5e,0xdc,0xe, -0x9c,0x72,0x60,0x56,0xc5,0x28,0xaa,0xfa,0x8,0xac,0xa4,0x89,0xf9,0x2d,0xa5,0x23, -0xbe,0xba,0x96,0x9e,0x3c,0xa6,0xa1,0xcf,0xc8,0x95,0x2d,0x80,0x7e,0xd2,0xe,0x5c, -0xe0,0x17,0xda,0x59,0x9d,0xa6,0x58,0xb7,0xc8,0x17,0x2c,0xd5,0x44,0xf8,0x65,0x1, -0x14,0xab,0x6b,0x2,0x78,0x3b,0xb5,0x4,0x30,0x20,0xed,0xc0,0x15,0xaf,0x26,0x66, -0x95,0xa8,0x62,0x65,0xa6,0x16,0xb8,0x78,0xa8,0x1,0x2f,0x53,0xeb,0x1d,0x1,0x3c, -0x34,0x7,0x62,0x51,0x61,0x74,0x3c,0x36,0x3,0x46,0xf7,0x8f,0x72,0xb9,0x76,0x8a, -0xab,0x6b,0xd6,0x33,0x4,0x6e,0xae,0xf,0xc3,0x36,0xa0,0xda,0x1a,0xa1,0x94,0x2f, -0x5b,0x81,0xa7,0x99,0x5c,0xa3,0x7c,0x75,0xd,0x7e,0x7,0x60,0xe2,0x76,0x0,0x82, -0x4,0x52,0x8a,0x7b,0xa6,0x40,0xb1,0xd8,0x15,0xa4,0x1,0x7,0xc6,0x5d,0x80,0x69, -0x17,0x60,0x69,0x75,0xd,0x80,0x9,0x9a,0x45,0xec,0xdc,0x11,0x10,0x9c,0x29,0xb1, -0x0,0xb8,0x5a,0x7d,0xda,0x6a,0x16,0xc5,0x2b,0x50,0xcb,0x97,0x2d,0x66,0xa1,0xe8, -0x43,0xca,0x97,0xf3,0x2,0x6a,0x3,0x70,0xb1,0x9a,0xb4,0x1a,0xbe,0x1a,0xa8,0x94, -0xf2,0x65,0x8b,0xe1,0x6b,0x40,0x5c,0xce,0xb,0x20,0x6a,0x0,0x70,0x33,0x63,0x6d, -0xae,0x4d,0x2d,0x9b,0x98,0xbb,0x36,0x9e,0x89,0x48,0xe0,0xd8,0xda,0x94,0x3,0x70, -0x93,0xf3,0x56,0xb,0xb,0x4a,0xf9,0xf2,0x5b,0x46,0x9a,0x9c,0xb7,0xa,0x3c,0xb3, -0x2b,0xc0,0xa6,0xf0,0xa4,0x16,0x16,0x94,0xf2,0xa5,0xec,0x2f,0xdd,0x16,0x9e,0x32, -0x60,0xa9,0xd8,0x1b,0x18,0x4,0x60,0xb5,0xb0,0xa0,0x94,0x2f,0xbf,0xcd,0xcf,0xdd, -0xad,0xd,0xc0,0x2d,0xc0,0xa6,0x14,0x43,0x73,0x35,0x45,0xf9,0xf2,0x5b,0xf8,0xe4, -0x86,0x14,0x23,0xb1,0x7a,0x27,0x51,0x9a,0xab,0x29,0xca,0x97,0x0,0x6c,0x4a,0xa2, -0xda,0x80,0xd,0x69,0xa2,0x66,0xf9,0x45,0xf9,0x52,0xef,0xfa,0xaa,0xa4,0x89,0x6d, -0x40,0xc6,0xc,0x80,0x60,0xf9,0x79,0xf9,0xb2,0xc,0xac,0x24,0xc2,0x53,0x32,0x0, -0xf0,0x8a,0xa9,0x9d,0xa,0xac,0x31,0xd5,0x1f,0x4,0x78,0x59,0x94,0x2f,0xcb,0xc0, -0xb2,0x5c,0x1b,0x6,0x38,0x2f,0xca,0x97,0xcd,0x40,0x6b,0x20,0xa0,0x5a,0x18,0x6a, -0x4,0xe,0x75,0x4b,0xc9,0x76,0x60,0x57,0xb9,0x66,0x6,0x2c,0xa,0xa6,0xed,0xb3, -0xb4,0xbf,0x5c,0x53,0xd,0x31,0xd8,0xa,0xac,0x94,0x4d,0x5a,0x80,0x46,0x9e,0x86, -0x67,0xfb,0xed,0xc0,0xd2,0xea,0x1a,0x44,0x35,0x74,0xc2,0x36,0x81,0xe9,0x16,0x2c, -0xe0,0x7f,0x9b,0xfb,0xd2,0xe2,0x98,0xeb,0xa,0xb0,0x5a,0xfa,0xca,0x8b,0xec,0xc, -0x1f,0xbe,0xb,0x2a,0x88,0x3,0x2f,0x58,0xd2,0x21,0x5a,0x28,0xc7,0x45,0x94,0x81, -0xd5,0x68,0x91,0x3,0x41,0xae,0xcd,0x18,0x3d,0x82,0xec,0x34,0xa0,0x81,0xcd,0xe2, -0xe,0xf1,0x90,0xef,0x30,0xae,0x7,0x56,0xe3,0x61,0xbe,0x6e,0x21,0xe4,0x1a,0xa4, -0x35,0x34,0x48,0xce,0x2c,0x16,0x75,0x88,0xf8,0x5a,0x25,0x4a,0x7,0x56,0x23,0x7e, -0xbe,0x32,0x3,0x72,0xd,0xae,0x8b,0xd0,0x90,0x4,0x31,0x7d,0x23,0x9c,0x74,0xc8, -0x69,0x94,0xf6,0xf9,0x32,0xb0,0x9a,0xd3,0x7c,0x7f,0x40,0xd0,0x87,0x36,0x4c,0x1b, -0x1a,0x26,0xe1,0x92,0x1c,0x5,0x3f,0xeb,0x90,0x26,0x2a,0xae,0xa6,0xc,0xdc,0x9e, -0x26,0xa2,0x3e,0xfc,0x5,0x4c,0x1b,0x12,0xc6,0x6c,0x46,0xc6,0xc7,0x7,0x1d,0x12, -0x61,0xc5,0xd5,0x54,0x7a,0xf5,0x9b,0x96,0xf3,0x70,0x77,0x1e,0x4b,0xc2,0x19,0xbb, -0x20,0xd6,0x23,0x2b,0x30,0x4e,0xf5,0x55,0x57,0xd3,0x15,0x78,0x9,0xe6,0x70,0x1, -0xe,0xbd,0x2b,0x10,0x93,0x28,0x59,0xbe,0xd4,0xf6,0xae,0xb1,0xc6,0xe5,0x3c,0x0, -0xba,0x70,0x53,0x5d,0xe6,0x75,0x7,0xfe,0xae,0x36,0x1e,0xc6,0x8d,0xcb,0x79,0x34, -0xdc,0xa4,0x3e,0x88,0x6e,0x2f,0xf5,0x9,0x68,0x1a,0xd6,0x9,0xf8,0x95,0xd2,0x7d, -0x59,0x0,0x69,0xf3,0xea,0x5a,0xb8,0xc1,0x87,0x9a,0x51,0x9f,0x6,0xdd,0x81,0x71, -0x6d,0x4e,0xd3,0xe,0xc,0x53,0x8f,0x4,0x60,0x8a,0x39,0xb0,0x76,0x96,0xa6,0x9e, -0x13,0x27,0x67,0x9e,0x1b,0x27,0xa7,0x81,0x7b,0x91,0xc5,0xfc,0xbc,0xfb,0xd2,0x8, -0x88,0xda,0x22,0xc4,0x1d,0x81,0x3e,0xf6,0xf,0x14,0xc0,0x5a,0x3b,0xac,0x3,0x2a, -0xdd,0x97,0xc2,0x53,0xfb,0x1c,0xd8,0x28,0xd7,0xc2,0x4d,0x2,0x9e,0x1,0x17,0xf5, -0xa,0x60,0xad,0xa7,0xa9,0x1,0x46,0x79,0xf9,0x52,0xee,0x3f,0xe4,0xda,0x82,0x86, -0xdb,0x3d,0xd,0x7,0x6e,0x38,0x70,0x53,0x0,0xeb,0x9d,0x77,0xd,0xf0,0xd3,0xbc, -0x7c,0x29,0xf7,0x1f,0x72,0xf5,0x54,0xb3,0x9c,0xd7,0x2,0xac,0xf,0x4f,0x35,0xc0, -0x87,0x79,0xf9,0xf2,0x5b,0xb9,0xe8,0x29,0xd6,0xf,0xb7,0x86,0xa7,0x2d,0x29,0x46, -0x7d,0x0,0xae,0x2,0x8b,0xf2,0xa5,0x4,0xa,0x5,0x4c,0xc3,0xad,0x1,0x78,0x5b, -0x4e,0x53,0x9b,0x62,0xd4,0x0,0x55,0x5,0x2c,0x6e,0x9f,0xc5,0x81,0x5b,0x53,0x8c, -0x4e,0x49,0x54,0xd,0x50,0xd5,0xf8,0xe2,0xf6,0x59,0x21,0x2,0xb7,0x26,0x51,0x9d, -0xd2,0xc4,0x5a,0x60,0x51,0xc5,0xd8,0x6,0x34,0x4a,0x13,0x6b,0x13,0xe1,0x3a,0xa0, -0x52,0xbe,0xe4,0xc0,0x7,0x12,0xd8,0x35,0x11,0x36,0x6,0x2a,0xe5,0x4b,0xe,0xf4, -0x25,0x70,0x90,0x54,0xbf,0xe,0x58,0x94,0x2f,0x95,0xa3,0x46,0x92,0xb0,0x2a,0xd7, -0x86,0x2,0x9e,0xd4,0x1,0xe3,0xb0,0x2a,0xd7,0x86,0x2,0xe6,0xc5,0x3d,0x71,0x5c, -0xc,0x9e,0x61,0xc5,0x6a,0xe4,0x1a,0xdb,0x1b,0x10,0xc6,0x90,0xd5,0xc8,0x35,0x36, -0x8c,0x5c,0x53,0xab,0x89,0xfa,0x9,0x3c,0xe5,0x59,0xca,0x86,0x91,0x6b,0x5a,0x33, -0x64,0x6e,0x87,0xa8,0x0,0xca,0x76,0xf8,0xc3,0x3,0x1a,0xea,0x43,0xb5,0xfb,0x72, -0x2b,0x50,0x6b,0x2c,0x47,0x7d,0x48,0xac,0x10,0x77,0x71,0xa7,0xa8,0xf,0x13,0x91, -0xb5,0x99,0xea,0x43,0xb5,0xfb,0x32,0x77,0xde,0x8,0x2c,0x3b,0x6f,0xa6,0xea,0x43, -0x4,0x1e,0xc3,0x1f,0x51,0x1f,0x4a,0xa0,0xa9,0x3e,0x54,0xbb,0x2f,0xf3,0xf0,0x84, -0xc0,0x72,0x78,0x62,0xaa,0x3e,0x4,0x20,0xe8,0xc3,0x30,0x42,0x7d,0x28,0x81,0xa6, -0xfa,0x50,0xed,0xbe,0xcc,0x3,0x30,0x2,0xcb,0x1,0x98,0xa9,0xfa,0x10,0xfe,0x84, -0xfa,0x70,0xc2,0x40,0x1f,0x26,0xac,0x93,0x3e,0x54,0xbb,0x2f,0xf3,0x14,0x3,0x81, -0xe5,0x14,0x83,0xa9,0x72,0xd,0xfe,0x84,0x72,0xcd,0x65,0x20,0xd7,0x46,0xac,0x93, -0x5c,0x53,0xbb,0x2f,0xf3,0x24,0xa,0x81,0xe5,0x24,0x8a,0xa9,0x72,0xd,0xf,0x53, -0x61,0xf4,0xcc,0x63,0x20,0xd7,0x1e,0x45,0xdb,0xd2,0xc4,0xb4,0xdc,0x2c,0x91,0xe2, -0xdd,0x53,0xba,0x2f,0xf3,0x34,0x11,0x81,0xe5,0x34,0x51,0x5,0xf2,0xc3,0x54,0x18, -0x19,0xfb,0x28,0xd7,0x1e,0x59,0xe1,0x96,0x44,0xb8,0x1e,0x58,0x94,0x2f,0x6b,0xa5, -0x7f,0x9e,0x8,0xb3,0xaa,0x5c,0xc3,0x45,0xbd,0x26,0x31,0x53,0xf,0x2c,0xca,0x97, -0x5d,0x80,0x47,0x28,0xd7,0x88,0xc5,0xe5,0xda,0x61,0x37,0x60,0x5e,0xbe,0x2c,0x1f, -0x45,0xb9,0x15,0x88,0x72,0xd,0x27,0xcc,0xc,0x8c,0x3,0xe5,0x5a,0xda,0xd,0x98, -0x97,0x2f,0x9b,0x8e,0x3e,0x29,0x6d,0x96,0xa3,0x78,0xb6,0x9,0xdc,0x4e,0x72,0x82, -0x72,0x2d,0xed,0xa6,0xf,0xb7,0xad,0x69,0xda,0x5b,0x81,0xa8,0x9e,0xe8,0x18,0xe4, -0x1a,0xa1,0xc7,0xc1,0x40,0x40,0xea,0xe9,0x1b,0xab,0x6b,0x37,0xcb,0x79,0x24,0x3d, -0x6,0xf5,0x94,0xdd,0x52,0xc3,0xa2,0x42,0xfd,0x2b,0x9,0x21,0x56,0x6f,0x1b,0x43, -0xb9,0xba,0x6,0x72,0x6d,0x7c,0x84,0xc0,0x71,0xd0,0xa5,0x6c,0xb2,0xbd,0x50,0x7c, -0xd9,0x4,0xb4,0x46,0x28,0x66,0xac,0x47,0x20,0x66,0x32,0xb3,0xa8,0x7a,0x9a,0xfa, -0x49,0xb3,0xa5,0xf6,0x3e,0x61,0x71,0x3,0x10,0x57,0xd7,0x88,0xc5,0x7f,0x5,0x67, -0x1c,0x6e,0xf1,0xa5,0x1d,0x80,0x60,0x28,0x81,0xde,0xea,0xad,0x3,0x71,0x75,0x8d, -0x58,0xfc,0xd7,0x34,0xb0,0xb6,0xc9,0xb5,0x16,0x60,0xe4,0x2b,0xc5,0x1b,0xf0,0xa4, -0x34,0xa8,0x7,0x9a,0xcb,0xb5,0x66,0x60,0xaa,0x74,0x89,0x9,0x39,0x7a,0xd5,0x9, -0x58,0x13,0xf1,0x9b,0x81,0x89,0x5f,0x6c,0x9c,0xba,0xe5,0xd1,0xf0,0xba,0x1b,0xd0, -0x30,0xa7,0x29,0x4c,0x3d,0x3f,0x61,0x0,0x93,0xc,0x8c,0xf7,0xeb,0x6e,0x40,0xc3, -0xac,0x2d,0x7f,0x81,0xf7,0x9c,0x69,0xc0,0xeb,0x9b,0x6e,0x40,0xc3,0x44,0x58,0x2d, -0xf2,0x91,0x2,0x38,0x39,0xb4,0xaf,0x37,0x54,0x19,0x83,0x1f,0x3a,0xb0,0xfd,0x6c, -0x3a,0x2c,0x3d,0xc9,0xf2,0x13,0x7,0x9e,0xd8,0xce,0xed,0x5e,0x81,0x31,0x8b,0x7d, -0xb9,0xdd,0x8e,0x3,0x71,0x96,0xef,0x2,0xc,0x22,0xbf,0xd9,0x2c,0xe6,0xd4,0x8f, -0x65,0x7f,0x9d,0x0,0xda,0xd7,0xe0,0xc0,0x8a,0x9e,0xd1,0xc1,0x81,0x53,0x98,0x93, -0xc1,0x42,0x3,0xa2,0xb7,0xca,0xf,0xe,0x1a,0x1c,0xe8,0x83,0x3a,0xfc,0x66,0xa5, -0x8e,0xe1,0x35,0x24,0xf3,0x76,0xde,0xf3,0x3f,0x38,0x30,0xf8,0x86,0xb1,0xef,0x6e, -0x90,0xe6,0xc8,0x59,0xca,0xd8,0xb1,0xf8,0x6,0xbf,0x8b,0xe1,0x4f,0x3c,0x33,0x60, -0x1a,0xc2,0x75,0xdc,0xdc,0x72,0x20,0xdc,0x4b,0xa1,0x2c,0x24,0x70,0xda,0xc5,0xb5, -0xc9,0xf4,0x8b,0x3,0x1b,0xad,0xe2,0xc,0x7e,0xf9,0x33,0x11,0x40,0x42,0x5,0xf0, -0xb9,0x0,0x5e,0x37,0x1,0x23,0x7b,0xbe,0x51,0x9c,0x77,0x76,0xd,0xed,0xc0,0x3f, -0xe3,0x65,0xd2,0x1c,0xc8,0xa5,0x4c,0x27,0xa0,0x8,0x4f,0x54,0xc6,0x9c,0x56,0x20, -0x41,0x20,0x1b,0x87,0x19,0x90,0x4b,0x99,0x76,0x20,0xd,0x73,0xa0,0x8,0xc0,0x44, -0x4e,0xea,0x56,0xe0,0x2d,0xf7,0xd4,0x67,0x2,0xb8,0xa1,0x42,0xca,0x7c,0x65,0x0, -0x5c,0x30,0x9,0x14,0x29,0x46,0x22,0x27,0x75,0xeb,0xa4,0xb9,0xf9,0x4e,0x56,0xd2, -0x25,0x90,0x4b,0x99,0x4e,0x40,0x91,0x44,0xc5,0xd2,0xa5,0xb5,0x2,0x57,0x1c,0xf8, -0x4d,0xe,0xe4,0xfb,0x35,0x4d,0x80,0x2f,0xbd,0xc,0xc8,0xd3,0x44,0x63,0xe0,0xfa, -0x1b,0xfc,0xf5,0xbb,0xab,0x1c,0xc8,0xc,0x81,0x20,0xf4,0x36,0xca,0xba,0x45,0xec, -0x76,0x5,0x5e,0xb3,0x75,0x7,0x60,0x64,0xe7,0x93,0x46,0xa4,0xfa,0xb1,0x37,0xd9, -0x37,0x70,0xa9,0x3,0x7d,0x31,0x3b,0x5b,0xc3,0xd3,0xfa,0x45,0x4f,0xe0,0x62,0xd3, -0xf,0xb8,0x50,0x81,0xeb,0xe,0x63,0xc8,0xb6,0x0,0xdb,0xec,0xf0,0x9a,0x3,0xff, -0xd4,0xf5,0xa,0x11,0x38,0x5b,0xea,0x63,0xf8,0xd0,0xe8,0xd8,0xd4,0xde,0xc0,0xc5, -0x26,0x9a,0xe9,0xb3,0xd4,0x10,0x18,0xf6,0x4,0xce,0x97,0xb1,0xab,0xdb,0x61,0x1, -0x6c,0x9a,0xa5,0xbd,0x81,0x91,0x8d,0x5b,0x3a,0x55,0x4f,0x63,0x6,0x9c,0x66,0xc0, -0xcc,0xf0,0xd1,0x7,0x7f,0x25,0xfc,0xe2,0xf,0x9,0x8,0xde,0xda,0xa5,0xbe,0xee, -0xbc,0x4f,0x0,0x98,0x72,0xb3,0x68,0x2,0x5e,0x95,0x80,0xd2,0x79,0xe3,0xe1,0xb2, -0x7e,0x23,0x90,0x78,0x90,0x42,0x6b,0xe1,0xe9,0xac,0x17,0x50,0x86,0x27,0x3c,0x2, -0xd9,0xbd,0xee,0xa0,0xf,0x21,0x0,0x53,0xe,0xc,0xa3,0x56,0x20,0xfc,0x45,0x2, -0x8b,0x0,0x7c,0x8c,0x8b,0x18,0x66,0xc0,0x3c,0xc5,0x80,0x5f,0x6f,0x4,0xb0,0xe9, -0x75,0x85,0xf,0xda,0xc,0xa,0xa0,0x4c,0x31,0xf0,0x54,0x69,0xdb,0x10,0x98,0x25, -0x51,0xa6,0x40,0x18,0x6e,0xbf,0x0,0xca,0x24,0xea,0x91,0xe5,0x4f,0x2c,0x43,0x60, -0x96,0x26,0x9a,0x2,0x61,0x42,0x7b,0x12,0x8,0x69,0x22,0xaf,0x44,0x1d,0x63,0xa5, -0x30,0x32,0x5,0x66,0x89,0xb0,0x29,0x30,0x72,0x2d,0x57,0x0,0x95,0x44,0xf8,0x2d, -0x3c,0x73,0xe8,0x83,0xbe,0xc0,0xe6,0x49,0x13,0x79,0x13,0x15,0x88,0x8b,0x4,0x8, -0x84,0xe9,0xb3,0xf,0x20,0x8c,0x5f,0xe4,0x47,0x8,0x2c,0xc4,0xc,0x9a,0xd6,0x3e, -0x81,0x93,0xa,0x90,0x8e,0xef,0xf8,0xa,0x41,0x90,0xee,0x15,0x28,0xc6,0xb0,0x90, -0x6b,0xec,0x76,0x57,0x60,0xc3,0xb,0x81,0x62,0x96,0x16,0x45,0x5,0xb6,0xa1,0x9d, -0x66,0x69,0x56,0xa7,0x31,0x5,0x4a,0x3b,0xcc,0x80,0x70,0x37,0x56,0xb4,0x93,0x1d, -0x66,0x95,0x28,0x53,0xa0,0xf4,0x34,0x6a,0x25,0x8a,0x1a,0x78,0x9a,0x92,0x5c,0xeb, -0x0,0x94,0xbe,0x54,0xad,0xb5,0x51,0x3,0x5f,0x5a,0x92,0x6b,0x39,0xd0,0x7a,0xaf, -0x6d,0xd2,0xc8,0xf0,0x24,0xbf,0x7,0xa3,0x85,0x4f,0x5b,0xa3,0x45,0x45,0xae,0x15, -0xc0,0xe6,0x78,0x78,0x75,0x15,0xa8,0x40,0x59,0x2f,0xa5,0xad,0xf1,0xb0,0x22,0xd7, -0x4c,0xcd,0xa2,0x4,0x94,0x15,0x61,0xda,0x1a,0xf1,0x2b,0x72,0x4d,0x2,0x5b,0x73, -0x9a,0x32,0xf0,0x12,0x72,0x9a,0x38,0x5b,0xef,0xea,0x22,0xd7,0xfa,0x2,0x45,0x55, -0x9f,0x76,0x97,0x6b,0x1a,0xb0,0x29,0x3a,0x95,0x80,0x62,0xdd,0x82,0x76,0x97,0x6b, -0x7d,0x81,0x62,0x65,0xe6,0x87,0x9,0x5c,0xe,0x2,0x14,0x29,0x6,0xed,0xae,0xf, -0x7b,0x3,0x13,0xf1,0xe0,0xf1,0xce,0xfa,0xd0,0x14,0x58,0xf2,0x34,0x79,0x87,0x42, -0x67,0x7d,0x68,0x6a,0x16,0xfd,0x81,0x25,0x7d,0xb8,0x7f,0x60,0x49,0x1f,0xf6,0x1, -0x16,0xd5,0x0,0xda,0x5d,0x1f,0xf6,0x0,0xa6,0xc5,0xea,0x2f,0xed,0x2e,0xd7,0x7a, -0x0,0x49,0xb1,0xc2,0x4d,0xbb,0xcb,0x35,0x36,0xc1,0xe5,0x72,0xbb,0xcb,0x2c,0x4d, -0x8a,0xec,0x98,0x76,0x97,0x6b,0x8c,0xaf,0xd1,0x77,0x2,0xc6,0xc5,0x97,0xd3,0x3e, -0x72,0xcd,0x4b,0x3b,0x2,0x23,0xb5,0x53,0x48,0xa4,0x18,0x69,0xed,0xd9,0x97,0xb5, -0x49,0x14,0xb5,0x5c,0x23,0x60,0xa1,0x80,0x65,0x8b,0x92,0x4,0x8a,0x24,0xca,0xc, -0x88,0x69,0xe2,0x9f,0x88,0xe5,0xfc,0x3f,0xa3,0xa2,0xc2,0x56,0x20,0xa6,0x89,0x66, -0x40,0x9c,0x9f,0x2b,0xc8,0xfd,0x12,0x4,0x62,0xb3,0x85,0x29,0xf0,0x81,0x2,0x14, -0x89,0xb0,0x39,0x70,0x1e,0xfb,0x78,0xcc,0x6b,0x37,0xa0,0xaf,0x1,0x31,0xd5,0x37, -0x7,0x5e,0xc4,0xc1,0x64,0x14,0xf2,0x6f,0x35,0x7,0x62,0x6f,0x62,0x5f,0xa0,0x1b, -0x87,0xd1,0x69,0x70,0x97,0xc0,0x28,0x8c,0x8e,0xfd,0xc,0x68,0x38,0x4b,0x2b,0xc0, -0xd2,0x13,0xad,0x1a,0x80,0xa9,0x37,0x9,0xa3,0x87,0x5e,0x47,0x60,0x65,0xc,0xcd, -0x81,0x14,0xbe,0x37,0xf2,0xdc,0x8e,0xc0,0xca,0x2c,0x45,0x3b,0x59,0x1b,0xd9,0x21, -0x3d,0x7e,0x2b,0x8c,0x3e,0xb8,0xec,0x8,0xac,0xd8,0xa1,0x21,0x10,0x3c,0xd,0x39, -0x7a,0x12,0x4c,0xde,0xbf,0xd8,0x9,0xe8,0x4f,0x9a,0x80,0x89,0x7,0x11,0xdf,0xcd, -0x7d,0x29,0x19,0x81,0x1d,0x7e,0x38,0xe7,0x81,0x12,0xb7,0xde,0x1b,0xcd,0xd2,0x8a, -0x2f,0xfd,0x41,0x1,0x63,0x7,0x80,0x4e,0x1e,0x9e,0xc8,0x33,0x98,0x62,0x37,0x1d, -0x81,0x95,0xf0,0xd4,0x4,0xc4,0xbc,0x3b,0xb2,0xf3,0x0,0x9c,0x7c,0x4,0xce,0xfb, -0x76,0x66,0xe,0x8c,0xe5,0xf6,0x78,0x2d,0x0,0x37,0x1,0xe7,0xb3,0xd9,0x66,0xbe, -0xcc,0x53,0x8c,0x4,0x54,0xba,0x7b,0xbb,0xec,0x6,0xac,0xa4,0x18,0x6f,0x34,0x0, -0x17,0xcb,0xd9,0x46,0xd1,0x87,0x31,0x4,0x16,0x8f,0xc6,0xdd,0x80,0x95,0x24,0xea, -0xe6,0x9a,0x6c,0x7,0xb2,0x68,0xa3,0xe8,0xc3,0xe5,0x14,0x53,0x8c,0x51,0x6,0x6c, -0x37,0xb,0x3e,0x7e,0xe5,0x34,0xb1,0x5,0xf8,0x54,0xd1,0x87,0xcb,0x2b,0xf0,0x8c, -0x69,0x57,0x60,0x39,0x11,0x6e,0x2,0x7e,0x69,0x7f,0xf9,0x58,0xd1,0x16,0x4b,0xcc, -0x6b,0xf7,0xc,0x7c,0xb9,0x5,0x68,0xe6,0x69,0xfa,0x0,0x7f,0xb1,0x1d,0x68,0x36, -0x69,0x3a,0x1,0x17,0xcb,0x85,0x7d,0xd7,0xc0,0x73,0x5,0x38,0xeb,0xa,0x5c,0x5f, -0xdd,0x74,0x6,0xce,0xf4,0x59,0x3a,0x0,0x30,0x69,0xf4,0x34,0x0,0x5c,0x16,0x76, -0xb8,0x77,0x20,0x68,0xfc,0xa5,0xf4,0xa5,0xe8,0x69,0x3a,0xcf,0xd2,0xa,0x30,0x68, -0x1,0x2a,0xd1,0x2,0x7d,0xa9,0x0,0x3e,0xd9,0x5,0xd8,0xe2,0x4b,0x95,0x78,0x88, -0xd1,0x2,0x5c,0x1b,0xc8,0xb5,0xdf,0xec,0x0,0x6c,0x8b,0x16,0x25,0xb9,0xb6,0xbc, -0x46,0x5f,0xba,0x64,0x6,0x2f,0xb1,0xba,0x56,0x1,0x1e,0x9b,0x3,0x31,0xe2,0x2f, -0xd7,0xe0,0xfa,0x6f,0xd,0x81,0x58,0x11,0xae,0x0,0x8f,0x3a,0x0,0x21,0x89,0x8a, -0x79,0x3c,0x9c,0x99,0x1,0x13,0x5e,0x68,0x2f,0x19,0xbe,0x4c,0xa2,0x4c,0xe5,0x5a, -0xf2,0xc,0x22,0xfe,0xcd,0xdc,0xc,0x88,0x55,0xfd,0x1a,0xa0,0x7c,0xa6,0xa9,0x59, -0x22,0x9c,0x8c,0xe0,0xc7,0x5e,0x5d,0x98,0x1,0x71,0xdd,0xa2,0x2,0xec,0x28,0xd7, -0x20,0x2f,0xf5,0xad,0xf7,0xd5,0xb6,0xfb,0x9a,0x2d,0x9d,0xea,0xea,0x5a,0xd,0xb0, -0x93,0x98,0xa1,0x87,0x6f,0x5,0x93,0xf,0x4c,0x81,0x7e,0xb4,0x33,0x30,0xf5,0x2c, -0x29,0x66,0xc,0x80,0x93,0x1f,0x27,0x10,0xe4,0xda,0xa1,0x7f,0x77,0xb7,0x54,0x28, -0x60,0xff,0xee,0x26,0xd,0x68,0xfc,0x30,0x1a,0x5,0x86,0xc0,0x5d,0xcd,0x2,0xeb, -0x34,0x11,0x0,0xdf,0xb,0xcd,0x80,0xc5,0x72,0x5e,0xd9,0xf0,0x3b,0x2c,0xe7,0xc5, -0xa0,0xf,0xb5,0xaf,0x68,0x0,0x16,0xcb,0x79,0x65,0xd7,0xd6,0x0,0x2c,0xc9,0x35, -0x96,0xbc,0xe5,0xeb,0x1b,0xe,0x1a,0x80,0xea,0x72,0x5e,0xa9,0xd6,0xb6,0x1d,0x58, -0x92,0x6b,0x8c,0xbc,0x51,0xda,0xdf,0xd3,0x0,0xac,0x2d,0x41,0xb7,0x55,0x13,0x4b, -0x72,0x8d,0xd1,0x3,0xcb,0xf1,0x76,0x1,0xb6,0xd5,0x4b,0x4b,0x72,0x8d,0xb1,0xc3, -0xd2,0x6,0xa6,0xae,0xc0,0xb6,0x8a,0x70,0x49,0xae,0x69,0x5,0xec,0x7e,0xc0,0x96, -0x9a,0x77,0x49,0xae,0x69,0x25,0xfa,0x66,0xe0,0x34,0xec,0xb5,0x8c,0x50,0x92,0x6b, -0xbc,0xe6,0x6d,0x6,0xbc,0xee,0x7,0x2c,0xc9,0x35,0x66,0x1f,0xb8,0x77,0x17,0x0, -0x0,0x15,0x2f,0x49,0x44,0x41,0x54,0xfe,0x52,0x80,0xc5,0x73,0x1d,0x4d,0x80,0x2f, -0xfb,0x2,0x5f,0xf4,0x5a,0x28,0x29,0xc9,0xb5,0x5e,0x40,0x4d,0xe3,0xb7,0x8e,0xa1, -0x2e,0xd7,0x3a,0x0,0xf3,0xfe,0x52,0xbd,0x8a,0xa1,0x3,0x37,0x6d,0x72,0xad,0x17, -0x30,0xf1,0x9d,0x6d,0xc0,0x55,0x9b,0x5c,0xeb,0x2,0xfc,0x26,0x3,0xc6,0xe1,0x6c, -0x1b,0x70,0xd1,0x26,0xd7,0xfa,0x1,0x8b,0x23,0xd5,0x4,0x70,0x95,0x3,0xaf,0xdb, -0xe4,0x5a,0x7,0x60,0xde,0xe7,0xcd,0xa2,0x62,0x97,0x9c,0x0,0x4e,0x72,0xe0,0x55, -0x9b,0x5c,0xeb,0x0,0xcc,0x3b,0xd9,0xd9,0xac,0x78,0x56,0x68,0x19,0x18,0xb4,0xc9, -0xb5,0xe,0x40,0xd1,0xab,0xff,0xb7,0x61,0xd,0xf0,0x7e,0xd6,0x31,0xc4,0xf,0x56, -0xee,0x78,0xb6,0xc9,0xd6,0x57,0xbe,0x1b,0x41,0x2,0xff,0xae,0x0,0x1e,0x66,0x40, -0x7a,0xd7,0x40,0xfe,0x3c,0xaa,0x8e,0x87,0xa9,0x6c,0x7d,0xe5,0x1b,0x3c,0x10,0xb8, -0xe6,0xcd,0x18,0x15,0xe0,0x2d,0x6b,0x5f,0xce,0x4b,0xda,0xa4,0x76,0xe,0xcc,0xb6, -0xb0,0x20,0x30,0x96,0x4f,0x1c,0x2b,0x4d,0x9a,0x1b,0xd6,0xde,0xf5,0x65,0xc,0xcc, -0x37,0xe9,0xa0,0x59,0x44,0x1,0x5b,0xb9,0x55,0xe0,0x9a,0xb5,0xf7,0xb5,0x19,0x3, -0xf3,0x6d,0x48,0x68,0xf8,0x91,0xc7,0xd6,0xb3,0xc2,0xf0,0xb3,0x5d,0x41,0xd7,0x83, -0x2,0xf3,0x8d,0x56,0xe0,0xda,0x26,0xe,0x5b,0xe0,0x2,0x14,0xd5,0xf7,0x3d,0x4d, -0x7,0x5,0xe6,0x5b,0xc9,0xc0,0x79,0x43,0xf2,0x7c,0x8d,0xdb,0x26,0xa8,0xf2,0xd0, -0xfb,0x17,0x2,0x3c,0x1c,0x70,0x4e,0x43,0xca,0xaf,0x1,0xc2,0x13,0x7c,0xd3,0xd4, -0xba,0xcc,0x81,0x4c,0x2,0x83,0x41,0x81,0x31,0xbb,0xbc,0x48,0xc5,0x35,0xe0,0x13, -0x24,0xaf,0xec,0x65,0x7e,0x4b,0x25,0x90,0xd7,0x94,0x87,0x3,0xe2,0x53,0xb1,0xc4, -0x86,0x47,0xec,0x7d,0x77,0x9e,0xdb,0x24,0x2c,0x1,0x29,0x1b,0x14,0x58,0x6c,0xe9, -0xc4,0x87,0x72,0x5a,0xc7,0xe,0x3e,0x23,0x5a,0x3,0xde,0x32,0x3,0x3b,0x5c,0x2b, -0x67,0x4d,0xb6,0xbc,0x8a,0x5d,0xb2,0xd8,0xe1,0x7f,0xe4,0x54,0x36,0x8f,0x6f,0x98, -0x81,0xa7,0xe9,0x0,0xcc,0xf7,0x1,0x47,0x28,0xa4,0x4e,0xdd,0xca,0xe6,0xf1,0x95, -0x2,0x8c,0x1d,0xea,0x24,0x16,0xa3,0x63,0x9b,0x4f,0xb4,0xc2,0x97,0x76,0x0,0x26, -0xd9,0xb6,0x1a,0xf8,0xcd,0xb2,0x46,0x2e,0x23,0x81,0xe,0x5c,0xab,0x40,0x9b,0xd8, -0x8,0x3c,0xb5,0xf8,0x33,0x2b,0x8a,0x68,0xd1,0x1,0x98,0xed,0xe5,0xc6,0x34,0x31, -0xb2,0x12,0x4f,0x3c,0xfe,0x42,0x1,0x5e,0xab,0x40,0x2b,0xb6,0x46,0x16,0x23,0x23, -0xeb,0x2c,0x3,0x8a,0x0,0xdc,0x1,0x98,0x7,0x2a,0x48,0x13,0x13,0x2b,0xf6,0xb4, -0xc7,0x92,0x23,0xf0,0x4a,0x1,0x2e,0x93,0x25,0x79,0xa,0x77,0x25,0x49,0xc6,0x19, -0x50,0xa4,0x18,0x3d,0x80,0x98,0x26,0x52,0x1b,0x81,0x49,0xa8,0x1,0x7d,0x15,0x48, -0x56,0xf4,0x29,0x3e,0x26,0x9b,0x9e,0x66,0x40,0x91,0x44,0xf5,0x0,0xf2,0x34,0xd1, -0xc6,0x86,0x5b,0xaa,0x2a,0xaf,0x17,0xf2,0x69,0xbe,0x39,0x90,0x6d,0x1c,0x98,0x47, -0x74,0x94,0x3,0x79,0x9a,0xd8,0x7,0x88,0x69,0xe2,0x3c,0xf2,0x53,0x8f,0xb9,0x1a, -0x30,0x2c,0x1,0x13,0x1b,0x6e,0x7a,0x32,0xca,0x66,0xa9,0x48,0x84,0x7b,0x0,0x79, -0x9a,0x78,0x33,0x9,0x0,0xa8,0x96,0x76,0x5f,0x50,0x56,0x6,0x5a,0x60,0xaa,0xf1, -0xd3,0x1c,0xc8,0x53,0xfd,0x1e,0x40,0x9e,0xd3,0xac,0x1,0x18,0x6a,0x83,0xf8,0xe2, -0xb6,0x2,0x1c,0x81,0xd,0x46,0x6c,0x20,0x20,0x7f,0xd0,0x8d,0x3a,0x88,0x2f,0x6e, -0x34,0x60,0x2,0x63,0x48,0xc0,0x70,0xce,0xb,0xe0,0x3f,0xdd,0x5,0x78,0x6d,0x8d, -0xc7,0xec,0x4f,0x4c,0x5,0xae,0x98,0x66,0xf8,0x2b,0x7c,0x8,0x8f,0xcf,0x9c,0x2, -0xe8,0xee,0x2,0xfc,0xda,0xa2,0x6f,0x26,0xae,0x7a,0x8c,0xc3,0x8b,0x45,0x1b,0xd0, -0x1b,0x18,0x78,0xad,0x1,0x1d,0x4,0x52,0x9c,0x59,0xc3,0x8c,0xe1,0x67,0x16,0x7f, -0x26,0x85,0xa,0xbc,0x2a,0x1,0xe9,0x53,0x2,0x49,0x82,0xcf,0xda,0xcd,0x22,0x6d, -0xde,0xfc,0xc8,0xcd,0xe2,0xb9,0xc5,0x62,0x77,0xad,0x7e,0xef,0x8b,0x40,0x9b,0x34, -0x30,0x4f,0x47,0x9,0x9,0xc1,0xc1,0x4f,0x5b,0xd,0xbf,0x5,0xc8,0xd,0xff,0xd0, -0x61,0x49,0x70,0xad,0x7e,0xef,0xdf,0x86,0x3a,0x10,0x9d,0x77,0xcc,0x1f,0x11,0x1a, -0xa,0xe0,0x93,0xad,0xae,0xad,0xd,0x88,0xae,0xd,0xe2,0x6f,0xe2,0x5d,0xab,0x2b, -0xe3,0xff,0xbd,0x4,0x24,0x10,0xa0,0x96,0x2a,0xf0,0x67,0x5b,0x9d,0x77,0xb,0x90, -0x6b,0xfc,0x3,0x97,0xfd,0xe1,0xd7,0x57,0x2a,0xf0,0x6f,0x98,0xe,0xa4,0x10,0x82, -0x35,0xe0,0xe1,0xd6,0xf0,0xd4,0x2,0xe4,0x55,0xc,0x78,0xff,0x71,0xa4,0x1d,0xac, -0xf4,0xdf,0x34,0x60,0x35,0xc5,0xa0,0xdb,0x3,0x70,0xb,0x90,0xd7,0x69,0x20,0xd9, -0xbf,0x3e,0xd6,0x80,0xff,0xb5,0x5,0x98,0x6c,0x4f,0x31,0x5a,0x80,0xbc,0x12,0x5, -0x1,0xff,0xda,0x77,0x94,0x7,0x4e,0xb2,0xff,0xdc,0x2,0xfc,0xfd,0xf6,0x24,0xaa, -0xd,0x88,0xb5,0x36,0xf0,0x21,0xd7,0x57,0x6f,0xa9,0x59,0xcd,0xb4,0x5,0xf8,0xc9, -0xf6,0x34,0x31,0x6d,0x3d,0x94,0x83,0xf1,0x3,0x86,0xbe,0x3a,0x25,0x9e,0x39,0xf0, -0xe1,0xf6,0x44,0x18,0xe6,0x5e,0xbb,0xf7,0x1,0xe3,0xff,0x32,0x4c,0x94,0x2,0xbd, -0xdf,0xc,0xa4,0x27,0x3b,0x2,0xe1,0x6e,0xc6,0xc5,0x43,0x6e,0x59,0x7e,0xa3,0xb6, -0x1,0x49,0xda,0x1f,0x28,0x6e,0x38,0xa4,0x6e,0xc5,0x63,0x7c,0x8b,0x23,0xa3,0xb7, -0x1,0x97,0x3b,0x3,0x67,0x1c,0x58,0x14,0x16,0x5f,0x34,0x3,0x17,0x3b,0x3,0x31, -0xbd,0x88,0xa,0x31,0x73,0xdb,0x2,0xf4,0x77,0x6,0x62,0x7a,0xa1,0x3c,0xff,0x74, -0xd3,0xc,0x4c,0x83,0x9d,0x81,0x98,0x23,0xe2,0xa2,0x85,0x3c,0x5a,0x69,0xd5,0xc, -0x24,0x4d,0x65,0x13,0x43,0xe0,0xc,0xa3,0xa2,0xe5,0x4d,0x70,0x18,0x13,0x7b,0xdd, -0xc,0xdc,0x34,0x15,0x86,0x4c,0x5c,0x1b,0x1a,0x46,0xc8,0xae,0x0,0xc8,0x17,0xcb, -0x62,0xeb,0x5a,0x7,0xa2,0x5c,0xc3,0xbc,0x7b,0x6c,0x53,0xfc,0xf7,0x70,0xd1,0x54, -0xfa,0x32,0x4,0x82,0x77,0xb,0x22,0x90,0xdf,0x38,0x6f,0x22,0x71,0x50,0xa3,0x2e, -0xd7,0x20,0xef,0x6,0xb9,0xc6,0x9f,0xb,0x1f,0x4e,0x9b,0x8a,0x7b,0x86,0x40,0xf0, -0x6e,0x41,0x62,0x1d,0x7a,0x11,0xcb,0x4f,0x86,0xd4,0xe5,0x5a,0x78,0x81,0x72,0x8d, -0xc7,0xc3,0xb3,0xa0,0xa9,0x5e,0x6a,0xa,0x8c,0xd3,0x90,0x5a,0x7,0x1,0xda,0x87, -0x3c,0xfb,0x52,0x97,0x6b,0xa1,0x83,0x72,0x6d,0x84,0x87,0x9e,0x9d,0x86,0x4d,0x15, -0x61,0x53,0x20,0x1,0x7f,0x3c,0x39,0xc2,0x7,0xff,0x66,0x6b,0xc0,0x5b,0x81,0x4f, -0xd9,0xde,0x81,0xa0,0xf,0xcf,0x1c,0xd4,0x87,0x4f,0xf1,0xe,0xfc,0xba,0xb1,0xc8, -0x6e,0xa,0x64,0xaf,0xc3,0x6d,0x7d,0x84,0x99,0x60,0x76,0x60,0xaa,0x2e,0x66,0xc4, -0x3c,0x7d,0x8a,0xe7,0xd3,0x7b,0x8d,0xcb,0x8,0xc6,0x40,0x98,0x2e,0x64,0xc4,0x68, -0x90,0x1f,0x9,0xab,0x3,0xc9,0xdb,0xa8,0xf,0x9f,0x42,0xbc,0xc6,0xa,0x56,0xc3, -0x42,0x89,0x31,0x30,0xe1,0x2d,0x63,0x8,0x74,0xe2,0x1a,0xa0,0xd4,0x87,0x93,0x50, -0x14,0xc3,0x47,0xef,0x92,0x5d,0x81,0x2,0x8a,0x40,0xf7,0xf,0xf5,0x40,0xd0,0x87, -0x9b,0xd7,0x85,0x8e,0xe4,0x87,0x58,0xb3,0x5e,0xaf,0x3a,0x20,0x75,0x26,0x61,0x59, -0x1f,0x26,0x58,0xa3,0x39,0x4f,0xee,0x87,0x6c,0x55,0xc8,0xb5,0xe1,0x80,0x56,0x50, -0x91,0x6b,0x2b,0x94,0x6b,0xc9,0x61,0xc8,0xd7,0x73,0x77,0x38,0x8a,0x52,0x7,0xf2, -0x59,0x2a,0x8f,0xd7,0x2e,0xc9,0xb5,0x15,0xca,0xb5,0xe4,0x18,0x82,0x21,0x5f,0xd0, -0x18,0x6,0x88,0xf,0x7,0xa8,0x7,0xd2,0x70,0x85,0x72,0x2d,0x19,0x87,0x14,0xf, -0x6a,0x24,0x56,0xef,0xb3,0x2f,0x75,0x20,0xba,0xb6,0xec,0xc4,0x72,0x5d,0xae,0x85, -0x2b,0x94,0x6b,0xa8,0xd9,0x30,0x4d,0x8c,0xfa,0x9f,0x7d,0xa9,0x1,0x29,0x3a,0xef, -0xec,0x4c,0x76,0x5d,0xae,0x85,0x2b,0x29,0xd7,0x56,0x98,0x26,0xde,0xeb,0xb8,0x9c, -0xa7,0x68,0x19,0xed,0xac,0xd4,0x54,0x6c,0xed,0xb4,0x2a,0x40,0x8,0x4b,0x2b,0x54, -0x4f,0xa7,0x36,0x5b,0x0,0x30,0x3e,0xe9,0xb8,0x9c,0xa7,0x56,0x31,0xb5,0x76,0xa, -0x79,0x88,0xab,0x5b,0x6,0xa2,0x63,0x43,0xe0,0xd8,0x61,0xb8,0x3b,0xcf,0xe9,0xba, -0x9c,0x97,0xbf,0xb0,0x1c,0xa3,0x9e,0xd0,0xc8,0x53,0xc,0xf9,0xe4,0x80,0xfa,0x14, -0x3,0xec,0x26,0x24,0x7e,0xd7,0xd5,0xb5,0xad,0x40,0x9e,0x44,0xc9,0x67,0x23,0xd4, -0x3,0x41,0x63,0x85,0x93,0xce,0xab,0x6b,0x5b,0x81,0xc2,0x8d,0x8b,0xa7,0x3f,0xd4, -0x3,0x97,0x8c,0x8d,0xdd,0x1e,0x67,0x5f,0x2a,0xc0,0xb8,0x74,0xe0,0x6e,0xf6,0x7c, -0x8b,0x7a,0xe0,0x82,0xb1,0x27,0x61,0x8f,0xb3,0x2f,0x95,0x49,0x53,0x7e,0x5,0xf2, -0x9,0x1e,0xf5,0x40,0x8f,0x57,0xe7,0x1b,0x8e,0xa2,0x24,0x56,0xd8,0x2,0xb4,0xab, -0x4b,0x1a,0xdb,0x81,0xf0,0xaf,0xb8,0xd8,0xd8,0x0,0x4c,0x1a,0xd7,0x4e,0x3a,0x3, -0xc1,0xf5,0x9d,0x87,0x8d,0xcf,0xe5,0x8e,0x9b,0xab,0x26,0x5d,0x81,0x33,0xf0,0x46, -0xcd,0xc0,0xa8,0x7c,0xea,0xf2,0x4e,0xc0,0xd8,0x61,0x51,0x18,0x36,0x2f,0xc1,0x58, -0xee,0x70,0xc0,0xd8,0xa,0x52,0x87,0x35,0x3,0x2d,0xcb,0x19,0xc,0x88,0xc3,0x93, -0x4,0xcd,0xc0,0x96,0x4d,0xac,0x37,0x4c,0x7d,0xa0,0x5e,0xb,0x90,0x4f,0x7,0x9b, -0xdd,0x19,0x90,0xf3,0xb0,0xb6,0x32,0x38,0xb0,0xde,0xf0,0x13,0x3e,0xdd,0x23,0xd6, -0xa,0x3c,0xed,0xc,0xac,0x75,0x6d,0x82,0x97,0xba,0xed,0x40,0xda,0x19,0x58,0xe7, -0xbc,0xe5,0xb9,0xfb,0x71,0xd0,0xa,0xb4,0xd3,0xce,0xc0,0x9a,0xf0,0xf4,0xbf,0xa4, -0x35,0xdb,0x6c,0x67,0xe0,0x4d,0x15,0x58,0x13,0x80,0xe5,0xc1,0xa8,0xc4,0xdf,0x7, -0xf0,0xa4,0x92,0x62,0xe4,0xc5,0xbe,0x9,0x63,0x3b,0x8f,0x61,0x15,0x78,0x5c,0x49, -0xa2,0x32,0x20,0x75,0x4d,0x80,0xa7,0x9d,0x81,0x95,0x34,0x31,0x3,0xca,0x87,0x97, -0xed,0x66,0x87,0x35,0xc0,0x4a,0x22,0x2c,0x81,0x7f,0x76,0xd8,0x7e,0x80,0x95,0x54, -0x5f,0x2,0x89,0x6f,0x0,0x6c,0x71,0xde,0x37,0xc4,0x72,0xeb,0x80,0x93,0x5a,0x60, -0x51,0x11,0x8e,0x6b,0x9e,0x36,0x60,0x14,0x9e,0x6e,0x12,0xcb,0xa9,0x3,0x5a,0x2d, -0xc0,0xa8,0xf6,0x89,0xa,0x6,0x1,0xf8,0x86,0x6d,0x3a,0xdc,0xd2,0x2,0xc8,0xb7, -0xd6,0x38,0x3d,0x52,0x8c,0x1b,0xb5,0x39,0xb1,0x3,0x90,0xa7,0x77,0x76,0x8f,0x24, -0xa,0x80,0xa1,0xf1,0x2c,0x2d,0x80,0xa9,0xd2,0xeb,0xd3,0x2d,0x4d,0xbc,0x61,0xff, -0x23,0xac,0xb7,0x43,0x5e,0x72,0xdf,0x6,0xa4,0xca,0xc1,0xd8,0x5d,0x33,0xef,0x8b, -0xa0,0xde,0xd3,0xc4,0x78,0x67,0xb6,0x1,0x89,0xd2,0x3e,0xd5,0x15,0xf8,0x9f,0xfc, -0x7a,0x5f,0x1a,0xe1,0xd8,0x6f,0x3,0xca,0x84,0xdd,0xef,0x3,0xfc,0x8b,0xab,0xfa, -0x68,0x31,0x4f,0x1b,0x80,0x71,0xed,0x63,0x3f,0xcc,0x80,0xef,0x5c,0xc7,0x38,0x18, -0xa9,0x9c,0x76,0xb8,0x2d,0x82,0xc7,0xc3,0x5,0x6b,0x0,0x46,0x5b,0x1e,0x6d,0x62, -0x0,0x4c,0x9f,0x2d,0x62,0x64,0x88,0x8d,0x79,0x20,0xef,0x2d,0x4b,0x44,0xfc,0x46, -0xe0,0x44,0x3e,0xec,0xab,0x7,0x90,0x3c,0x5b,0xf3,0xe,0x33,0x2f,0xb7,0x21,0x99, -0xd3,0x34,0x2,0x73,0x65,0xd7,0x3,0xc8,0x5d,0x5b,0xd6,0xed,0x8d,0x5e,0x42,0x66, -0x6d,0x3f,0x28,0x60,0x9a,0x3f,0xec,0xab,0x3b,0x50,0x38,0xef,0xec,0x18,0x0,0x74, -0xbc,0x32,0x11,0x6e,0x2,0xe6,0xf,0xa9,0xe9,0x6e,0x88,0x37,0xb7,0x3c,0x1e,0x66, -0x3b,0xa0,0x30,0xb4,0x48,0x60,0x93,0x1d,0x92,0xc,0xe8,0xf7,0x30,0x8b,0x3e,0xc0, -0x64,0xcb,0xf3,0x77,0xcc,0x81,0xd9,0xd9,0x11,0x38,0xd3,0xd,0x80,0xf1,0xd6,0x67, -0xc,0xed,0x0,0xd4,0xa2,0xc5,0x37,0x53,0x21,0xed,0xc4,0x43,0x67,0xc3,0x28,0x7f, -0xea,0xde,0xbe,0x80,0x53,0x57,0x94,0x57,0x82,0x88,0x3,0x27,0x19,0xd0,0xde,0x17, -0xf0,0x33,0x57,0x5e,0x21,0xf7,0xbb,0xa1,0x52,0xd3,0xe9,0x53,0x18,0x5a,0xf2,0x8c, -0x41,0xa6,0x78,0x4e,0x66,0x87,0xda,0x18,0x7e,0xf6,0xc,0x7e,0xb9,0x25,0x94,0x9d, -0xe3,0xdf,0xce,0x94,0xa7,0xee,0xd,0x2,0xe4,0xae,0x4d,0x7,0xfe,0x5b,0xcc,0xbb, -0xc9,0x6d,0xfa,0x17,0xf8,0xb7,0x53,0xa5,0x88,0x34,0x8,0x90,0x3b,0x6f,0x1d,0xf8, -0x2b,0x4,0x9e,0x6e,0x8,0x6e,0x4d,0x67,0xa3,0x2,0xe8,0xf,0x2,0x14,0x72,0x2d, -0x9,0x4b,0x93,0x26,0x3d,0xbd,0xd9,0xf0,0x49,0xf3,0x64,0xeb,0x83,0xb0,0xcc,0x6a, -0x6d,0x76,0x19,0x28,0xe4,0x5a,0xac,0xce,0x52,0xfe,0xeb,0xd1,0x5a,0x64,0x78,0xef, -0x35,0x3c,0xec,0xcb,0x14,0xe8,0x4b,0x20,0x71,0x72,0xb9,0x76,0x51,0x1,0x1e,0xac, -0xc5,0xa4,0x51,0xa,0x81,0x3d,0x22,0xa2,0xe5,0x6f,0x0,0x18,0xf2,0x7b,0x95,0x3a, -0xa9,0x93,0xcb,0x35,0xb7,0x2,0xfc,0xfc,0x5a,0x4c,0x1a,0x5,0x68,0xf7,0x5,0x8a, -0x16,0xe1,0xd4,0x85,0xeb,0x92,0x69,0x22,0xf5,0xa,0xa0,0x7c,0xbe,0xd6,0xff,0xbc, -0x12,0xf,0x85,0x12,0xd3,0x25,0x19,0xe,0xc8,0x13,0x61,0xde,0x5d,0xa3,0x3,0xa3, -0xab,0xd,0xcb,0x81,0xe2,0xb7,0xbe,0xc0,0xb,0xb1,0x73,0x6,0x3e,0x78,0x9e,0xa5, -0xfa,0xbc,0x17,0x53,0x7,0xc6,0x1,0xcb,0x81,0x8e,0x10,0x34,0x83,0x1,0x27,0x9a, -0x1d,0x4a,0x60,0xa2,0x0,0x5d,0x21,0xd9,0x6,0x3,0x5a,0x35,0xc0,0x24,0xf3,0x64, -0xd2,0xe2,0xc9,0xb0,0xb7,0xb4,0xa,0x8c,0x33,0x4f,0x26,0x7d,0x1a,0x1d,0x16,0xa8, -0x46,0x8b,0x9a,0x2b,0x94,0x55,0xe1,0x1,0x67,0x69,0x15,0x98,0x47,0xfc,0xc1,0x81, -0x95,0xb2,0xc9,0xf,0x1,0x28,0x7f,0xb7,0x87,0x73,0x6d,0x9b,0x49,0xd8,0x0,0xb4, -0x45,0x8e,0xd7,0x1f,0x58,0x75,0xde,0xcb,0x49,0xb0,0x4f,0x60,0x35,0x3c,0xcd,0x26, -0x7e,0xd9,0x79,0x2b,0x40,0x57,0xe4,0xe9,0x3,0x1,0x79,0x0,0x9e,0x7f,0x76,0x77, -0x40,0xa1,0xf,0xa7,0x77,0x7,0x14,0xfa,0xb0,0x11,0x98,0xb9,0x9e,0x61,0x80,0x42, -0xae,0x69,0x40,0x77,0x60,0x60,0x4d,0x22,0xac,0xc9,0x35,0x9e,0xb5,0xed,0x19,0xa8, -0x55,0x31,0x78,0x22,0x5c,0x7,0xec,0xf8,0x72,0x1b,0x80,0x7a,0x5e,0xea,0xe,0x3, -0xb4,0x1b,0x80,0x5a,0x25,0x6a,0xa8,0x31,0xdc,0x64,0xc0,0x1a,0x41,0xaa,0xd5,0xda, -0xbe,0x99,0xe,0x7,0xe4,0xbf,0xd6,0x0,0x1b,0xaa,0x89,0x3,0x0,0x6b,0x8a,0xa, -0xa6,0x40,0x5c,0x42,0xe1,0x67,0xdc,0xfb,0xfc,0x14,0x8,0x6a,0x61,0xe9,0xf,0x3f, -0x91,0x3f,0xc8,0x18,0x97,0x54,0x59,0xe4,0x88,0x16,0x88,0x89,0x97,0x3,0x6b,0xca, -0x26,0xcd,0xc0,0xc2,0xd3,0xe0,0x3d,0xb1,0x3c,0x5e,0x5a,0xc2,0x87,0xc7,0x10,0x80, -0xe2,0x68,0xc4,0x16,0x16,0xc8,0x70,0xbf,0x39,0x80,0x6c,0xd1,0xe4,0x61,0xb9,0x8, -0x8c,0xc2,0x4d,0x6d,0x25,0xca,0x10,0x48,0xe1,0x93,0x28,0xfc,0x55,0xec,0x10,0xf3, -0xf8,0x22,0x1c,0xfe,0xd8,0xe0,0x1e,0x61,0x80,0xb0,0x48,0x86,0x5f,0xcf,0xdb,0x58, -0x52,0xcb,0xc9,0x27,0x4d,0x76,0xdc,0x4,0xae,0xe2,0xd4,0xae,0xae,0x6d,0x5,0x12, -0x7e,0xf6,0xa2,0xc3,0x7,0x5,0x9b,0x8c,0x63,0xbe,0x17,0xce,0xc3,0x7e,0xe,0x86, -0xa9,0x16,0xe4,0x6,0xf2,0xf1,0xc3,0xb8,0xbf,0x91,0x1f,0x62,0xc0,0x6f,0xac,0xec, -0xf2,0xc2,0xf6,0xd1,0xda,0xd5,0xb5,0xe9,0xb6,0x78,0x8,0x99,0x15,0xc0,0x6c,0x3e, -0xed,0xf0,0x91,0xe,0x11,0x40,0x71,0xea,0x59,0xfc,0xc,0x65,0x3f,0x15,0xf,0x57, -0xe,0xf0,0x11,0x74,0xf0,0xa5,0x62,0xf4,0x4,0x50,0x6c,0x76,0x76,0xd8,0x6d,0xed, -0xea,0xda,0x56,0x20,0xd6,0x3e,0xf1,0x9d,0x3d,0xb4,0x2,0x2d,0x19,0xde,0xd8,0x93, -0x3,0x20,0x8f,0x8a,0xe7,0x3e,0xa0,0x10,0x81,0x91,0xb2,0x9e,0xf2,0xfd,0x16,0x2, -0x18,0x7b,0x19,0x70,0xeb,0xea,0x5a,0x5d,0x4e,0x13,0x79,0x90,0xa4,0xfb,0x56,0x30, -0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0xd,0x79,0x83,0x4d,0x6d,0xe2,0x10,0x3b, -0x71,0x89,0x13,0xbb,0x89,0x1b,0x79,0xb1,0x17,0xe1,0x43,0x43,0x1e,0xf3,0x1d,0x25, -0x2,0xb8,0x58,0x8,0xe0,0x72,0xfb,0xea,0x5a,0x5d,0xd6,0x6,0x9f,0x13,0x44,0x1, -0x1e,0x9d,0xb,0x40,0x6,0x40,0x5c,0x3f,0xa4,0x36,0x6e,0x8,0x1,0xa4,0x4b,0x0, -0x97,0x0,0x2e,0xf6,0xf1,0x79,0x62,0xd1,0x63,0xbe,0x67,0x46,0x0,0xaf,0xd7,0x2, -0x38,0xdb,0xbe,0xba,0x56,0xb,0xc,0xe2,0x20,0xa,0x1,0x9,0xd3,0x1d,0x8c,0x32, -0xb5,0x99,0xd,0xa9,0x98,0x4d,0xdd,0x14,0x70,0xd4,0x25,0x1e,0x20,0x7d,0xe2,0xc5, -0x41,0x2,0x3f,0x59,0xfc,0x98,0xef,0xa,0x92,0x93,0x46,0x2,0xbf,0x68,0x5f,0xb7, -0xf8,0x5e,0x80,0x99,0xb6,0x88,0xc2,0x24,0x80,0xcf,0x8,0xce,0x61,0x70,0x60,0x8e, -0x42,0x9a,0x79,0xe,0xd9,0xad,0xd,0x72,0xd6,0x21,0x5e,0xea,0x12,0x9f,0xba,0x9, -0x88,0xdb,0x38,0x24,0x3e,0x7c,0xe9,0x63,0xde,0xa4,0xaf,0x3,0x6f,0xdb,0x97,0x82, -0x54,0xf5,0xb4,0x3,0xf0,0x5a,0x5,0x4e,0xda,0x80,0x99,0x3e,0x1c,0xa,0x68,0xb5, -0x1,0x33,0x5,0xbc,0x3,0xf0,0x4a,0xbb,0xa5,0xac,0x5,0x98,0x69,0xfc,0xfe,0x40, -0xfe,0x10,0xe9,0xe,0x40,0x59,0xc5,0xe8,0x3f,0x4b,0x79,0x45,0x44,0x0,0x71,0x96, -0xb6,0x2,0x65,0x92,0xd2,0xdf,0xf0,0x6f,0x58,0xe,0xac,0x74,0x41,0x37,0x1,0x7b, -0xbb,0xb6,0x75,0x1,0xac,0xf4,0x79,0x97,0x80,0x4a,0xad,0xad,0xb7,0xf3,0xc6,0xc7, -0x23,0x89,0xd5,0x4d,0xe9,0xbc,0x9b,0x80,0x4a,0x35,0xf1,0xe7,0x7d,0xc3,0x93,0xa, -0xc,0x2a,0x9b,0x3,0x4a,0x40,0xa5,0x5e,0xfa,0x66,0xcf,0x0,0xac,0xa7,0x18,0x95, -0xed,0xf,0x25,0xa0,0x52,0x11,0x7e,0xb7,0x67,0x8a,0xa1,0x3,0x31,0xc5,0x68,0x2, -0x2a,0x35,0xef,0x8f,0x7b,0x26,0x51,0x7a,0xd6,0x86,0x49,0x54,0x13,0x50,0xa9,0xea, -0xdf,0xf6,0x4e,0x13,0xdf,0x17,0xc0,0xd7,0xb2,0x34,0xb1,0x11,0x58,0xac,0x5b,0xdc, -0xf6,0x4c,0x84,0x75,0x20,0x63,0x2d,0xc0,0x62,0x65,0xa6,0x2f,0x50,0x1f,0xc3,0x2a, -0x50,0xec,0xa3,0xcb,0x2a,0xdc,0xca,0xda,0x13,0xe9,0xae,0x9e,0x4,0xf0,0x44,0x2, -0xa9,0x11,0xb0,0x58,0x5d,0xeb,0xb,0x64,0xf,0xc4,0x2,0x4,0x19,0x85,0x26,0xc0, -0x1d,0xd6,0xf,0xb,0xd1,0x96,0xf7,0x51,0xd4,0x1,0x37,0xfc,0x58,0x12,0x7f,0xb1, -0xfb,0xa,0x69,0x6,0x8c,0xd4,0xcc,0xbb,0x15,0xb8,0xc3,0x1a,0x70,0x6,0x94,0xa7, -0xd,0xd0,0xa9,0x11,0x70,0x87,0x55,0xee,0xc,0x28,0x77,0x39,0x53,0x66,0x6,0xec, -0xdf,0x38,0xf0,0x63,0x1,0x1a,0xf6,0x62,0xd0,0x70,0x28,0xa0,0x61,0xb7,0xc9,0x70, -0x40,0xc3,0x7e,0x9a,0xe1,0x80,0x86,0x1d,0x43,0xd,0x40,0xad,0x81,0xa7,0x1d,0x68, -0xd8,0x13,0x35,0x1c,0x30,0x35,0x31,0xc3,0x74,0xdb,0x4f,0x54,0xde,0x91,0x60,0x0, -0x64,0x26,0x8b,0x87,0x83,0x2,0x27,0x6,0x66,0x38,0x28,0x30,0x32,0x31,0x43,0x87, -0xe,0x4,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0xa6,0xaf,0x88,0x76,0x8e,0x26,0xbb,0x1, -0x93,0xbb,0x6,0x92,0xbb,0x6,0xf6,0x78,0xfd,0x90,0x81,0xdc,0x48,0xa6,0xba,0xcb, -0xc2,0xef,0x22,0x4a,0x42,0x3b,0x24,0x30,0xad,0x1,0x7a,0x64,0xf,0x40,0x4c,0xa1, -0xe9,0x7d,0x9f,0x2b,0x28,0x4,0xf2,0xe3,0x2,0x21,0x6c,0x45,0x11,0x4b,0xdd,0xbd, -0x1,0x7f,0x6,0xaa,0xc9,0x65,0x3a,0x70,0x2,0x9e,0x26,0x61,0xc3,0x3,0x9,0xd7, -0x86,0xa0,0xb,0xdf,0x97,0x40,0xf4,0x19,0x3e,0xe3,0xda,0xf0,0x7c,0xb9,0x7,0x60, -0xf2,0x74,0xce,0x92,0xe8,0x92,0xc5,0xb,0x1,0x7c,0xf9,0xd0,0xe7,0xea,0xf7,0xfe, -0xeb,0x1,0x8b,0xe6,0xfc,0x94,0x36,0xda,0x21,0x9d,0xac,0x4f,0xf5,0x35,0xe0,0x66, -0xc5,0x36,0xcb,0x5,0x5b,0x66,0xc0,0x40,0x0,0x1f,0x3e,0x0,0x61,0xea,0xee,0xb, -0xb8,0x5a,0x14,0x57,0x98,0x1,0x4f,0x2,0xdc,0x41,0xb4,0x3f,0x60,0x36,0x86,0x8, -0x9c,0xc1,0x18,0x22,0x10,0xf,0xdb,0x70,0x9,0x9a,0x47,0x67,0xa0,0x2e,0x48,0x7f, -0x10,0xc0,0xcc,0x2c,0x5e,0xfa,0x3e,0xdf,0x88,0x8a,0x40,0x5c,0x8d,0xbf,0x20,0x1c, -0x3a,0x3c,0x10,0xd,0x1f,0xeb,0x33,0xb,0x0,0xe2,0x8a,0x84,0x9f,0x6,0x3c,0xc5, -0x98,0x11,0x1,0x1d,0xe,0xf8,0x1b,0x30,0x8b,0xd9,0x25,0x77,0x6d,0x1c,0x8,0x66, -0x41,0x0,0xe8,0x51,0x1,0x5c,0xc2,0x37,0xcd,0x7,0x5,0xda,0x17,0x30,0xa5,0xc4, -0xd1,0x4f,0x8,0x8c,0xd0,0xcd,0xf1,0xb1,0x13,0xc0,0xd,0x7c,0xd3,0x6a,0x48,0x20, -0x71,0x2e,0xb9,0xa7,0xc9,0xd3,0x8a,0xfb,0x1,0x3f,0x74,0xe1,0x92,0x34,0x7,0xdf, -0xdb,0xe4,0xc3,0x15,0x63,0xe7,0xab,0x97,0x4e,0x47,0x20,0x75,0xa7,0xdc,0x79,0x17, -0x40,0xe1,0x4b,0x17,0x2d,0x57,0x75,0x1b,0xbf,0xbd,0x86,0x8f,0x5f,0xbd,0xb4,0x3a, -0x2,0x7b,0xbe,0xd6,0xcb,0xf5,0x3b,0x0,0x3c,0xfa,0xcd,0xcb,0x71,0xd8,0xf,0x88, -0x75,0xb6,0x4d,0xaa,0xab,0x9b,0xcb,0xd,0x3e,0xf2,0x1b,0xcf,0x4a,0x15,0xe1,0x52, -0xb9,0xf3,0xeb,0xd9,0xfa,0x31,0x4c,0xed,0x71,0xdc,0x1b,0x88,0x95,0xc4,0x65,0xaa, -0xeb,0x37,0x37,0x81,0xe1,0xc4,0x63,0x1a,0xf0,0x11,0xdc,0x8e,0x8c,0xd1,0x12,0xf8, -0xbf,0xd9,0xe3,0x6b,0x10,0x6b,0x7f,0x78,0x79,0xd6,0x19,0x88,0xc7,0x1,0x2e,0x78, -0xad,0x74,0xc6,0xfb,0x6e,0x7c,0x26,0x8e,0xea,0x8,0x52,0x37,0x9,0x53,0x2f,0x82, -0x49,0x3b,0x41,0x7d,0xc7,0xeb,0xb8,0x79,0x42,0x72,0x9b,0xbe,0xcb,0x81,0xff,0xbc, -0x2f,0x70,0xc9,0x5c,0x36,0x67,0x3a,0x10,0x53,0x8c,0x8b,0xb,0xb8,0x52,0x7,0x26, -0x73,0x2,0xc1,0x63,0xa9,0x0,0xe9,0xc7,0x30,0xdb,0x92,0xbf,0xee,0xd,0x5c,0xc1, -0x7b,0xc1,0xbf,0xac,0x0,0x62,0x12,0x35,0x83,0xdb,0xf8,0xef,0x21,0x46,0x9f,0x13, -0x96,0xcc,0xb,0x61,0xb8,0xbe,0x25,0xe4,0xa,0x80,0x1f,0xdd,0x1b,0x1a,0x88,0x6e, -0x2e,0x86,0x48,0x15,0x1,0x70,0xa9,0x2,0x37,0x14,0x80,0xe3,0xe1,0x81,0xd8,0xc4, -0x99,0xc0,0x6f,0xf1,0x29,0x4b,0x12,0x15,0xb8,0x2,0x7f,0x94,0x1e,0x7f,0xf4,0x49, -0xd7,0x59,0x9a,0xf0,0x2,0xbb,0x9b,0x3,0xb1,0x67,0x44,0x16,0xd8,0x39,0x10,0x23, -0x47,0x4,0x57,0x98,0x1c,0xb1,0x4,0xf,0x5d,0x2d,0xc,0xff,0x18,0x1f,0x2b,0xb6, -0xfe,0xa4,0xab,0xe1,0xb7,0x1,0xb3,0x31,0xa4,0x6f,0xb0,0x64,0xfc,0x4b,0x5,0x18, -0x41,0xfc,0x62,0xe7,0xeb,0xce,0xae,0x4d,0x5,0xe2,0x2c,0x55,0x81,0xea,0x2c,0x3d, -0x3,0xb3,0x38,0xb1,0x7,0x70,0xde,0xd4,0x5f,0x81,0x65,0x2f,0xe4,0x9a,0x5,0xc4, -0x42,0x18,0x43,0x74,0x0,0xf3,0x34,0xe0,0xcb,0x7,0x1e,0x18,0xbd,0x1f,0xf1,0x43, -0x91,0xa9,0x41,0xa9,0xcc,0x60,0xd2,0xb8,0x2b,0xf8,0x54,0x1,0xc4,0x2,0x36,0x81, -0x14,0x23,0x39,0x83,0xa8,0xf,0xc0,0x89,0x9d,0x7b,0x9a,0xb4,0xe4,0x69,0x76,0x0, -0x5e,0xc2,0x2c,0x55,0x80,0x14,0x80,0x4,0x80,0x89,0x4,0x6e,0xf1,0xa5,0x3b,0x0, -0x17,0x0,0x9c,0x2e,0x14,0xc9,0x4,0x1,0x18,0x80,0x24,0xed,0x55,0x2d,0xde,0x5b, -0x78,0xda,0x1d,0x48,0x20,0x91,0xd9,0xe8,0xc7,0x3b,0xa3,0x59,0xf0,0xeb,0xb4,0x8, -0xc3,0xff,0x92,0x72,0xcd,0xeb,0x47,0x6,0x4,0xa7,0xb9,0x49,0x82,0xb2,0x20,0x15, -0xc0,0x53,0x46,0x42,0x88,0x16,0xe1,0x72,0x0,0x60,0x92,0x55,0xe9,0x63,0x8,0xc0, -0xe0,0xc7,0x16,0xf2,0x8b,0xd1,0x9b,0xba,0x31,0x7,0xa6,0xd6,0x5b,0x90,0x39,0x46, -0xe0,0xc7,0xcf,0x87,0x0,0x86,0x2,0xba,0x4,0x1f,0x36,0x9f,0x79,0xfc,0x8,0x6b, -0x3c,0x8b,0x1c,0x2d,0xe0,0x7c,0xc6,0x4b,0x93,0xf4,0x18,0xcc,0xc3,0xbb,0x80,0xf7, -0x10,0x76,0x98,0x88,0x68,0xc0,0x56,0x73,0xf0,0xa5,0xf3,0x29,0x3f,0x6e,0x19,0x37, -0x4e,0xe0,0x67,0x47,0x17,0x2,0x78,0xe6,0x8,0x21,0x34,0x88,0x1d,0xe2,0xa6,0x5, -0x4c,0x7c,0x57,0xb,0x0,0x2e,0xa6,0x1c,0x8e,0xd,0xce,0x8,0xce,0xe4,0x5a,0x8, -0xb0,0x48,0x44,0x8d,0x21,0x5c,0x9b,0x68,0x21,0xce,0x80,0x32,0xfe,0x71,0x28,0x46, -0x3c,0xe,0x14,0x41,0x38,0xdb,0xec,0xbe,0x23,0x50,0xde,0xc3,0xc,0x98,0xca,0x2b, -0xe6,0x60,0xaf,0x0,0x76,0xbb,0x42,0xc2,0xab,0xbf,0x51,0x6d,0x19,0x5f,0xde,0xbf, -0xc,0x98,0x5d,0x31,0xde,0xea,0x6c,0xc,0x11,0xd8,0x6d,0xc,0x13,0x5e,0xdf,0x9e, -0xd4,0x2e,0x54,0xc8,0xfb,0xb7,0xbc,0x84,0x59,0xea,0x7a,0xf9,0x8c,0xc1,0xf3,0x2c, -0xb2,0x59,0xa,0xc0,0x8e,0xb3,0xb4,0xe9,0xa,0xe5,0xfd,0x8b,0xef,0x81,0x7a,0xba, -0xe7,0x15,0x33,0xe6,0x9c,0xf1,0xbc,0x34,0xe0,0x9d,0x45,0xdd,0xed,0xb0,0xe1,0x4b, -0xc4,0xa0,0x25,0xf,0x3c,0x16,0xe3,0xb2,0x67,0x36,0x63,0xa2,0xdc,0xd3,0x70,0x60, -0x57,0x4f,0xd3,0xf0,0x12,0xf7,0x90,0x80,0x10,0x4d,0x1e,0x6,0xf2,0x8a,0xf9,0x55, -0x67,0xbe,0x94,0x3,0x3b,0xfa,0xd2,0x48,0x34,0x5d,0xd5,0xa6,0x8,0x99,0x6f,0xc9, -0xbe,0xc5,0x17,0x50,0xba,0x53,0x3c,0x9c,0x88,0xa6,0x2b,0x7b,0x7b,0x5e,0x5a,0xbc, -0xf2,0xbc,0x74,0x17,0x60,0xd3,0x15,0xee,0x27,0x0,0xb7,0xbe,0xca,0xd7,0x29,0xd7, -0x94,0x84,0x59,0x48,0x9f,0x61,0x6f,0x6,0x4,0x2e,0x59,0xe9,0x61,0x7,0x62,0xfe, -0xa6,0x72,0x34,0xc5,0x63,0x79,0xcc,0x67,0x29,0x3f,0x96,0xa6,0xd6,0x17,0x52,0xb0, -0x3d,0x8a,0x59,0x5b,0x28,0xe,0xcb,0x41,0x13,0x9c,0x82,0x59,0x3c,0xb4,0xc4,0x89, -0x59,0xae,0x70,0x3a,0x84,0xbb,0xf,0xf3,0x44,0x98,0x9f,0x93,0x5a,0xeb,0xb,0x79, -0xbd,0xd4,0x5d,0x8,0xdf,0x19,0x8,0xe8,0x34,0xa,0xd9,0x21,0xd6,0x4b,0x8b,0x50, -0xc5,0x81,0x63,0x67,0x80,0x2b,0xe4,0xa9,0xbe,0xb3,0x10,0x97,0xe1,0x89,0x86,0x80, -0x4b,0x98,0xd3,0x7,0x30,0xcd,0x22,0x79,0xd5,0xe7,0x12,0x98,0xba,0x3,0x8c,0x61, -0xf2,0x4,0x2b,0x51,0x8b,0xdc,0x7f,0xe2,0x5d,0x58,0xdc,0x7,0xe0,0x38,0x50,0x43, -0x15,0x97,0xdc,0xa9,0x37,0x4,0x10,0x6b,0x6d,0x58,0x2c,0x9d,0x89,0x1,0x7c,0x89, -0x35,0x1a,0xf0,0x3a,0x7,0x69,0xa0,0x86,0x2a,0x1,0xf4,0x87,0x2,0x62,0xed,0x52, -0x46,0xd8,0x5,0x3e,0x9a,0x43,0x2,0x59,0x36,0x6b,0x5c,0x9,0xc,0x7e,0xb4,0x40, -0x2c,0x96,0xa,0x87,0xcd,0x16,0xe0,0x56,0x97,0x19,0x30,0xcb,0xa8,0x1c,0x39,0x69, -0x6,0x3,0x52,0x71,0x19,0x38,0x55,0x17,0x60,0xfd,0x31,0x2,0xcf,0x64,0x12,0xc3, -0x8f,0xed,0xed,0x6c,0x87,0xd,0xc0,0x70,0x2e,0xe7,0xbb,0xcb,0xb3,0xd1,0x5,0x4e, -0xc9,0x43,0x9f,0x1d,0x8e,0x3,0x7e,0x9a,0x1c,0x4f,0x5a,0xe3,0x21,0x81,0xc1,0x5, -0x40,0x5d,0xe9,0x49,0xa7,0x6c,0x91,0xe0,0xb2,0x10,0x48,0xee,0x23,0xc5,0x8b,0x92, -0x1,0x81,0x24,0xb8,0x84,0xb,0x29,0xe2,0xe1,0x82,0x60,0x6e,0x18,0x2,0x30,0xdc, -0x4f,0xb4,0xa0,0xc1,0x14,0x2e,0xa4,0x88,0x13,0xb,0x34,0x3c,0x6c,0xf,0x3c,0xda, -0x73,0x78,0xba,0xf3,0x78,0x18,0xf3,0xdb,0xa9,0xcf,0xfb,0x89,0x1c,0x43,0x4b,0x9a, -0xc5,0xb0,0x40,0xf8,0xec,0x45,0x52,0x2,0x8e,0xb,0x60,0x58,0x7a,0x54,0xcf,0x8e, -0x63,0xe8,0x73,0x47,0x33,0x7,0x7d,0x28,0x3a,0x2f,0x19,0xef,0xbc,0xb4,0x4,0x10, -0x5b,0x3d,0xd1,0x2d,0x24,0xfe,0xa0,0x40,0x54,0x50,0x33,0x4f,0x5,0xa6,0xf7,0x8f, -0x39,0x90,0x3a,0xb1,0x88,0xfe,0x1e,0x1b,0xcc,0x2c,0x3c,0xf6,0x7b,0x54,0x50,0xa0, -0xf,0x71,0x7f,0x56,0xc4,0x1b,0x59,0xc3,0xf4,0xe4,0x50,0x0,0xff,0x92,0x88,0x83, -0xde,0x1c,0x36,0x94,0xa7,0x81,0xbc,0x14,0x1f,0x86,0xb7,0x4,0x31,0x83,0x5b,0xde, -0x2e,0xc1,0x34,0x70,0x65,0x26,0xb8,0x1f,0x72,0xf5,0xf4,0x84,0x14,0xe9,0xc7,0xee, -0x40,0xc8,0xd7,0x36,0x58,0x2f,0x5,0x27,0x9d,0x0,0x10,0x37,0xf5,0x4d,0x1,0x8a, -0x6b,0x4f,0xc1,0x6f,0x5,0x70,0x74,0xda,0x5d,0x1f,0xb6,0x3,0xe1,0xc7,0x4f,0xdc, -0x12,0x30,0x12,0xc0,0xd3,0xa3,0x42,0x33,0xe,0x7,0x44,0xa7,0x5d,0x6,0xc2,0x25, -0xb9,0x30,0x86,0xe3,0x83,0x22,0x7d,0x1b,0xe,0x98,0xe0,0x99,0xce,0x9e,0x6,0xf4, -0xc0,0xf2,0x2e,0x0,0x78,0x62,0x29,0x95,0x86,0xc1,0x80,0x44,0x74,0x43,0xab,0x40, -0x6c,0x1c,0x98,0x11,0xb9,0x6,0x2c,0xd3,0xb7,0xe1,0x66,0x29,0x6,0x60,0xcb,0x57, -0x81,0xc,0x81,0x4b,0x61,0xf8,0xb2,0x98,0x33,0x84,0x1d,0xca,0xc6,0x81,0x95,0xcc, -0x11,0x95,0x12,0x34,0x98,0x87,0x58,0x3f,0xe4,0x22,0x88,0x30,0xc6,0x86,0xd0,0x16, -0xbc,0x35,0x42,0x91,0xe2,0x2a,0x70,0x3f,0xf1,0xf0,0xae,0x81,0xdf,0x5b,0x3c,0xfc, -0x1e,0x80,0x59,0xe1,0x52,0xbd,0xdf,0x79,0x12,0xc5,0x8b,0xec,0xf7,0xbc,0xbb,0x3, -0xd2,0xae,0xcb,0x8,0xdb,0x27,0x8d,0x9d,0xa9,0x47,0x1,0xc4,0xe7,0xc,0xc6,0x59, -0x5d,0x4d,0x49,0x13,0x4b,0xb,0x96,0xbb,0xd8,0x21,0x63,0xfc,0x29,0x1b,0x12,0x18, -0xbb,0xfc,0xe1,0x4a,0xe2,0xfc,0x51,0x5,0x38,0x4a,0x40,0xd9,0xd,0x61,0xf8,0x89, -0xdc,0xd0,0x91,0x1,0xf9,0x86,0xe,0x47,0x1a,0xbb,0x2,0x4c,0x8,0xa8,0x82,0x21, -0xc,0x3f,0x81,0x94,0x3e,0x21,0x21,0x5f,0x99,0xc1,0x4e,0x85,0x39,0x5c,0xc5,0x25, -0xe8,0xb,0x2c,0xe6,0x89,0xfd,0x32,0xa2,0x12,0x35,0x1c,0x10,0x7c,0x26,0x36,0x30, -0x65,0xc0,0x5,0x7c,0xe8,0x74,0xc5,0x98,0x3f,0xff,0xa9,0x1,0x9,0xa4,0xfb,0x9, -0x8a,0x99,0x2,0xc8,0x2e,0xe0,0xff,0x5f,0xc2,0x18,0x7a,0x30,0x86,0x4f,0x6,0x9b, -0x34,0x12,0x48,0xfd,0x5,0x24,0x9f,0x3a,0x10,0xfb,0x4b,0x65,0x3f,0xd,0xb1,0xa2, -0xa1,0xe4,0x9a,0x4,0xa6,0x0,0xa4,0x25,0x20,0xf6,0x97,0xca,0x7e,0x1a,0x6a,0xcf, -0x7,0x32,0xfc,0x6c,0x49,0x16,0x9b,0xde,0x52,0x5f,0x5b,0x3,0xe6,0xfd,0xa5,0xb2, -0x9f,0x26,0x75,0x16,0x3,0xb9,0xb6,0x1c,0x78,0x57,0xe1,0xe9,0xce,0x81,0x3f,0xe4, -0x7a,0xe9,0xb0,0xfa,0xb0,0xad,0x5e,0x3a,0x98,0x3e,0x54,0x15,0x70,0x49,0xac,0xa4, -0x2e,0x2b,0xca,0x6d,0x83,0xe9,0xc3,0x42,0xb6,0x15,0x7,0x57,0x65,0x2f,0xa5,0x5e, -0x3a,0x9c,0x3e,0xcc,0x3,0xb1,0x5f,0x9c,0xa4,0x9c,0xcf,0x58,0x56,0x54,0xbf,0x6, -0xd3,0x87,0xf9,0xcb,0xcd,0xca,0xb8,0xa5,0xab,0xe,0xb3,0x85,0x9a,0x81,0xf4,0x61, -0xfe,0xba,0xa8,0x5e,0x42,0xbe,0xac,0x17,0xe,0xa8,0xf,0xf3,0xd7,0xac,0x66,0xd6, -0x28,0x6b,0x89,0x83,0xe9,0xc3,0xef,0xf,0x98,0xad,0x3e,0x97,0x6f,0xb3,0x1c,0xdb, -0xc1,0x4,0x69,0x31,0x43,0x6a,0x2e,0x61,0xa6,0x8c,0xed,0x50,0x82,0xb4,0x62,0xe6, -0xba,0x78,0x2c,0xa6,0xe8,0x50,0x82,0x54,0xb3,0xb,0x56,0x2,0x16,0x5,0xda,0xe1, -0x4,0xa9,0x61,0xaa,0x3f,0x9c,0x20,0xfd,0xff,0x49,0xae,0x7d,0xf,0xfa,0xb0,0x7c, -0x38,0x3a,0x46,0xdf,0x73,0x30,0x7,0x47,0x8e,0xa1,0x35,0xb4,0x3e,0x2c,0x1f,0xff, -0x8e,0x40,0xdc,0x16,0x6f,0x2b,0xa2,0x74,0x50,0x60,0xe9,0x80,0xfb,0x22,0xd5,0x17, -0xc0,0x61,0x12,0x61,0xd,0xe8,0x57,0x81,0x7,0x8f,0x18,0x7d,0x74,0x2a,0x80,0xce, -0xd0,0x76,0xf8,0xd2,0x9b,0x56,0x80,0xc7,0xa7,0xa2,0x9a,0x88,0xc0,0xd9,0x90,0x76, -0x88,0xea,0x69,0xe1,0xea,0x86,0xff,0x5a,0xc0,0x38,0x70,0x7c,0x20,0x24,0x77,0x3c, -0x38,0x70,0xae,0x3,0x27,0x12,0x78,0x66,0x9,0x60,0xf2,0x74,0x68,0xe0,0x52,0x7, -0x46,0x12,0x18,0x4a,0x20,0x79,0x3c,0x64,0xd6,0x6,0xfa,0x70,0x9e,0x78,0xe5,0x10, -0x29,0xba,0x2f,0x27,0xf0,0x3b,0x8c,0xe1,0x78,0xc8,0x59,0x8a,0xfa,0xb0,0xfc,0xdc, -0x7,0x12,0xe4,0xfd,0xa5,0x68,0xfc,0xc3,0x9a,0x5,0xea,0xc3,0xb2,0xe1,0x63,0xca, -0xed,0x2d,0xe1,0x9f,0x62,0x2e,0x4a,0x7,0x36,0x7c,0xbf,0xde,0xb5,0x71,0x71,0x2a, -0x37,0x79,0xc,0xec,0xda,0x5e,0x85,0xa7,0x81,0x81,0x24,0xad,0xee,0xb7,0x98,0x14, -0x65,0xb0,0xce,0x3d,0xc2,0x3f,0x42,0xa0,0x33,0xb0,0x59,0x60,0x2b,0x49,0x79,0x47, -0x9,0x3f,0xdb,0xc9,0xe6,0xeb,0x16,0x9d,0x1b,0xcb,0xd,0x24,0x77,0xb6,0xc1,0x43, -0x91,0x16,0x24,0xcc,0x1a,0xcb,0x49,0x18,0x83,0xa7,0x9b,0xd,0x8,0x2c,0xb6,0x3f, -0x28,0x76,0x8f,0x8d,0x74,0xa2,0xb1,0x1c,0xdb,0xe8,0x86,0xea,0xdc,0x33,0x4,0x76, -0xec,0x82,0x7e,0x5,0xbc,0x7b,0x60,0xdd,0x2c,0xdd,0x2b,0x10,0x77,0x76,0x95,0xe2, -0xa1,0x56,0x82,0x1e,0x6c,0xdd,0x22,0xf7,0x34,0xb8,0x9b,0x44,0x8f,0x87,0x3f,0x31, -0xe0,0xab,0x0,0x3c,0x7c,0x0,0x76,0xb1,0x53,0x81,0x95,0x33,0x6f,0x7e,0x4e,0xa9, -0x25,0x3f,0xc8,0x1e,0x12,0x98,0x38,0xe2,0x20,0x31,0x2d,0x3c,0x81,0x95,0xe0,0xd1, -0x5a,0x56,0xc8,0xcf,0x1c,0x33,0xf9,0xb0,0x2e,0xa9,0xbe,0x68,0xda,0xd1,0xbe,0x39, -0x3b,0x59,0xcd,0xaf,0x9b,0xc4,0xbb,0x7a,0x9a,0x4,0x72,0xcf,0xa4,0x54,0x6a,0xbb, -0x84,0x24,0x18,0x80,0x27,0x72,0x2b,0xd4,0x78,0x48,0x20,0x6e,0x2e,0x2e,0x6d,0xc5, -0x4d,0x83,0x5,0xbc,0x45,0x43,0x11,0x61,0xfe,0x40,0xbd,0x89,0xaf,0x80,0xaf,0x80, -0x3b,0x49,0xee,0xad,0x75,0x9a,0x7d,0x44,0x8b,0x9f,0x3e,0xf0,0x55,0x3c,0x7c,0x5, -0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x2c,0x80, -0x7f,0xf,0x8f,0x5b,0x9c,0x1e,0xf,0x3e,0xf1,0xfb,0x0,0x0,0x0,0x0,0x49,0x45, -0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//brd_wiznet.png: 13702 bytes diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon.ico b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon.ico deleted file mode 100644 index f63da06..0000000 Binary files a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon.ico and /dev/null differ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon_ico.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon_ico.h deleted file mode 100644 index f890e90..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon_ico.h +++ /dev/null @@ -1,107 +0,0 @@ -const char favicon_ico[] PROGMEM = { -0x0,0x0,0x1,0x0,0x1,0x0,0x30,0x30,0x10,0x0,0x1,0x0,0x4,0x0,0x68,0x6, -0x0,0x0,0x16,0x0,0x0,0x0,0x28,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x60,0x0, -0x0,0x0,0x1,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x0, -0x0,0x0,0x48,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x22, -0x24,0x0,0x8c,0x96,0x4,0x0,0xcb,0xd2,0x8d,0x0,0x57,0x5d,0x11,0x0,0xaa,0xb5, -0x4b,0x0,0x41,0x44,0x17,0x0,0xf0,0xf0,0xdc,0x0,0x6f,0x7b,0x9,0x0,0xbf,0xc5, -0x70,0x0,0xdc,0xe2,0xb4,0x0,0xfc,0xfe,0xfc,0x0,0x60,0x6e,0xc,0x0,0x4c,0x53, -0x14,0x0,0x99,0xa7,0x26,0x0,0x31,0x31,0x1c,0x0,0x7c,0x88,0x4,0x0,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa6,0x8d,0x14,0x8a,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11, -0x11,0x11,0x11,0x11,0x11,0x16,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11,0x11,0x11,0x35,0x5,0xb1,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0xe0, -0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa1,0x11,0x11,0x11,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11, -0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb1,0x11,0x11,0x4a,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa1,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x11,0x11,0x19,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x91,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x18,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0xf,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x11,0x11,0x2a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0x51,0x11,0x1a,0xaa,0xaa,0xa8,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x1,0x11,0x14,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x61,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41, -0x11,0xc0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xd1,0x11,0xe0,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x11, -0x11,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41,0x11,0x50,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x81, -0x11,0x30,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0xe,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x1c,0xa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xaa,0xaa,0x1,0x11,0x12,0xaa,0xaa,0xa6,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0xf1,0x11,0x1a,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x13,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xad,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x1a,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa2,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb, -0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xd1,0x11,0x11,0xf0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa4,0x11,0x11,0x11,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf1,0x11, -0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x21,0x11,0x11,0x11,0xf0, -0x0,0x0,0x0,0x0,0xe,0x11,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x41, -0x11,0x11,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 -}; -//favicon.ico: 1662 bytes diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p.png b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p.png deleted file mode 100644 index a6dc8a3..0000000 Binary files a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p.png and /dev/null differ diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p_png.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p_png.h deleted file mode 100644 index c1be58d..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p_png.h +++ /dev/null @@ -1,815 +0,0 @@ -const char m1284p_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x4,0xf8,0x0,0x0,0x3,0x3b,0x1,0x3,0x0,0x0,0x0,0xed,0x52,0xbc, -0x4d,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0x12,0x74,0x0, -0x0,0x12,0x74,0x1,0xde,0x66,0x1f,0x78,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54, -0x78,0xda,0xed,0xdd,0x5f,0x8c,0x23,0xc7,0x9d,0x1f,0xf0,0x59,0x4f,0x20,0x26,0xb0, -0xb5,0xf4,0x21,0x2f,0x6,0xbc,0xbb,0xf4,0xc5,0x4f,0x79,0x73,0x5e,0x6e,0x25,0x68, -0xb5,0xb4,0x90,0x7,0x3f,0xfa,0xf1,0x2,0x8,0xd2,0x2a,0x2f,0xf9,0x3,0x45,0x4b, -0x19,0x86,0x96,0xbb,0xe2,0x72,0x7a,0xd6,0x3,0x64,0x1e,0x12,0xdc,0xdc,0x21,0x2f, -0x39,0x48,0xde,0x31,0x70,0x7,0xf8,0xe1,0x60,0xad,0x2,0x45,0xa2,0x6c,0x2e,0xa7, -0x39,0x98,0xb3,0x6,0xc1,0x59,0xe2,0x19,0x4e,0x30,0xb6,0x29,0xb2,0x38,0x37,0x97, -0xa3,0x90,0x11,0xbb,0x38,0x1e,0x2f,0xab,0x67,0x8a,0x5d,0x95,0xfe,0x57,0xfd,0xb7, -0xba,0xd9,0xff,0x48,0xb6,0x70,0x43,0xdc,0x59,0xda,0x9d,0xdd,0x99,0x8f,0xaa,0xbb, -0xab,0xbe,0xfd,0xab,0xea,0xea,0x15,0x9a,0xef,0xcf,0xca,0x85,0xef,0xc2,0xe7,0xfe, -0xf4,0x4b,0xc5,0x5c,0xfb,0x7a,0x12,0xca,0xb5,0xaf,0x3b,0xc9,0xb9,0x8f,0x5e,0xf8, -0xd2,0xf9,0x60,0xce,0x7d,0x60,0x91,0xbe,0xc1,0x5a,0x71,0x73,0x73,0x73,0x5a,0xda, -0x23,0xd7,0xae,0x14,0x89,0x2c,0xcc,0xf6,0x21,0x71,0x91,0x3e,0xd8,0x42,0xb5,0x5a, -0x4d,0xa1,0x2d,0x65,0x34,0x42,0xd3,0x8,0x3f,0xbb,0x7,0x85,0x85,0xfa,0xba,0x58, -0xf5,0x61,0xc3,0x77,0x1e,0xc1,0xd7,0xbf,0x56,0x58,0xac,0x8f,0xaa,0x40,0xb9,0xdc, -0x52,0xe0,0x8,0x11,0xba,0xc0,0x63,0x17,0xd9,0xb7,0xaf,0xb6,0x1f,0xc8,0xaf,0x6f, -0x4f,0x6d,0x3f,0xaa,0xf9,0x3e,0x2d,0x12,0x2a,0xe4,0xcf,0x87,0x71,0xed,0xcd,0x12, -0x68,0x3d,0xd,0x5b,0xd3,0x9b,0x84,0xe6,0xd0,0x57,0x33,0x8f,0x6f,0x9d,0x12,0x25, -0x7f,0x3e,0xbd,0x7f,0xc1,0x62,0x4b,0x91,0x14,0x4a,0xf0,0xec,0xbf,0xd2,0x3e,0x3c, -0x1c,0xb4,0x6f,0x81,0x45,0xf9,0xcc,0xfe,0xf9,0xf9,0x3d,0x72,0xe5,0x69,0x4a,0xc6, -0xe5,0x99,0x7f,0x85,0xf4,0xfb,0x10,0x83,0x85,0xf9,0x62,0x7f,0x94,0x7e,0x1f,0x60, -0x28,0xe6,0xd9,0xb7,0x9b,0x67,0x1f,0x3e,0xec,0xf7,0x31,0xa,0xe8,0x87,0xc6,0xfe, -0x13,0x93,0x90,0xc3,0x8,0xa3,0x7a,0x86,0xbe,0x7e,0x9f,0x4,0xfa,0x10,0xe0,0xf8, -0xfa,0xc9,0x13,0x45,0x52,0xdf,0x79,0xc0,0xb1,0x87,0x9c,0x3,0x5f,0x17,0x2b,0x60, -0x81,0x3e,0xd4,0x57,0x8f,0x6f,0x90,0x6f,0xc0,0xf5,0x41,0xba,0x58,0x5f,0xf,0x2b, -0x41,0xed,0x57,0xf5,0x1f,0xf8,0xe6,0x7c,0x7c,0x2d,0x24,0x15,0x8a,0x9c,0x5b,0x5d, -0x74,0x78,0x78,0x18,0xe4,0x1b,0x94,0x17,0xe7,0xbb,0x81,0x3a,0x93,0xb8,0xb7,0x92, -0xa,0x7d,0xd3,0xff,0x9b,0x7,0x73,0xf1,0x91,0x56,0xf5,0x91,0x14,0xdb,0x7,0xb9, -0xbe,0xb9,0x5c,0x1f,0xad,0x6a,0x5,0xc6,0xf6,0x49,0x9c,0x3,0xf,0xe7,0xd3,0xbf, -0xb4,0x1a,0x15,0x80,0x38,0xe7,0xdf,0x8a,0xfd,0xf1,0x7,0xfd,0x31,0xcf,0x37,0x9f, -0xfe,0xb9,0xf5,0x1,0x4,0xbc,0x52,0x4b,0xa8,0x6f,0x81,0xe3,0x5b,0xeb,0xff,0x40, -0xd0,0x9f,0xa3,0x4f,0xbe,0x1e,0xe1,0xb0,0x7,0xf9,0x56,0xd5,0x1b,0xba,0xff,0x5d, -0x10,0x77,0x38,0xbe,0x92,0xfd,0xaf,0xfb,0x69,0x7c,0xe8,0x0,0x95,0x13,0xfb,0xea, -0xa7,0xb4,0x35,0x84,0xe2,0xda,0x3c,0x7d,0x5d,0x29,0x79,0xfb,0xad,0x1d,0xab,0xfd, -0x33,0xdc,0x29,0xf8,0xaf,0xf,0xe8,0xf0,0x7d,0x54,0x4e,0xe3,0x8b,0x12,0xd2,0x2, -0x7d,0x81,0x41,0xbf,0xe3,0xf0,0xfd,0x3c,0x4d,0x8a,0x96,0x15,0x30,0xf,0xdf,0x23, -0xe7,0xf1,0x4d,0x95,0xf2,0xaf,0xc6,0xf6,0xb5,0x3d,0xbe,0x31,0xe7,0x6f,0xc0,0xcc, -0x7c,0x7d,0x31,0xae,0x6f,0xdd,0x38,0x9f,0x8a,0x44,0x30,0x7c,0x3,0x61,0x2b,0xdc, -0x17,0xe9,0xfc,0x1b,0x6,0xe5,0xa0,0xb8,0x3e,0xb2,0x62,0xfc,0xec,0x55,0xe6,0x1b, -0x92,0x62,0x6,0xed,0x77,0x18,0x14,0xb5,0x85,0x38,0xbe,0x35,0xf5,0x6,0xb3,0x6c, -0x70,0xbe,0x41,0x84,0xba,0xe1,0x93,0xb3,0xf0,0xc9,0x1,0xbf,0x5d,0x8e,0xe5,0x6b, -0xb5,0x94,0xcf,0x69,0xc7,0x48,0x56,0x37,0x85,0x55,0xc3,0x77,0xd8,0xe1,0xf8,0x88, -0x1e,0x9e,0xb1,0x54,0x8e,0x78,0xfd,0x4e,0x53,0xf4,0x42,0x2e,0xdf,0x67,0x6a,0x87, -0xab,0x75,0xb9,0xe5,0xcb,0xe6,0x78,0x3e,0xdc,0x34,0x7d,0x53,0xc1,0xea,0x90,0x2d, -0xdf,0x8,0x58,0xfd,0xdf,0x54,0xf0,0xf7,0xde,0x47,0xf6,0xf,0x29,0x66,0xe1,0xeb, -0x2a,0x54,0xf3,0x6d,0x68,0xbe,0xb6,0xf9,0xf3,0xfe,0xbe,0xd4,0x61,0xc7,0xc2,0xf8, -0xe7,0x86,0x2e,0xb8,0xa3,0x47,0xa9,0x2e,0xb4,0xc6,0xf,0xd9,0x6a,0x21,0xfb,0x84, -0xdd,0xcd,0x64,0x98,0xb1,0x7d,0x43,0x45,0x3d,0x91,0x8f,0xe8,0x25,0xcd,0x37,0x36, -0x7d,0x3,0xc1,0xf4,0x8d,0xcd,0x66,0xb9,0xc4,0xf7,0x8d,0xad,0x56,0x9b,0x5a,0x91, -0x61,0x7d,0xd6,0x5,0xd2,0xd6,0x23,0x46,0x39,0xb2,0xf,0xd3,0x5f,0xd2,0xc1,0xca, -0xec,0x8f,0xc3,0xd7,0x5e,0x89,0xf4,0xb9,0x94,0x85,0xaf,0x8b,0x8a,0xff,0x23,0x62, -0xfb,0xbd,0xa3,0x1f,0xc9,0x66,0x82,0xf6,0x1b,0x8,0x89,0x7d,0x2d,0x48,0xef,0xa9, -0x5d,0xa9,0x7e,0xfe,0xb1,0x6f,0xf3,0xf7,0x65,0xee,0xf9,0xe7,0xf3,0x45,0x3e,0xff, -0x9c,0x23,0x9a,0xfe,0xbb,0x24,0xba,0xf,0x10,0x99,0x5d,0xbf,0xff,0x99,0x5d,0xbf, -0x45,0xff,0xf5,0xab,0xfa,0xfa,0x46,0x4,0x3,0xd6,0xf,0x9e,0x71,0xfd,0xda,0x83, -0x90,0x8,0x12,0xfb,0xd6,0x1e,0x4c,0xbf,0xa2,0xf6,0x7f,0xda,0xad,0xe0,0xcd,0x6b, -0x2,0xac,0xe3,0xbd,0x3d,0x3c,0xdc,0x33,0x7d,0xac,0xec,0xb,0x1d,0xbe,0xb5,0xb2, -0xe5,0x73,0x54,0x85,0xad,0x6,0xb2,0x93,0x23,0xb1,0x7b,0x74,0xb1,0x6f,0xfd,0x97, -0x94,0x4c,0x5f,0x31,0xfa,0xf8,0x36,0x55,0x87,0x5b,0x4d,0xf0,0xcc,0x9a,0xd0,0x79, -0xfe,0xb4,0xd5,0x3a,0x1d,0x8e,0xb9,0x3e,0xdf,0x81,0xb,0xf7,0x39,0x5a,0xd7,0xf6, -0x11,0x68,0xfa,0x4,0xed,0xa4,0xbd,0xb4,0xdb,0x7e,0xa5,0x3c,0x7b,0xfc,0xbd,0x59, -0xd2,0x5,0x7f,0x48,0x84,0x47,0x2f,0x1d,0xb7,0x5a,0xc7,0xc3,0x69,0x31,0x3,0x9f, -0x63,0x7c,0x73,0xf8,0xcc,0xe3,0x7b,0x53,0xeb,0xa,0xb0,0xb0,0x3,0x94,0x68,0xf9, -0x45,0x13,0x14,0x88,0x0,0x5f,0xea,0xb6,0x5a,0x5d,0x2b,0x1f,0xa4,0xf2,0x1d,0x72, -0x7d,0xdb,0xfb,0xac,0x49,0xa2,0xfb,0xda,0x86,0x40,0xcd,0x57,0xf0,0x35,0xdd,0xc7, -0x4e,0xed,0x54,0x3e,0x47,0xbe,0x5a,0xbf,0x66,0xf9,0x2a,0xa6,0xf,0xea,0x3e,0x31, -0x92,0xcf,0x14,0xa8,0x3f,0x3,0xbe,0xd6,0x6c,0xb5,0x9a,0x94,0x4d,0xf5,0xa6,0xf2, -0xb9,0x4e,0x21,0xdf,0xf9,0xa7,0xfb,0x2e,0xed,0xb7,0xeb,0xd1,0x7d,0xda,0x3f,0xde, -0xa8,0xb5,0x5a,0x35,0xfb,0xdb,0xce,0xd5,0x37,0x2d,0x8,0x72,0x9c,0xf6,0xd3,0x7d, -0x97,0x5a,0xad,0x4b,0x72,0x29,0xe3,0xf6,0x73,0x1c,0x5f,0xe8,0x38,0xbe,0x40,0x20, -0x71,0x7d,0xf7,0x70,0xab,0x85,0x31,0xec,0x64,0xdc,0x7e,0x3b,0xbe,0xfe,0x4f,0xbb, -0x3e,0x60,0xc4,0xeb,0xc3,0xe1,0xd3,0xfb,0x67,0x8c,0x1e,0x65,0xeb,0x23,0x6b,0x76, -0x5f,0xb8,0xdf,0x2e,0xd3,0x75,0x7d,0xfc,0x50,0x50,0x6c,0x9f,0xf1,0xc1,0xa8,0x92, -0xad,0xef,0x8c,0x38,0x7c,0xeb,0x45,0xba,0x72,0x53,0xf7,0x61,0xb5,0x7f,0xae,0xe7, -0xc1,0x37,0x24,0xce,0xdc,0x55,0x24,0xee,0xdc,0x16,0xdf,0x37,0xc9,0xf8,0xfa,0x0, -0xdc,0xf6,0x8b,0x53,0x3f,0x70,0xfb,0x9e,0x4,0xf8,0x64,0xf4,0xeb,0x72,0xba,0xeb, -0x37,0x76,0x7e,0xe1,0xfa,0x7e,0x5f,0xe0,0xfb,0xd0,0xf7,0xbb,0x20,0x5d,0xff,0x97, -0x8d,0xf,0x6,0xb4,0x1f,0x7c,0xbf,0xb,0x53,0xfa,0x80,0xdd,0xbf,0x24,0xf6,0x5, -0xf6,0xcf,0xf0,0x49,0x32,0xdf,0xe7,0x6a,0xff,0x22,0xdc,0xbd,0x79,0x59,0xfd,0xd7, -0x6d,0xbb,0x7f,0x26,0xc5,0x4d,0x51,0x48,0xe2,0xb,0x1c,0xdf,0xa4,0x3f,0x4a,0xe6, -0xeb,0xa9,0xfd,0xf3,0xcd,0x6a,0x6f,0x62,0xfb,0xf4,0xf1,0x17,0xd5,0x76,0x68,0xa6, -0x3e,0xd8,0x78,0x31,0x91,0xaf,0xa5,0xe6,0xab,0x9b,0x95,0x91,0xe6,0xbb,0xe5,0xf0, -0x4d,0x94,0x56,0x7e,0x7c,0x2f,0x55,0x46,0xc4,0xe1,0xdb,0x56,0x7d,0x84,0x36,0xb3, -0xf5,0xa1,0xea,0x5b,0x89,0xae,0x5f,0x51,0xf7,0x49,0x6a,0x68,0x26,0xc0,0x6e,0x3f, -0x35,0x44,0x37,0xb2,0xf5,0x25,0xed,0xff,0x34,0xdf,0xab,0x15,0xf8,0x91,0x76,0x4d, -0xd8,0x3e,0xfa,0x11,0xfd,0xab,0x6c,0x7d,0x49,0xc7,0xf,0xd3,0x37,0xb1,0xfb,0x17, -0xed,0xfa,0xa5,0x13,0xfa,0xc3,0x7c,0xf8,0xb4,0xfb,0xf3,0x57,0x8d,0xeb,0xc3,0xd1, -0xff,0x65,0x7f,0x7d,0x24,0xf5,0x69,0x85,0x89,0xaa,0xd1,0xbf,0xb8,0xf2,0x55,0x84, -0xfe,0x45,0xae,0x45,0xf4,0x71,0xe6,0xb7,0xa2,0x8f,0x1f,0xea,0xa7,0x6a,0xf4,0xcf, -0x8e,0x7c,0x10,0xa9,0x7f,0x46,0x8d,0x85,0xf8,0x12,0xe7,0x2b,0x33,0x2a,0x43,0x3a, -0xbe,0x59,0x9a,0x6b,0xfb,0x25,0xcc,0x57,0x68,0xdb,0x14,0xa0,0x1e,0xc,0xf5,0xe9, -0x1f,0x85,0xfb,0x65,0xb7,0xef,0x50,0x19,0x87,0xfa,0xe2,0xe5,0x17,0x73,0xb2,0x53, -0xf5,0x8d,0x78,0xbe,0x43,0xdd,0x0,0x49,0x49,0x6f,0xb3,0x93,0x91,0xf7,0xcb,0xac, -0x88,0x21,0xca,0x77,0x4b,0xa6,0xaf,0x7f,0x16,0xba,0x92,0x36,0xb1,0xf,0xf2,0x7c, -0xfd,0xa9,0xfe,0x55,0xc5,0xf8,0x91,0xd2,0x6b,0xde,0x2f,0xb3,0x5,0x45,0x22,0x32, -0x6b,0x68,0x88,0x8a,0x6f,0x84,0xf9,0xd8,0xfd,0x9b,0x18,0xdf,0xc7,0x3b,0xff,0x44, -0x7d,0xe1,0x3,0xc4,0x13,0xe3,0x4f,0xfd,0xc4,0xfb,0xe5,0xa,0x6b,0x3f,0x68,0xd6, -0x20,0x55,0x9f,0x12,0xb2,0x5a,0xd4,0xba,0x3f,0x57,0x1b,0x50,0x51,0x3e,0xbc,0x59, -0x9c,0xe5,0x1b,0xaf,0x86,0xb6,0x9f,0x38,0x31,0x7c,0x46,0xc5,0x8,0x7e,0xec,0xfd, -0x32,0xb4,0x7c,0x34,0x92,0x8f,0xb2,0xfb,0x73,0xf5,0x4f,0x4f,0xcf,0x1a,0x3d,0x14, -0xb9,0x7f,0x9e,0xe1,0xd3,0xbf,0x11,0xf2,0x9e,0x7f,0xe2,0x67,0xb6,0x4f,0xb0,0x7c, -0xbc,0xd5,0xac,0xc8,0xed,0x2b,0x1b,0xbe,0x2e,0x9e,0xe5,0x3b,0xa5,0xa1,0xd7,0x87, -0x28,0x19,0x3e,0xf3,0xfb,0x7b,0xaf,0x5f,0x71,0x28,0x78,0x7d,0x50,0x54,0x94,0xa0, -0xcb,0xc2,0x31,0xbe,0xa9,0x3e,0xe5,0x8d,0x6,0x9e,0xe9,0x33,0xab,0x9c,0x41,0xfd, -0x8b,0xd8,0xf,0xf7,0x41,0x8e,0xaf,0xce,0xfb,0xa1,0x9b,0x3c,0xdf,0x87,0xb3,0x7d, -0x66,0xa9,0x2f,0xa8,0x7f,0x16,0xbf,0x2d,0x18,0xd7,0x47,0x80,0xaf,0x62,0xf9,0xfa, -0xe6,0x71,0xdc,0xe8,0x2b,0x9c,0x93,0xca,0x2a,0x46,0x8b,0xe,0xdf,0x4f,0xc4,0xaf, -0xcf,0xf6,0x19,0x7,0x18,0x6e,0xf3,0xc7,0xb7,0xbe,0xd1,0xff,0x29,0x12,0xe4,0xfa, -0xfa,0x56,0xfb,0x21,0x73,0xa8,0x47,0xf0,0x50,0x19,0xf8,0xaf,0xf,0x6b,0xa9,0x8e, -0xe0,0xf2,0x75,0x23,0xb7,0x5f,0x80,0xcf,0xea,0x9f,0x8b,0x5c,0xdf,0xe1,0xd8,0xea, -0x9f,0xd7,0x98,0x8f,0xfb,0x3,0xd9,0x9f,0xb3,0xf2,0xa9,0xee,0x8b,0x70,0x7d,0x98, -0xff,0x61,0x41,0xbe,0x4,0xe3,0x1b,0xf7,0xb3,0xc7,0xab,0x5f,0xf5,0x22,0xf4,0x2f, -0xc6,0x1f,0x18,0xf0,0x63,0x44,0x7c,0xdf,0x20,0x60,0x71,0x51,0x91,0x57,0xbf,0xea, -0x45,0xe8,0x9f,0x8d,0xf6,0x6b,0x67,0xe5,0x6b,0xaf,0xac,0x66,0x9b,0xaf,0x8c,0xf3, -0xaf,0xb3,0x4f,0xb3,0xf1,0x75,0x58,0x87,0x1a,0xa1,0xfd,0xa2,0xd5,0x37,0xf4,0xef, -0xd7,0xd9,0x98,0xb3,0x6f,0x3f,0x71,0x7d,0x68,0xcb,0xf4,0xc9,0xcf,0xe1,0xfd,0x4b, -0x68,0xf7,0x50,0x99,0x8b,0xef,0x30,0xa9,0xcf,0x18,0x3f,0x3a,0xdf,0xa4,0xe8,0x37, -0xa7,0x4d,0x38,0x4,0x7d,0xc7,0x12,0xe2,0x81,0x7a,0xae,0x68,0xdf,0x4c,0x3d,0x4b, -0x78,0x3e,0xf3,0xcb,0xda,0x49,0xbc,0xc2,0x4e,0xbb,0xa0,0xf3,0x4f,0x4e,0xea,0x33, -0xff,0x73,0xff,0xa5,0xe6,0x13,0xe0,0x81,0x28,0xbe,0x39,0x17,0x9f,0xbd,0x98,0x23, -0x51,0xfd,0x8f,0xfc,0x47,0x8a,0xce,0x8f,0x5,0x88,0x36,0xc4,0x74,0xed,0x17,0x9c, -0x4b,0x13,0xfa,0x8c,0xfe,0x85,0xfc,0x27,0x2a,0x9f,0x1f,0x7f,0x7,0xa2,0x96,0x88, -0xc2,0xc2,0x79,0xf2,0xe7,0x6c,0x36,0x53,0xe5,0xfb,0xe9,0xe7,0x94,0x7e,0xfd,0xc5, -0xe7,0x20,0x52,0xe6,0xe5,0x1b,0xa6,0xf3,0x49,0x2,0xed,0xbe,0x58,0xd3,0x7c,0x83, -0xf2,0x5c,0x7c,0xe9,0xee,0x8f,0xce,0x24,0x1,0xe9,0xbe,0x96,0x58,0x11,0xd3,0x5d, -0x1f,0x97,0xe6,0xe1,0x3b,0x81,0x65,0xd4,0x6d,0xaa,0xbe,0x66,0xdf,0xf1,0x24,0x47, -0x7e,0x7c,0xa7,0xb0,0x2c,0x3f,0xd7,0xdc,0x84,0x68,0xef,0x30,0x67,0x3e,0xe3,0xfe, -0xed,0x8,0x66,0x96,0xf,0x32,0xf6,0xd1,0x6c,0xf3,0xd5,0x6c,0x5f,0xcc,0xf5,0x43, -0xec,0x2f,0xcd,0xd5,0x7,0x3e,0xb5,0xd7,0xbb,0x24,0xf2,0xc1,0xd9,0xf5,0xb5,0x54, -0xbe,0xae,0xbd,0x62,0x3e,0x91,0x8f,0x66,0xe5,0xa3,0xa7,0x87,0x87,0xb4,0xed,0xed, -0xe2,0x61,0x63,0x84,0x63,0x75,0x92,0x91,0x7d,0x68,0x4f,0x5b,0x91,0x6,0xa7,0x65, -0xa4,0xaf,0x56,0xf3,0xfa,0xf6,0xf6,0xcc,0x5,0x6b,0xe2,0x98,0x2,0xdd,0x75,0xda, -0xef,0xfb,0x1f,0xa4,0x87,0x8d,0x98,0x1d,0x7b,0x64,0xdf,0xb0,0xa5,0x2f,0x3b,0xc1, -0x60,0xa8,0xdf,0xa9,0x78,0x7d,0xad,0x96,0xd9,0x72,0xea,0x8d,0xfa,0xb6,0xee,0x3a, -0xea,0xf7,0xfb,0x3e,0x1f,0xaa,0xce,0xcb,0x77,0xd0,0x6a,0x19,0xbe,0x83,0xbf,0xac, -0x72,0x7d,0x2d,0xcb,0xf7,0xf2,0x9f,0x69,0xae,0xd3,0x59,0x3e,0x54,0x58,0xa5,0x47, -0xf,0xba,0x30,0xa3,0xe3,0xcb,0x7c,0xe8,0xcf,0x1b,0x1c,0x9f,0xa2,0xd8,0xbe,0xfe, -0xbf,0x63,0xbe,0xb6,0xf7,0xfb,0x9c,0x23,0xfb,0x2f,0x4e,0x70,0x9d,0xf6,0x76,0x7e, -0x93,0x9d,0xef,0x81,0xe1,0x6b,0xbe,0x5b,0xe6,0xfa,0x1e,0x58,0x3e,0xa9,0x1d,0xd4, -0x7e,0xe7,0xc8,0xbe,0x3e,0x34,0x9f,0xb8,0xf3,0xdb,0xcc,0xdb,0xaf,0xc9,0x6b,0x3f, -0x8c,0x1d,0xed,0x27,0x5,0x1e,0x5f,0x5,0xdb,0xfd,0xcb,0x84,0x2e,0xd0,0x87,0x50, -0x34,0xdf,0xd4,0xee,0x9f,0x51,0xa9,0x4e,0xff,0x62,0xa7,0x5b,0x59,0x88,0xf,0x42, -0x8e,0xef,0x53,0x10,0xf6,0xa3,0xd1,0xd1,0x2a,0xfd,0xe1,0x83,0xec,0x7c,0x3f,0xd, -0xf3,0x1,0xf0,0x53,0xaf,0xef,0xf0,0xf0,0xef,0xc2,0x7d,0x58,0xa0,0x2d,0xb1,0xfb, -0x28,0xab,0xfe,0xf9,0xe7,0x9a,0x6f,0xfa,0x3c,0xdf,0xf7,0xe0,0xc1,0xcf,0x4d,0xdf, -0x18,0x19,0xbe,0x99,0xf3,0x33,0x93,0x4c,0x7d,0x59,0xd5,0xaf,0x7c,0xbe,0x4e,0x5e, -0x7d,0xa8,0x20,0xd0,0x3d,0x31,0xab,0xfe,0x39,0x7b,0x5f,0xb6,0xe3,0xdb,0x3f,0x4a, -0xdf,0xca,0x45,0xfb,0x5d,0xf8,0xbe,0x38,0xbe,0x76,0xce,0x7d,0xda,0xe3,0x83,0x39, -0xf6,0x11,0xad,0x4a,0x91,0x57,0xdf,0xda,0x1e,0x7d,0xac,0xad,0x2d,0xc8,0xab,0x4f, -0xbd,0x1,0xbb,0xa1,0x4d,0xd9,0xe5,0xd7,0x47,0x1e,0x6b,0x25,0x1b,0xfe,0xfc,0x8c, -0xf3,0xf9,0x23,0xa3,0x50,0xc5,0xfd,0x32,0x75,0x94,0x97,0x33,0xf6,0x75,0x15,0xfa, -0xa1,0xf6,0x4c,0x13,0x7f,0x7e,0xc6,0xf9,0xfc,0x96,0x51,0xed,0x12,0x78,0x5f,0x76, -0x3e,0xbf,0x95,0xb1,0x6f,0xa8,0xd0,0x9f,0x6a,0x3e,0x7e,0xd5,0xc9,0xf9,0xfc,0x9b, -0x51,0xe7,0x2a,0xf3,0xbe,0xec,0x7c,0xfe,0x2d,0x6b,0x1f,0x56,0x7d,0xe3,0x95,0xec, -0x3e,0x85,0x8c,0x8f,0x2f,0x2a,0xfe,0x54,0x9b,0xa3,0xc9,0xac,0xfd,0x68,0xc6,0xd7, -0x7,0x34,0x8e,0x6f,0x66,0xe7,0x5f,0xd6,0x3e,0x40,0x1f,0x6b,0x73,0x13,0x99,0x5d, -0xbf,0x19,0xfb,0xd6,0x1e,0xd0,0xc7,0x31,0x1e,0xd4,0x5d,0xd4,0x3e,0x6d,0xce,0xf1, -0x6d,0x5a,0xde,0xcc,0xb5,0x8f,0xc4,0xd8,0x58,0x77,0x19,0x3e,0xb6,0xfd,0x41,0x6e, -0x7d,0x6d,0x9a,0x6f,0x1f,0xbd,0xf0,0x5d,0xf8,0x2e,0x7c,0x17,0xbe,0xb,0xdf,0x85, -0xef,0xc2,0x77,0xe1,0xcb,0x81,0x6f,0xaa,0xdf,0xec,0xad,0xe6,0xdd,0x27,0x5f,0xdd, -0xc1,0x74,0x33,0xbf,0x3e,0x3c,0x7a,0x78,0x4a,0x6b,0x79,0xf4,0xe9,0xb7,0x7e,0x47, -0x78,0xf4,0xce,0x71,0x2b,0xdf,0x3e,0xdc,0xcd,0xa9,0x6f,0x5f,0xf7,0x7d,0x80,0xbb, -0xdf,0xcf,0x91,0x4f,0x2e,0x15,0x91,0xe9,0x6b,0xaa,0x3e,0xf9,0xea,0x7,0x78,0xf8, -0x5f,0x32,0xf3,0xd,0x56,0x56,0x84,0x74,0x3e,0x2c,0xa1,0xa1,0xc3,0x87,0x95,0x9f, -0xe1,0x21,0xce,0xcc,0xd7,0x9e,0xb9,0x30,0x69,0xa6,0x6f,0x84,0xf,0x3c,0xbe,0x6e, -0x76,0xbe,0xf4,0x1f,0x3c,0x32,0x9e,0x49,0x56,0x7d,0xef,0xe9,0xbe,0xc7,0xb8,0x5b, -0xcd,0xa7,0xef,0x6f,0xe4,0xb2,0xea,0xdb,0xc1,0xad,0xad,0x1c,0xf9,0xe4,0xab,0xb4, -0x6a,0xfa,0x30,0x2,0x47,0x59,0x8f,0x6f,0xe9,0xdb,0x4f,0x21,0xd6,0xf5,0xb,0x61, -0xd6,0xbe,0x5d,0xf8,0x6e,0xda,0xeb,0x43,0x39,0x5f,0x65,0xfd,0x1f,0x40,0x59,0xfb, -0x76,0x86,0xd,0x90,0x2,0x77,0xa2,0xfa,0x8,0x62,0xed,0x47,0x45,0x9c,0xb5,0x4f, -0x78,0xb5,0x91,0xe6,0x25,0x3e,0x3,0xd5,0x47,0x8b,0xf3,0xf4,0x1d,0xa7,0xf3,0xb9, -0x4b,0xfd,0xe5,0xec,0x7d,0xa3,0xb4,0xed,0xe7,0xcc,0x7,0xd9,0xb7,0xdf,0xdd,0xd7, -0xf2,0xed,0x13,0x6e,0xdb,0x3e,0x61,0x75,0x6d,0x90,0xce,0x97,0xfd,0xf5,0xeb,0xf0, -0x11,0x1,0xd7,0x81,0x90,0xc6,0xb7,0x9f,0x7d,0xff,0xb7,0x3,0xaf,0xb3,0xfe,0x45, -0x11,0x50,0x4d,0xfc,0x9f,0x5b,0x71,0x7d,0x6a,0xbe,0xda,0x60,0xfd,0x73,0xf6,0xe3, -0x87,0xa3,0x7f,0xc6,0x2,0xaa,0x8a,0xef,0x5d,0x8f,0xdd,0xbf,0x48,0xe6,0x3,0x27, -0xaa,0x4f,0x1d,0x7f,0xe7,0x37,0xbe,0x61,0x1,0x56,0xc4,0x46,0x35,0xb6,0x6f,0x84, -0x5,0x47,0xbe,0x9a,0x9f,0xf,0x9,0xf0,0x8f,0x13,0xf9,0x68,0xc1,0x91,0xef,0xe7, -0xe7,0x83,0x2,0x7c,0x2e,0x99,0xaf,0xb6,0x90,0xe3,0x3b,0x28,0x83,0x5a,0x2,0x9f, -0x9a,0xaf,0xf0,0xfc,0xae,0xf,0x57,0x5f,0x3,0xea,0xa0,0x1a,0xbf,0xfd,0x14,0xdb, -0x97,0x7d,0xff,0xe2,0xfc,0xd4,0xc0,0xda,0x0,0x25,0xf0,0xe1,0xda,0xfc,0xf2,0x55, -0xda,0x73,0x42,0xcf,0x57,0xd5,0xf9,0x8d,0x6f,0x19,0xf8,0x68,0x71,0x73,0xde,0xbe, -0x69,0x6e,0xf3,0x95,0xf1,0x31,0x9f,0xc5,0x5f,0x99,0xfd,0x50,0xa8,0xbf,0xfd,0xd8, -0xce,0xb4,0xf3,0x6c,0x3f,0xe3,0x59,0x7c,0x12,0xb8,0x3,0x75,0xe8,0xf1,0x45,0xf3, -0xf7,0x6d,0x9a,0x1,0x86,0xd2,0xb3,0xd8,0x3e,0x84,0x3b,0x73,0xcc,0x57,0x6,0xac, -0x94,0x8d,0x6f,0x63,0x4e,0xfd,0x9f,0xb9,0xaa,0x24,0xb5,0xf,0xcd,0x69,0xfc,0x18, -0xd3,0x8c,0x7c,0x73,0x1a,0x7f,0xd9,0x6a,0x2d,0x41,0x7f,0x2e,0x74,0xc5,0x7a,0x48, -0x34,0xae,0xf,0xce,0x29,0xbf,0xf8,0xda,0xcf,0x88,0xfc,0x8f,0x67,0x6c,0x79,0x64, -0xf8,0xc6,0xab,0x73,0xf7,0xf9,0xce,0x3f,0xc3,0xd7,0x4,0xe5,0x8,0x3e,0x4a,0x6d, -0xdf,0x9c,0x8e,0xaf,0xf9,0x6c,0xac,0xd7,0xd7,0x90,0xc4,0x78,0x3e,0x30,0xaf,0x7c, -0x55,0xf4,0xf4,0xcf,0xa6,0x8f,0xc6,0x3c,0xbe,0x60,0x5e,0xf9,0x6a,0x3f,0x85,0x8f, -0xa2,0x8e,0x7e,0x8,0x34,0xdf,0xbc,0xf2,0x95,0xf7,0xbb,0xc6,0xf2,0x75,0x34,0xdf, -0xb4,0x34,0xcf,0xf1,0x6d,0x9c,0xc6,0xa7,0xbf,0x3a,0x41,0x2e,0x2e,0x32,0x5f,0x99, -0x3e,0x18,0xc5,0x37,0x75,0xbc,0xfc,0xa2,0x3c,0xef,0x7c,0x2a,0x1b,0xef,0x1,0x64, -0xfd,0x4b,0x14,0x1f,0xa6,0xf3,0x6f,0x3f,0xfb,0x1e,0xdd,0xd8,0x15,0x2b,0x7e,0xff, -0x3c,0xdf,0xf3,0x8f,0xef,0x8b,0x5a,0x1f,0xb2,0xae,0x5f,0x3a,0xf7,0xfb,0x23,0x8c, -0x12,0xfa,0xa8,0x30,0x9f,0xfa,0x55,0x7a,0x9f,0xb2,0x65,0xf9,0x9a,0x73,0x9f,0xff, -0x90,0x8b,0xd0,0xf6,0xf1,0x97,0x93,0x17,0xbd,0xd7,0x47,0xc3,0xf2,0x89,0x73,0x19, -0x7f,0x15,0x65,0xcf,0xea,0xff,0xb0,0xb1,0xa7,0x23,0x64,0xc3,0xc9,0xac,0xe5,0xee, -0x5a,0xbe,0x6a,0x5a,0xbe,0x1f,0xcf,0x25,0xbf,0x28,0x4a,0xcb,0xda,0x5e,0x12,0x1b, -0x5d,0xa,0x64,0x71,0x81,0xf3,0x19,0x6,0xfb,0xde,0xe2,0xf9,0x48,0x9b,0xa4,0xf3, -0x11,0xbc,0x66,0x75,0x74,0xd8,0x90,0xc6,0xf2,0x61,0xfb,0xfc,0xe3,0x1d,0x5f,0x2, -0xee,0x27,0xf0,0x4d,0xbf,0x2a,0xd8,0x3e,0x1,0xd8,0xfd,0x4b,0x21,0x8d,0x8f,0x77, -0x7d,0x10,0xf0,0x66,0x3a,0x1f,0xad,0xda,0x3e,0x7b,0x7c,0x23,0xc1,0xbe,0x93,0xa3, -0x20,0x1f,0xaf,0x7f,0x21,0xe0,0x4e,0x86,0x3e,0xb2,0xba,0x3e,0x18,0x7c,0xab,0xa8, -0xd,0xab,0x81,0x3e,0xa9,0xc7,0xb9,0x3f,0x17,0x82,0xea,0x57,0xe9,0x7d,0x8f,0x9c, -0x3e,0x45,0x4,0x15,0x2,0x43,0x7d,0xa4,0xc7,0xa9,0x6f,0x8,0x41,0xe3,0x1b,0x69, -0x4b,0x69,0x7d,0xf6,0xf5,0x61,0xfb,0xce,0xa3,0xfa,0xcc,0x4f,0xb0,0xf,0xf4,0x53, -0xfa,0x80,0xdd,0xbf,0xe8,0x3e,0x38,0xc3,0x77,0xc6,0xf3,0x5,0xe6,0x2b,0x9,0xe8, -0x9b,0xb3,0xa4,0xf1,0xd9,0xfd,0xb3,0xea,0x5b,0x3f,0x1a,0x68,0x5b,0x89,0x4f,0xe8, -0x53,0xb1,0xda,0x2f,0xb0,0x3e,0x24,0x1,0x92,0xb2,0xfd,0x5c,0x47,0x63,0x55,0x9c, -0xea,0xc7,0x77,0xbc,0x76,0x9e,0x8d,0xef,0x24,0x5b,0x9f,0x9a,0x99,0x75,0x1f,0x51, -0xa6,0x2,0x29,0xac,0x6e,0x7e,0xc9,0xac,0x8,0xa2,0xbb,0xe5,0x6b,0x5f,0xde,0x85, -0x5,0xdf,0xf5,0xeb,0xf4,0x65,0x97,0xaf,0x2,0x7d,0x48,0xbb,0x3e,0xf6,0xb5,0x5e, -0x9b,0x8,0x6a,0xcf,0x5d,0x63,0xd7,0xb6,0xd4,0xec,0xc3,0x5e,0xff,0x0,0xfa,0xfa, -0x3f,0x87,0x6f,0x2f,0xbb,0x7c,0x15,0xe8,0xc3,0x9a,0x4f,0x9b,0xf0,0x43,0x5e,0xdf, -0x8,0x99,0x3e,0x6f,0xfe,0xa3,0x73,0xb8,0x3f,0xf,0xf4,0x29,0x6a,0xff,0x7c,0xf3, -0x92,0xe5,0x13,0x98,0xaf,0xdf,0x1c,0xd1,0x9d,0xfe,0x1,0xf0,0xfb,0x88,0xe5,0xe3, -0xe6,0x2b,0x73,0x77,0xa7,0x88,0x3e,0x2b,0x34,0x7d,0x95,0x13,0x9d,0x4,0xb6,0xa, -0x52,0xcf,0x51,0x44,0x3f,0xff,0x56,0x4d,0x5f,0xaf,0xab,0xfa,0x76,0x9b,0x40,0x2f, -0x89,0x97,0x9c,0xbe,0xa9,0xe5,0xdb,0xe4,0xe5,0x97,0x98,0xbe,0xb0,0xf6,0xb3,0x7e, -0x8b,0xb5,0x1f,0x14,0xac,0xec,0xf0,0xe9,0xd7,0x55,0x1f,0xd8,0xe0,0xb4,0xdf,0xd8, -0xf2,0x35,0x17,0xe5,0x63,0xe7,0x1f,0xb2,0xcf,0x3f,0xb5,0xfd,0xd0,0x1a,0x68,0x8a, -0x7e,0xdf,0x91,0xe5,0xc3,0xbc,0xe3,0x6b,0xee,0xce,0x96,0xa9,0x4f,0xfb,0x9e,0xd8, -0xed,0xeb,0x1e,0xf7,0xe1,0x1a,0xa8,0x73,0x7c,0xfb,0xb6,0x8f,0x77,0x7d,0xcc,0xc3, -0xa7,0xc7,0x6a,0xb5,0xff,0xc3,0xf6,0xf9,0x77,0xfc,0x59,0xb9,0x54,0x37,0x7c,0x27, -0xc8,0xe5,0xb3,0xe7,0x3f,0xb8,0xf9,0x6a,0x5f,0xfb,0x99,0x73,0xf0,0x11,0xf7,0xf8, -0xa1,0x45,0x56,0xc5,0xcc,0x57,0x5a,0x13,0xb6,0xb1,0x6c,0xf8,0x8c,0xe2,0xa1,0x7e, -0xff,0xeb,0xca,0x57,0x1b,0x87,0x10,0x18,0xbe,0xe9,0x5c,0x7c,0x9e,0xf1,0x57,0x6b, -0x33,0x6c,0x8e,0x6f,0xda,0x7a,0x49,0xf0,0x86,0xb6,0xed,0xe6,0x80,0x15,0x5f,0xfd, -0xf5,0x83,0x7a,0xdf,0x28,0xdf,0xec,0xab,0x51,0x63,0x2e,0xbe,0xe0,0x7c,0x85,0x74, -0x1f,0x34,0xeb,0x1b,0xe6,0x8d,0xa9,0xcf,0x67,0xee,0x14,0x3e,0xaf,0xe3,0x1b,0x92, -0xaf,0xdc,0xbe,0x80,0xf9,0x41,0xc1,0xd8,0x28,0x3e,0x91,0x4f,0x11,0xd2,0xb7,0xdf, -0xed,0xcf,0xc2,0xdb,0x6f,0x4b,0x1c,0x59,0xbe,0x8d,0xc5,0xfb,0xda,0xd2,0x30,0xfc, -0xfc,0x3b,0x11,0xff,0x9f,0xe5,0xab,0xc7,0xf4,0x91,0x95,0xd8,0x3e,0x35,0x5f,0x95, -0xbe,0xbe,0xb,0xb7,0xb4,0xeb,0x57,0x6f,0xbf,0x76,0xc5,0xf0,0x19,0x93,0x77,0xfe, -0xfa,0x95,0x62,0xee,0xf4,0xaf,0xfa,0xd4,0x4f,0xcc,0xf3,0x4f,0x6d,0xbf,0xd7,0x57, -0x63,0xf9,0xd4,0x7c,0x25,0x8d,0xfa,0x7,0x55,0xd6,0xff,0x1,0x60,0xfa,0xcc,0xc9, -0x4f,0xed,0xfe,0x3,0x39,0xfb,0x3f,0xfd,0xfa,0x38,0xd2,0x7d,0xa,0x5d,0x8b,0x7b, -0x7d,0x98,0x9d,0x85,0xfe,0x29,0xa0,0x48,0xbe,0xd1,0x44,0xe9,0x1f,0x8,0x6c,0xfc, -0x0,0xe2,0x23,0xc1,0x39,0xbe,0x69,0xbe,0xa1,0x73,0xfc,0xd0,0xfb,0x97,0x5d,0x7d, -0xfc,0xc0,0x74,0x27,0xa6,0xef,0x81,0x63,0xe1,0x3d,0xc1,0xc3,0x8,0x3e,0x35,0x5f, -0x91,0x87,0xfd,0x83,0xef,0xda,0xbe,0x77,0x5d,0xf9,0x40,0xf7,0x39,0xc7,0x5f,0xbd, -0x7f,0x5e,0x4f,0xe8,0x5b,0x73,0xd5,0x87,0xe,0x22,0xf8,0xd4,0x7c,0x40,0x6e,0xef, -0x36,0xaf,0x7b,0x96,0x1c,0x68,0x97,0x6,0x42,0xc5,0x3d,0xdd,0x77,0xe0,0xc8,0x2f, -0xce,0xea,0xd7,0x6a,0x4a,0x5f,0x94,0xe3,0xab,0xe6,0x2b,0x22,0x81,0x8d,0x2a,0x27, -0x3f,0xa3,0x9,0x6a,0xf9,0x7c,0xc6,0x27,0x9b,0xf6,0x43,0xd1,0xda,0x6f,0x22,0x81, -0x26,0xcf,0x87,0x47,0x78,0x4d,0xf7,0x35,0x7c,0xf9,0x2a,0xe9,0xf9,0xd7,0xd2,0xde, -0xf5,0x19,0xcb,0xa7,0xe6,0x2b,0x49,0x2,0x75,0xbe,0x4f,0xfd,0x9b,0x9a,0x6f,0xc3, -0x97,0xaf,0xf4,0xeb,0x97,0xc6,0xbf,0x7e,0xd5,0x84,0xce,0xd6,0x5d,0x44,0xf4,0x69, -0xf9,0xea,0x2a,0xa8,0x6f,0x71,0xee,0xdf,0x94,0x9e,0xe9,0x43,0xbe,0x7c,0x85,0x74, -0x5f,0xfc,0xfe,0x4f,0xfb,0xab,0xac,0x83,0x51,0x8e,0xa3,0xf8,0x9c,0xf9,0xaa,0xa7, -0xe7,0xab,0xb1,0xe0,0xf3,0xf9,0xee,0x7f,0xd,0x5f,0xec,0xf1,0xc3,0xe5,0x23,0xa7, -0x51,0x7c,0xce,0x7c,0xa5,0x18,0xf9,0x8a,0xb5,0x1f,0x69,0x99,0x3e,0x7f,0xfd,0xc0, -0xf4,0xc5,0x1d,0x7f,0xc9,0x1f,0x3a,0x7c,0xf4,0x9f,0x45,0xf1,0x39,0xc7,0x5f,0xc5, -0x99,0x5f,0x34,0x9f,0x79,0x7d,0x4,0xfa,0x62,0xe7,0x97,0xbe,0xd3,0x17,0x3b,0x5f, -0x61,0xdd,0x37,0xb0,0xee,0xcf,0xd7,0xd4,0xfe,0x85,0x5f,0xbf,0x4a,0xe1,0xc3,0x28, -0x71,0x7e,0xd1,0x7d,0xb7,0x21,0x3b,0xff,0xa8,0xa0,0xf6,0xcf,0x34,0xeb,0xf6,0x9b, -0x16,0x53,0xe6,0x2b,0x2a,0xcc,0xae,0x5f,0xa5,0xf0,0xd1,0xf8,0xf9,0xea,0xcb,0xbb, -0x70,0x53,0xbb,0x7e,0xa1,0x9e,0xaf,0x4,0x61,0x76,0xfd,0x2a,0xa1,0x4f,0xbb,0x3e, -0x62,0xfa,0xb4,0xfa,0x55,0xbd,0x7f,0xa0,0xdf,0x5f,0xee,0xba,0xf2,0x95,0xed,0xdb, -0xf,0xe8,0xff,0x12,0xdc,0x7f,0x24,0xf0,0x79,0xf3,0xd5,0x3b,0xd4,0x5c,0xdf,0xbe, -0x56,0x64,0xf7,0xbf,0xbe,0xf1,0x23,0x1b,0x9f,0x3c,0x58,0x29,0x94,0x22,0xe4,0xab, -0x6b,0xfd,0x83,0xa2,0x2f,0x5f,0x61,0x69,0x27,0xb8,0xbe,0x81,0x92,0xd6,0x5f,0x62, -0xfb,0xb4,0x7c,0x25,0xed,0xaa,0xf9,0xc0,0x9b,0xaf,0xb0,0xd4,0xb2,0x7c,0xbe,0xfc, -0x12,0xc7,0x37,0x2e,0xa7,0xf1,0x69,0xf5,0x2b,0x35,0x5f,0x21,0x5f,0x3e,0xc0,0xd2, -0xe3,0x92,0xe9,0x1b,0xa6,0xf2,0xe9,0xe5,0x6,0xc3,0x37,0x75,0xff,0x69,0xf9,0x88, -0xee,0x47,0x68,0x3f,0xa4,0xe6,0x2b,0x8e,0x6f,0x64,0xbc,0x86,0x2c,0xe8,0xf8,0x46, -0xae,0x9f,0x2,0x68,0x5f,0xbf,0x34,0xb6,0x2f,0x30,0x5f,0xc9,0x57,0x1,0xc,0xac, -0x5f,0xc5,0xf3,0x95,0xed,0xfb,0x37,0x57,0xa5,0x4a,0xf3,0x5d,0x11,0xdc,0xbf,0x3b, -0x16,0x22,0xe6,0x2b,0x6c,0xce,0xb9,0x73,0xeb,0x57,0x49,0x7d,0xae,0xcf,0x99,0xe6, -0xfb,0xba,0xe8,0xf6,0x91,0x99,0xf9,0x8a,0x98,0x3e,0x3c,0x62,0xbe,0x7d,0x5e,0xff, -0x3c,0x7e,0xae,0xae,0x6d,0x53,0x9f,0xc2,0xf7,0x44,0x3f,0xbe,0x33,0x7c,0xfe,0x7c, -0x35,0x35,0x7d,0xe8,0x9,0x8,0x1b,0xdf,0x50,0xf7,0x79,0xba,0x9d,0xca,0xa7,0xf0, -0x7c,0xca,0xcc,0x7c,0x75,0xce,0x7c,0x93,0x52,0xb8,0xef,0xa5,0xda,0xad,0x28,0xbe, -0x76,0x31,0xd4,0x27,0x44,0xf6,0x9d,0x9d,0xea,0x3e,0xed,0x3d,0x8b,0xb3,0xd6,0xb7, -0x1b,0xbe,0x6,0x88,0x36,0xff,0xe1,0xf0,0x9d,0xa7,0xf0,0x19,0xed,0x77,0x7b,0x42, -0x23,0xe5,0x17,0xd4,0x7d,0x2d,0xa1,0x6f,0x8c,0x1c,0xbe,0x6b,0x9e,0xab,0x1a,0xcf, -0xf0,0xb5,0x25,0x29,0x9a,0x6f,0xfc,0xdc,0x6b,0x1d,0x10,0xfb,0xf8,0x4e,0x2f,0xa9, -0x97,0x64,0xd5,0xe1,0xbb,0xca,0xf1,0x29,0xe3,0xa7,0xad,0xe,0x43,0xcb,0x57,0xdd, -0x5d,0x8,0xd9,0xf5,0xb,0xda,0x2f,0xd3,0x48,0xf9,0xa,0xe1,0x37,0xa2,0xf9,0xa8, -0xb6,0x1c,0x97,0x6d,0x40,0xa8,0x39,0x61,0xc3,0xe1,0xfb,0x5a,0xd9,0xfd,0xa,0x19, -0xcd,0x47,0xe0,0x9b,0xb0,0xe7,0xc8,0x57,0x3f,0xec,0x1f,0x74,0x58,0xff,0x7,0xc0, -0xb7,0xa3,0xe5,0x2b,0xd5,0x17,0xf1,0xf8,0x6a,0x6f,0x48,0x95,0x1d,0x6,0x78,0xe0, -0x1e,0x3f,0xa6,0x25,0xcf,0xf8,0xa1,0xf9,0x14,0x3b,0x5f,0x21,0xd3,0x67,0xe6,0x97, -0x1d,0x96,0xaf,0x4,0x10,0x96,0xaf,0x10,0xbe,0x17,0xcd,0x37,0xd5,0xce,0x3f,0x6b, -0x3,0xcc,0x55,0xd5,0x37,0x74,0xfb,0xe4,0xa2,0x77,0x7c,0xbb,0x65,0xfb,0xb4,0xf9, -0xc1,0x97,0xfb,0x7,0x8f,0x7c,0x3e,0x2c,0x89,0xdb,0x61,0xe3,0x2f,0xc2,0xf5,0x5a, -0x24,0xdf,0x29,0x75,0xbc,0x1c,0x50,0x3b,0xc7,0xd5,0xfb,0x5e,0xb3,0xca,0xa4,0xfa, -0xb8,0xd3,0x85,0x62,0xb5,0x82,0xed,0x7c,0x40,0x5f,0xde,0x6d,0x3e,0xe2,0xe4,0x2b, -0xf1,0x56,0x58,0xbe,0x8a,0x3c,0xbe,0x41,0x67,0xfb,0x11,0xc5,0x11,0x14,0x82,0xdb, -0xef,0x75,0xcb,0xa7,0xd5,0xaf,0xfa,0x60,0xa3,0xc2,0xc9,0x57,0x3b,0xec,0xf8,0x22, -0x9e,0x8f,0xb4,0xf5,0x2d,0x42,0x23,0x5e,0xbf,0xec,0xfc,0xe3,0xf9,0x38,0xe7,0x5f, -0xb5,0x82,0x1c,0xf5,0xab,0xcb,0xa0,0x59,0xe0,0xe4,0xab,0xbe,0xe5,0xe3,0x1d,0x5f, -0x2,0xaa,0xd1,0xda,0x4f,0xef,0xff,0xac,0xd,0x44,0x6b,0xda,0x62,0x35,0xb7,0xcf, -0xf3,0xa,0x28,0xcd,0x57,0x79,0x4,0xed,0x7c,0x5,0xfb,0xa0,0xe,0x39,0xf9,0xaa, -0xc7,0x7c,0x90,0x77,0x7d,0x10,0x50,0x89,0xe1,0x23,0x56,0x79,0xb3,0xac,0xbd,0xb8, -0xd4,0xe5,0xf3,0xde,0xa,0x8,0xa,0xaa,0xfc,0xe8,0x5,0x47,0xbe,0xea,0x19,0xbe, -0x13,0xec,0xce,0x57,0x5f,0x66,0x3e,0xc0,0xeb,0x5f,0x8,0x78,0x25,0x9a,0x6f,0x52, -0xf6,0x8c,0xbf,0x10,0xcd,0xf0,0x5,0xe5,0xab,0x53,0xa3,0x7e,0xc5,0xf2,0xd5,0x67, -0xec,0xfe,0x6d,0x83,0xd7,0x3f,0x13,0xfd,0x46,0x34,0x82,0x4f,0x2,0x69,0x7c,0xce, -0x7c,0x65,0xe4,0x3,0xb3,0xbe,0x81,0x11,0xa,0xcd,0x57,0xa4,0x4d,0xa3,0xf9,0xfa, -0xce,0x7c,0x35,0xfd,0xd7,0x31,0x7d,0xce,0xf1,0xf7,0x38,0x96,0xf,0x24,0xf1,0xe1, -0x56,0x72,0xdf,0x99,0xe1,0xd3,0xeb,0x2f,0xb3,0xf3,0x95,0x4,0x60,0x34,0x1f,0xf0, -0xfa,0x66,0x5e,0x1f,0x41,0xed,0xd7,0xd5,0xf3,0x95,0x1c,0x2d,0xbf,0x48,0x20,0xe2, -0xfa,0x3a,0x9f,0x4f,0x2e,0x25,0xf4,0xed,0xc6,0xa9,0x5f,0x9d,0x80,0x71,0x42,0x9f, -0xb7,0x7f,0xe,0xbf,0x3e,0x1c,0xf3,0x83,0x38,0x4e,0xfd,0x2a,0xfa,0xf8,0x6,0xa8, -0xfb,0xfa,0xe0,0xfb,0x84,0xc0,0xfa,0x95,0x35,0x3f,0x88,0x3,0xea,0x57,0x30,0xd5, -0xfd,0x25,0xaf,0xbe,0xc1,0xf1,0x55,0x3,0xeb,0x57,0x48,0xf5,0x21,0xdf,0xfc,0xa0, -0x9a,0xaf,0xd8,0xfd,0x51,0x27,0xd5,0xfd,0x39,0xaf,0x72,0x40,0x5c,0xf5,0x97,0x30, -0x9f,0x96,0xaf,0x24,0x97,0xcf,0xae,0x5f,0xb1,0xfb,0xdf,0x47,0x99,0xd7,0xaf,0xa2, -0xfb,0xb4,0x7c,0xf5,0x70,0xb7,0xd9,0x9,0xab,0x5f,0xc1,0x54,0xf5,0xa1,0x74,0xbe, -0x90,0xfa,0xd5,0x3c,0x7c,0xf2,0xa5,0xa0,0x72,0x60,0x35,0x7e,0xfd,0x8a,0x9d,0x7f, -0x90,0x77,0x7c,0x93,0xd5,0x4f,0x15,0x2a,0x7f,0x83,0xef,0xb3,0xf6,0x3b,0x8b,0x5c, -0xbf,0xfa,0x14,0x86,0xe5,0xab,0x64,0x3e,0x12,0xe8,0x63,0xd,0x1c,0x32,0x3f,0x78, -0xe8,0xce,0x57,0x4f,0xc3,0xb0,0xfe,0x25,0xd9,0xfa,0x1c,0xea,0xf0,0x89,0x57,0x15, -0xd1,0xf7,0x7,0x91,0x10,0x9c,0xaf,0xa0,0x3b,0x5f,0x59,0xf5,0x2b,0xc8,0x9f,0x5f, -0x98,0xa6,0xf4,0xdd,0xfc,0xfc,0xcc,0xe1,0x33,0x5f,0x78,0xe0,0xf5,0x39,0xf3,0x15, -0x70,0xe7,0x97,0x27,0x30,0x7c,0x7e,0xe6,0x3c,0x9d,0x8f,0xb4,0xa6,0x67,0x7f,0x61, -0x2f,0x36,0x1,0xfc,0xf6,0x73,0x8e,0xbf,0x7b,0x6e,0x5f,0x78,0xfd,0x2a,0xfd,0xf1, -0x6d,0x29,0x6f,0xfc,0x10,0x79,0x7d,0xf2,0x8c,0xf5,0xed,0x91,0xf3,0x55,0x6,0xbe, -0xab,0x6f,0xb4,0xec,0x27,0xb6,0x3a,0xb3,0xdb,0xcf,0xa8,0x5f,0x45,0x9e,0x7f,0x8b, -0xbf,0xfe,0xca,0xed,0x7b,0x3c,0xfa,0x89,0xc3,0x17,0x70,0xfe,0xf9,0xeb,0x57,0x84, -0x46,0xf6,0xd5,0xd3,0xb5,0x9f,0xea,0x3,0xbc,0xf3,0x4f,0xab,0x5f,0x21,0x4e,0xbe, -0x32,0xea,0x57,0x75,0x1a,0x71,0x7e,0x90,0x24,0x5a,0x7f,0xa0,0xfb,0xf4,0xdb,0x61, -0xae,0x4f,0x36,0xeb,0x43,0x43,0x4e,0xbe,0x32,0xea,0x57,0x35,0xbf,0x2f,0xa0,0xff, -0x4b,0xb4,0xfe,0x4a,0xf7,0xe9,0xe5,0x84,0xd6,0xa8,0xd7,0x12,0x5d,0x1d,0x9d,0xa3, -0x7e,0x75,0x10,0x98,0xaf,0x1a,0x7e,0x5f,0xc0,0xf8,0x11,0x7f,0xfd,0xb,0xf3,0xe9, -0xe5,0x98,0x9d,0xab,0xbd,0x96,0xdd,0xbf,0xb4,0xcb,0xae,0xfa,0x15,0xa,0xcc,0x57, -0x3f,0xf2,0x5f,0x1f,0x1,0xe3,0x6f,0x1c,0x9f,0xdd,0x19,0x7c,0x63,0xd6,0x8b,0x71, -0xf4,0xfa,0x95,0xa3,0xfe,0x42,0xfb,0xbb,0x4d,0xe8,0x5f,0x7f,0xe5,0xf0,0xf9,0xf2, -0xcb,0x38,0xee,0xfa,0x2b,0xca,0x69,0xbf,0xa0,0xff,0x14,0xbd,0x7e,0x85,0x1c,0xf9, -0xaa,0xf,0x36,0x42,0x9f,0x5f,0xa0,0xbc,0xf5,0xed,0xf1,0xda,0x8f,0x72,0xce,0xbf, -0x40,0x9f,0xa7,0x7e,0x85,0x76,0x40,0x13,0x2c,0xd6,0x37,0x15,0xc2,0x7d,0x95,0x47, -0xc8,0x51,0xbf,0xe2,0xaf,0x6f,0x9f,0xed,0x8b,0x71,0xfd,0x7a,0x7c,0x9e,0xcf,0xdf, -0x95,0x5c,0xf9,0x4f,0xab,0x5f,0x55,0xed,0x7c,0x75,0xed,0x69,0x50,0x2f,0x84,0x3d, -0x3f,0x13,0xe4,0x8b,0xd1,0xff,0x85,0xfb,0xb4,0x99,0x5c,0x71,0x76,0xfd,0xca,0x98, -0x1f,0x54,0x22,0xfb,0x62,0x8c,0x1f,0xb3,0x7d,0x60,0x76,0xfd,0xca,0xc8,0x57,0x67, -0xd1,0x7d,0x1b,0x19,0xfa,0x22,0xd4,0x37,0x7e,0xa5,0xfb,0x9e,0x78,0x7c,0x1,0xfb, -0xb7,0xc7,0xcb,0xf7,0xe1,0x3e,0x10,0xc9,0x77,0xf6,0xb1,0xee,0x53,0x16,0xef,0x1b, -0x6e,0x47,0x6a,0x3f,0x3d,0x1f,0xdc,0x9e,0xbf,0xcf,0x78,0x43,0xfc,0x9e,0x67,0xa5, -0x98,0x18,0xc9,0xd7,0x96,0x3c,0xbe,0xa0,0x4f,0xa,0x9f,0xf1,0x86,0xf8,0xd6,0xe9, -0x30,0x68,0xfc,0xf0,0xd4,0xaf,0x9a,0xbb,0x10,0x4,0xe6,0x2b,0xfa,0x79,0xb1,0x98, -0xb9,0x4f,0x7b,0x43,0xfc,0xda,0xf1,0x81,0x85,0x10,0x3,0x7d,0xda,0xfc,0xe0,0xf3, -0xfd,0x83,0x6d,0x3b,0x5f,0x79,0x7d,0xa3,0x9,0xca,0xd2,0xa7,0xf5,0x69,0xfa,0x1b, -0xe2,0x5,0xfb,0xf8,0x42,0x10,0xe2,0x1b,0x4d,0x5a,0xfd,0x83,0x5b,0x76,0x7e,0x69, -0x2d,0xc2,0x27,0xb5,0x9d,0x3e,0xed,0xfa,0x5d,0x17,0x2,0xeb,0x57,0xce,0xe7,0x7, -0x39,0x3e,0xc4,0xf5,0xc5,0xab,0xbf,0xf8,0x7c,0xc0,0xeb,0x13,0xc4,0xc0,0xfa,0x95, -0xf5,0xfc,0x20,0x2f,0x5f,0x65,0xec,0x93,0x4b,0x2e,0x9f,0x5c,0x9a,0xe1,0xb,0x7e, -0x7e,0xd0,0xbe,0x3e,0x60,0x86,0x3e,0x4,0x99,0x6f,0x4d,0xf3,0x21,0x38,0xbb,0xfd, -0xc2,0xf3,0x15,0x1d,0x51,0x10,0xf2,0xf3,0xe2,0xfa,0xb4,0xe0,0xae,0xf9,0x7e,0x50, -0x6c,0x69,0x3e,0x23,0xc7,0x43,0xf0,0x83,0x62,0x80,0x4f,0xcb,0x57,0x3b,0xa0,0x1e, -0xec,0x23,0xa3,0xd0,0xed,0x8a,0xe2,0xfb,0xb6,0xa9,0xf6,0x86,0xf8,0x1f,0x14,0xf7, -0xc,0xdf,0xb6,0x5e,0xa2,0xfe,0x41,0xd1,0xb8,0x3e,0xa6,0x77,0x39,0xf5,0xab,0x96, -0xe1,0xd3,0xd7,0x77,0xf2,0x7c,0x42,0xc6,0x3e,0xed,0xf3,0x83,0x22,0xef,0x97,0x14, -0x37,0x42,0xea,0x57,0xd8,0x59,0xbf,0xb2,0x3e,0x57,0x9,0xf7,0x95,0x99,0x91,0xd7, -0x5f,0xc5,0xf2,0xd1,0x46,0x48,0xfd,0xa,0x3b,0xeb,0x43,0x33,0x4f,0xf4,0xa8,0xeb, -0xaf,0xd2,0xf9,0x9c,0xe3,0x2f,0x8a,0xe7,0x8b,0xb8,0xfe,0xca,0xfd,0x19,0x14,0x5c, -0x20,0xcf,0x2f,0x29,0xbd,0x23,0xcc,0x7c,0x7e,0x30,0xb2,0xaf,0x1,0x92,0xec,0xff, -0xe2,0x1,0x79,0x7e,0x79,0x6f,0x56,0xfb,0xdd,0x8e,0xec,0x7b,0x6d,0xe,0x3e,0x42, -0x43,0x7c,0x7a,0x7d,0x57,0x8a,0xe8,0x8b,0xbc,0xfe,0x2a,0xd6,0xf1,0x55,0xf4,0xfa, -0xda,0xe3,0xcb,0x4f,0x15,0x39,0xf5,0x2b,0x63,0x7d,0x7b,0x25,0x62,0xfb,0x45,0x5e, -0x7f,0xe5,0xb9,0x40,0xdc,0x20,0xcf,0x2f,0xe5,0x67,0xb4,0xfe,0xef,0xa5,0x9,0xa1, -0x9c,0xfa,0x95,0xee,0x3,0xd1,0x7d,0x89,0x8e,0xef,0xb6,0x1b,0xe4,0xf9,0xa5,0x31, -0x7e,0xb8,0x7c,0xa3,0x89,0xe9,0x33,0xf3,0xcb,0xa3,0xa8,0xbe,0x7b,0x49,0x7c,0x44, -0x70,0x81,0x3c,0xbf,0xf4,0xfb,0xb4,0xf5,0xed,0x92,0xcb,0xf7,0x6e,0xb4,0xfb,0x8f, -0xc8,0xeb,0xaf,0xdc,0x9f,0x33,0xba,0xae,0x7f,0xc3,0x2f,0x19,0x9b,0x6e,0xb9,0x7f, -0x69,0xd6,0xaf,0xc8,0xe7,0x97,0x9f,0x2a,0xd9,0xf9,0x80,0xbf,0xbe,0xdd,0xe3,0xcb, -0xea,0xfd,0x5b,0xc8,0x75,0xc1,0x42,0x44,0x39,0xed,0x47,0x9e,0xee,0x13,0x47,0xbe, -0xa,0x7a,0x7e,0xd0,0xe5,0xf3,0xbd,0x7f,0x8b,0xb4,0xe5,0x24,0x3e,0xf7,0x5,0xb, -0x7d,0xfd,0xb3,0xee,0x1b,0x49,0xc4,0x91,0xaf,0x82,0x9e,0x1f,0x74,0xd5,0xf,0x7c, -0xef,0xdf,0x22,0xa0,0x2a,0xd0,0xb4,0xfd,0x1f,0xa4,0xbc,0xf6,0x53,0x9e,0xd8,0xbe, -0x90,0xe7,0x7,0xbd,0x3e,0xf7,0xfb,0xb7,0x62,0xac,0xbf,0x8a,0xe1,0x9b,0xbe,0xae, -0xd5,0xef,0x9f,0x4c,0x9e,0x72,0xe6,0x2b,0x73,0x7e,0x30,0xd0,0xc7,0x7d,0xff,0x56, -0x42,0x1f,0x2e,0xb9,0x7c,0xee,0x5f,0xaa,0x5f,0xde,0x9,0xae,0x5f,0xb9,0x7d,0x72, -0x69,0xad,0x64,0xfa,0xb8,0xef,0xdf,0x22,0xe0,0x3f,0x24,0xba,0x3e,0x2a,0xee,0xeb, -0xa3,0xe2,0x39,0xbe,0x3b,0xc1,0xf5,0x2b,0xb7,0xf,0x4b,0x2d,0xe8,0xf0,0xf9,0xde, -0xbf,0x45,0xda,0xc3,0x24,0xe7,0x1f,0xac,0xba,0x7c,0xee,0x5f,0x52,0xed,0x9,0xd7, -0x88,0xfb,0xaf,0x71,0x7c,0xae,0xf7,0x6f,0x91,0xa8,0xeb,0x9b,0xe2,0xf9,0xea,0xd1, -0x7d,0x22,0xf3,0x71,0xdf,0xbf,0x25,0x25,0xf4,0x21,0xb7,0xf,0x25,0xf6,0x8d,0x0, -0x3b,0xff,0xb8,0xef,0xdf,0x9a,0x8f,0x8f,0xe0,0xa8,0xbe,0xd0,0xe7,0x67,0x68,0x8c, -0xf5,0x57,0x7c,0xdf,0x4a,0x11,0x43,0x8e,0x4f,0xd1,0x7d,0x8d,0x4f,0xd7,0xca,0x33, -0xdb,0x2f,0xec,0xf9,0x99,0x14,0xe3,0x9b,0x71,0xb3,0x4f,0xbe,0x64,0xf8,0xcc,0x5f, -0xda,0xf9,0xea,0x39,0xcd,0xf7,0xc7,0xdd,0x16,0x98,0xe9,0xb,0x7b,0x7e,0x26,0xb9, -0xcf,0x28,0x68,0x50,0xa5,0xd6,0xed,0x6a,0x3e,0xb9,0xc4,0xab,0xff,0xbd,0xd8,0xe8, -0xc2,0x99,0xbe,0xb0,0xf5,0x7,0xc9,0x7d,0xec,0x63,0xfa,0xf8,0xf5,0xc9,0x17,0x1b, -0x78,0xf6,0xf5,0x11,0xb6,0xfe,0x20,0x5d,0xfd,0xca,0xf0,0xfd,0xba,0x68,0xf9,0xdc, -0x5b,0x8a,0xa,0xe4,0x78,0xa6,0x6f,0xf6,0xfb,0x21,0x52,0xfb,0x1c,0xed,0x47,0xdc, -0xed,0x47,0x9e,0xae,0xce,0x6e,0x3f,0x67,0x3e,0x10,0x17,0xec,0x1b,0x55,0x67,0x9f, -0x7f,0xb3,0x7c,0x29,0xea,0xa7,0xb3,0x7c,0xca,0x4,0xcf,0xbe,0x7e,0x9d,0x3e,0xde, -0xf5,0x9b,0xda,0xf7,0x16,0xcf,0xa7,0xd7,0xaf,0x94,0xc9,0x94,0xd7,0xff,0x9d,0x4, -0xe6,0xab,0xf4,0xfb,0x5f,0xf9,0x3e,0xf7,0x6f,0xbc,0xc8,0xf3,0xe1,0x90,0xfa,0x8b, -0x44,0xc7,0xf7,0x9f,0xc7,0xbc,0x7c,0xe5,0x1c,0x3f,0x84,0xdb,0xc6,0x7b,0xb9,0xe2, -0xad,0xbf,0xa,0x1a,0x4d,0x7c,0xc7,0x37,0xac,0x3e,0x44,0x61,0xb3,0x87,0x78,0xf9, -0xc5,0xb9,0xfe,0xe0,0xe6,0x6b,0xa8,0x6e,0xf8,0xce,0x17,0xef,0x6b,0x18,0x63,0x6, -0x27,0x5f,0x39,0x7c,0xc6,0xcd,0x69,0xca,0xe3,0x1b,0xe4,0xbb,0x1b,0x32,0x3f,0xa8, -0xe,0x87,0xa,0xe0,0xe4,0x2b,0xd7,0xfb,0xb7,0x5e,0x7a,0x8d,0xa4,0xf7,0xad,0x9b, -0x3b,0x4e,0xfb,0x7d,0xd5,0xb0,0xf6,0x3b,0x41,0x8a,0xe8,0xc8,0x57,0xdc,0xe3,0xfb, -0xd2,0xed,0x9b,0x96,0x6f,0x23,0x73,0x1f,0x9,0x5b,0x7f,0x45,0xc9,0x75,0xe5,0x96, -0x23,0x5f,0x1,0xde,0xf5,0xf1,0x6a,0xe5,0x23,0xcb,0x57,0xcf,0xdc,0x67,0xd4,0xaf, -0xc4,0x6b,0xd8,0xaa,0x29,0xbf,0x2b,0xa3,0x4e,0xa1,0xa0,0xef,0x2f,0xaa,0x9e,0x9d, -0x53,0xe8,0xc8,0x57,0x22,0x2f,0x5f,0xbd,0x5a,0xb1,0xce,0xbf,0x44,0xeb,0xf,0x5c, -0xbe,0x7d,0xaf,0xcf,0xa8,0x5f,0xbd,0x2c,0xd5,0xac,0x5b,0xd9,0x4a,0xb5,0xda,0xa8, -0xd5,0xf4,0xe7,0x7b,0xdc,0xd7,0x87,0xb9,0xa7,0xb5,0x37,0x5f,0xbd,0xaa,0x5d,0x1f, -0xb1,0xf7,0xbf,0xa,0xf0,0x6d,0x70,0xc7,0xf,0xfa,0xd2,0xa4,0x59,0xb7,0x7c,0x95, -0x46,0xd5,0xf0,0x51,0x77,0xff,0x82,0x26,0xdc,0xf1,0xad,0xaa,0xf5,0x2f,0xbb,0xc9, -0xd7,0xbf,0xb8,0x7c,0x97,0x2,0x7c,0xc4,0xf2,0x11,0x8,0x27,0xb8,0x56,0x33,0xe6, -0x67,0x9c,0xfd,0x33,0x46,0xbf,0x2f,0x72,0x7d,0x5a,0xff,0xbc,0x9e,0xdc,0xd7,0xe6, -0x2d,0xb9,0x32,0x2a,0xb2,0x56,0xbe,0x1a,0x7d,0xd4,0xb5,0x7c,0x63,0xf8,0x4,0x17, -0x56,0x9d,0xf3,0x83,0xa1,0xf9,0x2a,0xe1,0xfe,0x57,0xf6,0x7,0x70,0xda,0xcf,0xbe, -0x15,0x37,0xf3,0xd5,0xe4,0xd8,0xf2,0xd1,0xca,0xef,0xb0,0x50,0x3,0xf1,0xf2,0x4b, -0x8a,0xf6,0x3,0x9c,0xf3,0xcf,0xeb,0x1b,0x39,0x7c,0xb0,0xd2,0xa8,0x9,0x35,0x31, -0x9e,0x6f,0x37,0x23,0xdf,0x3e,0xd7,0xa7,0x4c,0xa4,0xd3,0x9a,0xe5,0xab,0x56,0x9b, -0xb3,0x7c,0xbe,0x7c,0x75,0x94,0x7c,0xfd,0x95,0xcb,0x47,0xf9,0x3e,0xe4,0xe8,0xff, -0x5e,0x97,0xd1,0x81,0x50,0x10,0xc3,0xf2,0xd5,0x46,0xfa,0xfd,0xaf,0x62,0xf9,0x5c, -0xbf,0x2b,0x98,0x5f,0xd0,0xfa,0x67,0x38,0xda,0xd5,0x1f,0x4a,0x35,0x9f,0x9f,0x61, -0xfd,0x33,0xa,0x7a,0x3e,0xa0,0xbe,0x0,0x9f,0x68,0x8e,0x32,0xda,0xf8,0x36,0xfc, -0x78,0xc7,0xd8,0x3c,0xd4,0xc8,0x7,0x65,0xe6,0xb,0x7a,0xbe,0x62,0x23,0xa9,0x2f, -0xa0,0x34,0xcd,0xf3,0x39,0xc7,0x5f,0xd5,0x67,0xc,0xba,0xc6,0xf3,0x3d,0xac,0xfd, -0xb8,0xcf,0xa7,0x24,0xcd,0xf7,0xc9,0x7d,0xa,0x3d,0xfe,0x89,0xe8,0xf0,0x89,0x73, -0xf5,0x29,0xa4,0x94,0xc0,0xb7,0x6f,0xfb,0x46,0xc0,0xf2,0xa5,0x7f,0x7e,0x86,0xe3, -0x53,0x60,0x4c,0x1f,0xa6,0xa3,0xd7,0x64,0xcb,0xa7,0xe6,0x2b,0xe6,0x3,0xe9,0x9f, -0x9f,0x49,0xec,0x3b,0xc7,0xaf,0xcb,0xb0,0x50,0xd0,0xea,0xe3,0x48,0xf5,0x11,0xbb, -0xfd,0xec,0x7c,0x5,0xd2,0xef,0x2f,0xc5,0xf1,0xd1,0x48,0xbe,0xc9,0xf7,0xd5,0x80, -0x55,0xab,0x69,0xf3,0xb,0x3,0xd5,0xe7,0xb8,0x3e,0x30,0xb4,0x7c,0xe9,0xf7,0xe7, -0x4a,0xe3,0x53,0x7,0xb8,0x9a,0xb1,0xff,0x95,0x34,0x72,0xf4,0x2f,0xc8,0x7a,0x7f, -0x72,0x6,0xfb,0x9b,0xf1,0x7c,0x20,0x8a,0x4f,0xfa,0xab,0xa,0x6c,0xd6,0x6a,0xdf, -0x35,0x7d,0x76,0xff,0x3c,0xcb,0x97,0xb4,0xfe,0x62,0xfb,0xc4,0x68,0xbe,0xd7,0x61, -0xb3,0xb0,0x7a,0x3d,0x6a,0xbe,0xca,0xd0,0x27,0x44,0xf3,0x9,0x15,0x35,0x1f,0x54, -0xe3,0xe5,0x97,0x2c,0x7c,0x84,0x46,0x3c,0xbe,0xc9,0x7c,0x49,0xeb,0xa7,0xcc,0x37, -0xfd,0x27,0x91,0xc6,0x5f,0xa9,0x5b,0xa9,0xd6,0x66,0xf9,0x52,0x3d,0x9f,0x1c,0x6b, -0x7c,0x23,0xde,0xfd,0xaf,0x26,0x5d,0x35,0x60,0x9,0x7a,0xff,0x87,0xa3,0xd7,0xaf, -0xe6,0xe6,0x9b,0xf2,0xf6,0x97,0x32,0xf3,0xd5,0x29,0x85,0xb0,0xb0,0xb,0x66,0xd4, -0xaf,0xd8,0xdf,0x4a,0xb8,0xfe,0x6a,0x86,0xef,0xdc,0xeb,0xc3,0xd4,0xca,0x57,0xc7, -0x74,0xf8,0x9,0xde,0x1,0xfe,0xfa,0x90,0xc8,0xdd,0xff,0x25,0xd9,0xfa,0xab,0x59, -0xc7,0x57,0x9,0x1b,0x7f,0x87,0x1f,0x2b,0x3c,0xdf,0x8f,0x79,0xf9,0x25,0xee,0xfa, -0xab,0xed,0xc,0x7c,0xc7,0x3f,0x51,0x44,0x8e,0xef,0xad,0x0,0x5f,0x9c,0xf5,0x25, -0x56,0x9a,0x4a,0xe9,0xdb,0xb7,0xf3,0x55,0x8f,0x5b,0xbf,0xb2,0x7d,0xb1,0xd6,0x5f, -0xc9,0x42,0x34,0x1f,0xe,0xcf,0x57,0x8a,0x6c,0xe7,0x2b,0xdb,0xc7,0xbf,0x3e,0x62, -0xad,0xbf,0x1a,0xd3,0x64,0xbe,0x73,0xbc,0xbf,0xf7,0xa8,0x50,0xd8,0x64,0x3e,0x62, -0xe7,0xab,0xa7,0x43,0xf7,0xd7,0x8b,0xb9,0xfe,0x6a,0x8f,0xfd,0x8b,0x35,0x47,0x6b, -0xdd,0x2e,0x6a,0xfb,0xe7,0xc8,0x41,0xbe,0xc9,0xf7,0x9b,0x2d,0x35,0xbf,0x88,0xcc, -0x67,0x5f,0x1f,0x33,0xf6,0xd7,0x8b,0xb9,0xfe,0xca,0x62,0x15,0x7c,0x7d,0xac,0xb6, -0xff,0xd0,0x58,0x8,0xcc,0x57,0xf5,0x96,0x9d,0xaf,0x24,0x47,0xff,0x32,0xe3,0xf9, -0xe4,0x78,0xeb,0xaf,0xac,0xcb,0x83,0x58,0x2b,0xa5,0xda,0xcc,0xa1,0xed,0xdf,0xa4, -0x3d,0xbd,0x1a,0x30,0xfe,0xd6,0x45,0x35,0x5f,0x19,0xfb,0x8b,0x4a,0x8e,0xfe,0x79, -0xe6,0xfe,0x7a,0xb1,0xd6,0x5f,0x91,0x95,0xe8,0x1f,0xaf,0x6f,0x4f,0xcd,0x57,0xae, -0xf5,0x57,0x91,0xf2,0x55,0xbc,0xf1,0x2d,0x4d,0xfb,0x29,0x6a,0x7e,0x41,0xb1,0xf3, -0xb,0x69,0xf,0x4,0x3a,0xff,0xf3,0x4f,0xf5,0xb5,0x92,0xf9,0x80,0x10,0xc7,0xb7, -0x1f,0xed,0xfa,0xe5,0xe4,0xab,0x66,0xab,0x99,0x24,0x5f,0x11,0xb0,0x16,0x27,0xbf, -0x1c,0xfa,0xfa,0x3f,0xec,0x2c,0x1,0x29,0xcc,0x27,0xfb,0xf2,0xd5,0xfe,0x5e,0xc3, -0xc8,0x57,0xa,0xe,0xf0,0xed,0xf1,0xf7,0xbf,0x8a,0xe5,0x93,0x23,0xfa,0x70,0x70, -0xbe,0xd2,0xf7,0x9f,0x54,0xcf,0x2a,0xc1,0x18,0x3f,0xae,0x14,0x8b,0x61,0xf7,0xe7, -0x44,0x7f,0x10,0x28,0xb2,0x6f,0x2a,0x44,0xf3,0xa1,0xe0,0x7c,0x65,0xec,0x8f,0x59, -0xd9,0x11,0xcc,0xf1,0xd7,0x78,0xae,0x27,0x28,0x5f,0x91,0xb6,0x12,0xc7,0xe7,0xcf, -0x7,0x7c,0xdf,0x38,0x78,0xfc,0x7d,0xa2,0xef,0x2f,0x55,0x69,0xf9,0x7c,0x9b,0xdc, -0xfd,0xeb,0x40,0x2c,0x9f,0x3f,0x5f,0x5,0xb4,0x9f,0x30,0xcb,0xd7,0xf4,0xf9,0x9a, -0x3c,0x9f,0x4,0x70,0xba,0x7c,0xcf,0xf7,0x85,0xac,0x1f,0x1f,0xe9,0xfb,0x5f,0xbd, -0x52,0x33,0x7d,0x9f,0x5f,0x66,0x3e,0xee,0xfe,0x89,0x8b,0xf7,0xd,0xf4,0xfd,0xaf, -0x60,0xc3,0xbc,0x3e,0xae,0x5a,0xed,0xc7,0xdd,0xbf,0xf8,0x64,0x3e,0x3e,0x7d,0x7f, -0x6,0x54,0x72,0xac,0x44,0xfb,0xf5,0xdd,0x4a,0xa1,0x0,0x59,0xff,0x2,0xa0,0xb9, -0x3e,0x1b,0x2b,0xf6,0xf1,0x9d,0xcb,0xfd,0x9b,0xcb,0x67,0xf5,0xcf,0xb2,0x3e,0xbf, -0x0,0x1d,0x2b,0xf9,0x1a,0xd,0x35,0xbf,0x74,0x6c,0xdf,0x8f,0xca,0x5e,0xdf,0xfe, -0x5c,0xee,0x7f,0x5d,0x3e,0xd7,0xf8,0x46,0x46,0x13,0xcc,0xf1,0x19,0x7f,0x1d,0x8a, -0xbe,0xf6,0x9b,0x4b,0xfd,0xc0,0xed,0x73,0xe5,0x3,0x32,0x72,0xd6,0x3e,0xaa,0x8, -0xd7,0x6a,0xf6,0xfe,0xa2,0xac,0x7f,0xc6,0xd3,0x62,0x31,0xb3,0xfa,0x8b,0xf8,0xe1, -0x5a,0x78,0xff,0x37,0x70,0xad,0xbf,0x72,0xf9,0xee,0xde,0xad,0x15,0x56,0xbd,0xfb, -0x8b,0x66,0x5c,0xbf,0x12,0x1b,0xd6,0x4e,0x2a,0x11,0xda,0x8f,0xbe,0xe4,0xf4,0x9, -0xa2,0x9a,0xf,0x2a,0xf3,0xad,0x5f,0x81,0x4a,0x17,0x45,0x3f,0xff,0xe8,0x4b,0xce, -0xf3,0xaf,0xda,0x50,0x7d,0x85,0xd8,0xbe,0x58,0xf5,0x53,0x60,0xed,0xb7,0x3a,0xeb, -0xfa,0xd5,0x7d,0x3b,0xce,0xeb,0x57,0xf7,0xc1,0xd8,0xf9,0x2a,0x96,0x4f,0x82,0x38, -0x5a,0xff,0x67,0x3c,0x3f,0x28,0x3a,0xfb,0xbf,0xf,0xef,0x56,0x5,0xa3,0xff,0xb, -0xda,0x9f,0x1,0xa5,0xde,0xff,0x2a,0xb2,0x8f,0xb3,0xfe,0x4a,0xb4,0xf2,0x95,0xfe, -0xfc,0xf9,0xe0,0xae,0x95,0xaf,0x80,0xe9,0x1b,0xf2,0xe7,0x3f,0x62,0xac,0xbf,0x7a, -0x12,0xd5,0xc7,0x59,0xdf,0x4,0xac,0x7c,0xa5,0xef,0x8f,0x54,0x69,0x88,0x66,0x3e, -0x30,0x96,0xfe,0x7a,0xdf,0xbf,0x65,0xfb,0xce,0xe3,0xf8,0x66,0x5c,0x1f,0x21,0x3e, -0x3b,0xbf,0x78,0x7d,0xb7,0x4c,0xdf,0x1,0x7f,0xfe,0x2d,0xc6,0xf1,0xc5,0x68,0x46, -0xff,0xc2,0x7c,0x24,0x64,0xfd,0xd5,0x13,0x23,0x9f,0x8a,0x96,0xf,0x64,0xe7,0x93, -0xd7,0x4a,0xa9,0xdb,0x6f,0xa4,0xb7,0xdf,0x2b,0xf7,0x59,0xbe,0xb2,0xce,0xbf,0x6, -0xff,0xf8,0xc6,0x5d,0x7f,0x75,0xa8,0x9e,0xea,0xeb,0x9a,0x6f,0x5a,0x46,0x74,0x5c, -0xd2,0x7c,0x9b,0x44,0xbb,0x21,0x8e,0xe8,0x1b,0xe8,0xfb,0x5f,0x41,0xb3,0xfd,0xe4, -0xab,0x56,0xfb,0x6d,0xf0,0xaf,0x8f,0xb8,0xeb,0xaf,0xfa,0xb4,0xac,0xa,0x81,0xb6, -0xc1,0xb2,0x36,0xd9,0xa7,0xf9,0x6a,0x53,0xed,0x28,0x84,0x5e,0xbf,0xd5,0x46,0xdf, -0x9c,0x1f,0x54,0x7a,0x46,0x3e,0x30,0x8f,0xaf,0x62,0xf9,0x82,0xfa,0x97,0x98,0xeb, -0xf,0xfa,0xa4,0xf5,0x4d,0xd3,0x77,0xf0,0x97,0x55,0xc3,0x77,0xfe,0xfb,0x3f,0xe1, -0xf4,0x7f,0xce,0xfb,0x96,0xe3,0xf7,0x3e,0x45,0xc6,0xfc,0xa0,0xde,0xff,0x1,0xd8, -0xf0,0xfb,0x2,0xf6,0xe7,0x8a,0xb9,0x7e,0xa3,0x4f,0x1f,0x7f,0x6c,0xfa,0xd0,0x9f, -0x37,0xc,0x1f,0x39,0xfd,0x23,0x4f,0x7e,0xf6,0xf9,0xde,0xff,0xad,0xea,0xb3,0xf7, -0x97,0xe2,0xf8,0x82,0xc6,0xb7,0x98,0xeb,0x5f,0xfa,0xb4,0xd5,0x7b,0x60,0xfa,0x9a, -0xef,0x96,0xd,0x1f,0xba,0x53,0x8,0xf5,0x29,0xc7,0xef,0xf7,0xb1,0xd3,0xc7,0xfa, -0x67,0x35,0x5f,0xcd,0xc1,0xc7,0xda,0xaf,0xc9,0xda,0xf,0xdd,0xd1,0xdb,0x6f,0x1a, -0x54,0xbf,0x52,0x7a,0x1f,0xf4,0x71,0x61,0xb5,0x13,0x2f,0x5f,0x25,0xda,0xff,0x2a, -0xcc,0x17,0x38,0xbf,0xa5,0xec,0x36,0x5e,0xc6,0xb1,0xeb,0x43,0x34,0xeb,0xf6,0xb, -0xf6,0xf5,0x72,0xee,0xdb,0x69,0x3c,0xc4,0xb1,0xeb,0x57,0x34,0xc9,0xfa,0xab,0x43, -0x68,0xfa,0xa6,0xcf,0x33,0xdf,0xe6,0xce,0x2c,0x1f,0xd9,0x69,0xf4,0xcd,0xf9,0xc1, -0xc0,0x7c,0x15,0xb0,0xbe,0x3d,0xc5,0xfa,0x2b,0xdf,0xf8,0x16,0xec,0x73,0xd4,0xaf, -0xbc,0xf9,0x2a,0xf8,0xfd,0x5b,0x34,0xe5,0xfa,0xab,0xe8,0x3e,0xed,0x8b,0x1,0xf9, -0x6a,0x12,0x5c,0xdf,0xa0,0x19,0xac,0xbf,0x8a,0xe8,0xb,0xce,0x57,0xb6,0x2f,0x68, -0x7f,0x2e,0xba,0x58,0x1f,0xf6,0xe4,0x2b,0xe6,0x1b,0xe6,0xc3,0x37,0xd2,0x7d,0xaf, -0x8,0x22,0xcb,0x57,0x33,0x8f,0xef,0x62,0x7d,0x3,0x64,0xe4,0x2b,0x56,0xbf,0x42, -0xa1,0xcf,0xf,0x26,0xf3,0xa9,0xe3,0x98,0xb9,0x66,0x77,0x7d,0xc5,0xdc,0x51,0x4f, -0x1d,0x8b,0xa,0x21,0xbe,0x6a,0xe3,0xd3,0x8a,0x99,0xaf,0xf4,0xfd,0xf,0x20,0x7b, -0x7f,0x8a,0x9d,0xf,0x2,0xde,0x1f,0xbf,0x10,0x9f,0x9a,0xaf,0xba,0xd,0x33,0x5f, -0xe9,0xef,0x1f,0x84,0x2d,0xcb,0x27,0x6,0xd6,0xaf,0x16,0xe9,0x7b,0x5f,0xf3,0x39, -0xf2,0x55,0xd3,0xf2,0x9,0x33,0xc6,0xb7,0xf4,0xcf,0xa7,0xf0,0x8a,0x62,0xbe,0x7c, -0xd5,0x6d,0xba,0xf2,0xd5,0xeb,0x66,0xfd,0x6f,0x7a,0xb9,0x10,0xe6,0x4b,0xf9,0xfc, -0x5b,0x64,0x5f,0xef,0x83,0x6e,0xb3,0xb0,0xa,0xe3,0xe5,0xab,0x5,0xfa,0x76,0x1b, -0x2f,0xce,0xac,0xbf,0x64,0xd7,0x7e,0xb1,0xcf,0x3f,0x35,0x5f,0x69,0x3e,0x10,0xdb, -0x97,0xac,0x7e,0x1a,0xdf,0xb7,0xd3,0x78,0x2b,0xfe,0xfa,0xf6,0xb9,0xf9,0x88,0xec, -0xcf,0x57,0x9f,0x56,0x5,0xfd,0xf9,0x1e,0x5,0xc5,0xc9,0x57,0xd9,0xd6,0x9f,0x99, -0x6f,0xea,0x9d,0x3f,0x72,0xe6,0xab,0xa1,0x9e,0xaf,0xd6,0x68,0xa4,0x7c,0x95,0x7a, -0xfd,0x15,0xd7,0x77,0xee,0x9b,0xdf,0x72,0xe4,0xab,0x3,0x3d,0x1f,0x3c,0xa6,0x91, -0xf2,0x55,0xea,0xf5,0x57,0x5c,0x5f,0xd8,0xf3,0x65,0x4f,0xf4,0xfd,0x9b,0x2a,0x3f, -0xda,0x2e,0x9e,0xf,0x0,0x0,0x12,0x4f,0x49,0x44,0x41,0x54,0xa3,0x91,0xf2,0x55, -0xc2,0xfd,0xaf,0x66,0xf9,0x42,0xf6,0x6f,0x37,0x7d,0x6c,0xfc,0xb5,0xf3,0x15,0xa, -0xf0,0x35,0xc0,0x42,0xdb,0x6f,0xa4,0xfb,0x5e,0x31,0xcf,0x3f,0x35,0x5f,0x6d,0x31, -0x1f,0xff,0xf8,0xc6,0xdf,0xff,0x6a,0xf,0x1f,0x9a,0x3e,0xf9,0x7e,0xd9,0xf4,0x15, -0x37,0xa3,0xfa,0xcc,0x7c,0xc5,0xde,0x4f,0x77,0xd5,0x6a,0x3f,0xc8,0xbf,0x3e,0xe2, -0xef,0x7f,0xd5,0x3a,0xed,0x9b,0x3e,0xd4,0x34,0xa6,0x17,0x55,0x50,0x6d,0x86,0x6f, -0x7c,0x19,0x16,0xa,0x80,0xf5,0x2f,0xce,0x7c,0xc5,0x7c,0x80,0xd7,0xbf,0x24,0xd9, -0xff,0x6a,0xed,0x98,0xf9,0x60,0xd7,0xf4,0x29,0xd8,0xf2,0x1d,0xf1,0xcf,0x3f,0x78, -0x1f,0xd5,0x6a,0xdb,0x1c,0x9f,0x75,0x7d,0x6c,0xf0,0xfa,0xe7,0x24,0xfb,0x5f,0x9, -0xd8,0xf2,0x61,0xe6,0xa3,0x96,0x6f,0x97,0x9f,0x9f,0xe1,0x9b,0xaa,0xcf,0xde,0x5f, -0x94,0xe3,0xe3,0x8e,0x6f,0x49,0xf6,0xbf,0x72,0xfa,0xb6,0x99,0xcf,0x3a,0xff,0xd6, -0xf9,0x3e,0xb0,0x66,0x3d,0x3f,0xa8,0xe7,0x2b,0x76,0x7d,0x84,0xcd,0xf,0xd2,0x64, -0xfb,0x5f,0x39,0x7c,0xd3,0x5b,0xbe,0xf6,0x5b,0xe7,0xd5,0xaf,0x74,0x9f,0xfb,0xf9, -0xc1,0x68,0xf9,0x2a,0xc9,0xf8,0xe6,0xf0,0x51,0xff,0xf1,0xd,0x6e,0xbf,0x24,0xf9, -0x85,0xb4,0xe3,0xef,0xaf,0xb2,0x66,0xfb,0x80,0xff,0xfa,0xd8,0xcd,0xd6,0x17,0xf5, -0xfd,0x74,0xce,0xfe,0x5,0xdb,0xfd,0x8b,0xe8,0xeb,0x5f,0x8e,0x12,0xfb,0x78,0xd7, -0x6f,0x12,0x9f,0xb3,0x7f,0x16,0xb8,0xfd,0x33,0xe7,0xfd,0x24,0x70,0xd,0x9,0x46, -0xff,0x17,0x54,0xbf,0x82,0xbc,0xfe,0x2f,0x89,0x2f,0xc2,0xfd,0xb9,0xbf,0x7f,0x86, -0x81,0xf5,0x2b,0x76,0x7f,0xde,0xe1,0x8d,0x1f,0x4,0xbc,0x4e,0xe7,0xe1,0xf3,0xb5, -0x1f,0xb2,0xf2,0x55,0xcf,0x5d,0x1f,0x42,0x1d,0xd3,0xf7,0x88,0x37,0xfe,0x92,0x36, -0x9c,0x47,0xfb,0xfd,0x3e,0x24,0xbf,0x78,0x7d,0x8f,0xd8,0xf1,0xe5,0xe5,0x97,0x84, -0xfb,0x5f,0xcd,0xf2,0x9d,0xa,0xd1,0x7d,0x95,0x30,0x9f,0x34,0x1f,0x5f,0x58,0xbe, -0xd2,0x7d,0xaf,0x54,0xad,0xfa,0x95,0xe5,0xe3,0x1d,0xdf,0xc5,0xfb,0x6,0xfa,0xf5, -0xc1,0xe6,0x8f,0xe4,0xab,0x13,0x18,0x96,0xaf,0x12,0xee,0x7f,0x15,0xc9,0xb7,0x55, -0x77,0x3c,0xf8,0x3d,0xfe,0x4a,0xc5,0x35,0x3f,0x68,0xcd,0x6f,0x3d,0x81,0x61,0xfd, -0x4b,0xf6,0xf7,0x6f,0x47,0x56,0xff,0x57,0x7d,0xbe,0xe5,0xe8,0x5f,0x6a,0xd,0xfe, -0xfc,0xe0,0xef,0x59,0xfd,0x5,0x66,0xb8,0xff,0x55,0x88,0xcf,0x1a,0xdf,0x8,0x7e, -0x69,0x87,0xe3,0x33,0xf3,0x95,0x3d,0x3f,0x38,0x97,0xfd,0xaf,0x82,0x7d,0x56,0x3e, -0x20,0xd4,0xe9,0x3,0xb5,0xa6,0xd3,0xe7,0x98,0x1f,0x84,0xf3,0xa8,0x5f,0x85,0xf8, -0xac,0xf5,0x57,0x47,0xaf,0xb9,0x7d,0x9e,0xf5,0xed,0x73,0xad,0x5f,0x45,0x69,0x3f, -0xfc,0x86,0xdb,0x17,0xfb,0xf9,0xbc,0xb9,0xf8,0x76,0x33,0xf5,0x65,0x5f,0xbf,0xb7, -0xf3,0x55,0xf5,0x5e,0x2b,0x96,0x2f,0xcb,0xfd,0xaf,0x66,0xd4,0x87,0xf4,0xf5,0x7, -0xae,0xfe,0xf,0xde,0xaf,0x1a,0xf3,0x83,0xc1,0xbe,0x2c,0xf7,0xbf,0xa,0xf7,0x71, -0xd6,0x5f,0x59,0xf9,0x2a,0xd8,0xe7,0xda,0xff,0xea,0xee,0xcd,0xcb,0x86,0x6f,0x3a, -0x8f,0xf9,0x19,0xbf,0xcf,0xca,0x57,0xc1,0x3e,0xd7,0xfe,0x57,0xd5,0xde,0xc4,0xf0, -0x9d,0x2f,0xc6,0x67,0x8d,0xbf,0xc1,0x3e,0xd7,0xfe,0x57,0x95,0xd1,0x64,0x7e,0xc7, -0x97,0xdc,0x49,0xeb,0x7b,0xa9,0x32,0x22,0xf3,0xf3,0xd1,0x9f,0xa6,0xf7,0x49,0x37, -0x99,0x6f,0xe,0xf3,0xbf,0x62,0x5a,0xdf,0xab,0x15,0xf8,0x11,0xf3,0xd5,0x17,0x71, -0xfd,0xc6,0xf7,0xb1,0xf3,0x2f,0xdd,0xfa,0x3,0xd7,0xf3,0x47,0xec,0x67,0x4c,0xef, -0xd2,0xd4,0x3e,0xf5,0xfa,0x48,0xb1,0xff,0x15,0xf0,0xfd,0xc,0xed,0xf9,0xad,0x90, -0xfa,0x41,0x4c,0x5f,0x55,0xeb,0x5f,0xd2,0xee,0x3f,0xa4,0xf,0xe0,0xcc,0x21,0x17, -0x43,0xeb,0x2f,0xb3,0x7c,0x9e,0xfd,0xdb,0xab,0x5a,0xff,0x9c,0xf5,0xfe,0x57,0xc1, -0xcf,0xf,0xc6,0xf5,0xa5,0xde,0xff,0x8a,0xce,0xb9,0xfd,0xd8,0xb7,0x4a,0xb5,0xbf, -0x59,0x86,0xe7,0x1f,0xf7,0xb3,0x9b,0x81,0x8f,0x7b,0xfd,0x66,0xe4,0x4b,0xb1,0xff, -0x55,0xf0,0x67,0xd6,0xfa,0xd,0xfe,0xfb,0x7,0xa9,0xb9,0x8e,0xd7,0xfb,0xad,0x92, -0xae,0xbf,0x4a,0xee,0xd3,0xdf,0x5f,0xe6,0xf7,0x99,0xeb,0xc8,0x39,0xbe,0xe4,0xfb, -0x27,0x26,0xf2,0x11,0x10,0xe0,0xbb,0x15,0xe4,0xdb,0x58,0xac,0xef,0x57,0x1,0xbe, -0xa0,0xe3,0xbb,0x88,0xf5,0x1b,0xe,0x9f,0xf2,0x71,0xce,0x7d,0xbd,0x98,0xd7,0xc7, -0x82,0x7d,0x38,0xe0,0xfa,0xa0,0x4b,0xf4,0xad,0x7f,0x6f,0x2c,0xcb,0xfd,0xe2,0x96, -0xb6,0xfe,0x0,0x71,0x7d,0x64,0xa9,0xbe,0x9a,0x4,0xab,0xd5,0xdb,0xa8,0xaa,0xad, -0x7f,0x19,0x1c,0xe5,0xd0,0x7,0x2a,0x15,0xf1,0xf6,0x4,0x7,0xaf,0xcf,0xa1,0x57, -0x97,0xe8,0x23,0x18,0x54,0x20,0xbd,0x33,0xa1,0x20,0xde,0xf8,0x86,0x16,0xb4,0xbe, -0x49,0xf5,0xbd,0xe,0xc9,0xe4,0x32,0x35,0xe6,0x7,0x4b,0x39,0xf4,0x9,0x15,0x32, -0x21,0x39,0x6e,0xbf,0x4a,0xa5,0x35,0x21,0x58,0xc,0xf5,0x61,0xf9,0x2b,0x45,0x7a, -0xa9,0xfd,0xca,0xda,0x83,0x31,0xad,0x6f,0x6e,0xa6,0x7a,0x7e,0x35,0xa6,0x4f,0xbd, -0x7e,0x6b,0x13,0x5a,0x9d,0xe1,0xc3,0xa,0xa2,0x6b,0x0,0xee,0xec,0xc0,0xb5,0xba, -0xb6,0xb5,0xf0,0xa2,0x7c,0xb4,0x76,0x32,0x96,0xc7,0xb7,0xe9,0x96,0xbe,0xbf,0xe8, -0x61,0x88,0xf,0x6b,0xbe,0xde,0xe,0x68,0xd5,0x16,0xea,0x13,0x8c,0xa,0x96,0x91, -0xaf,0x60,0x4,0x1f,0xae,0xe1,0x5a,0xaa,0xfd,0xaf,0xe2,0xf9,0x44,0xeb,0x96,0x2f, -0x30,0x5f,0xe9,0xe7,0xdf,0xd3,0xaa,0xaf,0x5d,0x71,0xfa,0x92,0xae,0xbf,0x4a,0x91, -0xaf,0xf6,0x42,0xdb,0xef,0x12,0x80,0xdd,0x7,0x0,0x55,0x51,0x2d,0xd1,0xfe,0x57, -0x73,0xcb,0x2f,0xcc,0x57,0x55,0x7d,0x22,0x80,0x55,0x58,0x4b,0xb2,0xff,0x55,0x16, -0x3e,0x25,0xd4,0x57,0xd3,0x7d,0x3f,0xba,0xe,0x6a,0x49,0xf6,0xbf,0xca,0x22,0x5f, -0xf1,0x7c,0x97,0x54,0x18,0xd2,0xfb,0x97,0xba,0x36,0xb5,0x4,0x85,0x8a,0x58,0x4b, -0xb2,0xff,0x55,0x8a,0x7c,0xa5,0xa8,0xf9,0x6a,0x2b,0x28,0x5f,0xad,0x9d,0x92,0x1a, -0x94,0xff,0xa9,0xda,0x3f,0xaf,0xb5,0x5f,0xa9,0x8a,0x63,0x5a,0x59,0xdd,0x4c,0xb2, -0xff,0x55,0x8a,0x7c,0x75,0x4f,0x42,0xd5,0x6a,0x50,0xbe,0x5a,0x3b,0x56,0x6a,0xfd, -0xab,0xdf,0xf4,0x7f,0xab,0xa4,0xef,0x1f,0x8c,0x9f,0xaf,0xde,0x97,0x26,0x58,0x8, -0x1a,0x3f,0xd6,0xd4,0xe3,0xdb,0xfa,0xfc,0x63,0x9e,0xef,0x5e,0xb6,0xbe,0x75,0x73, -0x65,0xaf,0x2f,0x5f,0x29,0x93,0x9,0xfd,0x6e,0x98,0xaf,0x3e,0xea,0x51,0x72,0xc9, -0xe7,0x4b,0xf4,0xfe,0xc1,0xe0,0xf,0xdb,0xc6,0xdd,0x97,0xaf,0x14,0x35,0x5f,0x5d, -0xf,0xca,0x57,0xea,0xf5,0xf1,0x66,0x6b,0xd4,0xe3,0x1f,0x8a,0x6c,0xc7,0x37,0x1a, -0x90,0xaf,0x14,0x35,0x5f,0x5,0xce,0x6f,0x55,0x31,0xbd,0xd7,0xf3,0xfa,0xc6,0xd7, -0x93,0xad,0xbf,0x4a,0xe2,0x33,0xf2,0x55,0xa0,0xaf,0xa6,0x1e,0x5f,0xd5,0xa7,0x25, -0x2c,0x7b,0x78,0x86,0x7,0xc9,0xd7,0xf,0xc5,0xf4,0xa9,0xd7,0x6f,0x5d,0xcd,0x57, -0x81,0xbe,0xba,0xea,0x1b,0xa9,0x3e,0xb5,0x7,0xec,0x58,0xbf,0x9,0x86,0xb,0xf2, -0xe9,0xf9,0x4a,0x91,0xa8,0xde,0xff,0x9d,0xe0,0x80,0xeb,0x63,0x72,0x55,0xf3,0xe1, -0x47,0xec,0xf7,0x4e,0xe7,0xe2,0x2b,0xec,0xb4,0x67,0xe4,0x2b,0x7d,0xff,0x2b,0xf9, -0x7e,0xc9,0xdc,0x5f,0xb4,0x88,0xdc,0x23,0x1c,0xf4,0xf8,0x6e,0x67,0xea,0x23,0xf8, -0x21,0x10,0xc2,0xf3,0x95,0xbe,0xbf,0x40,0x95,0x3d,0x7f,0x24,0xa1,0xa1,0x3b,0x61, -0x79,0x7c,0xed,0x93,0x4c,0x7d,0x8a,0xf2,0x8e,0xb1,0x61,0x77,0x70,0xbe,0x32,0xf6, -0x97,0xea,0x9a,0xbe,0x11,0x3e,0x8,0x6f,0x3f,0x9a,0xad,0x8f,0xce,0xf2,0x29,0x86, -0x4f,0x2e,0x9b,0x3e,0xda,0xf0,0xf8,0x36,0x69,0xd9,0xf0,0xb5,0xb,0xda,0xfa,0xa6, -0xac,0x7d,0x1f,0xcc,0xf2,0xe9,0xfb,0x5f,0x55,0x30,0x70,0xfb,0xb4,0x19,0x85,0x82, -0xee,0x7b,0xc0,0x7c,0xc6,0xfe,0x57,0x52,0xa6,0xfd,0x9f,0x72,0x38,0xcb,0x87,0x8d, -0xfd,0xaf,0x28,0x30,0xd7,0x5f,0x51,0x63,0x93,0x98,0xa9,0xfe,0x7a,0x58,0x6d,0xb9, -0xce,0x9f,0xa,0xe,0xdf,0x9,0x38,0xc9,0xd6,0xa7,0xfc,0x2c,0xc8,0x47,0x8a,0x5b, -0xda,0xfe,0xa2,0xc8,0xd8,0x5f,0xca,0xf4,0x61,0x85,0x18,0xd7,0xef,0x54,0x13,0x69, -0x9,0xb,0x3e,0x2c,0x39,0x8e,0x6f,0xd6,0xe3,0x5b,0x98,0xf,0xe9,0xf7,0xbf,0x3, -0xc3,0xd7,0x65,0xbe,0xf3,0x55,0xdb,0xa7,0xff,0xdb,0xf6,0x26,0x6b,0xbf,0x83,0xec, -0x7d,0x4,0x3f,0xe6,0xf4,0x2f,0xc6,0x97,0x1c,0xf9,0xa,0xa0,0xa6,0x68,0xf8,0x8, -0x42,0x5e,0xdf,0x80,0xf9,0xae,0xcf,0x21,0x1f,0x70,0xfb,0x67,0xd3,0x47,0x8b,0x96, -0x4f,0xbe,0x6f,0x5e,0xbf,0xb4,0xe8,0xf3,0xc9,0xa6,0x6f,0x3a,0x97,0xfa,0xb,0xd, -0xba,0xff,0x20,0x97,0x69,0xd8,0xfa,0x2b,0x6a,0xbf,0x5a,0xc7,0x9c,0x17,0x3c,0x5d, -0xb0,0x8f,0xd0,0xe0,0xfd,0xf,0x78,0xed,0x7,0x17,0xed,0xc3,0xd1,0x7c,0x63,0xc7, -0xf5,0x9b,0x7d,0xfd,0x34,0xd8,0x17,0x92,0xaf,0x5c,0xbe,0x3d,0x47,0xff,0xb7,0x50, -0x9f,0x91,0xaf,0xf8,0xf3,0x83,0x53,0x6b,0xfa,0x77,0xbb,0xe8,0xf2,0x91,0x45,0xf9, -0xcc,0xf1,0x43,0x9f,0x1f,0x6c,0xcb,0xe6,0xf3,0xf1,0x1c,0xdf,0xdb,0x65,0xd3,0x37, -0xb9,0x9e,0xd1,0xfb,0x7,0x63,0xf9,0x88,0xbe,0xff,0x41,0x55,0x2c,0x7,0xd5,0x77, -0xff,0x94,0x8d,0xbf,0xd2,0x41,0x46,0xef,0x1f,0x4c,0xe0,0xab,0xf4,0xc5,0x20,0xdf, -0x6,0xf3,0xf5,0x87,0xcb,0x38,0xbe,0x8a,0xb1,0xff,0x95,0x12,0xe8,0xdb,0x5c,0xb2, -0x4f,0x99,0xe1,0x3,0xce,0x7c,0x9a,0xea,0xfd,0x83,0x89,0x7c,0xd8,0xd8,0xff,0xa, -0x8b,0xb3,0xe6,0x17,0x2c,0x5f,0x7d,0x41,0xfd,0x4b,0x71,0xb,0xb2,0xfa,0x15,0x80, -0x28,0xd8,0x87,0xdd,0xbe,0x8c,0xd7,0x1f,0x4,0xfb,0x50,0xb5,0xc3,0xea,0x57,0x0, -0xfe,0x6d,0x29,0xc8,0x67,0x15,0x30,0xe1,0x41,0xca,0xf7,0xf,0xc6,0xf4,0x4d,0xb0, -0xbd,0xbf,0x28,0x12,0x3,0xdb,0x8f,0x10,0x47,0x7d,0x23,0xf5,0xfa,0x97,0x38,0x3e, -0x6a,0xef,0x2f,0xea,0xed,0x9f,0x9d,0xeb,0x87,0x84,0x7f,0x6f,0xd7,0x87,0x16,0xe9, -0xbb,0x4c,0xbd,0xfb,0x8b,0xf2,0x7d,0xef,0x6d,0xb2,0x6,0xcc,0x60,0xfd,0x55,0xac, -0x7c,0x55,0x89,0xb4,0xfe,0x6a,0x6f,0xd3,0xfe,0xfd,0x45,0xb6,0x1f,0xc1,0x85,0x48, -0xeb,0xff,0xf6,0xa,0xcb,0xf1,0xd1,0x2a,0x8c,0xe4,0x7b,0xb0,0xe1,0xf2,0x2d,0xec, -0xfa,0xa5,0x7a,0xff,0x77,0x12,0xf0,0xfc,0x20,0xb2,0xde,0xaf,0xbb,0x7b,0xe8,0xf2, -0x2d,0xaa,0xff,0x73,0xe7,0x2b,0xf3,0xfe,0x48,0x2e,0x15,0x37,0xd,0xdf,0xd0,0xda, -0xdf,0x7b,0x8a,0x5d,0xbe,0x45,0x8d,0x1f,0xee,0x7c,0xd5,0x4,0xac,0x7e,0x55,0x33, -0x7c,0x7,0x81,0xfb,0x4b,0x6d,0x2c,0x23,0x5f,0xb1,0xfb,0xf3,0x11,0x36,0x7d,0x28, -0xd3,0xfd,0xaf,0x52,0xe4,0x17,0x63,0xff,0x2b,0x6a,0xd5,0x87,0xb0,0xe9,0xd3,0xf6, -0x67,0x90,0xaf,0xee,0x60,0xa,0x37,0x73,0xe0,0x23,0x56,0x7d,0x6d,0x9f,0xf9,0xe4, -0xf2,0x11,0x1e,0x3d,0x3c,0xa5,0x9d,0xda,0x32,0x7d,0x18,0x79,0xea,0x57,0xac,0xfd, -0xb4,0xe7,0x7,0xf1,0xe8,0x9d,0xe3,0xd6,0xa3,0xe5,0xf8,0x88,0x39,0x3f,0x8,0xdd, -0xf5,0x2b,0xcb,0xa7,0xed,0xcf,0xa0,0xfa,0x70,0x17,0xe2,0xe5,0xf8,0xcc,0xf9,0xc1, -0x5d,0x77,0xfd,0xca,0xba,0x3e,0xb4,0xfd,0x19,0xf0,0xe8,0x83,0xe5,0xf9,0x26,0x76, -0xfd,0x0,0x20,0xd6,0xbf,0x10,0xd6,0xbf,0xe8,0xcf,0x6f,0xc9,0x57,0x3f,0xc0,0x43, -0x88,0x96,0xe4,0xb3,0xeb,0x2f,0xce,0xfa,0xd5,0xa6,0xc3,0x87,0x95,0x9f,0xa9,0x3e, -0xc7,0x2b,0x17,0x17,0x5b,0xbf,0x9a,0xb9,0xbf,0xa8,0xe6,0xeb,0x42,0xb0,0x1c,0x5f, -0x58,0xfd,0xca,0x6a,0xbf,0xc7,0xaa,0x4f,0x5c,0x92,0xf,0x47,0xf0,0xed,0xe0,0x16, -0x5c,0xf5,0x7d,0xb7,0xa5,0xd7,0xaf,0xb2,0xdd,0xff,0x2a,0x55,0xfd,0x2a,0x60,0xff, -0x2b,0x9c,0xe9,0xf3,0xd3,0x29,0xf2,0xd5,0x90,0x9f,0xaf,0x4e,0x3b,0x59,0xee,0x7f, -0x95,0x22,0xbf,0x1c,0xf0,0xf3,0xd5,0xf1,0xa3,0x2c,0xf7,0xbf,0x4a,0xe1,0x43,0xfc, -0x7c,0x85,0x61,0x96,0xfb,0x5f,0xa5,0xc8,0x2f,0x88,0x9f,0xaf,0x2,0x7d,0xd,0x90, -0x13,0x5f,0x56,0xfb,0x5f,0x65,0x93,0xaf,0x44,0x96,0xaf,0x10,0xf3,0x65,0xb5,0xff, -0x55,0xca,0x7c,0x65,0xec,0x2f,0xa5,0xbf,0x2e,0x44,0xcf,0x57,0x30,0xac,0x7f,0xc9, -0x7e,0xfd,0xd5,0xcc,0x7c,0x65,0xf8,0xfa,0x94,0xe5,0x2b,0xc0,0x7c,0x59,0xed,0x7f, -0x95,0x49,0xbe,0x62,0xeb,0xf,0x48,0xc8,0xfb,0x93,0xe9,0x1c,0xd6,0x5f,0x45,0xcd, -0x57,0x77,0x4b,0x2c,0x5f,0xad,0x86,0xfb,0x32,0x5e,0x7f,0x15,0x9a,0xaf,0xe0,0x42, -0xf6,0xbf,0x4a,0x9e,0xaf,0xe0,0x82,0xf6,0xef,0x4c,0x9a,0xaf,0x40,0xae,0x7d,0x61, -0xeb,0xdb,0xf3,0x91,0xaf,0xa,0xa1,0xf5,0xab,0x9c,0xe4,0x2b,0x73,0x7e,0x50,0x60, -0xf9,0xa,0xb2,0xfa,0x15,0x6f,0xfc,0x58,0xbc,0x8f,0xe8,0xf3,0x1f,0x55,0xf6,0xfe, -0x41,0x89,0xed,0x7f,0x75,0xd0,0xe4,0x8d,0xbf,0xcb,0xf2,0x55,0x7a,0x2,0xcb,0x57, -0xe6,0xfe,0x57,0xa8,0xc9,0xcb,0x2f,0x8b,0xf7,0x19,0xfb,0x23,0x55,0xd8,0xf8,0x3b, -0x62,0xe3,0x6f,0xfe,0x7d,0xf9,0x38,0xbe,0xd8,0xd8,0xff,0xca,0xf4,0xa9,0xf9,0xca, -0xf2,0x2d,0xf9,0xfa,0x50,0xf3,0x15,0xb0,0xe7,0x7,0x7d,0xf9,0xa,0x35,0x97,0xdc, -0xbf,0xa8,0xf9,0x6a,0xdb,0x9e,0x1f,0x4,0xcc,0x87,0x99,0x6f,0x7f,0xd9,0xfd,0xf3, -0x4,0xdf,0x72,0xcc,0xf,0xa,0x2c,0x5f,0xcd,0x65,0xff,0xab,0x64,0xf9,0xa,0x38, -0xe6,0x7,0x5,0x96,0xaf,0x72,0xe3,0x63,0xcf,0xf,0xe6,0x37,0x5f,0x81,0x8b,0x7c, -0x95,0x2a,0x5f,0x81,0x9c,0xe7,0x2b,0xcd,0x87,0x63,0xbd,0x1f,0x67,0xf1,0xe3,0xc7, -0x69,0xc0,0xfc,0x20,0xcd,0x49,0xbe,0x3a,0xee,0xf1,0xeb,0x57,0x34,0x4f,0xe3,0x2f, -0xa7,0x7e,0x45,0x73,0x92,0x5f,0xf0,0x6f,0xa8,0x7b,0xfd,0x38,0xf3,0xbd,0x97,0x13, -0xdf,0xff,0xd,0xf0,0xfd,0x4d,0x4e,0x8e,0xaf,0xb9,0xfe,0xa,0xb0,0x7c,0xc5,0x7c, -0x78,0xf9,0xf9,0x6a,0xcb,0x3a,0xff,0x98,0xf,0x2b,0x96,0x2f,0x7,0xf9,0xaa,0xca, -0xfa,0x3f,0xce,0xfc,0x20,0xcd,0x41,0xbe,0xaa,0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa, -0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa,0xe6,0x3c,0x5f,0x55,0x73,0x9e,0xaf,0xaa,0x39, -0xcf,0x57,0x5f,0x84,0xf9,0xc1,0x40,0x5f,0x4e,0xf2,0x95,0xdb,0x27,0x5f,0xb1,0xea, -0xcf,0x39,0xc9,0x57,0x6e,0x1f,0x1e,0x21,0x9c,0xaf,0x7c,0xe5,0xf5,0x61,0x94,0xaf, -0x7c,0x15,0xe8,0xdb,0xcf,0xa9,0xf,0xe6,0xf9,0xf8,0xca,0x57,0x6d,0x5f,0x2e,0xaf, -0xf,0xc5,0xf6,0xe5,0xb1,0x7f,0xb1,0xe7,0x7,0x97,0x9e,0xaf,0x2,0x7c,0x21,0xef, -0x77,0xce,0x83,0x2f,0xec,0xfd,0xce,0x4b,0xf7,0xe5,0x2a,0x5f,0x71,0xdb,0x2f,0x47, -0xf9,0xe5,0xb,0xef,0xcb,0xc7,0xf5,0x1b,0x58,0xbf,0xda,0xc8,0x53,0xfd,0x6a,0x70, -0xb7,0xc4,0xf2,0x95,0xb9,0xbe,0x98,0xa2,0x9c,0xd4,0xaf,0x80,0x5e,0xdf,0x10,0x59, -0x7d,0x43,0x9b,0xd7,0xa,0x7e,0x3f,0xdd,0x12,0x8e,0xef,0xaf,0x74,0x9f,0xf6,0x94, -0xba,0x91,0xf,0x4,0xd3,0x7,0x73,0x52,0x1f,0xfa,0x38,0xe7,0x3e,0xa3,0xfe,0xc7, -0xe6,0x8f,0x46,0xf8,0x3b,0xcc,0x97,0xab,0xf9,0x41,0xd3,0xa7,0xe6,0xab,0xe7,0x4c, -0x1f,0x58,0xe6,0xf5,0xf1,0x3d,0x59,0xee,0x5f,0x2e,0x16,0xec,0xfa,0x95,0x3d,0xff, -0xc6,0xea,0x2f,0x60,0x89,0xfd,0xb,0x91,0x50,0xf5,0xf6,0x4,0x41,0xbb,0x7e,0x65, -0xaf,0xbf,0xb2,0x7c,0x4b,0xec,0x9f,0x9,0x70,0xef,0x2f,0xea,0x7c,0x7f,0x63,0x1e, -0xea,0x57,0xa,0xa8,0xd0,0x3b,0x13,0xcc,0x7d,0xff,0xe0,0x66,0x3e,0x7c,0x64,0x72, -0x19,0xe7,0x76,0x7e,0x50,0xf7,0xe5,0x78,0xfe,0x4d,0xf5,0x85,0xef,0x2f,0xba,0x6c, -0x9f,0x84,0x6a,0x13,0x6d,0x29,0x62,0x4e,0xf3,0x15,0x39,0x91,0xc7,0xb7,0x49,0x51, -0xf3,0xe1,0xc3,0x1c,0xd6,0xaf,0xb4,0x47,0x8e,0xcd,0xfd,0xaf,0x4e,0xa1,0x9e,0xaf, -0xd6,0xca,0x2c,0x5f,0x6d,0xe4,0xe1,0xfe,0x5c,0xb0,0xf6,0xbf,0x32,0xf3,0x55,0xcb, -0xca,0x57,0xa2,0xe9,0x13,0x73,0x32,0xfe,0xee,0x51,0xf7,0xfe,0x57,0x2c,0xbf,0xfc, -0x38,0x57,0xf9,0xc5,0xf6,0xb1,0xf7,0xbf,0xbd,0x95,0x13,0x9f,0xf1,0xfc,0xe5,0x6f, -0xcb,0xbe,0xf9,0xd5,0x5c,0xcd,0xf,0xfe,0x6,0xb0,0x7c,0x85,0xf3,0x70,0x7d,0x9c, -0x9f,0xc,0xd4,0x7c,0xe5,0x98,0x1f,0xb4,0xe7,0xdf,0x70,0x1e,0xea,0x57,0x13,0x9, -0xaa,0xf9,0x2a,0xbf,0xf3,0x83,0x13,0x50,0xb9,0xed,0xdc,0xff,0xa,0xb2,0xf9,0x41, -0x5,0x55,0xf3,0x50,0x3f,0x90,0x0,0x54,0xf3,0xd5,0x77,0xed,0x7c,0xc5,0xe6,0x7, -0xf3,0x91,0xaf,0x54,0xdf,0x40,0xcd,0x57,0xd7,0x73,0x3b,0x3f,0xa8,0xb6,0xdf,0x24, -0xcf,0xf3,0x6f,0x12,0xa8,0xe4,0xdb,0x27,0xa9,0xed,0x87,0xf2,0x3b,0x3f,0x38,0x39, -0x81,0x12,0x31,0xfa,0x3f,0x1c,0xe0,0xdb,0x5b,0x66,0xff,0x87,0xec,0x7c,0xa5,0xef, -0x2f,0x3a,0xb8,0x6f,0xd5,0xaf,0x50,0x1e,0xee,0xcf,0xb1,0x9d,0xaf,0x8c,0xfd,0x9b, -0xd8,0xf3,0x3d,0x23,0x63,0x7f,0xd1,0x1c,0xe5,0x2b,0xee,0xfe,0xa2,0xaa,0x6f,0x33, -0x27,0xf9,0xc5,0xf0,0xfd,0xda,0xca,0x2f,0xd,0x36,0xfe,0xe6,0xc4,0x67,0xec,0x2f, -0x6a,0xaf,0x5f,0x63,0x3e,0x9c,0x93,0xe3,0x6b,0xec,0x2f,0xa,0xac,0x7c,0xc5,0xc6, -0xdf,0x65,0xae,0xbf,0xfa,0x70,0xba,0xa6,0xa8,0xf9,0x6a,0x93,0xf5,0x2f,0x80,0xf9, -0xb0,0x72,0x8e,0x72,0x90,0xaf,0xaa,0xb5,0xc7,0xe7,0xd2,0x44,0xbf,0xff,0xc5,0xdc, -0xfd,0x45,0x97,0x9c,0xaf,0x2a,0x8d,0xdf,0x9e,0x4b,0xee,0x7c,0x25,0xb2,0x7c,0x85, -0x96,0x3f,0xbe,0x11,0xd8,0x20,0xe7,0x93,0x9,0x2e,0xf2,0xf2,0x55,0x4e,0x7c,0xe8, -0xce,0x65,0x9c,0xd7,0xf5,0x57,0x9a,0x6f,0x7c,0x27,0xc2,0xfe,0x7,0xcb,0xf3,0xf5, -0x51,0x9e,0x7d,0xa8,0xb6,0x3,0x3f,0xc8,0x71,0xbe,0xba,0x3b,0x5d,0x83,0xef,0x98, -0xf9,0x2a,0x68,0x7e,0x10,0x2d,0xb1,0xff,0x13,0x1c,0xf5,0x2b,0x63,0x7e,0xd0,0xdc, -0xbf,0x4e,0xcd,0x57,0xec,0xfe,0x68,0xb8,0xc4,0xf1,0x43,0xab,0x51,0xb1,0x7c,0x65, -0xd4,0x37,0x44,0x96,0xf,0xac,0xfa,0xfd,0x30,0x47,0xf5,0xd,0x6b,0x7f,0x51,0x47, -0xfd,0xe5,0x20,0x27,0xf9,0xc5,0xc8,0xa7,0x3d,0xcb,0x87,0x73,0xe6,0x53,0x3c,0x3e, -0x36,0x3f,0xdd,0xc8,0x55,0xfd,0xaa,0x2b,0x7a,0xeb,0x57,0x1b,0x4b,0xbc,0x3e,0xbe, -0x27,0x2b,0x5a,0xfd,0xa,0xda,0xf5,0xab,0x3,0xd1,0x5b,0xbf,0x5a,0x62,0xff,0x42, -0x24,0x74,0x4f,0xab,0x5f,0x75,0xec,0xfa,0x95,0xb9,0xbf,0xa8,0xa3,0x7e,0x85,0x96, -0xd7,0x3f,0x13,0x50,0x79,0x5f,0xf5,0x39,0xf6,0x17,0x85,0xa2,0x98,0xa3,0xf9,0x41, -0x5,0x54,0x14,0xad,0x7e,0x65,0xef,0x2f,0xca,0xfa,0xe7,0x7c,0xd4,0xaf,0x34,0xdf, -0x40,0xcd,0x57,0x8f,0x72,0x9a,0xaf,0x8c,0xf6,0x23,0xb8,0x92,0xd3,0xfc,0xa2,0x4d, -0xf,0x6a,0xbe,0x42,0x5e,0x7d,0x12,0xaa,0xab,0x3e,0x4,0x73,0x9a,0xaf,0xc8,0x89, -0xda,0xff,0x49,0xa4,0x8,0x73,0xfa,0xfc,0xa0,0xbe,0x23,0xb1,0x3b,0x5f,0xb1,0xe7, -0x7,0xaf,0xe4,0xe2,0xf9,0x41,0xc1,0x97,0xaf,0x58,0xfd,0xde,0xce,0x57,0x38,0x57, -0xf9,0xca,0xff,0xfc,0x20,0xce,0x49,0x7e,0x31,0xf6,0xef,0x4,0xc0,0x9b,0xaf,0x86, -0xb9,0xf2,0xf5,0xcb,0x5e,0x5f,0x5e,0x8e,0x2f,0xf2,0xd4,0xaf,0x50,0xe,0xea,0x57, -0xa4,0xf1,0xb7,0x57,0xd9,0xfc,0x20,0x74,0xd7,0xaf,0x72,0xb1,0xbe,0x5d,0x79,0xaf, -0x7f,0x26,0x99,0xf3,0x83,0xde,0xfd,0x45,0x41,0xe,0xea,0x57,0xca,0xfb,0xfd,0x27, -0x92,0x73,0xff,0x2b,0xc7,0xfc,0xa0,0xb8,0xfc,0xf1,0x8d,0xe2,0xf7,0xfb,0xca,0xc4, -0xe9,0x73,0xd4,0xaf,0x56,0xf3,0xe0,0xfb,0x40,0xf5,0x5d,0xc6,0x9d,0xbc,0xce,0xf, -0xe2,0xc6,0xcb,0xca,0x24,0xbf,0xf5,0xa1,0x2f,0x80,0xef,0xa1,0x92,0xe7,0xf9,0x41, -0xa5,0xd1,0x57,0xd8,0xfc,0x20,0xcc,0x5f,0xbe,0xa2,0x8a,0x23,0x5f,0x75,0x3c,0xf9, -0x2a,0xf,0xcf,0x47,0x11,0x47,0xbe,0x7a,0xe4,0xc9,0x57,0x9d,0x9c,0x8d,0xbf,0xd0, -0x93,0xaf,0x1e,0xe5,0x2c,0x5f,0x41,0x4f,0xbe,0x62,0xc7,0x17,0xe5,0xdd,0x97,0xa3, -0xe3,0xab,0xe6,0x2b,0xd1,0xfb,0xfc,0x20,0x5c,0x6e,0xbe,0xfa,0x9a,0x27,0x5f,0x9, -0xde,0x7c,0x5,0x96,0x9b,0xaf,0x10,0x5b,0x7f,0x65,0xf8,0xec,0xf5,0xed,0xcc,0xb7, -0xb1,0xdc,0x7c,0xa5,0xfa,0x9c,0xf9,0x8a,0xad,0x3f,0x50,0x72,0xb1,0xff,0x95,0x9a, -0xaf,0xd0,0x1d,0x57,0xbe,0xba,0x5b,0x62,0xf9,0x2a,0x17,0xbe,0xf,0xfa,0xda,0xfc, -0x20,0xcc,0x71,0xbe,0xd2,0xe6,0xdf,0x60,0x8e,0xf3,0x95,0xe6,0x3,0x39,0xce,0x57, -0xaa,0x2f,0xbf,0xeb,0xdb,0xd5,0x7c,0x25,0xab,0xf9,0xaa,0x10,0x56,0xbf,0x82,0x39, -0xc9,0x57,0xe6,0xfc,0xa0,0xe0,0xad,0x5f,0x75,0x72,0x92,0xaf,0x8c,0xf5,0xd9,0x6c, -0x7f,0x51,0xbb,0x7e,0xf5,0x28,0x57,0xfb,0x5f,0xd9,0xfb,0x8b,0x32,0x5f,0x5e,0x9f, -0xcf,0xfb,0xc2,0xf8,0x96,0x79,0x7c,0xdb,0xa5,0x17,0xd4,0xfc,0x2,0x78,0xcf,0xf, -0xd6,0x72,0x90,0xaf,0x68,0x4b,0xea,0x4b,0x13,0xb4,0x1d,0xf6,0xfc,0xe0,0x52,0xdf, -0xf,0xd1,0x92,0xc0,0x6d,0x63,0xff,0x4e,0x7c,0x14,0xe4,0x5b,0xe6,0xfa,0xd8,0xfa, -0x13,0xe0,0x7a,0x3e,0xf,0xb2,0xfd,0x45,0xf3,0xf1,0xfc,0x20,0xad,0x63,0x70,0xe7, -0xb2,0xf3,0xf9,0x41,0xb6,0xbf,0x68,0x4e,0xd6,0xb7,0x6b,0xed,0x47,0xf2,0xfb,0xfc, -0x20,0xad,0x4b,0x20,0xcf,0xf9,0x45,0xf5,0xf5,0x27,0x4,0xe5,0xd7,0xd7,0x2,0x2f, -0xa8,0xf9,0x25,0xbf,0xfb,0x8b,0x8a,0x56,0x7e,0x39,0x9,0xf4,0x2d,0xb3,0xff,0x3, -0x56,0x7e,0x91,0xa8,0xb3,0x7e,0xe5,0xf4,0xe5,0x63,0x7f,0x6,0xdd,0x67,0xd5,0xaf, -0x9c,0xbe,0x7c,0xe4,0x2b,0xd3,0xd7,0x5,0x81,0xef,0xbf,0x5c,0xae,0xef,0xf3,0x9c, -0xfb,0x7e,0x97,0x4b,0xdf,0xb7,0xc1,0xb,0x66,0x7d,0x48,0x9f,0x4b,0x6f,0xc3,0x7c, -0xf9,0x8,0xb8,0xdd,0x37,0xe7,0xdf,0x8c,0xf3,0x2f,0x7f,0x3e,0x2d,0x5f,0x55,0x59, -0xff,0x97,0x37,0x9f,0x2,0xde,0xd0,0xf2,0x55,0xd5,0x37,0x3f,0x98,0x17,0x5f,0x5b, -0xcf,0x57,0x55,0xdf,0xfc,0xa0,0xe5,0x73,0xbc,0x9f,0x78,0x19,0xbe,0x9e,0x9e,0xaf, -0xaa,0x91,0xde,0xef,0xbc,0xc,0x5f,0x5f,0x32,0x7c,0x51,0xde,0xef,0xbc,0x1c,0x5f, -0xdf,0x3f,0xff,0x76,0x12,0xf9,0xbb,0xcd,0xff,0xfa,0xbd,0xf5,0x82,0x39,0xff,0x96, -0xe8,0xb3,0xc0,0xfd,0xf,0x2,0x3e,0x9f,0x17,0x8b,0x4b,0xf4,0x39,0xf6,0x3f,0x8, -0xf8,0x8c,0x26,0x68,0x99,0x3e,0x7b,0xfc,0xfd,0xa2,0xfa,0x50,0xde,0x7d,0x5b,0xb9, -0xf6,0x7d,0x5e,0xcc,0x79,0xfb,0xd1,0x5c,0xfb,0xc8,0x88,0x5c,0xf8,0xd2,0x1c,0xdf, -0xab,0x74,0xc1,0xfd,0x33,0xbf,0x6,0x54,0xc8,0xcd,0xf8,0x96,0x73,0x5f,0xb6,0x9f, -0xb,0xdf,0x85,0x2f,0xe6,0x7,0xad,0x83,0x5f,0x17,0xb,0x8,0x9f,0x4c,0xae,0x95, -0xbe,0xa7,0x28,0x68,0xe7,0x5a,0x9,0xe4,0xc9,0x77,0x8c,0x3a,0x6f,0x11,0x7c,0x7c, -0x2a,0x3d,0x19,0xc1,0xdb,0x67,0x67,0xe8,0xf9,0x11,0xdc,0xce,0x9b,0x4f,0x51,0x8e, -0x8f,0xc1,0x68,0x24,0x81,0x27,0x4f,0xa4,0xd6,0x8,0xde,0xca,0x97,0xef,0xe0,0x45, -0x85,0x1e,0x63,0x0,0xa1,0xa4,0x1a,0xa1,0xa8,0x32,0xf3,0xe4,0xeb,0xa1,0x83,0x7f, -0xf3,0x34,0xed,0xe1,0x5f,0xc2,0x92,0xf4,0x4b,0xcd,0x27,0x5d,0xcb,0x99,0xef,0xb7, -0x5d,0xe5,0xb0,0x87,0x3f,0x1,0xb0,0xf7,0x49,0xaf,0x7,0xc4,0xde,0x28,0x57,0xbe, -0x75,0xcd,0xa7,0xac,0xe3,0x3e,0x80,0xad,0x7e,0xab,0x5,0xc4,0xd6,0x71,0xae,0x7c, -0x3b,0xba,0x6f,0x7,0xf7,0x7b,0xb0,0xde,0x5f,0x5f,0x7,0x62,0xfd,0xb3,0x62,0x9e, -0x7c,0x42,0xb5,0xd7,0x25,0x58,0xa8,0xf5,0x5b,0x12,0xee,0x2b,0x8a,0xb8,0xa3,0x40, -0x90,0x33,0x9f,0xda,0x3f,0xb,0xb5,0xc3,0x9d,0x2b,0x5f,0x3e,0x54,0x7d,0x8f,0x2f, -0xe7,0xab,0x7f,0xbe,0x18,0x7f,0x2f,0x7c,0x17,0xbe,0xb,0xdf,0x85,0xef,0xc2,0x77, -0xe1,0xbb,0xf0,0x5d,0xf8,0x2e,0x7c,0x5f,0x28,0x1f,0x21,0x14,0x62,0xfd,0xc9,0x79, -0xee,0x7,0xd2,0xc3,0xe5,0xfa,0xa6,0xf7,0xe9,0xd6,0x29,0x11,0xa8,0xfe,0x7c,0x99, -0x59,0xe,0x3e,0x33,0xbe,0xd4,0xd1,0xff,0xbf,0xbd,0x64,0xdf,0x33,0xa4,0x78,0x34, -0xd,0xf4,0x6d,0xd1,0xff,0x2a,0x2c,0xd7,0xf7,0xd5,0x69,0x79,0xcf,0xe5,0x1b,0x3a, -0x7d,0x45,0x7a,0x6d,0xc9,0xbe,0x75,0x99,0x6e,0xc8,0x2,0x6d,0xb,0x9d,0xdd,0xe9, -0xb5,0xfa,0x58,0xa0,0x7b,0x54,0x2e,0xe,0x48,0xf1,0x4c,0x2e,0x52,0x48,0x8a,0xf4, -0xc6,0x92,0x7d,0x7f,0x7d,0x42,0xff,0xf9,0xef,0x54,0xdf,0x8d,0xcd,0x75,0xf9,0xf2, -0xf7,0x6,0xcf,0x9e,0x3e,0xa0,0x72,0xa1,0x7d,0xbf,0xf0,0xad,0x71,0x91,0xe,0xdf, -0xfe,0x2e,0x7d,0x66,0xc9,0xbe,0xe9,0xe0,0xe6,0xea,0xa0,0x4c,0x3b,0x57,0x4a,0x6f, -0xb,0x1f,0xbd,0xb0,0xff,0xec,0xa9,0x7a,0x7c,0x8f,0x3e,0x29,0x1f,0xad,0x1e,0x75, -0xe8,0x70,0xbb,0x43,0xbf,0xb5,0x6c,0x5f,0xfb,0x2b,0x97,0xda,0x25,0xda,0x79,0xbb, -0xbc,0x72,0xff,0xa9,0xc2,0x96,0xee,0x3b,0xdd,0xba,0xb9,0x5a,0xdc,0xef,0xd0,0x23, -0xd5,0xf7,0x2f,0x96,0xed,0xeb,0x18,0xfd,0xcb,0xdb,0xc2,0xca,0xdd,0xa7,0x4a,0xdb, -0x86,0x6f,0xfb,0xc6,0x6a,0xa9,0xd3,0xa1,0xa7,0xe5,0xe,0x7d,0x6a,0xe9,0xbe,0x8e, -0xe1,0xa3,0xe5,0x93,0x7f,0x28,0x5a,0x3e,0x95,0xd6,0xa1,0x67,0xe5,0xce,0xf0,0xf2, -0xb2,0x7d,0xfb,0xcc,0x57,0x3a,0xfa,0x87,0xef,0x6c,0x3d,0x73,0x7a,0xa4,0x1d,0xdf, -0x67,0x4e,0xcb,0xea,0xf1,0x95,0x85,0xce,0xde,0xb5,0xa5,0x5f,0x1f,0x45,0xcd,0xd7, -0xbe,0x42,0x37,0xc6,0x4f,0xfd,0xdb,0xf6,0x8d,0xd5,0x13,0x2a,0xaf,0xaa,0xff,0x28, -0xf,0x8a,0x74,0xba,0xb6,0xba,0xb7,0xbe,0x6c,0xdf,0xb8,0xa4,0xfb,0x6e,0xd0,0x7, -0xf2,0x53,0xf7,0xd4,0x8b,0xf9,0x4c,0xef,0x5f,0x56,0xcb,0x6a,0xff,0x32,0xbd,0x7f, -0x69,0x6f,0xc9,0xe3,0x9b,0xe3,0x3,0xb4,0xff,0x31,0x5a,0xb,0x12,0x23,0x3c,0x5c, -0xe4,0xab,0xb,0xdf,0x85,0xef,0xc2,0x77,0xe1,0xcb,0x9b,0xaf,0x9c,0x17,0xdf,0x86, -0x5c,0x56,0x73,0xc0,0x26,0xa5,0x85,0xb1,0x0,0xd4,0x31,0x64,0xcf,0xe9,0x23,0xca, -0xd2,0xef,0x7f,0x57,0x6,0xc5,0xb3,0xc1,0xb5,0x4b,0xf4,0xa1,0x9a,0x52,0xb7,0xa7, -0x25,0xfa,0x60,0xdb,0xe1,0x9b,0xde,0x5b,0xb6,0x6f,0xfa,0xcc,0xde,0xd6,0xd9,0xde, -0x95,0x7f,0x45,0xdf,0xfe,0xde,0xe6,0xb5,0x92,0x5c,0x52,0x33,0xbd,0xf3,0xab,0x7f, -0xb0,0xf4,0xf6,0x9b,0xc2,0xce,0x69,0xe7,0xda,0x19,0x2d,0x9f,0x6d,0x5f,0x29,0x9d, -0xa8,0xb7,0x97,0xeb,0x74,0x7b,0x4f,0x2e,0xad,0x3d,0x27,0xdf,0x24,0x74,0x7a,0x69, -0xe9,0xe7,0xdf,0x94,0x76,0x8e,0x3e,0x29,0x9d,0x91,0xf2,0xd9,0xc3,0x2b,0xdb,0x47, -0x9a,0xef,0x5e,0xf1,0xc1,0xf8,0xf2,0x8d,0x3f,0x18,0x5f,0xbb,0x4f,0xa7,0xbb,0x4b, -0xf7,0xc9,0xa4,0xb8,0xff,0x49,0x69,0x77,0x2a,0x9c,0xbc,0x5d,0xda,0x6e,0xb,0x74, -0xf8,0xf0,0x99,0xb2,0x7c,0xda,0xb9,0xb1,0x7e,0xf4,0x27,0xaa,0xef,0x6c,0xe9,0xbe, -0x93,0x69,0xa9,0xf3,0x8b,0xed,0x8d,0x29,0x3d,0xfa,0xef,0xdb,0xdb,0xeb,0x65,0xf5, -0xfc,0x7b,0x46,0x98,0x1e,0x75,0x6e,0xfc,0xf5,0xfe,0x27,0xcf,0xe6,0xc1,0x77,0x44, -0xb7,0xb6,0xfe,0xd7,0xf6,0x89,0x4c,0xf7,0xff,0x6c,0x7b,0x7b,0x5b,0xbb,0x3e,0x9e, -0xa1,0xed,0x61,0xe7,0xc6,0x2f,0x3a,0x9d,0x5c,0xf8,0xb6,0x68,0xa7,0xb4,0xbb,0x7d, -0x76,0x42,0xb7,0x36,0x54,0xdf,0xb6,0xee,0x5b,0x37,0x7c,0xff,0x2d,0xf,0xbe,0x12, -0xec,0x94,0xf7,0x1e,0x9e,0x9d,0xd2,0xd2,0xa6,0xe9,0x7b,0x96,0x5e,0x31,0x7c,0x1b, -0xaa,0x6f,0xb8,0xec,0xfe,0xe5,0xd2,0xe0,0xb2,0xd0,0xbe,0x76,0x69,0x48,0x56,0xd7, -0xaf,0xac,0xae,0x97,0xe8,0xde,0xfa,0xb3,0x5a,0x9f,0x7d,0xe5,0x17,0xed,0xe2,0xbe, -0xea,0xdb,0x5b,0x76,0xff,0xbc,0xa2,0xfa,0xd4,0xf1,0x63,0x38,0xbd,0xd4,0xfe,0x9a, -0x56,0xe8,0x78,0xb0,0xfe,0x2c,0x5d,0x19,0x5f,0xfe,0xca,0x2f,0x6,0xb9,0xf0,0x51, -0x8a,0x45,0x8a,0x5,0xed,0xf5,0x2e,0x48,0xd0,0xfe,0x4f,0xbb,0x69,0x3,0x5a,0xed, -0xf,0x8b,0x30,0xbf,0xf9,0xa5,0x93,0xef,0x7c,0x45,0x8a,0xf9,0xf6,0xa9,0x39,0xe6, -0x22,0x3f,0xff,0xa3,0xf3,0xfd,0x7f,0x6e,0x69,0x1,0x55,0x8,0x9e,0xa1,0x2b,0x0, -0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//m1284p.png: 12987 bytes diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/clean.bat b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/clean.bat deleted file mode 100644 index 9977613..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/clean.bat +++ /dev/null @@ -1,3 +0,0 @@ -del *.b#* -del *.s#* -pause diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/globals.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/globals.h deleted file mode 100644 index 0d3650c..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/globals.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -#define HTTPD_MAX_BUF_SIZE 512 //For Mega644p(4kb RAM)/Mega128(4kb RAM) - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Internet/httpServer_avr/httpServer.h" -#include "webpage.h" - -#define _MAIN_DEBUG_ - -//#include "Application/loopback/loopback.h" -//#include "Application/webserver_simple/webserver_simple.h" - -//#include // itoa etc.. -/* - * (11) Try move all pages saved at from RAM to FLASH address space - * Example of flash data access look at: - * <01_m1284p_bb00_minimum_PSTR_webpage_test> - * <09_m1284p_WIZNET_simple_webserver> - * - * Success initial porting on 10/12/2018 - FREE RAM on webserver: 7936 bytes (From total 16kbytes)! - * NEED further optimization to AVR_RAM->AVR_FLASH point (damn Harvard architecture :( )! - * - * It works on AtMega1284p(16kbytes RAM), but need TODO finish (DONE on v2.3b 12/12/2018)!! - * - * TODO DONE: - * After v2.3 optimization: - * (+4kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 2048 see )) : FREE RAM on webserver: 10372 bytes - much better! (RAM enough for AtMega1284/AtMega2560 ie. AVR with 8-16Kb RAM) - * (+1kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 512 see )) : FREE RAM on webserver: 13444 bytes - awesome! (RAM enough for AtMega644/AtMega128 ie. AVR with 4Kb RAM) - * - * OK 1) Father optimization / (v2.3 12/12/2018) - * OK 2) Father optimization / (v2.3 12/12/2018) - * OK 3) Rename httpServer.*->httpServer_avr.*, httpParser.*->httpParser_avr.*, httpUtil.*->httpUtil_avr.* (v2.3b 12/12/2018) - * Actually made another way: rename parent folder to - * OK 4) Fix not correct showed value on (v2.2 12/12/2018) - * OK 5) Correct indentation in all <*.html> and <*.js> sources and repack it again in . (v2.2 12/12/2018) - * OK 6) Add to webserver (v2.1 12/12/2018) + also added binary files support in webserver via: , bin2hex_v2.py - * 7) Publish sources in my github, wiznetmuseim, avrfreaks etc.. (optional) - * - * (10) Try repeat example HTTPServer_LPC11E36_LPCXpresso on AVR Mega1284p (All pages still in RAM) - * Here used to WEB-server handle cgi-like requests, with AJAX + JSON - * Description here: - * http://wiznetmuseum.com/portfolio-items/w5500-evb-web-server/ - * - * To better undestand AJAX look here (actually here used AJAX + XHTML): - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-automatically-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/AJAX-read-switches-analog/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-XML-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-gauge/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-IO/ - * - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * For prepare binary data (some image data, like favicon.ico) use script. - * Example usage: - * >bin2hex_v2.py favicon.ico - * >out favicon_ico.h - * After that insert into end content from favicon.ico; - * Then use this resource in www server like (look in ): - * reg_httpServer_binContent_avr(PSTR("favicon.ico"),favicon_ico, (uint32_t)sizeof(favicon_ico)); // favicon.ico : webserver icon - * - * - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example (bin2hex_v2.py BETTER SUIT for AVR!!): - * https://tomeko.net/online_tools/file_to_hex.php?lang=en - * - * (9) Simple webserver, based on code from: - * http://www.ermicro.com/blog/?p=1773 - * Article: Integrating Wiznet W5100, WIZ811MJ network module with Atmel AVR Microcontroller - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~10..12.2018 - */ - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v2.3d Static IP HTTP_server FLASH Pages WIZNET_5500 ETHERNET 12/12/2018\r\n"; // Program name - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - if(1) - { - /* Web content registration (web content in webpage.h, Example web pages) */ - - // Index page and netinfo / base64 image demo - reg_httpServer_webContent_avr(PSTR("index.html"), PSTR(index_page)); // index.html : Main page example - - //favicon.ico - reg_httpServer_binContent_avr(PSTR("favicon.ico"),favicon_ico, (uint32_t)sizeof(favicon_ico)); // favicon.ico : webserver icon - - //brd_wiznet.png - reg_httpServer_binContent_avr(PSTR("brd_wiznet.png"),brd_wiznet_png, (uint32_t)sizeof(brd_wiznet_png)); // brd_wiznet.png : webserver image - - //m1284p.png - reg_httpServer_binContent_avr(PSTR("m1284p.png"),m1284p_png, (uint32_t)sizeof(m1284p_png)); // m1284p.png : webserver image - - reg_httpServer_webContent_avr(PSTR("netinfo.html"), PSTR(netinfo_page)); // netinfo.html : Network information example page - reg_httpServer_webContent_avr(PSTR("netinfo.js"), PSTR(wiz550web_netinfo_js)); // netinfo.js : JavaScript for Read Network configuration (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"netinfo.html", (uint8_t *)netinfo_page); // netinfo.html : Network information example page - //reg_httpServer_webContent((uint8_t *)"netinfo.js", (uint8_t *)wiz550web_netinfo_js); // netinfo.js : JavaScript for Read Network configuration (+ ajax.js) - - // AJAX JavaScript functions - reg_httpServer_webContent_avr(PSTR("ajax.js"), PSTR(wiz550web_ajax_js)); // ajax.js : JavaScript for AJAX request transfer - //reg_httpServer_webContent((uint8_t *)"ajax.js", (uint8_t *)wiz550web_ajax_js); // ajax.js : JavaScript for AJAX request transfer - - //Device info page && related ajax script - reg_httpServer_webContent_avr(PSTR("info.html"), PSTR(info_page)); //info.html - reg_httpServer_webContent_avr(PSTR("info.js"), PSTR(wiz550web_info_js)); // info.js : JavaScript for Device information (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"info.html", (uint8_t *)info_page); //info.html - //reg_httpServer_webContent((uint8_t *)"info.js", (uint8_t *)wiz550web_info_js); // info.js : JavaScript for Device information (+ ajax.js) - - reg_httpServer_webContent_avr(PSTR("img.html"), PSTR(img_page)); // img.html : Base64 Image data example page - //reg_httpServer_webContent((uint8_t *)"img.html", (uint8_t *)img_page); // img.html : Base64 Image data example page - - // Example #1 - reg_httpServer_webContent_avr(PSTR("dio.html"), PSTR(dio_page)); // dio.html : Digital I/O control example page - reg_httpServer_webContent_avr(PSTR("dio.js"), PSTR(wiz550web_dio_js)); // dio.js : JavaScript for digital I/O control (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"dio.html", (uint8_t *)dio_page); // dio.html : Digital I/O control example page - //reg_httpServer_webContent((uint8_t *)"dio.js", (uint8_t *)wiz550web_dio_js); // dio.js : JavaScript for digital I/O control (+ ajax.js) - - // Example #2 - reg_httpServer_webContent_avr(PSTR("ain.html"), PSTR(ain_page)); // ain.html : Analog input monitor example page - reg_httpServer_webContent_avr(PSTR("ain.js"), PSTR(wiz550web_ain_js)); // ain.js : JavaScript for Analog input monitor (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"ain.html", (uint8_t *)ain_page); // ain.html : Analog input monitor example page - //reg_httpServer_webContent((uint8_t *)"ain.js", (uint8_t *)wiz550web_ain_js); // ain.js : JavaScript for Analog input monitor (+ ajax.js) - - // Example #3 - reg_httpServer_webContent_avr(PSTR("ain_gauge.html"), PSTR(ain_gauge_page)); // ain_gauge.html : Analog input monitor example page; using Google Gauge chart - reg_httpServer_webContent_avr(PSTR("ain_gauge.js"), PSTR(ain_gauge_js)); // ain_gauge.js : JavaScript for Google Gauge chart (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"ain_gauge.html", (uint8_t *)ain_gauge_page); // ain_gauge.html : Analog input monitor example page; using Google Gauge chart - //reg_httpServer_webContent((uint8_t *)"ain_gauge.js", (uint8_t *)ain_gauge_js); // ain_gauge.js : JavaScript for Google Gauge chart (+ ajax.js) - -#ifdef _MAIN_DEBUG_ - //display_reg_webContent_list(); - display_reg_webContent_list_avr(); -#endif - } -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - //uint32_t timer_link_1sec = millis(); - uint32_t timer_httpd_1sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } - } - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - } // End of user's code - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - //loopback_tcps(0,ethBuf0,5000); - //loopback_udps(1, ethBuf1, 3000); - - //Use WEBbrowser to connect to webserver: http://192.168.0.199/index.html - //websrv_simple(2, ethBuf2_WEBSRV, 80); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //Not used here, because led1 handle via websrv - /* - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - */ - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/userHandler.c b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/userHandler.c deleted file mode 100644 index 6d0e5d1..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/userHandler.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file userHandler.c - * @brief User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -//#include "board.h" -#include "httpUtil.h" -#include "userHandler.h" -//#include "adcHandler.h" -#include "wizchip_conf.h" -#include "globals.h" - -/* Unavailable Pins (W5500-EVB component preempted) */ -// >> UART Rx/Tx : D0 (Rx), D1 (Tx) -// >> W5500 SPI(SPI0) : D11 (MOSI), D12 (MISO), D13 (SCK) - -/* On-board Devices */ -// >> Input : D14 (SW1) / D15 (SW2) -// >> Input : AIN (Potentiometer / TEMP.Sensor) -// >> Output : D8 (LED R) / D9 (LED G) / D10 (LED B) - -/* NXP LPC11Exx GPIO functions */ -// GPIO: Pin state -//Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); - -// GPIO: Pin direction -//Chip_GPIO_GetPinDIR((LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); - -// Pre-defined Get CGI functions -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_netinfo(uint8_t * buf, uint16_t * len); -void make_json_led1(uint8_t * buf, uint16_t * len); -void make_info(uint8_t * buf, uint16_t * len); - -// Pre-defined Set CGI functions -int8_t set_diodir(uint8_t * uri); -int8_t set_diostate(uint8_t * uri); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len) -{ - //return 0; //Just a stub, not used yet.. - //uint8_t ret = 1; // ret = 1 means 'uri_name' matched - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched - uint8_t cgibuf[14] = {0, }; - int8_t cgi_dio = -1; - int8_t cgi_ain = -1; - - uint8_t i; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { -// // to do -// ;//make_json_todo(buf, len); - } - else if(strcmp_P((const char *)uri_name,PSTR("get_netinfo.cgi")) == 0) - { - make_json_netinfo(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_led1.cgi")) == 0) - { - make_json_led1(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_info.cgi")) == 0) - { - make_info(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else - { -// // get_dio0.cgi ~ get_dio15.cgi -// for(i = 0; i < DIOn; i++) -// { -// memset(cgibuf, 0x00, 14); -// sprintf((char *)cgibuf, "get_dio%d.cgi", i); -// if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) -// { -// make_json_dio(buf, len, i); -// cgi_dio = i; -// break; -// } -// } -// -// if(cgi_dio < 0) - //Analog Ins reading get_ain0.cgi ~ get_ain7.cgi - if(1) - { - // get_ain0.cgi ~ get_ain5.cgi (A0 - A5), get_ain6.cgi for on-board potentiometer / Temp.Sensor - LPC11Exx - //for(i = 0; i < AINn; i++) //for LPC11xx - for(i = 0; i < 8; i++) //for AVR Mega1284p, available AIN0..AIN7 - { - memset(cgibuf, 0x00, 14); - sprintf((char *)cgibuf, "get_ain%d.cgi", i); - if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) - { - make_json_ain(buf, len, i); - cgi_ain = i; - ret = 1; - break; - } - } - } - -// if((cgi_dio < 0) && (cgi_ain < 0)) ret = 0; - } - - return ret; -} - - -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len) -{ -// return 0; //Just a stub, not used yet.. - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched -// uint8_t ret = 1; // ret = '1' means 'uri_name' matched - uint8_t val = 0; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { - // to do - ;//val = todo(uri); - //*len = sprintf((char *)buf, "%d", val); - } -// // Digital I/O; dio_s, dio_d -// else if(strcmp_P((const char *)uri_name,PSTR("set_diodir.cgi")) == 0) -// { -// //val = set_diodir(uri); -// //printf_P(PSTR("+++set_diodir.cgi uri_name: %s; uri: %s;\r\n")); -// *len = sprintf_P((char *)buf, PSTR("%d"), val); -// ret = 1; -// } - else if(strcmp((const char *)uri_name, "set_diostate.cgi") == 0) - { - //When uri_name=set_diostate.cgi, and uri HTTP POST request which contains something like: - //pin=8&val=1; or pin=8&val=1; (look && ) - - /* - This is LPC11xx handler - val = set_diostate(uri); - len = sprintf((char *)buf, "%d", val); - len ret = 1; - */ - - - //!!Just for debug - PRINTF("\r\n+++set_diostate.cgi uri_name: %s\r\nuri: %s\r\n", uri_name, uri); - - //Parse URI (Very dirty!!) - if(strstr_P(uri,PSTR("pin=LED1&val=0"))) - { - led1_low(); - *len = sprintf_P((char *)buf, PSTR("LED1: OFF")); - ret = 1; - } - else if(strstr_P(uri,PSTR("pin=LED1&val=1"))) - { - led1_high(); - *len = sprintf_P((char *)buf, PSTR("LED1: ON")); - ret = 1; - } - else - { - //*len = sprintf_P((char *)buf, PSTR("%d"), -1); - *len = sprintf_P((char *)buf, PSTR("???")); - ret = 1; - } - } -// else -// { -// ret = 0; -// } -// - return ret; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Get CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin) -//{ -// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// -// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\ -// \"dio_s\":\"%d\",\ -// \"dio_d\":\"%d\"\ -// });", -// pin, // Digital io pin number -// pin_state, // Digital io status -// pin_dir // Digital io directions -// ); -//} -// -void make_json_led1(uint8_t * buf, uint16_t * len) -{ - if(led1_read()) - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: ON\"});")); //Send back LED1 state via call-back function - } - else - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: OFF\"});")); //Send back LED1 state via call-back function - } - -} - -void make_info(uint8_t * buf, uint16_t * len) -{ - /* - * Send program metrics: - * Program name - * time-date compile - * MCU info - * free ram info - * uptime device - */ - *len = sprintf_P((char *)buf,PSTR(\ - "
%S"\
-			"Compiled at: %S %S\r\n"\
-			"MCU is: %S; CLK is: %luHz\r\n"\
-			"Free RAM: %dbytes\r\n"\
-			"Uptime: %lusec\r\n
"),\ - str_prog_name,\ - compile_time, compile_date,\ - str_mcu, F_CPU,\ - freeRam(),\ - millis()/1000); -} - -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin) -{ - *len = sprintf_P((char *)buf,PSTR( "AinCallback({\"ain_p\":\"%d\",\ - \"ain_v\":\"%d\"\ - });"), - pin, // ADC input pin number - //get_ADC_val(pin) // ADC input value for LPC11xx - adc_read(pin) // ADC input value for AVR - ); -} - -void make_json_netinfo(uint8_t * buf, uint16_t * len) -{ - wiz_NetInfo netinfo; - ctlnetwork(CN_GET_NETINFO, (void*) &netinfo); - - // DHCP: 1 - Static, 2 - DHCP - *len = sprintf_P((char *)buf,PSTR( "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\ - \"ip\":\"%d.%d.%d.%d\",\ - \"gw\":\"%d.%d.%d.%d\",\ - \"sn\":\"%d.%d.%d.%d\",\ - \"dns\":\"%d.%d.%d.%d\",\ - \"dhcp\":\"%d\"\ - });"), - netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5], - netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3], - netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3], - netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3], - netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3], - netinfo.dhcp - ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Set CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//int8_t set_diodir(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // Direction; NotUsed/Input/Output -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > Output) val = Output; -// } -// } -// -// if(val == Input) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input -// else Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -// -// return pin; -//} -// -//int8_t set_diostate(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // State; high(on)/low(off) -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > On) val = On; -// } -// -// if(val == On) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High -// else Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -// } -// -// return pin; -//} diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/userHandler.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/userHandler.h deleted file mode 100644 index 1f9af30..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/userHandler.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file userHandler.h - * @brief Header File for User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __USERHANDLER_H -#define __USERHANDLER_H - -#include -//#define _WEB_DEBUG_ - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Public Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined CGI Interface Functions Handler -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP GET Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP POST Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - - -#endif - diff --git a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/webpage.h b/11_m1284p_WIZNET_HTTPServer_FLASH_pages/webpage.h deleted file mode 100644 index 5e5b50f..0000000 --- a/11_m1284p_WIZNET_HTTPServer_FLASH_pages/webpage.h +++ /dev/null @@ -1,2407 +0,0 @@ -#ifndef _WEBPAGE_H_ -#define _WEBPAGE_H_ -/* - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example: - * https://tomeko.net/online_tools/file_to_hex.php?lang=en -*/ - -/************************************************************************************* - * JavaScript Functions - *************************************************************************************/ -//main AJAX code -#define wiz550web_ajax_js \ -"function AJAX(a, e)\n"\ -"{\n"\ -" var c = d();\n"\ -" c.onreadystatechange = b;\n"\ -" function d()\n"\ -" {\n"\ -" if(window.XMLHttpRequest)\n"\ -" {\n"\ -" return new XMLHttpRequest()\n"\ -" }\n"\ -" else\n"\ -" {\n"\ -" if(window.ActiveXObject)\n"\ -" {\n"\ -" return new ActiveXObject(\"Microsoft.XMLHTTP\")\n"\ -" }\n"\ -" }\n"\ -" }\n"\ -" function b()\n"\ -" {\n"\ -" if(c.readyState==4)\n"\ -" {\n"\ -" if(c.status==200)\n"\ -" {\n"\ -" if(e)\n"\ -" {\n"\ -" e(c.responseText)\n"\ -" }\n"\ -" }\n"\ -" }\n"\ -" }\n"\ -" this.doGet = function()\n"\ -" {\n"\ -" c.open(\"GET\", a, true); c.send(null)\n"\ -" };\n"\ -" this.doPost = function(f)\n"\ -" {\n"\ -" c.open(\"POST\", a, true);\n"\ -" c.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\n"\ -" c.setRequestHeader(\"ISAJAX\", \"yes\");\n"\ -" c.send(f)\n"\ -" }\n"\ -"}\n"\ -"function $(a)\n"\ -"{\n"\ -" return document.getElementById(a)\n"\ -"}\n"\ -"function $$(a)\n"\ -"{\n"\ -" return document.getElementsByName(a)\n"\ -"}\n"\ -"function $$_ie(a, c)\n"\ -"{\n"\ -" if(!a)\n"\ -" {\n"\ -" a = \"*\"\n"\ -" }\n"\ -" var b = document.getElementsByTagName(a);\n"\ -" var e = []; for(var d = 0; d\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server\n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Web Server Demopage\n"\ -"

\n"\ -" Network Information
\n"\ -" Base64 Image Data
\n"\ -"
\n"\ -" Board Schematic
\n"\ -" Mounting Scheme
\n"\ -"
\n"\ -" Ex1> Digital I/O
\n"\ -" Ex2> Analog Input
\n"\ -" Ex3> Analog Input: Google Gauge Chart
\n"\ -"
\n"\ -" Device Information
\n"\ -"\n"\ -"\n"\ -"" -#define wiz550web_info_js \ -"function getInfo()\n"\ -"{\n"\ -" var oUpdate;\n"\ -" setTimeout(function()\n"\ -" {\n"\ -" oUpdate = new AJAX('get_info.cgi', function(t)\n"\ -" {\n"\ -" try\n"\ -" {\n"\ -" //*eval(t);\n"\ -" document.getElementById('info_txt').innerHTML = t;\n"\ -" }\n"\ -" catch(e)\n"\ -" {\n"\ -" alert(e);\n"\ -" }\n"\ -" }\n"\ -" ); oUpdate.doGet();\n"\ -" }\n"\ -" , 300); setTimeout('getInfo()', 3000);\n"\ -"}\n"\ -"" - - -#define netinfo_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Network Info\n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Web Server Network Information\n"\ -"

\n"\ -"\n"\ -"
    \n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"
\n"\ -"\n"\ -"\n"\ -"" - - -#define dio_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Digital I/O v1.1\n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -" \n"\ -"\n"\ -"

LED1: unknown..

\n"\ -"\n"\ -"
\n"\ -" \n"\ -"
\n"\ -"
\n"\ -"\n"\ -"\n"\ -"\n"\ -"" - -#define ain_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Analog Input\n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" \n"\ -" \n"\ -"
\n"\ -"\n"\ -"
\n"\ -" \n"\ -"
\n"\ -"
\n"\ -"\n"\ -"\n"\ -"" - -#define info_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Device Info\n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Device Information\n"\ -"

\n"\ -"

..

\n"\ -"\n"\ -"\n"\ -"" - - -//!! No space at RAM in AtMega1284p (16kb only..) -//!! Need replace all pages into FLASH memory (PROGMEM) - Shame AVR-8bit HARVARD Architecture!! - -#define ain_gauge_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Analog Input Gauge\n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" \n"\ -" \n"\ -"
\n"\ -" \n"\ -"\n"\ -"
\n"\ -"
\n"\ -"\n"\ -"\n"\ -"" - -/* Base64 Image converter: http://base64.wutils.com/encoding-online/ */ -#define img_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Image\n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
wizwebserver.png
\n"\ -"\n"\ -"\n"\ -"" - -const char favicon_ico[] PROGMEM = { -0x0,0x0,0x1,0x0,0x1,0x0,0x30,0x30,0x10,0x0,0x1,0x0,0x4,0x0,0x68,0x6, -0x0,0x0,0x16,0x0,0x0,0x0,0x28,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x60,0x0, -0x0,0x0,0x1,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x0, -0x0,0x0,0x48,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x22, -0x24,0x0,0x8c,0x96,0x4,0x0,0xcb,0xd2,0x8d,0x0,0x57,0x5d,0x11,0x0,0xaa,0xb5, -0x4b,0x0,0x41,0x44,0x17,0x0,0xf0,0xf0,0xdc,0x0,0x6f,0x7b,0x9,0x0,0xbf,0xc5, -0x70,0x0,0xdc,0xe2,0xb4,0x0,0xfc,0xfe,0xfc,0x0,0x60,0x6e,0xc,0x0,0x4c,0x53, -0x14,0x0,0x99,0xa7,0x26,0x0,0x31,0x31,0x1c,0x0,0x7c,0x88,0x4,0x0,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa6,0x8d,0x14,0x8a,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11, -0x11,0x11,0x11,0x11,0x11,0x16,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11,0x11,0x11,0x35,0x5,0xb1,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0xe0, -0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa1,0x11,0x11,0x11,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11, -0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb1,0x11,0x11,0x4a,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa1,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x11,0x11,0x19,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x91,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x18,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0xf,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x11,0x11,0x2a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0x51,0x11,0x1a,0xaa,0xaa,0xa8,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x1,0x11,0x14,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x61,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41, -0x11,0xc0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xd1,0x11,0xe0,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x11, -0x11,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41,0x11,0x50,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x81, -0x11,0x30,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0xe,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x1c,0xa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xaa,0xaa,0x1,0x11,0x12,0xaa,0xaa,0xa6,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0xf1,0x11,0x1a,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x13,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xad,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x1a,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa2,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb, -0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xd1,0x11,0x11,0xf0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa4,0x11,0x11,0x11,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf1,0x11, -0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x21,0x11,0x11,0x11,0xf0, -0x0,0x0,0x0,0x0,0xe,0x11,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x41, -0x11,0x11,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 -}; -//favicon.ico: 1662 bytes - -const char brd_wiznet_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x3,0x7f,0x0,0x0,0x3,0x91,0x1,0x3,0x0,0x0,0x0,0x78,0x37,0x89, -0x3e,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54,0x78,0xda,0xed,0x9d,0x4f, -0x88,0x24,0x47,0xbe,0xdf,0x33,0x95,0x62,0x72,0x17,0x86,0x49,0x2d,0xef,0xd2,0x82, -0x66,0x52,0x8b,0x6c,0xf6,0x62,0xcc,0xc,0xc2,0xb8,0x5,0xed,0x4e,0x3d,0x16,0x2c, -0x1e,0x6,0xeb,0x6c,0xf0,0x61,0x16,0xc1,0xd3,0xc1,0x97,0x1a,0xe6,0xe0,0x16,0x2e, -0x3a,0xab,0xdd,0x8b,0xda,0x7,0xa1,0x32,0xf8,0x22,0xc1,0xb0,0x7d,0xf4,0xd5,0xe0, -0xcb,0x33,0x98,0x37,0x59,0x2e,0x31,0xe5,0x83,0x50,0xfb,0xea,0x93,0xb2,0xb6,0x96, -0xad,0x8b,0xb0,0xb2,0xdc,0x87,0x8d,0xf6,0x8b,0xcd,0x78,0xbf,0x5f,0x44,0x64,0x66, -0x44,0x66,0x56,0x66,0x64,0x56,0x56,0xeb,0x8f,0xa7,0x44,0xcd,0x1f,0x4d,0x77,0x7d, -0x3a,0x33,0xe2,0xf7,0xe7,0xfb,0x8b,0x5f,0x44,0x5a,0xec,0x6e,0x5f,0xa9,0xf5,0xa, -0xf8,0xa,0xf8,0xa,0xf8,0xe3,0x6,0xde,0x5e,0xde,0x31,0x70,0x73,0x71,0xc7,0xc0, -0xd5,0xe3,0x3b,0x6,0xae,0xdf,0xfd,0xa9,0x3,0xff,0xf8,0xf1,0x5d,0x3,0x9f,0xde, -0x31,0x30,0xf9,0xf0,0x8e,0x81,0x64,0xfd,0x3d,0x7b,0x1a,0x3a,0xb6,0x1e,0x1c,0x38, -0x71,0xe8,0xaf,0x67,0xcb,0x74,0xe4,0x3d,0xf,0xae,0xbe,0xb6,0xf7,0xa,0x24,0x1c, -0x38,0x39,0xf1,0xd7,0x93,0x88,0x8e,0xdc,0xbf,0xf1,0xfd,0xcf,0xac,0x61,0x5d,0xdb, -0x77,0x25,0x60,0x70,0xfd,0xe0,0x4d,0xf6,0xd9,0x43,0xef,0xf2,0xf9,0x57,0xe3,0x67, -0x8b,0x77,0x0,0x78,0x3a,0xac,0x6b,0x9b,0x97,0x7e,0x80,0xe0,0xfa,0x1f,0xbf,0xc9, -0xfc,0x93,0xf,0xdc,0xe7,0x5f,0x9f,0x3e,0x5b,0xbf,0x93,0xfa,0xf,0xc6,0xc3,0xba, -0xb6,0x55,0xe9,0x7,0x8,0xae,0xff,0xd1,0x17,0x2c,0xa0,0x1f,0x7c,0x44,0xbf,0x1a, -0x3d,0x5b,0x3c,0x3a,0x7e,0xf8,0x60,0xd8,0x2b,0x5c,0x6f,0xf4,0xbf,0xdf,0xf8,0xd7, -0xff,0xe0,0x73,0x37,0xa0,0x8b,0x35,0x89,0xff,0xef,0xc8,0x1d,0x1d,0xfe,0xee,0x5f, -0xe,0x3b,0x86,0xeb,0xdb,0x12,0xf0,0xa,0x81,0xc7,0x87,0xeb,0xf5,0x26,0xfe,0xe3, -0xe8,0xe1,0xb3,0x37,0x9f,0x7f,0xed,0xec,0x15,0x18,0xfb,0xd7,0xff,0xf0,0xb,0x76, -0x7c,0xe0,0xae,0x57,0x5f,0xfd,0xf5,0xb3,0xf4,0xd9,0x17,0xcf,0xbf,0xe,0xf7,0x7a, -0x4b,0x63,0xef,0xfa,0x9f,0x7c,0xc1,0xfc,0x3,0x67,0xbd,0xf8,0xfa,0xbd,0xbf,0x48, -0x9f,0xfd,0x47,0xeb,0xb5,0x61,0x81,0x37,0xa5,0x49,0xb3,0xbe,0xbe,0x7e,0xfc,0x5, -0x9b,0xbe,0x79,0xb3,0x9e,0x7e,0x5,0xc0,0xcd,0x1b,0x43,0x3,0x89,0xab,0xff,0x7d, -0x1,0xc0,0xcf,0x9d,0xc9,0xe3,0x1b,0x30,0xfc,0xb3,0x67,0x94,0x80,0xa7,0x19,0x16, -0x48,0xbd,0x12,0x70,0x81,0xc0,0xf8,0xe9,0x66,0x6d,0xc5,0xe9,0x33,0x4a,0xc3,0x3e, -0x40,0x7a,0xcf,0x83,0xf,0x5e,0xe0,0xc7,0xb1,0xc4,0xa,0xf6,0x9f,0xb5,0x11,0xcb, -0x85,0x5b,0x27,0x80,0xb1,0xe5,0x97,0xfe,0xf5,0xc5,0xf0,0xc0,0xc4,0x72,0x58,0x22, -0x81,0x91,0xe5,0xdd,0x1,0xf0,0xc9,0x9c,0x25,0x73,0x9,0xf4,0x3d,0x96,0xfe,0x66, -0xdf,0xc0,0xcd,0x8a,0x6d,0x96,0x2,0xf8,0xa5,0x37,0x65,0xf4,0xc9,0x5d,0x0,0x13, -0x1c,0x3f,0x97,0xbd,0x74,0xa7,0x8c,0x7c,0x15,0xde,0x1,0x90,0xbc,0xcf,0x81,0xb, -0x67,0xca,0x6e,0xbf,0xbe,0xb,0x20,0x75,0x5,0x70,0xd6,0xa,0x4c,0xc0,0x5b,0xa7, -0x87,0x60,0x3d,0xdf,0xf4,0x6,0x32,0x0,0xa6,0x2e,0x4b,0xc2,0x5,0x5b,0xc4,0x0, -0xfc,0x9d,0x19,0xf0,0x6a,0x30,0xe0,0xf3,0xe6,0x5b,0x1a,0xec,0xc,0xc,0xc1,0x2c, -0x18,0x18,0x7f,0xb0,0x60,0xf3,0x4,0xbc,0xce,0x81,0xe2,0xac,0x6b,0xbe,0x3e,0xf0, -0x7e,0x99,0xfe,0xeb,0xe3,0xe3,0x4f,0xee,0x79,0x3f,0x9f,0xf7,0xf3,0x34,0xc1,0x25, -0x23,0xe1,0x25,0xa3,0xbe,0xf0,0x34,0xe9,0xbb,0xcd,0xc0,0x13,0xd7,0x4a,0xff,0xd5, -0xd1,0xe1,0x6b,0xaf,0xdf,0xb3,0xcf,0x7b,0x1,0x69,0x0,0xb6,0x7,0xc0,0xd4,0xaf, -0xfa,0xd2,0x3a,0xe0,0xf1,0x87,0x7,0xe9,0x5f,0x3d,0xfe,0xf4,0xc3,0xe7,0x2f,0x1f, -0x3f,0xdf,0x1,0x8,0x86,0x6f,0xa,0xbc,0x39,0x4e,0xff,0xea,0x9d,0xaf,0x6e,0xae, -0x3e,0xf9,0xd8,0x1a,0x24,0xf3,0x4e,0xff,0x9d,0x12,0xe1,0xed,0x7a,0xe0,0xbf,0x0, -0xe0,0xf3,0x7b,0x3,0x1,0xe9,0xa8,0x1d,0xf8,0x6f,0x10,0xf8,0xf2,0x63,0xbf,0x1f, -0x30,0x2,0xcb,0x9a,0x40,0x68,0x7,0xc3,0x4f,0x21,0x5a,0x10,0xa2,0xdf,0xd2,0xe9, -0x45,0x75,0xc,0x3f,0x7c,0xfc,0xe9,0xcd,0xe7,0x7d,0xc7,0x90,0x4d,0x1c,0x9,0x73, -0x19,0x5,0xe0,0x2d,0xd,0x75,0x60,0x29,0x11,0x3c,0x86,0x59,0xfa,0xe1,0xa3,0xc3, -0x9b,0xdf,0xf6,0x9d,0xa5,0xc,0xe2,0xa1,0x80,0x81,0x2d,0x22,0x30,0xd5,0x81,0xf, -0xec,0xb2,0x1d,0xbe,0x9d,0x7e,0x78,0x7c,0x7c,0xf3,0xdb,0x5f,0xf5,0xb4,0x43,0xa, -0x1f,0x48,0x1d,0x91,0x30,0x25,0xf0,0x2e,0x1,0xd3,0xc3,0x37,0x6a,0x7c,0x8d,0x48, -0xfc,0x7b,0xa6,0x18,0xbf,0x80,0xf7,0xdb,0x0,0x7b,0x1f,0x26,0x9,0x58,0x87,0x7a, -0x4b,0xf1,0x3,0x8e,0x8f,0xb6,0x0,0x53,0xa7,0xa7,0x6b,0x7b,0x2c,0xa4,0x35,0xc2, -0x66,0xf0,0xa6,0x44,0xab,0x62,0xa4,0xc7,0xa7,0xdb,0xae,0xd0,0xed,0x9,0x7c,0xa, -0x6f,0x48,0x78,0x31,0xe8,0x63,0xa6,0x91,0xda,0x6d,0xc0,0x5d,0xe3,0x61,0xe9,0xa, -0x99,0xb3,0x67,0x60,0x79,0xc,0x4b,0x85,0xa1,0xe1,0x81,0xe5,0x59,0xca,0xd8,0x77, -0x1a,0xf0,0x60,0x34,0x74,0x15,0xa3,0x64,0x87,0x65,0xa0,0xf5,0x64,0x68,0x60,0xc9, -0xd3,0x94,0x80,0xcc,0x5a,0xe,0xd,0x2c,0xf9,0x52,0x15,0x88,0xce,0xfb,0x7c,0xb5, -0xf7,0xc2,0xd0,0x77,0x8d,0xd1,0x62,0xaf,0xc0,0xbd,0xa8,0xa7,0x3b,0x7,0x26,0xd2, -0xd,0xaf,0xb8,0xba,0xa8,0xde,0xd2,0xe9,0xc5,0xd0,0xc0,0x50,0x40,0x71,0x32,0xce, -0x6b,0x80,0x9e,0xbd,0x77,0xa0,0xf2,0x5a,0xee,0x3,0x18,0x8,0x68,0xc,0x7f,0x9e, -0x31,0xdd,0x97,0x32,0xc8,0x1e,0xef,0x5b,0x43,0xbb,0x36,0x30,0x3d,0xea,0x63,0x42, -0x2c,0xe0,0x54,0xfd,0xe,0xd0,0xa7,0x87,0x8f,0x86,0x9e,0xa5,0x60,0xf3,0x69,0x6, -0xc5,0x37,0x55,0x73,0xd6,0x3d,0x38,0x6f,0x7e,0x1f,0x2f,0x24,0xb8,0x94,0x62,0x90, -0x70,0x1f,0xc0,0x58,0x81,0x3a,0x3a,0x70,0xc9,0xf6,0x1,0x54,0x67,0xcc,0x4c,0x7, -0x82,0x59,0xec,0x1,0xa8,0xce,0x18,0x80,0xef,0x1f,0xa8,0xcd,0x98,0x40,0x3,0xe2, -0xbf,0xe,0x1f,0x80,0xd5,0x19,0x3,0x70,0x62,0xe9,0xe5,0xb3,0xe1,0xe3,0x21,0xf7, -0x2f,0x97,0x32,0xed,0xd3,0x81,0xab,0xdb,0xbd,0xc4,0xc3,0xcc,0x6d,0xe3,0x7b,0xaa, -0x7b,0xb6,0xdb,0x3b,0x9,0xc0,0x8a,0xc5,0xdc,0xde,0x41,0x3c,0x54,0x6b,0x6d,0xf1, -0x3e,0x96,0xf3,0x78,0xbd,0xd4,0xf2,0x61,0xec,0x7c,0x7e,0x4b,0xd5,0x5a,0xdb,0x1f, -0xdf,0x64,0x69,0x30,0x38,0xf0,0x75,0x1d,0xa8,0xd6,0xda,0xd6,0x3f,0x67,0xa9,0x3f, -0x34,0x90,0xc8,0x7c,0x34,0xe1,0x19,0x9b,0x5e,0xfa,0x5a,0x9f,0x73,0x2b,0x1d,0xba, -0x5e,0xfa,0x6b,0x10,0x33,0x97,0x2c,0xf6,0xdd,0x2a,0x70,0x29,0xac,0x74,0x58,0x20, -0x48,0xa7,0xcd,0x6a,0xc1,0x7e,0xef,0x9,0xb3,0xd0,0x6a,0x6d,0x1b,0x19,0x94,0x7, -0xaf,0x26,0x2,0x70,0xe5,0x8a,0x12,0xb4,0x5e,0x6b,0x13,0xbe,0x7d,0x3f,0xc0,0xb, -0x1,0x54,0x6b,0x6d,0xa2,0x34,0xb6,0x2f,0xe0,0x4c,0x0,0xd5,0x5a,0x1b,0x66,0x6d, -0xd4,0xdf,0x17,0x10,0xc4,0x61,0x5c,0x72,0x6d,0x3c,0xd5,0x77,0x7,0x9f,0xa5,0x58, -0xd5,0xbf,0x64,0x4b,0x10,0x87,0x49,0x30,0xad,0xd6,0xda,0x2e,0xee,0x10,0x18,0x87, -0xfb,0x0,0xe2,0x42,0x89,0x23,0x6a,0xde,0xc4,0x2f,0x1,0x3d,0x99,0xf3,0xc,0xee, -0x69,0x5c,0xe1,0x69,0x68,0x9,0xc8,0x2b,0x1a,0x89,0x2e,0x5f,0xad,0x86,0x97,0x6d, -0xbe,0xd8,0x25,0x7c,0x69,0x5a,0x2,0xf2,0xfc,0x9f,0xe8,0x9,0x40,0xe3,0x6b,0xe7, -0xc6,0x81,0xaa,0xae,0xd8,0x2f,0x90,0x54,0x3d,0x77,0xa3,0x55,0x92,0x9d,0x23,0x7e, -0xb8,0x7,0x20,0x75,0x57,0x7c,0xc1,0x92,0x1c,0xf8,0x2c,0x39,0xc8,0xa,0x77,0x3e, -0x8b,0x20,0xf4,0x62,0x3a,0xa3,0xd7,0xfa,0x6,0x0,0x12,0x67,0xc5,0x17,0x2c,0x71, -0x96,0xe6,0xb,0x96,0x0,0x9c,0x9c,0x5,0xfc,0xa,0x7,0x7,0x26,0xf6,0xa,0xec, -0x50,0xac,0xae,0xe5,0xb,0x96,0x0,0xb4,0x4e,0x2,0x1c,0xc3,0xd4,0xb2,0x86,0x6, -0x3e,0x1,0x20,0x38,0xee,0xe5,0x85,0xcb,0xe6,0x4e,0x1,0xbc,0xff,0x20,0xc0,0x59, -0xba,0x7,0x60,0xf2,0x21,0xdb,0x80,0xe3,0x5e,0x2d,0x16,0x6c,0xb1,0x98,0xe6,0xc0, -0x87,0xf7,0x2,0xb4,0xc3,0x3d,0x0,0xc9,0xdb,0x6c,0x93,0xbc,0xaf,0x1,0x27,0x30, -0x96,0xfe,0x6b,0x1,0xf7,0x34,0xaf,0x6b,0x63,0x18,0x5b,0x2c,0xdc,0x15,0x48,0x1d, -0xb6,0x21,0x6e,0x15,0x38,0x81,0x49,0x3,0xa1,0x69,0x52,0x2,0x36,0x5,0x64,0x33, -0x60,0xea,0xf0,0x5,0xcb,0xa,0x30,0x12,0xb3,0x34,0x2a,0x1,0xa3,0x9d,0xaf,0x30, -0x84,0x68,0x1,0xca,0x69,0x9,0x91,0x76,0xce,0xc4,0xa4,0x59,0xc2,0x18,0x7a,0xa0, -0x17,0xd7,0x15,0xe3,0x5f,0x95,0xc5,0x55,0xf,0x60,0x70,0x1,0x50,0x8,0x4f,0x0, -0x9d,0xc9,0x2c,0x34,0x39,0xf3,0x99,0x2b,0xef,0x5d,0x52,0x2,0xfe,0x97,0x5d,0x81, -0x24,0x98,0xf3,0xf5,0xc3,0x4,0x60,0x4b,0x99,0x67,0x13,0x0,0x5e,0xd2,0x20,0x2b, -0x2c,0x68,0xc0,0x78,0x67,0xd7,0x16,0xac,0xf8,0x72,0x1e,0x1,0xd8,0x46,0x2a,0x9, -0xa,0xc0,0x45,0xf6,0xe7,0x12,0xf0,0xcb,0x7d,0x3a,0xef,0x1a,0x2d,0x49,0x3e,0xbd, -0x13,0x20,0xe8,0x80,0x8,0x26,0xee,0x1c,0x80,0x6f,0xde,0xd,0xf0,0x81,0x1d,0xf9, -0xa9,0x7f,0x1,0xc0,0x7f,0xb6,0xb3,0xa7,0x29,0xd5,0x4b,0x33,0xe1,0xd,0xd3,0x7, -0x47,0x51,0x8c,0xe4,0xfa,0xd3,0x8f,0x29,0x8,0xa9,0x77,0x1,0x18,0xee,0xc,0x2c, -0x95,0x2f,0xb3,0x12,0x83,0x27,0xa,0x2a,0x62,0xde,0xae,0xbf,0xa2,0x0,0xfc,0x0, -0x22,0x24,0x61,0x77,0x3,0xfc,0x14,0x80,0xf4,0x3,0xf0,0x47,0xc9,0xee,0xc0,0xa0, -0x52,0xfd,0x2a,0x55,0x6e,0x70,0xc,0xef,0x23,0x70,0x61,0x83,0x20,0xd8,0x3d,0xc5, -0xf0,0x2a,0xd5,0xaf,0x1c,0x7e,0x9e,0x25,0xde,0xf1,0x31,0x2,0xd7,0x30,0x86,0xd1, -0xee,0x49,0x94,0x5b,0xa9,0x7e,0xe5,0xd0,0x28,0xab,0x12,0xaf,0x29,0x0,0x89,0xb, -0xc0,0xff,0xb0,0x3b,0xb0,0xe6,0x1e,0x66,0x57,0x9c,0xc1,0x1,0x48,0x0,0xe8,0x0, -0xf0,0x60,0x77,0x60,0xa9,0x5e,0x9a,0x5f,0xb1,0x2,0x6,0x20,0x98,0xc5,0xed,0xcd, -0xbb,0xec,0xf7,0x47,0xbb,0x3,0x5b,0x66,0xc,0x17,0xa4,0xeb,0xd4,0xa6,0x6c,0x73, -0x73,0xc1,0xe2,0xd3,0xdd,0x81,0x6d,0x33,0xc6,0xe5,0x42,0xd1,0xa5,0xec,0x66,0x3, -0xb9,0xdd,0xee,0x76,0xd8,0x3a,0x63,0x34,0x7d,0xb8,0x1c,0x0,0x58,0x3b,0x63,0x4a, -0xf0,0x5c,0x2c,0xae,0x86,0x0,0xea,0xf5,0x52,0xee,0x5b,0x10,0x8a,0x1,0x98,0x84, -0x85,0x3e,0xe4,0xc0,0xf9,0x10,0xc0,0x3a,0xb7,0x2d,0x5d,0x37,0x46,0x5f,0xd,0x71, -0x31,0x4,0xb0,0xcb,0xcb,0xb9,0x63,0x60,0xfa,0xf6,0x1d,0x3,0xe9,0x87,0xbb,0x3, -0xcb,0xd,0xad,0x9,0x26,0x9e,0x52,0x1f,0x4e,0x66,0xa5,0x24,0x8a,0xc,0x30,0x4b, -0xcb,0xd,0xad,0x31,0x36,0x62,0x49,0x7d,0x88,0x42,0x46,0x3,0x6e,0x86,0x8,0xc0, -0xbc,0x4e,0x53,0x34,0xb4,0x46,0x96,0x9f,0xe9,0x43,0x50,0x4e,0xa1,0xae,0x9e,0x56, -0xb1,0x35,0x80,0x3e,0x9c,0x73,0x7d,0x98,0x35,0xb4,0x46,0x27,0x7e,0xa6,0xf,0xd3, -0xfb,0x7,0x39,0x50,0xd4,0x67,0xdc,0x21,0x80,0x58,0xdc,0x8b,0x5,0xf0,0xa5,0x37, -0x65,0x2f,0x7d,0x3f,0xd3,0x87,0xe9,0xc9,0x71,0xe,0xbc,0xe2,0xbf,0x7e,0x37,0x14, -0x30,0x91,0xfd,0xa5,0xee,0x94,0x2d,0x3c,0x3f,0xd3,0x87,0x8,0xcc,0xf4,0xe1,0xd5, -0x70,0x82,0x94,0x37,0xb4,0xca,0xfe,0xd2,0x39,0x0,0x2f,0xfd,0x4c,0x1f,0x72,0xe0, -0x64,0x2f,0xc0,0xac,0xa1,0x75,0x9,0xc0,0xb9,0x9f,0xe9,0x43,0xe,0x8c,0x6,0x7, -0x62,0xbb,0x27,0x44,0xa,0x12,0x8a,0x76,0xcf,0x79,0xec,0x67,0xfa,0x30,0xf5,0xc0, -0x79,0xc7,0x3f,0x7e,0xa0,0x14,0xa4,0xd8,0x5f,0x9a,0xd9,0xa1,0x14,0xa4,0xa9,0xb, -0xf1,0x30,0x19,0x1a,0x98,0x35,0xb4,0xa6,0x7e,0xe1,0x69,0x32,0x41,0xea,0x26,0xb9, -0x20,0x1d,0xe,0x58,0xee,0x2f,0x45,0x5f,0x9a,0x9,0xd2,0xcb,0x4d,0xee,0xda,0x86, -0x3,0x1a,0xbe,0x5e,0x1,0x3b,0x0,0x4b,0x4d,0x58,0xc9,0x23,0x30,0x85,0x27,0xf0, -0xbf,0x21,0x4d,0xc4,0x78,0x78,0x7e,0x31,0x34,0xb0,0xd4,0x66,0x96,0xbc,0x5,0xc0, -0xf7,0x0,0x38,0x81,0x7f,0x82,0x64,0xf8,0xdc,0x19,0x1a,0x58,0x6a,0xa4,0x43,0xb3, -0x88,0x60,0xa6,0x4e,0xe0,0x8d,0x91,0xc2,0xb2,0x87,0x36,0x8b,0x52,0xab,0xe0,0xfc, -0x35,0x9f,0x7d,0xf2,0x3a,0xc4,0xc3,0xd7,0x21,0x1e,0xfe,0x2c,0x4c,0xf,0xde,0x18, -0xda,0xf0,0x4b,0xcd,0x90,0x18,0x2d,0xa6,0xf,0x20,0x1e,0x42,0x0,0x3e,0x39,0xc, -0xb3,0x86,0xd6,0x1,0x5d,0x5b,0xa9,0xdd,0x73,0x31,0x5,0xe0,0x43,0x0,0x9e,0x88, -0x0,0x2c,0x9b,0x3f,0x6,0x4,0x96,0x1a,0x5a,0xf7,0xf,0xbc,0xeb,0x2b,0xac,0x8c, -0xe1,0xbe,0x81,0xe5,0x59,0xba,0x77,0x60,0xd9,0xe,0x31,0x1e,0x62,0x8a,0x61,0x59, -0x5a,0x5e,0xba,0x3f,0x4f,0xb3,0x7f,0x60,0xc9,0x97,0xee,0x1f,0xf8,0x2a,0x1e,0xb2, -0x3d,0x9b,0x5,0x64,0x8a,0xc,0x32,0x45,0x16,0x81,0x6a,0x9b,0x4,0x6c,0xf8,0xcc, -0xfb,0xce,0x81,0x4,0xbe,0x82,0xd8,0x62,0x8f,0x58,0x8c,0x6f,0x80,0x46,0x0,0x9d, -0xc0,0x1b,0xa5,0xa2,0xdc,0x28,0x34,0xa0,0x2f,0x95,0xa9,0x21,0xa,0xb1,0x8,0xdf, -0xb6,0x34,0x4d,0xe1,0xf,0x52,0xb9,0x86,0x39,0x20,0x70,0xc,0x40,0xc8,0x76,0x97, -0x90,0xf4,0xce,0xf1,0xbd,0x64,0xec,0x72,0xce,0x98,0x77,0xc1,0x52,0xf,0xf3,0xe3, -0xc1,0x81,0x90,0xf0,0x6e,0x20,0xdb,0x45,0xf5,0xbe,0xc0,0x37,0x24,0xbf,0x53,0x8, -0x57,0xfe,0x9c,0xa5,0xc1,0x2,0xde,0xd3,0x57,0xc0,0x9f,0x8,0xf0,0x7a,0x40,0xb3, -0x70,0xe0,0xed,0xe6,0xeb,0xf8,0x5b,0xa2,0xc5,0x2b,0xe0,0xe0,0xd1,0xe2,0x15,0xf0, -0x15,0xf0,0xa7,0xe,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0x21,0x6,0x77,0x2c,0xf0,0xee, -0x7e,0x85,0x44,0xf6,0xb3,0xf1,0x6d,0xe6,0x4d,0x40,0x5e,0x52,0x76,0x76,0x7,0x26, -0x1c,0x18,0xb6,0x3,0xb3,0x5e,0xc2,0x5d,0x81,0x71,0x76,0x3f,0x5b,0x80,0x69,0xd6, -0xda,0xb7,0x2b,0x90,0xf,0xd,0x66,0x77,0x2d,0x40,0x6a,0x65,0xb7,0x62,0x47,0xa0, -0xa8,0xf6,0x7b,0x3f,0x3c,0x20,0x29,0xe6,0xf2,0x6e,0x40,0xf1,0x39,0x6e,0x2b,0x50, -0x4c,0x2e,0xcb,0xdf,0x15,0x28,0xe7,0x82,0xd3,0xa,0x14,0x93,0xcb,0xf2,0x76,0x5, -0xd2,0xbc,0x75,0xb6,0x5,0x18,0xe5,0xb7,0x62,0x37,0x20,0xc9,0x3b,0x59,0x5b,0x80, -0x93,0xfc,0x56,0xec,0x6,0x94,0x43,0x3,0xb3,0xaf,0xa,0x4c,0x8b,0x11,0xb,0x59, -0xd1,0x63,0xbb,0x1b,0x30,0xce,0x3d,0x69,0x33,0x30,0xb5,0xac,0x8e,0x76,0xb1,0x5, -0x28,0x87,0x6,0x3e,0xba,0xf9,0x96,0x52,0xd5,0xc7,0x77,0x2,0x2a,0xf1,0xc1,0x67, -0x45,0x17,0xb6,0xd7,0x2,0x24,0xea,0x37,0xf5,0x5,0x7a,0xb9,0x55,0xe0,0xec,0xab, -0x1,0x16,0xc7,0x3c,0x86,0x89,0xf2,0x4d,0xdd,0x80,0x13,0xd,0x98,0xdf,0x29,0xa7, -0x6e,0xc,0x8b,0x29,0x19,0xc6,0xc5,0x4f,0xd6,0x11,0xa8,0xbc,0xa6,0x85,0x55,0x80, -0x21,0xd6,0x0,0xdf,0x29,0x80,0x51,0xf1,0x93,0xed,0x4,0x4c,0x8a,0x96,0xf2,0x1a, -0xe0,0xb3,0x2,0x38,0x51,0xba,0xeb,0x77,0x1,0xc6,0x45,0x86,0xd1,0xc,0x54,0x9b, -0xdd,0x77,0x1,0x46,0xc5,0x94,0x6d,0x4,0x9e,0x15,0xc0,0x70,0x27,0x60,0x31,0x85, -0xbc,0x46,0xe0,0xa9,0x9e,0x6c,0xf5,0x7,0x16,0x9f,0xe3,0x36,0x7a,0x9a,0x91,0x6e, -0xbd,0xbd,0x81,0x69,0xf1,0x39,0x4e,0x23,0xf0,0x89,0x66,0x4c,0xfd,0x81,0x54,0xd9, -0xdb,0xd1,0xe8,0x69,0xde,0x53,0x6e,0xc5,0x2e,0x40,0xa2,0xf8,0x9d,0x17,0x86,0x99, -0xb7,0xb3,0xb,0x30,0x69,0xce,0xbc,0x3f,0xf,0x6b,0x80,0xf6,0x2e,0xc0,0xb8,0x19, -0x78,0x10,0x68,0x40,0x3f,0x19,0x6,0xe8,0xa4,0x5b,0x80,0xe9,0x3b,0xbe,0x6,0x14, -0xbf,0xed,0xe,0xf4,0x85,0xf9,0xd7,0x0,0x9f,0x5d,0x7d,0xaf,0x40,0x47,0x75,0x4c, -0x6d,0x7b,0x7d,0x9a,0x80,0x32,0xe7,0xac,0x1,0x7e,0xa4,0x1,0x5d,0xa6,0x8d,0x79, -0xd3,0x2b,0x6c,0x2,0xda,0x32,0x48,0xd5,0x1,0xb5,0x31,0xf4,0xc5,0x17,0x1a,0xdc, -0xd2,0xb4,0x11,0xe8,0xca,0xb8,0x5f,0x33,0x4b,0xef,0x69,0xb3,0x34,0x10,0xf1,0x7a, -0x67,0xa0,0x57,0x7c,0x5e,0x19,0xf8,0x99,0x66,0x87,0xa1,0xf8,0xc9,0x76,0x6,0xfa, -0x32,0x77,0xb,0xda,0x3c,0x4d,0xe,0x94,0xe5,0x7b,0x74,0xb5,0x14,0xbe,0x8d,0x5a, -0x21,0xaf,0xf4,0x27,0xf8,0xb6,0xb1,0xd2,0xdf,0x1f,0xf8,0x77,0x2a,0x50,0xfe,0x6e, -0x67,0x8b,0x5c,0xb8,0xb2,0x46,0xf8,0x6,0xe4,0xac,0xca,0x1f,0xca,0x2a,0x7f,0x33, -0x30,0x90,0xe9,0x70,0x1b,0xd0,0x96,0x29,0x98,0x4d,0xc1,0x40,0xc4,0xda,0xa1,0xcb, -0x37,0x5b,0x25,0xbc,0xc5,0x5,0x8d,0x2b,0xe0,0x6b,0xf9,0x13,0xab,0x19,0x18,0xca, -0x84,0xdf,0x18,0x48,0xe0,0x8f,0x84,0x97,0x30,0x1d,0x5e,0xc2,0x8c,0x79,0x9,0xd3, -0xcb,0x4a,0x98,0xf0,0x3e,0x1b,0x4,0xe8,0xca,0x44,0xdd,0x86,0x2f,0x86,0x6f,0xb0, -0xe1,0x9b,0x6d,0xf8,0xbb,0x3,0x6f,0x17,0x60,0x2e,0x7c,0x8d,0x7,0x63,0xec,0xc3, -0xfb,0xa4,0x11,0x98,0x69,0x28,0x63,0x20,0x7c,0x13,0xa6,0xa9,0x98,0x39,0x2,0x8, -0x86,0x14,0xa0,0xc2,0x23,0xbb,0x60,0x36,0x1e,0xbc,0x1f,0xe,0xb,0x8c,0xbc,0x49, -0x10,0xf9,0x56,0x30,0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0x9d,0x5a,0xc4,0xa6, -0x36,0x71,0x88,0x9d,0xb8,0xc4,0x89,0xef,0xd,0x2,0xf4,0xa4,0xd8,0xb2,0x23,0x3f, -0xa,0xa2,0x60,0x12,0x4c,0x42,0x0,0x32,0x0,0xa6,0x76,0xa,0x38,0xea,0x50,0x7, -0x90,0x2e,0x71,0x93,0x46,0xa0,0x9d,0xe9,0x60,0x73,0x60,0x10,0x7,0x51,0x8,0x48, -0x16,0x85,0x60,0x94,0xa9,0xcd,0xec,0xd4,0x1,0xa4,0x9b,0x2,0x8e,0xba,0xc4,0x23, -0x43,0x3,0xc3,0x24,0x88,0x58,0x1c,0x9c,0xb3,0x38,0x84,0x29,0x3,0xa,0xe4,0x3c, -0x75,0x99,0x4d,0x3d,0xe6,0x10,0x2f,0x75,0x89,0x4f,0xfb,0x3,0xd9,0x4e,0xc0,0x54, -0x8b,0x20,0x9e,0x1,0x30,0xda,0xd,0x48,0x35,0xa0,0x6b,0x0,0xb4,0x82,0xdd,0x80, -0xda,0x4d,0x5a,0xb7,0x3,0xd3,0xe0,0xae,0x81,0xe1,0xd5,0x4e,0xb3,0x74,0x30,0xa0, -0xa9,0x1d,0xee,0x8,0xec,0xee,0x69,0xea,0x81,0xd,0x9e,0x66,0xb,0xd0,0xd8,0x97, -0xfe,0x8,0x80,0x96,0xbf,0x53,0x78,0xda,0x11,0xd8,0x3d,0x0,0x6f,0x1,0x36,0x5, -0x60,0xb6,0x53,0x8a,0xb1,0x23,0xb0,0x7b,0x12,0xb5,0x5,0xd8,0x90,0x44,0x7d,0x1e, -0xee,0x94,0x26,0x6e,0x1,0x36,0xa4,0x89,0xba,0x3e,0xec,0x9c,0x8,0x53,0x55,0x8b, -0x84,0x6,0xc0,0x92,0x3e,0xec,0x9c,0xea,0x53,0xf5,0x6c,0xbc,0x2,0xb8,0x3d,0xd5, -0x2f,0xc9,0x35,0x9f,0x69,0x35,0x81,0x76,0xf5,0x44,0xd9,0xff,0x29,0x82,0x53,0x18, -0xb7,0x8b,0x99,0x12,0xb0,0xb3,0x5c,0xa3,0xec,0xdb,0xa2,0x14,0x11,0xc6,0xa1,0x81, -0x5c,0xab,0x13,0xa4,0xe6,0xa,0x18,0x80,0xf9,0xdf,0x6e,0x42,0x1a,0x1a,0x8,0xd2, -0xdd,0x34,0xfe,0x36,0xe0,0x56,0xc9,0x5d,0xd2,0x87,0x9d,0xab,0x18,0xdb,0x80,0x5b, -0xab,0x18,0x25,0x7d,0xd8,0xb9,0x4e,0xb3,0xd,0x68,0xb2,0x24,0xdb,0xab,0x12,0x55, -0x3,0xac,0xaf,0x44,0x25,0x76,0xe2,0xe0,0xb6,0x7d,0x30,0xa7,0xf4,0x71,0x7a,0x2, -0xbe,0x8c,0x58,0x7d,0x6a,0x6d,0x35,0xc0,0xfa,0x5a,0x5b,0x62,0x25,0x36,0x7,0x82, -0xcf,0x7c,0x44,0x8f,0x21,0xa6,0x9f,0x5a,0x7d,0xaa,0x89,0x35,0xc0,0xfa,0x6a,0x62, -0x62,0x8d,0x0,0x11,0xfe,0x19,0x92,0x24,0xfa,0x68,0x74,0x64,0x3d,0xb2,0x8e,0xac, -0x3e,0xf5,0xd2,0x1a,0x60,0x7d,0xbd,0x74,0x43,0x9e,0x92,0x53,0xc6,0x6e,0x19,0xf5, -0xc9,0xe8,0xad,0xa3,0xf1,0xa3,0xf1,0xc9,0x51,0x9f,0x8a,0x70,0xd,0xb0,0xbe,0x22, -0xbc,0xa1,0x4f,0xe9,0x29,0xdf,0xab,0xfd,0x4d,0x92,0x58,0x47,0xe9,0xa3,0xf4,0xe4, -0xa4,0x4f,0xcd,0xbb,0xe,0x58,0x5b,0xf3,0xe6,0xc0,0x73,0xb6,0x84,0x49,0xb3,0xe1, -0x40,0x48,0x89,0xfb,0x54,0xf5,0xeb,0x80,0xb5,0x55,0x7d,0x0,0x92,0x53,0x8b,0xcd, -0x0,0xb8,0xdc,0xbc,0x6,0xc0,0x30,0xd,0xfa,0xac,0x5b,0xd4,0x1,0x6b,0xd7,0x2d, -0x36,0x94,0x4f,0x9a,0xb,0x0,0xae,0x36,0x9f,0x1,0xd0,0x4a,0x83,0x3e,0x2b,0x33, -0x75,0xc0,0xda,0x95,0x19,0x0,0xda,0xe4,0x28,0xbc,0x4,0xe0,0x7a,0x93,0x1e,0xa5, -0x90,0xec,0x6,0x13,0x93,0x20,0xe1,0x37,0x1,0x93,0x70,0xeb,0xda,0x53,0xe,0xb4, -0xfc,0x3b,0x2,0x92,0x91,0x45,0x68,0xe8,0x66,0xc0,0xc0,0x3a,0xb,0x8c,0xc2,0xa0, -0xd7,0x4,0xe4,0xf1,0xb0,0x7e,0x39,0x2f,0xb1,0x36,0x49,0x48,0xcf,0x7c,0xb8,0xa5, -0xdf,0x71,0x20,0x3d,0x9,0x8c,0x16,0x2c,0xe7,0x5b,0x80,0xde,0x1a,0x80,0x3c,0xc5, -0xa8,0x5f,0xb0,0x4c,0xec,0xd,0x9,0xe9,0x38,0xc0,0xd4,0x84,0x3,0xd3,0x93,0xc0, -0x68,0x49,0x76,0x53,0xf,0x4c,0x9d,0x2,0x58,0xbb,0x24,0xb,0x40,0x7a,0x4a,0xc7, -0x61,0x6,0x4,0xc3,0xf,0x8c,0x16,0x9d,0xb5,0x13,0x29,0xa,0x20,0x79,0xaa,0x0, -0xeb,0x16,0x9d,0x37,0x30,0x8a,0xa7,0xa7,0xa7,0x19,0x10,0x5d,0x5b,0x60,0xb4,0xac, -0xae,0x1d,0x99,0x28,0x80,0x98,0xa6,0x13,0xaa,0x0,0xeb,0x96,0xd5,0x37,0x30,0x8a, -0xa7,0x96,0x38,0x14,0x14,0x80,0xe8,0xbc,0x5d,0xb3,0xc6,0x1,0xaf,0x1e,0x98,0x7e, -0x54,0x0,0xeb,0x1a,0x7,0x0,0x8,0x2,0x62,0xc3,0xb3,0xb6,0x4d,0xca,0xc3,0x93, -0x6b,0xd6,0x1a,0xb1,0xa8,0xde,0x52,0xb8,0x68,0xd,0x58,0xd7,0x1a,0x1,0x40,0xd0, -0xec,0x19,0x90,0x7,0x60,0xd7,0xac,0xf9,0x63,0x59,0xf,0x64,0xbf,0x2a,0x80,0x4d, -0xcd,0x1f,0x4a,0x5e,0x6a,0xd8,0xde,0x42,0xaa,0xc0,0x2b,0xc6,0x37,0x2b,0xe6,0xc0, -0xa6,0xf6,0x16,0xd,0x68,0xd4,0xc0,0x43,0x83,0xa,0xf0,0x1b,0xc6,0x1b,0x79,0x73, -0x60,0x53,0x3,0x8f,0x6,0x34,0x6b,0x51,0xf2,0x6a,0xd,0x3f,0x50,0x66,0x69,0x53, -0x8b,0x92,0x6,0x34,0xeb,0xfa,0xba,0xd8,0xee,0xda,0x32,0x60,0x43,0xd7,0x97,0x6, -0x34,0xeb,0x6b,0xdb,0xb4,0x3,0x1b,0xfa,0xda,0xb4,0x7e,0x1a,0xb3,0xce,0x3d,0xc5, -0xd7,0x6c,0x3,0x36,0x74,0xee,0xe9,0x40,0xa3,0xde,0x44,0xc5,0xd7,0x6c,0x3,0x1a, -0xf7,0x26,0xc6,0x46,0x49,0xa9,0xa7,0x2,0xc3,0x12,0xf0,0x32,0xab,0x7a,0xf1,0xa1, -0x69,0x3,0x9a,0xbd,0x16,0xa,0x30,0x2d,0x3,0xf5,0x53,0xbf,0xda,0x6e,0xa9,0xd9, -0x6b,0xd9,0x4,0xd4,0xcf,0x1c,0x1c,0x6,0x48,0x9a,0x80,0xec,0xbc,0x19,0xa8,0x1c, -0x98,0x6b,0xc,0x2c,0x7c,0x4d,0x1d,0x30,0x9,0x9a,0x81,0xc5,0x24,0x37,0x6,0x16, -0x3f,0xa3,0x0,0x62,0x15,0x10,0xf7,0xa,0x9,0xa0,0xf6,0x94,0x92,0x17,0x9a,0x5c, -0xe3,0x3b,0xb2,0x13,0x94,0x6b,0x47,0x2e,0xd6,0x63,0xcb,0x1f,0x1c,0x1b,0x64,0x54, -0x39,0x10,0x86,0x46,0x0,0xb5,0x69,0xa3,0xcb,0x35,0xbe,0xab,0x7e,0x8e,0x72,0xed, -0xc8,0x9d,0xf8,0x13,0x9f,0x31,0x56,0x5a,0x16,0x30,0x7,0x62,0x9d,0x4c,0x2,0xd5, -0x47,0xdd,0xd5,0x0,0x2f,0xb7,0x3,0x7d,0x83,0xcc,0xad,0x6,0xc8,0x26,0xf5,0xc0, -0x91,0x15,0x4e,0xc2,0x3f,0xc3,0x78,0xa0,0x3e,0xbc,0x67,0xb9,0xc2,0xe0,0x53,0x93, -0x91,0x4c,0xaa,0x40,0x2c,0x3b,0x66,0xc0,0xc4,0xaf,0x1,0xa2,0x3e,0xc,0xcf,0xd9, -0x2d,0x98,0x5,0xe8,0xc3,0x93,0x13,0xff,0xd2,0x33,0x7,0x2a,0xde,0x34,0x3,0x62, -0x61,0x35,0x3,0x2a,0x8f,0x19,0xd0,0xe5,0x5a,0x88,0xc7,0xdb,0x59,0x3e,0xe8,0xc3, -0x93,0x93,0x60,0xe1,0x9b,0x3,0x95,0xb3,0xa7,0x33,0xa0,0x28,0x1d,0xcb,0xd9,0x1f, -0x7,0xf5,0xc0,0x33,0x9f,0x3b,0x8d,0xd,0x7,0xb2,0xe,0x40,0xe5,0x50,0x5f,0xe, -0xf4,0x27,0x61,0xe4,0x5b,0x5,0x90,0xba,0xb5,0x40,0x32,0xe,0xf8,0x81,0x48,0xa0, -0xf,0xe1,0x96,0x76,0x2,0xce,0x75,0x60,0xb6,0xa6,0x92,0xc7,0xee,0xa8,0xe,0x8, -0xfa,0xd0,0x66,0x17,0x69,0x70,0x5,0xfa,0x10,0xe4,0x76,0xd0,0x5,0x18,0xeb,0x40, -0x10,0x31,0x80,0x54,0x80,0xc4,0xaf,0x3,0xda,0xc4,0x66,0x97,0xa9,0x7f,0x5,0xea, -0xe9,0x24,0x98,0xf8,0xbe,0x67,0x2e,0xd7,0x28,0x36,0xbf,0xf2,0x8d,0xf2,0xf5,0xc0, -0xfc,0x98,0xda,0x92,0x5c,0xb3,0x98,0x9b,0x7a,0x2,0x18,0x79,0xbe,0x67,0x2e,0xd7, -0x52,0x5c,0x48,0xe0,0xfb,0x83,0x68,0x3d,0x30,0x9b,0x36,0xba,0x5c,0x3b,0x25,0x20, -0xd7,0xdc,0xab,0xef,0x10,0xc8,0x5c,0xc3,0x5b,0x2a,0x82,0xe1,0x14,0xae,0xd1,0xa7, -0x21,0xa8,0x3c,0x56,0xb,0x4c,0xdd,0xaa,0x2f,0x5,0x31,0x83,0x72,0xed,0x37,0x3c, -0xf3,0xe,0xd8,0xa5,0x21,0x50,0x1c,0xa8,0x8f,0x47,0x51,0x4d,0xe1,0xed,0x6f,0x1, -0x66,0xe,0xb5,0x46,0xae,0x8d,0x38,0xd0,0xdc,0xe,0x45,0xce,0xb6,0x81,0xdf,0xae, -0xc1,0xa6,0xae,0x38,0xb0,0x32,0x4b,0xf3,0x38,0x5c,0x23,0xd7,0x4e,0x7d,0xe,0x34, -0xf0,0x34,0xc4,0x2a,0xa2,0x2f,0xf9,0x30,0x72,0xd6,0xf3,0xc8,0xbd,0xe6,0x40,0x69, -0x87,0xf3,0x50,0x39,0x7b,0xef,0x9c,0xaf,0x37,0x54,0xe5,0x5a,0x7a,0x86,0x40,0x23, -0x5f,0xca,0x8f,0x6e,0x92,0x39,0x5b,0xea,0x4e,0xec,0x9b,0xcb,0x89,0xb3,0xc2,0x74, -0x29,0xf3,0x34,0x1a,0x10,0xe2,0x70,0x6c,0xd5,0xc8,0x35,0x6c,0x99,0x6,0x60,0x11, -0x2d,0xb6,0x3,0xe5,0xf1,0xbe,0xc2,0xc4,0x60,0x4a,0x6f,0x7c,0xcb,0x5e,0x22,0xf0, -0x89,0xf4,0xa5,0x1a,0x30,0xc5,0x15,0xb2,0xa0,0x2a,0xd7,0xa4,0x20,0xcd,0x3,0x70, -0x3,0x50,0x1e,0xef,0x2b,0x76,0x1e,0xde,0xb3,0xac,0xd3,0x13,0xcb,0x4a,0x28,0x7c, -0xcb,0x13,0x19,0x2d,0x34,0x20,0x4c,0x9b,0x49,0x5d,0x43,0x6b,0x39,0x4d,0x6c,0x0, -0x4e,0x44,0x8a,0xcc,0xed,0x22,0x7d,0xcb,0xb2,0x8e,0xc7,0x96,0x35,0xce,0x80,0x18, -0xf,0x75,0x20,0xf5,0xea,0x1b,0x5a,0x4b,0x59,0x5b,0x3,0x50,0x8a,0x0,0x6e,0x17, -0xe9,0xa9,0x65,0x1d,0x42,0x7e,0x7d,0x9c,0x1,0x31,0xc5,0xd0,0x81,0xa8,0x1b,0xdc, -0x5d,0x80,0xa9,0x94,0x39,0x7c,0x18,0xd2,0x91,0x13,0xdf,0x8f,0xdd,0xe8,0x30,0x7, -0x42,0x12,0x55,0x2,0x26,0xf5,0xd,0xad,0x21,0xeb,0x8,0x24,0x2,0xe8,0x26,0xf7, -0x63,0x2f,0xe6,0xc0,0xec,0x5b,0x4a,0x40,0xa,0x79,0x5a,0xd,0xd0,0x35,0x7,0x8e, -0x6c,0xe9,0xb8,0xf9,0x15,0x92,0xfb,0xb1,0x9f,0x34,0x2,0xad,0xd3,0xda,0x96,0x5d, -0x73,0x20,0xb1,0x73,0x2d,0x93,0x8e,0x7e,0x49,0xef,0xc7,0x1,0x69,0x4,0xbe,0x7e, -0x5c,0x3,0xe4,0x9b,0xde,0xcd,0x80,0x36,0x15,0xc0,0x4b,0xe,0x3c,0x1a,0xb7,0x2, -0x5d,0xea,0xe0,0x36,0xfa,0xe6,0x54,0xdf,0x0,0x38,0xe7,0xc0,0x13,0x23,0xa0,0x15, -0x54,0x80,0x49,0x67,0xe0,0x86,0x3,0x3,0x6a,0x2,0x7c,0x51,0x5,0x4e,0xd8,0xdd, -0x2,0xbb,0xcc,0x52,0x39,0x69,0xc8,0x6e,0xc0,0xa0,0xab,0x59,0x70,0xbb,0x48,0x47, -0x7e,0xbb,0x59,0x38,0x64,0xc7,0x2b,0x94,0x5,0x15,0x7e,0xae,0xaf,0xa9,0xe1,0xef, -0x32,0x86,0x79,0x5,0xc7,0x2f,0xb9,0xb6,0x10,0x23,0x5b,0xd5,0xb5,0x51,0x74,0x6d, -0x41,0x79,0x39,0xf,0x66,0x29,0x56,0xf4,0xed,0x24,0xd,0xc,0x9d,0xb7,0x28,0x6b, -0xab,0xce,0x3b,0xb4,0x44,0x97,0x41,0x9,0x88,0xad,0x29,0xa,0x50,0x2e,0xe7,0x61, -0xc6,0x77,0x6c,0x8d,0x21,0xb0,0x5,0x86,0xe1,0x89,0xc7,0x8b,0x74,0x8c,0x30,0x19, -0x9e,0xce,0x64,0x1f,0x45,0x9,0x88,0xad,0x29,0x2a,0x50,0x2e,0xe7,0xc5,0x3e,0xc5, -0xa5,0xbc,0x47,0xa4,0x15,0x98,0x9f,0xaf,0xf,0x76,0x1,0x77,0xc5,0x1a,0x9f,0x59, -0x16,0xa5,0x1c,0xee,0x30,0x19,0x80,0x43,0xfd,0x27,0xf4,0xb,0x20,0x97,0x6b,0x24, -0x4,0xb9,0x16,0x92,0x11,0x3d,0x1a,0x3f,0x4a,0xc2,0x36,0x60,0xfe,0x4,0x1,0xb4, -0xb,0xdf,0xb2,0x48,0x60,0xd9,0x3c,0xe2,0x9f,0xc2,0xe0,0x8a,0x14,0x43,0x3f,0x13, -0x1a,0x53,0x8c,0x40,0x93,0x6b,0x24,0x5c,0xe2,0x73,0x9b,0x79,0x55,0x3f,0x6e,0xd, -0xc0,0x49,0x56,0xd7,0x44,0xbb,0x98,0x4e,0xec,0x8d,0x3f,0x71,0x96,0x8,0x1c,0x41, -0x7a,0x28,0x92,0x28,0x1d,0x88,0x49,0x94,0xe,0x4c,0xc4,0x72,0xde,0x6,0xfe,0x5f, -0x32,0x6b,0x5,0x12,0x4b,0xb1,0xdd,0x45,0xe4,0xac,0x2e,0x23,0x77,0xce,0x3,0x70, -0x9e,0x26,0xea,0x40,0x4c,0x13,0x55,0x20,0x5c,0x9f,0x90,0x6b,0x9,0x2,0x2f,0x5a, -0x81,0xc5,0xcb,0xe7,0xe3,0xb8,0x58,0x62,0xca,0x7f,0x1b,0xa5,0x4f,0x8a,0x44,0xb8, -0xfc,0xdd,0x2a,0x10,0x34,0xfe,0x9c,0x17,0x5b,0x57,0x89,0x45,0xf0,0x88,0x16,0x73, -0xe0,0x94,0x7f,0x8a,0x48,0xf5,0x37,0x93,0x93,0x27,0x45,0xaa,0xdf,0x8,0x4,0xb1, -0xc6,0x63,0xdb,0x9a,0x22,0xd0,0x53,0x36,0x5a,0xb5,0xc9,0xb5,0x5,0xb7,0x6a,0x1f, -0xde,0x1,0x5d,0xf9,0x86,0x40,0x90,0x6b,0x10,0xbb,0xf9,0xf9,0xc3,0xa9,0x75,0xca, -0xaf,0xd0,0x58,0xae,0xdd,0x70,0xab,0x16,0x72,0x6d,0x1d,0xfc,0xce,0x8,0x88,0x72, -0xd,0xc4,0x1a,0xfe,0xbc,0xdf,0x31,0x7a,0x84,0x7,0xd1,0x98,0xdd,0xd2,0x85,0xbe, -0x92,0x60,0xe,0x4,0xb9,0x36,0xe,0x64,0x99,0x2e,0x5,0xe0,0x5f,0x1a,0x2,0x4b, -0xf,0xc,0xe9,0x2,0xa4,0xa7,0xa1,0xf8,0x4e,0x43,0x3b,0x2c,0xe4,0x9a,0x12,0xd3, -0xe8,0xfa,0xc5,0xef,0xcc,0x66,0x29,0xca,0x35,0x69,0x37,0x49,0xe1,0x69,0xd2,0x86, -0x65,0x12,0xe1,0x4b,0x6f,0xb,0x41,0xc3,0x81,0x9b,0xab,0x93,0x27,0x45,0xd9,0x24, -0xa4,0xca,0xf7,0x73,0x3b,0x8c,0x1c,0x45,0xae,0xc9,0x1a,0x56,0x52,0xf8,0xd2,0xb4, -0x61,0x99,0x44,0x0,0x69,0x96,0xb8,0x49,0x20,0xb1,0xce,0x32,0x4f,0x13,0x71,0x51, -0xe3,0xeb,0x9e,0x26,0xb2,0xb,0xb9,0x46,0xa4,0x9c,0xa5,0x4a,0xb4,0x68,0x5,0xf2, -0x7b,0x5e,0xd4,0x69,0x68,0x6a,0xe5,0xbe,0x14,0x97,0xd5,0x13,0xa5,0x46,0xcf,0x7d, -0x69,0x64,0x15,0x72,0x2d,0x3,0xa6,0x4a,0x3c,0x6c,0x58,0x97,0x91,0xc0,0x40,0xab, -0x7a,0xab,0xd1,0x2,0x57,0xb9,0x63,0x65,0x15,0x42,0x44,0xb,0x6c,0xf9,0x68,0x90, -0x6b,0x93,0x36,0x20,0x1f,0x3f,0xa2,0x1,0xb3,0x78,0x88,0xab,0xdc,0x91,0xb2,0xce, -0x22,0xe2,0x21,0x3e,0xee,0xab,0x9,0x68,0xb7,0x1,0xa7,0xda,0x34,0x55,0x23,0x3e, -0x56,0x13,0x27,0xc5,0x4a,0x92,0x8c,0xf8,0x69,0x33,0x30,0xba,0x73,0xa0,0x63,0xa4, -0x80,0x7d,0xd,0x28,0x93,0x28,0x4,0x2a,0x8b,0x73,0x32,0x89,0x6a,0xb9,0xa5,0x71, -0x2b,0x70,0x55,0x8,0xfd,0xc,0xa8,0x2c,0x23,0xa8,0x40,0x91,0x26,0x92,0xa3,0x66, -0xa0,0xdb,0x6,0xdc,0x68,0xab,0x41,0x15,0xe0,0x91,0x55,0x4a,0x84,0x93,0xd3,0xbe, -0xc0,0x2b,0x71,0x5d,0xb7,0x45,0x1,0xac,0xe,0x38,0xb6,0xf4,0x54,0x3f,0xb3,0xc3, -0x2d,0xc0,0xa6,0xf5,0x4a,0x9,0xa4,0xe2,0x32,0x65,0xf9,0xb2,0x2,0x64,0x1a,0x70, -0x92,0x7b,0x9a,0x7a,0x60,0xda,0xb4,0x22,0x2b,0x81,0xfc,0xf3,0x49,0x1e,0xf,0x9b, -0x81,0x56,0xee,0x4b,0xb7,0x0,0x43,0xe2,0xd1,0x36,0x20,0x9a,0x4,0x1d,0xe7,0xe5, -0xcb,0x46,0x60,0x8d,0xb6,0x28,0x3,0xfd,0x36,0xa0,0xd0,0xf8,0x47,0x79,0xf9,0xb2, -0x65,0xc,0xdb,0x80,0xb4,0x1d,0x78,0x29,0x8b,0x85,0xb2,0x7c,0xd9,0x36,0x4b,0x5b, -0x80,0x91,0xdb,0xa,0xe4,0xa1,0x62,0x9e,0x97,0x2f,0x5b,0xec,0x70,0x31,0x39,0x6d, -0x4,0x4e,0x9c,0x56,0x20,0x37,0xc4,0x79,0x56,0xbe,0x6c,0xf3,0x34,0xb,0xeb,0x54, -0xa6,0x18,0xd8,0xb6,0x18,0xaa,0xdd,0x31,0x1c,0x8,0xfa,0xa4,0x4d,0x3d,0xf1,0x50, -0x71,0x9e,0x95,0x2f,0xdb,0x7c,0xe9,0x4b,0xeb,0x48,0x66,0x6d,0x90,0x22,0xc6,0x15, -0x20,0x8,0xa2,0x71,0x1b,0x90,0xff,0x44,0x7,0x4a,0xf9,0xb2,0x8,0x4f,0x6b,0x56, -0x9,0x4f,0x5f,0x3e,0x3c,0x90,0xc0,0x33,0x87,0x4d,0x42,0x7a,0x2,0x60,0x7c,0xa2, -0x70,0xb0,0xe4,0x40,0x94,0x7d,0x6d,0x40,0x1c,0x33,0xd0,0x94,0xb2,0x7c,0x9,0xf7, -0xb0,0x8,0xc0,0x6b,0x56,0x9,0xc0,0x5f,0x6,0x7,0x32,0x11,0x1e,0xdb,0x30,0xd5, -0xc8,0x99,0x35,0xb6,0x1,0x48,0x21,0xe9,0xa,0xa5,0xb0,0x6d,0x15,0xa4,0x81,0xaa, -0x80,0x1,0x58,0xa4,0x18,0x6b,0x56,0x49,0x31,0xbe,0xc,0x25,0x90,0x9e,0xbe,0x5, -0x16,0x15,0xa7,0x30,0x8f,0x11,0xe8,0x3f,0xf,0x79,0x71,0xc2,0x8d,0xee,0xb7,0x2, -0x75,0x8d,0xff,0x2d,0xd6,0x29,0x79,0x12,0x85,0xc0,0x4a,0x12,0x55,0x0,0x47,0x23, -0x5c,0x5d,0x4b,0x4f,0x1e,0x11,0xf8,0x4,0xea,0xfb,0xfc,0xa,0x47,0x5e,0xdc,0xe, -0x9c,0x72,0x60,0x56,0xc5,0x28,0xaa,0xfa,0x8,0xac,0xa4,0x89,0xf9,0x2d,0xa5,0x23, -0xbe,0xba,0x96,0x9e,0x3c,0xa6,0xa1,0xcf,0xc8,0x95,0x2d,0x80,0x7e,0xd2,0xe,0x5c, -0xe0,0x17,0xda,0x59,0x9d,0xa6,0x58,0xb7,0xc8,0x17,0x2c,0xd5,0x44,0xf8,0x65,0x1, -0x14,0xab,0x6b,0x2,0x78,0x3b,0xb5,0x4,0x30,0x20,0xed,0xc0,0x15,0xaf,0x26,0x66, -0x95,0xa8,0x62,0x65,0xa6,0x16,0xb8,0x78,0xa8,0x1,0x2f,0x53,0xeb,0x1d,0x1,0x3c, -0x34,0x7,0x62,0x51,0x61,0x74,0x3c,0x36,0x3,0x46,0xf7,0x8f,0x72,0xb9,0x76,0x8a, -0xab,0x6b,0xd6,0x33,0x4,0x6e,0xae,0xf,0xc3,0x36,0xa0,0xda,0x1a,0xa1,0x94,0x2f, -0x5b,0x81,0xa7,0x99,0x5c,0xa3,0x7c,0x75,0xd,0x7e,0x7,0x60,0xe2,0x76,0x0,0x82, -0x4,0x52,0x8a,0x7b,0xa6,0x40,0xb1,0xd8,0x15,0xa4,0x1,0x7,0xc6,0x5d,0x80,0x69, -0x17,0x60,0x69,0x75,0xd,0x80,0x9,0x9a,0x45,0xec,0xdc,0x11,0x10,0x9c,0x29,0xb1, -0x0,0xb8,0x5a,0x7d,0xda,0x6a,0x16,0xc5,0x2b,0x50,0xcb,0x97,0x2d,0x66,0xa1,0xe8, -0x43,0xca,0x97,0xf3,0x2,0x6a,0x3,0x70,0xb1,0x9a,0xb4,0x1a,0xbe,0x1a,0xa8,0x94, -0xf2,0x65,0x8b,0xe1,0x6b,0x40,0x5c,0xce,0xb,0x20,0x6a,0x0,0x70,0x33,0x63,0x6d, -0xae,0x4d,0x2d,0x9b,0x98,0xbb,0x36,0x9e,0x89,0x48,0xe0,0xd8,0xda,0x94,0x3,0x70, -0x93,0xf3,0x56,0xb,0xb,0x4a,0xf9,0xf2,0x5b,0x46,0x9a,0x9c,0xb7,0xa,0x3c,0xb3, -0x2b,0xc0,0xa6,0xf0,0xa4,0x16,0x16,0x94,0xf2,0xa5,0xec,0x2f,0xdd,0x16,0x9e,0x32, -0x60,0xa9,0xd8,0x1b,0x18,0x4,0x60,0xb5,0xb0,0xa0,0x94,0x2f,0xbf,0xcd,0xcf,0xdd, -0xad,0xd,0xc0,0x2d,0xc0,0xa6,0x14,0x43,0x73,0x35,0x45,0xf9,0xf2,0x5b,0xf8,0xe4, -0x86,0x14,0x23,0xb1,0x7a,0x27,0x51,0x9a,0xab,0x29,0xca,0x97,0x0,0x6c,0x4a,0xa2, -0xda,0x80,0xd,0x69,0xa2,0x66,0xf9,0x45,0xf9,0x52,0xef,0xfa,0xaa,0xa4,0x89,0x6d, -0x40,0xc6,0xc,0x80,0x60,0xf9,0x79,0xf9,0xb2,0xc,0xac,0x24,0xc2,0x53,0x32,0x0, -0xf0,0x8a,0xa9,0x9d,0xa,0xac,0x31,0xd5,0x1f,0x4,0x78,0x59,0x94,0x2f,0xcb,0xc0, -0xb2,0x5c,0x1b,0x6,0x38,0x2f,0xca,0x97,0xcd,0x40,0x6b,0x20,0xa0,0x5a,0x18,0x6a, -0x4,0xe,0x75,0x4b,0xc9,0x76,0x60,0x57,0xb9,0x66,0x6,0x2c,0xa,0xa6,0xed,0xb3, -0xb4,0xbf,0x5c,0x53,0xd,0x31,0xd8,0xa,0xac,0x94,0x4d,0x5a,0x80,0x46,0x9e,0x86, -0x67,0xfb,0xed,0xc0,0xd2,0xea,0x1a,0x44,0x35,0x74,0xc2,0x36,0x81,0xe9,0x16,0x2c, -0xe0,0x7f,0x9b,0xfb,0xd2,0xe2,0x98,0xeb,0xa,0xb0,0x5a,0xfa,0xca,0x8b,0xec,0xc, -0x1f,0xbe,0xb,0x2a,0x88,0x3,0x2f,0x58,0xd2,0x21,0x5a,0x28,0xc7,0x45,0x94,0x81, -0xd5,0x68,0x91,0x3,0x41,0xae,0xcd,0x18,0x3d,0x82,0xec,0x34,0xa0,0x81,0xcd,0xe2, -0xe,0xf1,0x90,0xef,0x30,0xae,0x7,0x56,0xe3,0x61,0xbe,0x6e,0x21,0xe4,0x1a,0xa4, -0x35,0x34,0x48,0xce,0x2c,0x16,0x75,0x88,0xf8,0x5a,0x25,0x4a,0x7,0x56,0x23,0x7e, -0xbe,0x32,0x3,0x72,0xd,0xae,0x8b,0xd0,0x90,0x4,0x31,0x7d,0x23,0x9c,0x74,0xc8, -0x69,0x94,0xf6,0xf9,0x32,0xb0,0x9a,0xd3,0x7c,0x7f,0x40,0xd0,0x87,0x36,0x4c,0x1b, -0x1a,0x26,0xe1,0x92,0x1c,0x5,0x3f,0xeb,0x90,0x26,0x2a,0xae,0xa6,0xc,0xdc,0x9e, -0x26,0xa2,0x3e,0xfc,0x5,0x4c,0x1b,0x12,0xc6,0x6c,0x46,0xc6,0xc7,0x7,0x1d,0x12, -0x61,0xc5,0xd5,0x54,0x7a,0xf5,0x9b,0x96,0xf3,0x70,0x77,0x1e,0x4b,0xc2,0x19,0xbb, -0x20,0xd6,0x23,0x2b,0x30,0x4e,0xf5,0x55,0x57,0xd3,0x15,0x78,0x9,0xe6,0x70,0x1, -0xe,0xbd,0x2b,0x10,0x93,0x28,0x59,0xbe,0xd4,0xf6,0xae,0xb1,0xc6,0xe5,0x3c,0x0, -0xba,0x70,0x53,0x5d,0xe6,0x75,0x7,0xfe,0xae,0x36,0x1e,0xc6,0x8d,0xcb,0x79,0x34, -0xdc,0xa4,0x3e,0x88,0x6e,0x2f,0xf5,0x9,0x68,0x1a,0xd6,0x9,0xf8,0x95,0xd2,0x7d, -0x59,0x0,0x69,0xf3,0xea,0x5a,0xb8,0xc1,0x87,0x9a,0x51,0x9f,0x6,0xdd,0x81,0x71, -0x6d,0x4e,0xd3,0xe,0xc,0x53,0x8f,0x4,0x60,0x8a,0x39,0xb0,0x76,0x96,0xa6,0x9e, -0x13,0x27,0x67,0x9e,0x1b,0x27,0xa7,0x81,0x7b,0x91,0xc5,0xfc,0xbc,0xfb,0xd2,0x8, -0x88,0xda,0x22,0xc4,0x1d,0x81,0x3e,0xf6,0xf,0x14,0xc0,0x5a,0x3b,0xac,0x3,0x2a, -0xdd,0x97,0xc2,0x53,0xfb,0x1c,0xd8,0x28,0xd7,0xc2,0x4d,0x2,0x9e,0x1,0x17,0xf5, -0xa,0x60,0xad,0xa7,0xa9,0x1,0x46,0x79,0xf9,0x52,0xee,0x3f,0xe4,0xda,0x82,0x86, -0xdb,0x3d,0xd,0x7,0x6e,0x38,0x70,0x53,0x0,0xeb,0x9d,0x77,0xd,0xf0,0xd3,0xbc, -0x7c,0x29,0xf7,0x1f,0x72,0xf5,0x54,0xb3,0x9c,0xd7,0x2,0xac,0xf,0x4f,0x35,0xc0, -0x87,0x79,0xf9,0xf2,0x5b,0xb9,0xe8,0x29,0xd6,0xf,0xb7,0x86,0xa7,0x2d,0x29,0x46, -0x7d,0x0,0xae,0x2,0x8b,0xf2,0xa5,0x4,0xa,0x5,0x4c,0xc3,0xad,0x1,0x78,0x5b, -0x4e,0x53,0x9b,0x62,0xd4,0x0,0x55,0x5,0x2c,0x6e,0x9f,0xc5,0x81,0x5b,0x53,0x8c, -0x4e,0x49,0x54,0xd,0x50,0xd5,0xf8,0xe2,0xf6,0x59,0x21,0x2,0xb7,0x26,0x51,0x9d, -0xd2,0xc4,0x5a,0x60,0x51,0xc5,0xd8,0x6,0x34,0x4a,0x13,0x6b,0x13,0xe1,0x3a,0xa0, -0x52,0xbe,0xe4,0xc0,0x7,0x12,0xd8,0x35,0x11,0x36,0x6,0x2a,0xe5,0x4b,0xe,0xf4, -0x25,0x70,0x90,0x54,0xbf,0xe,0x58,0x94,0x2f,0x95,0xa3,0x46,0x92,0xb0,0x2a,0xd7, -0x86,0x2,0x9e,0xd4,0x1,0xe3,0xb0,0x2a,0xd7,0x86,0x2,0xe6,0xc5,0x3d,0x71,0x5c, -0xc,0x9e,0x61,0xc5,0x6a,0xe4,0x1a,0xdb,0x1b,0x10,0xc6,0x90,0xd5,0xc8,0x35,0x36, -0x8c,0x5c,0x53,0xab,0x89,0xfa,0x9,0x3c,0xe5,0x59,0xca,0x86,0x91,0x6b,0x5a,0x33, -0x64,0x6e,0x87,0xa8,0x0,0xca,0x76,0xf8,0xc3,0x3,0x1a,0xea,0x43,0xb5,0xfb,0x72, -0x2b,0x50,0x6b,0x2c,0x47,0x7d,0x48,0xac,0x10,0x77,0x71,0xa7,0xa8,0xf,0x13,0x91, -0xb5,0x99,0xea,0x43,0xb5,0xfb,0x32,0x77,0xde,0x8,0x2c,0x3b,0x6f,0xa6,0xea,0x43, -0x4,0x1e,0xc3,0x1f,0x51,0x1f,0x4a,0xa0,0xa9,0x3e,0x54,0xbb,0x2f,0xf3,0xf0,0x84, -0xc0,0x72,0x78,0x62,0xaa,0x3e,0x4,0x20,0xe8,0xc3,0x30,0x42,0x7d,0x28,0x81,0xa6, -0xfa,0x50,0xed,0xbe,0xcc,0x3,0x30,0x2,0xcb,0x1,0x98,0xa9,0xfa,0x10,0xfe,0x84, -0xfa,0x70,0xc2,0x40,0x1f,0x26,0xac,0x93,0x3e,0x54,0xbb,0x2f,0xf3,0x14,0x3,0x81, -0xe5,0x14,0x83,0xa9,0x72,0xd,0xfe,0x84,0x72,0xcd,0x65,0x20,0xd7,0x46,0xac,0x93, -0x5c,0x53,0xbb,0x2f,0xf3,0x24,0xa,0x81,0xe5,0x24,0x8a,0xa9,0x72,0xd,0xf,0x53, -0x61,0xf4,0xcc,0x63,0x20,0xd7,0x1e,0x45,0xdb,0xd2,0xc4,0xb4,0xdc,0x2c,0x91,0xe2, -0xdd,0x53,0xba,0x2f,0xf3,0x34,0x11,0x81,0xe5,0x34,0x51,0x5,0xf2,0xc3,0x54,0x18, -0x19,0xfb,0x28,0xd7,0x1e,0x59,0xe1,0x96,0x44,0xb8,0x1e,0x58,0x94,0x2f,0x6b,0xa5, -0x7f,0x9e,0x8,0xb3,0xaa,0x5c,0xc3,0x45,0xbd,0x26,0x31,0x53,0xf,0x2c,0xca,0x97, -0x5d,0x80,0x47,0x28,0xd7,0x88,0xc5,0xe5,0xda,0x61,0x37,0x60,0x5e,0xbe,0x2c,0x1f, -0x45,0xb9,0x15,0x88,0x72,0xd,0x27,0xcc,0xc,0x8c,0x3,0xe5,0x5a,0xda,0xd,0x98, -0x97,0x2f,0x9b,0x8e,0x3e,0x29,0x6d,0x96,0xa3,0x78,0xb6,0x9,0xdc,0x4e,0x72,0x82, -0x72,0x2d,0xed,0xa6,0xf,0xb7,0xad,0x69,0xda,0x5b,0x81,0xa8,0x9e,0xe8,0x18,0xe4, -0x1a,0xa1,0xc7,0xc1,0x40,0x40,0xea,0xe9,0x1b,0xab,0x6b,0x37,0xcb,0x79,0x24,0x3d, -0x6,0xf5,0x94,0xdd,0x52,0xc3,0xa2,0x42,0xfd,0x2b,0x9,0x21,0x56,0x6f,0x1b,0x43, -0xb9,0xba,0x6,0x72,0x6d,0x7c,0x84,0xc0,0x71,0xd0,0xa5,0x6c,0xb2,0xbd,0x50,0x7c, -0xd9,0x4,0xb4,0x46,0x28,0x66,0xac,0x47,0x20,0x66,0x32,0xb3,0xa8,0x7a,0x9a,0xfa, -0x49,0xb3,0xa5,0xf6,0x3e,0x61,0x71,0x3,0x10,0x57,0xd7,0x88,0xc5,0x7f,0x5,0x67, -0x1c,0x6e,0xf1,0xa5,0x1d,0x80,0x60,0x28,0x81,0xde,0xea,0xad,0x3,0x71,0x75,0x8d, -0x58,0xfc,0xd7,0x34,0xb0,0xb6,0xc9,0xb5,0x16,0x60,0xe4,0x2b,0xc5,0x1b,0xf0,0xa4, -0x34,0xa8,0x7,0x9a,0xcb,0xb5,0x66,0x60,0xaa,0x74,0x89,0x9,0x39,0x7a,0xd5,0x9, -0x58,0x13,0xf1,0x9b,0x81,0x89,0x5f,0x6c,0x9c,0xba,0xe5,0xd1,0xf0,0xba,0x1b,0xd0, -0x30,0xa7,0x29,0x4c,0x3d,0x3f,0x61,0x0,0x93,0xc,0x8c,0xf7,0xeb,0x6e,0x40,0xc3, -0xac,0x2d,0x7f,0x81,0xf7,0x9c,0x69,0xc0,0xeb,0x9b,0x6e,0x40,0xc3,0x44,0x58,0x2d, -0xf2,0x91,0x2,0x38,0x39,0xb4,0xaf,0x37,0x54,0x19,0x83,0x1f,0x3a,0xb0,0xfd,0x6c, -0x3a,0x2c,0x3d,0xc9,0xf2,0x13,0x7,0x9e,0xd8,0xce,0xed,0x5e,0x81,0x31,0x8b,0x7d, -0xb9,0xdd,0x8e,0x3,0x71,0x96,0xef,0x2,0xc,0x22,0xbf,0xd9,0x2c,0xe6,0xd4,0x8f, -0x65,0x7f,0x9d,0x0,0xda,0xd7,0xe0,0xc0,0x8a,0x9e,0xd1,0xc1,0x81,0x53,0x98,0x93, -0xc1,0x42,0x3,0xa2,0xb7,0xca,0xf,0xe,0x1a,0x1c,0xe8,0x83,0x3a,0xfc,0x66,0xa5, -0x8e,0xe1,0x35,0x24,0xf3,0x76,0xde,0xf3,0x3f,0x38,0x30,0xf8,0x86,0xb1,0xef,0x6e, -0x90,0xe6,0xc8,0x59,0xca,0xd8,0xb1,0xf8,0x6,0xbf,0x8b,0xe1,0x4f,0x3c,0x33,0x60, -0x1a,0xc2,0x75,0xdc,0xdc,0x72,0x20,0xdc,0x4b,0xa1,0x2c,0x24,0x70,0xda,0xc5,0xb5, -0xc9,0xf4,0x8b,0x3,0x1b,0xad,0xe2,0xc,0x7e,0xf9,0x33,0x11,0x40,0x42,0x5,0xf0, -0xb9,0x0,0x5e,0x37,0x1,0x23,0x7b,0xbe,0x51,0x9c,0x77,0x76,0xd,0xed,0xc0,0x3f, -0xe3,0x65,0xd2,0x1c,0xc8,0xa5,0x4c,0x27,0xa0,0x8,0x4f,0x54,0xc6,0x9c,0x56,0x20, -0x41,0x20,0x1b,0x87,0x19,0x90,0x4b,0x99,0x76,0x20,0xd,0x73,0xa0,0x8,0xc0,0x44, -0x4e,0xea,0x56,0xe0,0x2d,0xf7,0xd4,0x67,0x2,0xb8,0xa1,0x42,0xca,0x7c,0x65,0x0, -0x5c,0x30,0x9,0x14,0x29,0x46,0x22,0x27,0x75,0xeb,0xa4,0xb9,0xf9,0x4e,0x56,0xd2, -0x25,0x90,0x4b,0x99,0x4e,0x40,0x91,0x44,0xc5,0xd2,0xa5,0xb5,0x2,0x57,0x1c,0xf8, -0x4d,0xe,0xe4,0xfb,0x35,0x4d,0x80,0x2f,0xbd,0xc,0xc8,0xd3,0x44,0x63,0xe0,0xfa, -0x1b,0xfc,0xf5,0xbb,0xab,0x1c,0xc8,0xc,0x81,0x20,0xf4,0x36,0xca,0xba,0x45,0xec, -0x76,0x5,0x5e,0xb3,0x75,0x7,0x60,0x64,0xe7,0x93,0x46,0xa4,0xfa,0xb1,0x37,0xd9, -0x37,0x70,0xa9,0x3,0x7d,0x31,0x3b,0x5b,0xc3,0xd3,0xfa,0x45,0x4f,0xe0,0x62,0xd3, -0xf,0xb8,0x50,0x81,0xeb,0xe,0x63,0xc8,0xb6,0x0,0xdb,0xec,0xf0,0x9a,0x3,0xff, -0xd4,0xf5,0xa,0x11,0x38,0x5b,0xea,0x63,0xf8,0xd0,0xe8,0xd8,0xd4,0xde,0xc0,0xc5, -0x26,0x9a,0xe9,0xb3,0xd4,0x10,0x18,0xf6,0x4,0xce,0x97,0xb1,0xab,0xdb,0x61,0x1, -0x6c,0x9a,0xa5,0xbd,0x81,0x91,0x8d,0x5b,0x3a,0x55,0x4f,0x63,0x6,0x9c,0x66,0xc0, -0xcc,0xf0,0xd1,0x7,0x7f,0x25,0xfc,0xe2,0xf,0x9,0x8,0xde,0xda,0xa5,0xbe,0xee, -0xbc,0x4f,0x0,0x98,0x72,0xb3,0x68,0x2,0x5e,0x95,0x80,0xd2,0x79,0xe3,0xe1,0xb2, -0x7e,0x23,0x90,0x78,0x90,0x42,0x6b,0xe1,0xe9,0xac,0x17,0x50,0x86,0x27,0x3c,0x2, -0xd9,0xbd,0xee,0xa0,0xf,0x21,0x0,0x53,0xe,0xc,0xa3,0x56,0x20,0xfc,0x45,0x2, -0x8b,0x0,0x7c,0x8c,0x8b,0x18,0x66,0xc0,0x3c,0xc5,0x80,0x5f,0x6f,0x4,0xb0,0xe9, -0x75,0x85,0xf,0xda,0xc,0xa,0xa0,0x4c,0x31,0xf0,0x54,0x69,0xdb,0x10,0x98,0x25, -0x51,0xa6,0x40,0x18,0x6e,0xbf,0x0,0xca,0x24,0xea,0x91,0xe5,0x4f,0x2c,0x43,0x60, -0x96,0x26,0x9a,0x2,0x61,0x42,0x7b,0x12,0x8,0x69,0x22,0xaf,0x44,0x1d,0x63,0xa5, -0x30,0x32,0x5,0x66,0x89,0xb0,0x29,0x30,0x72,0x2d,0x57,0x0,0x95,0x44,0xf8,0x2d, -0x3c,0x73,0xe8,0x83,0xbe,0xc0,0xe6,0x49,0x13,0x79,0x13,0x15,0x88,0x8b,0x4,0x8, -0x84,0xe9,0xb3,0xf,0x20,0x8c,0x5f,0xe4,0x47,0x8,0x2c,0xc4,0xc,0x9a,0xd6,0x3e, -0x81,0x93,0xa,0x90,0x8e,0xef,0xf8,0xa,0x41,0x90,0xee,0x15,0x28,0xc6,0xb0,0x90, -0x6b,0xec,0x76,0x57,0x60,0xc3,0xb,0x81,0x62,0x96,0x16,0x45,0x5,0xb6,0xa1,0x9d, -0x66,0x69,0x56,0xa7,0x31,0x5,0x4a,0x3b,0xcc,0x80,0x70,0x37,0x56,0xb4,0x93,0x1d, -0x66,0x95,0x28,0x53,0xa0,0xf4,0x34,0x6a,0x25,0x8a,0x1a,0x78,0x9a,0x92,0x5c,0xeb, -0x0,0x94,0xbe,0x54,0xad,0xb5,0x51,0x3,0x5f,0x5a,0x92,0x6b,0x39,0xd0,0x7a,0xaf, -0x6d,0xd2,0xc8,0xf0,0x24,0xbf,0x7,0xa3,0x85,0x4f,0x5b,0xa3,0x45,0x45,0xae,0x15, -0xc0,0xe6,0x78,0x78,0x75,0x15,0xa8,0x40,0x59,0x2f,0xa5,0xad,0xf1,0xb0,0x22,0xd7, -0x4c,0xcd,0xa2,0x4,0x94,0x15,0x61,0xda,0x1a,0xf1,0x2b,0x72,0x4d,0x2,0x5b,0x73, -0x9a,0x32,0xf0,0x12,0x72,0x9a,0x38,0x5b,0xef,0xea,0x22,0xd7,0xfa,0x2,0x45,0x55, -0x9f,0x76,0x97,0x6b,0x1a,0xb0,0x29,0x3a,0x95,0x80,0x62,0xdd,0x82,0x76,0x97,0x6b, -0x7d,0x81,0x62,0x65,0xe6,0x87,0x9,0x5c,0xe,0x2,0x14,0x29,0x6,0xed,0xae,0xf, -0x7b,0x3,0x13,0xf1,0xe0,0xf1,0xce,0xfa,0xd0,0x14,0x58,0xf2,0x34,0x79,0x87,0x42, -0x67,0x7d,0x68,0x6a,0x16,0xfd,0x81,0x25,0x7d,0xb8,0x7f,0x60,0x49,0x1f,0xf6,0x1, -0x16,0xd5,0x0,0xda,0x5d,0x1f,0xf6,0x0,0xa6,0xc5,0xea,0x2f,0xed,0x2e,0xd7,0x7a, -0x0,0x49,0xb1,0xc2,0x4d,0xbb,0xcb,0x35,0x36,0xc1,0xe5,0x72,0xbb,0xcb,0x2c,0x4d, -0x8a,0xec,0x98,0x76,0x97,0x6b,0x8c,0xaf,0xd1,0x77,0x2,0xc6,0xc5,0x97,0xd3,0x3e, -0x72,0xcd,0x4b,0x3b,0x2,0x23,0xb5,0x53,0x48,0xa4,0x18,0x69,0xed,0xd9,0x97,0xb5, -0x49,0x14,0xb5,0x5c,0x23,0x60,0xa1,0x80,0x65,0x8b,0x92,0x4,0x8a,0x24,0xca,0xc, -0x88,0x69,0xe2,0x9f,0x88,0xe5,0xfc,0x3f,0xa3,0xa2,0xc2,0x56,0x20,0xa6,0x89,0x66, -0x40,0x9c,0x9f,0x2b,0xc8,0xfd,0x12,0x4,0x62,0xb3,0x85,0x29,0xf0,0x81,0x2,0x14, -0x89,0xb0,0x39,0x70,0x1e,0xfb,0x78,0xcc,0x6b,0x37,0xa0,0xaf,0x1,0x31,0xd5,0x37, -0x7,0x5e,0xc4,0xc1,0x64,0x14,0xf2,0x6f,0x35,0x7,0x62,0x6f,0x62,0x5f,0xa0,0x1b, -0x87,0xd1,0x69,0x70,0x97,0xc0,0x28,0x8c,0x8e,0xfd,0xc,0x68,0x38,0x4b,0x2b,0xc0, -0xd2,0x13,0xad,0x1a,0x80,0xa9,0x37,0x9,0xa3,0x87,0x5e,0x47,0x60,0x65,0xc,0xcd, -0x81,0x14,0xbe,0x37,0xf2,0xdc,0x8e,0xc0,0xca,0x2c,0x45,0x3b,0x59,0x1b,0xd9,0x21, -0x3d,0x7e,0x2b,0x8c,0x3e,0xb8,0xec,0x8,0xac,0xd8,0xa1,0x21,0x10,0x3c,0xd,0x39, -0x7a,0x12,0x4c,0xde,0xbf,0xd8,0x9,0xe8,0x4f,0x9a,0x80,0x89,0x7,0x11,0xdf,0xcd, -0x7d,0x29,0x19,0x81,0x1d,0x7e,0x38,0xe7,0x81,0x12,0xb7,0xde,0x1b,0xcd,0xd2,0x8a, -0x2f,0xfd,0x41,0x1,0x63,0x7,0x80,0x4e,0x1e,0x9e,0xc8,0x33,0x98,0x62,0x37,0x1d, -0x81,0x95,0xf0,0xd4,0x4,0xc4,0xbc,0x3b,0xb2,0xf3,0x0,0x9c,0x7c,0x4,0xce,0xfb, -0x76,0x66,0xe,0x8c,0xe5,0xf6,0x78,0x2d,0x0,0x37,0x1,0xe7,0xb3,0xd9,0x66,0xbe, -0xcc,0x53,0x8c,0x4,0x54,0xba,0x7b,0xbb,0xec,0x6,0xac,0xa4,0x18,0x6f,0x34,0x0, -0x17,0xcb,0xd9,0x46,0xd1,0x87,0x31,0x4,0x16,0x8f,0xc6,0xdd,0x80,0x95,0x24,0xea, -0xe6,0x9a,0x6c,0x7,0xb2,0x68,0xa3,0xe8,0xc3,0xe5,0x14,0x53,0x8c,0x51,0x6,0x6c, -0x37,0xb,0x3e,0x7e,0xe5,0x34,0xb1,0x5,0xf8,0x54,0xd1,0x87,0xcb,0x2b,0xf0,0x8c, -0x69,0x57,0x60,0x39,0x11,0x6e,0x2,0x7e,0x69,0x7f,0xf9,0x58,0xd1,0x16,0x4b,0xcc, -0x6b,0xf7,0xc,0x7c,0xb9,0x5,0x68,0xe6,0x69,0xfa,0x0,0x7f,0xb1,0x1d,0x68,0x36, -0x69,0x3a,0x1,0x17,0xcb,0x85,0x7d,0xd7,0xc0,0x73,0x5,0x38,0xeb,0xa,0x5c,0x5f, -0xdd,0x74,0x6,0xce,0xf4,0x59,0x3a,0x0,0x30,0x69,0xf4,0x34,0x0,0x5c,0x16,0x76, -0xb8,0x77,0x20,0x68,0xfc,0xa5,0xf4,0xa5,0xe8,0x69,0x3a,0xcf,0xd2,0xa,0x30,0x68, -0x1,0x2a,0xd1,0x2,0x7d,0xa9,0x0,0x3e,0xd9,0x5,0xd8,0xe2,0x4b,0x95,0x78,0x88, -0xd1,0x2,0x5c,0x1b,0xc8,0xb5,0xdf,0xec,0x0,0x6c,0x8b,0x16,0x25,0xb9,0xb6,0xbc, -0x46,0x5f,0xba,0x64,0x6,0x2f,0xb1,0xba,0x56,0x1,0x1e,0x9b,0x3,0x31,0xe2,0x2f, -0xd7,0xe0,0xfa,0x6f,0xd,0x81,0x58,0x11,0xae,0x0,0x8f,0x3a,0x0,0x21,0x89,0x8a, -0x79,0x3c,0x9c,0x99,0x1,0x13,0x5e,0x68,0x2f,0x19,0xbe,0x4c,0xa2,0x4c,0xe5,0x5a, -0xf2,0xc,0x22,0xfe,0xcd,0xdc,0xc,0x88,0x55,0xfd,0x1a,0xa0,0x7c,0xa6,0xa9,0x59, -0x22,0x9c,0x8c,0xe0,0xc7,0x5e,0x5d,0x98,0x1,0x71,0xdd,0xa2,0x2,0xec,0x28,0xd7, -0x20,0x2f,0xf5,0xad,0xf7,0xd5,0xb6,0xfb,0x9a,0x2d,0x9d,0xea,0xea,0x5a,0xd,0xb0, -0x93,0x98,0xa1,0x87,0x6f,0x5,0x93,0xf,0x4c,0x81,0x7e,0xb4,0x33,0x30,0xf5,0x2c, -0x29,0x66,0xc,0x80,0x93,0x1f,0x27,0x10,0xe4,0xda,0xa1,0x7f,0x77,0xb7,0x54,0x28, -0x60,0xff,0xee,0x26,0xd,0x68,0xfc,0x30,0x1a,0x5,0x86,0xc0,0x5d,0xcd,0x2,0xeb, -0x34,0x11,0x0,0xdf,0xb,0xcd,0x80,0xc5,0x72,0x5e,0xd9,0xf0,0x3b,0x2c,0xe7,0xc5, -0xa0,0xf,0xb5,0xaf,0x68,0x0,0x16,0xcb,0x79,0x65,0xd7,0xd6,0x0,0x2c,0xc9,0x35, -0x96,0xbc,0xe5,0xeb,0x1b,0xe,0x1a,0x80,0xea,0x72,0x5e,0xa9,0xd6,0xb6,0x1d,0x58, -0x92,0x6b,0x8c,0xbc,0x51,0xda,0xdf,0xd3,0x0,0xac,0x2d,0x41,0xb7,0x55,0x13,0x4b, -0x72,0x8d,0xd1,0x3,0xcb,0xf1,0x76,0x1,0xb6,0xd5,0x4b,0x4b,0x72,0x8d,0xb1,0xc3, -0xd2,0x6,0xa6,0xae,0xc0,0xb6,0x8a,0x70,0x49,0xae,0x69,0x5,0xec,0x7e,0xc0,0x96, -0x9a,0x77,0x49,0xae,0x69,0x25,0xfa,0x66,0xe0,0x34,0xec,0xb5,0x8c,0x50,0x92,0x6b, -0xbc,0xe6,0x6d,0x6,0xbc,0xee,0x7,0x2c,0xc9,0x35,0x66,0x1f,0xb8,0x77,0x17,0x0, -0x0,0x15,0x2f,0x49,0x44,0x41,0x54,0xfe,0x52,0x80,0xc5,0x73,0x1d,0x4d,0x80,0x2f, -0xfb,0x2,0x5f,0xf4,0x5a,0x28,0x29,0xc9,0xb5,0x5e,0x40,0x4d,0xe3,0xb7,0x8e,0xa1, -0x2e,0xd7,0x3a,0x0,0xf3,0xfe,0x52,0xbd,0x8a,0xa1,0x3,0x37,0x6d,0x72,0xad,0x17, -0x30,0xf1,0x9d,0x6d,0xc0,0x55,0x9b,0x5c,0xeb,0x2,0xfc,0x26,0x3,0xc6,0xe1,0x6c, -0x1b,0x70,0xd1,0x26,0xd7,0xfa,0x1,0x8b,0x23,0xd5,0x4,0x70,0x95,0x3,0xaf,0xdb, -0xe4,0x5a,0x7,0x60,0xde,0xe7,0xcd,0xa2,0x62,0x97,0x9c,0x0,0x4e,0x72,0xe0,0x55, -0x9b,0x5c,0xeb,0x0,0xcc,0x3b,0xd9,0xd9,0xac,0x78,0x56,0x68,0x19,0x18,0xb4,0xc9, -0xb5,0xe,0x40,0xd1,0xab,0xff,0xb7,0x61,0xd,0xf0,0x7e,0xd6,0x31,0xc4,0xf,0x56, -0xee,0x78,0xb6,0xc9,0xd6,0x57,0xbe,0x1b,0x41,0x2,0xff,0xae,0x0,0x1e,0x66,0x40, -0x7a,0xd7,0x40,0xfe,0x3c,0xaa,0x8e,0x87,0xa9,0x6c,0x7d,0xe5,0x1b,0x3c,0x10,0xb8, -0xe6,0xcd,0x18,0x15,0xe0,0x2d,0x6b,0x5f,0xce,0x4b,0xda,0xa4,0x76,0xe,0xcc,0xb6, -0xb0,0x20,0x30,0x96,0x4f,0x1c,0x2b,0x4d,0x9a,0x1b,0xd6,0xde,0xf5,0x65,0xc,0xcc, -0x37,0xe9,0xa0,0x59,0x44,0x1,0x5b,0xb9,0x55,0xe0,0x9a,0xb5,0xf7,0xb5,0x19,0x3, -0xf3,0x6d,0x48,0x68,0xf8,0x91,0xc7,0xd6,0xb3,0xc2,0xf0,0xb3,0x5d,0x41,0xd7,0x83, -0x2,0xf3,0x8d,0x56,0xe0,0xda,0x26,0xe,0x5b,0xe0,0x2,0x14,0xd5,0xf7,0x3d,0x4d, -0x7,0x5,0xe6,0x5b,0xc9,0xc0,0x79,0x43,0xf2,0x7c,0x8d,0xdb,0x26,0xa8,0xf2,0xd0, -0xfb,0x17,0x2,0x3c,0x1c,0x70,0x4e,0x43,0xca,0xaf,0x1,0xc2,0x13,0x7c,0xd3,0xd4, -0xba,0xcc,0x81,0x4c,0x2,0x83,0x41,0x81,0x31,0xbb,0xbc,0x48,0xc5,0x35,0xe0,0x13, -0x24,0xaf,0xec,0x65,0x7e,0x4b,0x25,0x90,0xd7,0x94,0x87,0x3,0xe2,0x53,0xb1,0xc4, -0x86,0x47,0xec,0x7d,0x77,0x9e,0xdb,0x24,0x2c,0x1,0x29,0x1b,0x14,0x58,0x6c,0xe9, -0xc4,0x87,0x72,0x5a,0xc7,0xe,0x3e,0x23,0x5a,0x3,0xde,0x32,0x3,0x3b,0x5c,0x2b, -0x67,0x4d,0xb6,0xbc,0x8a,0x5d,0xb2,0xd8,0xe1,0x7f,0xe4,0x54,0x36,0x8f,0x6f,0x98, -0x81,0xa7,0xe9,0x0,0xcc,0xf7,0x1,0x47,0x28,0xa4,0x4e,0xdd,0xca,0xe6,0xf1,0x95, -0x2,0x8c,0x1d,0xea,0x24,0x16,0xa3,0x63,0x9b,0x4f,0xb4,0xc2,0x97,0x76,0x0,0x26, -0xd9,0xb6,0x1a,0xf8,0xcd,0xb2,0x46,0x2e,0x23,0x81,0xe,0x5c,0xab,0x40,0x9b,0xd8, -0x8,0x3c,0xb5,0xf8,0x33,0x2b,0x8a,0x68,0xd1,0x1,0x98,0xed,0xe5,0xc6,0x34,0x31, -0xb2,0x12,0x4f,0x3c,0xfe,0x42,0x1,0x5e,0xab,0x40,0x2b,0xb6,0x46,0x16,0x23,0x23, -0xeb,0x2c,0x3,0x8a,0x0,0xdc,0x1,0x98,0x7,0x2a,0x48,0x13,0x13,0x2b,0xf6,0xb4, -0xc7,0x92,0x23,0xf0,0x4a,0x1,0x2e,0x93,0x25,0x79,0xa,0x77,0x25,0x49,0xc6,0x19, -0x50,0xa4,0x18,0x3d,0x80,0x98,0x26,0x52,0x1b,0x81,0x49,0xa8,0x1,0x7d,0x15,0x48, -0x56,0xf4,0x29,0x3e,0x26,0x9b,0x9e,0x66,0x40,0x91,0x44,0xf5,0x0,0xf2,0x34,0xd1, -0xc6,0x86,0x5b,0xaa,0x2a,0xaf,0x17,0xf2,0x69,0xbe,0x39,0x90,0x6d,0x1c,0x98,0x47, -0x74,0x94,0x3,0x79,0x9a,0xd8,0x7,0x88,0x69,0xe2,0x3c,0xf2,0x53,0x8f,0xb9,0x1a, -0x30,0x2c,0x1,0x13,0x1b,0x6e,0x7a,0x32,0xca,0x66,0xa9,0x48,0x84,0x7b,0x0,0x79, -0x9a,0x78,0x33,0x9,0x0,0xa8,0x96,0x76,0x5f,0x50,0x56,0x6,0x5a,0x60,0xaa,0xf1, -0xd3,0x1c,0xc8,0x53,0xfd,0x1e,0x40,0x9e,0xd3,0xac,0x1,0x18,0x6a,0x83,0xf8,0xe2, -0xb6,0x2,0x1c,0x81,0xd,0x46,0x6c,0x20,0x20,0x7f,0xd0,0x8d,0x3a,0x88,0x2f,0x6e, -0x34,0x60,0x2,0x63,0x48,0xc0,0x70,0xce,0xb,0xe0,0x3f,0xdd,0x5,0x78,0x6d,0x8d, -0xc7,0xec,0x4f,0x4c,0x5,0xae,0x98,0x66,0xf8,0x2b,0x7c,0x8,0x8f,0xcf,0x9c,0x2, -0xe8,0xee,0x2,0xfc,0xda,0xa2,0x6f,0x26,0xae,0x7a,0x8c,0xc3,0x8b,0x45,0x1b,0xd0, -0x1b,0x18,0x78,0xad,0x1,0x1d,0x4,0x52,0x9c,0x59,0xc3,0x8c,0xe1,0x67,0x16,0x7f, -0x26,0x85,0xa,0xbc,0x2a,0x1,0xe9,0x53,0x2,0x49,0x82,0xcf,0xda,0xcd,0x22,0x6d, -0xde,0xfc,0xc8,0xcd,0xe2,0xb9,0xc5,0x62,0x77,0xad,0x7e,0xef,0x8b,0x40,0x9b,0x34, -0x30,0x4f,0x47,0x9,0x9,0xc1,0xc1,0x4f,0x5b,0xd,0xbf,0x5,0xc8,0xd,0xff,0xd0, -0x61,0x49,0x70,0xad,0x7e,0xef,0xdf,0x86,0x3a,0x10,0x9d,0x77,0xcc,0x1f,0x11,0x1a, -0xa,0xe0,0x93,0xad,0xae,0xad,0xd,0x88,0xae,0xd,0xe2,0x6f,0xe2,0x5d,0xab,0x2b, -0xe3,0xff,0xbd,0x4,0x24,0x10,0xa0,0x96,0x2a,0xf0,0x67,0x5b,0x9d,0x77,0xb,0x90, -0x6b,0xfc,0x3,0x97,0xfd,0xe1,0xd7,0x57,0x2a,0xf0,0x6f,0x98,0xe,0xa4,0x10,0x82, -0x35,0xe0,0xe1,0xd6,0xf0,0xd4,0x2,0xe4,0x55,0xc,0x78,0xff,0x71,0xa4,0x1d,0xac, -0xf4,0xdf,0x34,0x60,0x35,0xc5,0xa0,0xdb,0x3,0x70,0xb,0x90,0xd7,0x69,0x20,0xd9, -0xbf,0x3e,0xd6,0x80,0xff,0xb5,0x5,0x98,0x6c,0x4f,0x31,0x5a,0x80,0xbc,0x12,0x5, -0x1,0xff,0xda,0x77,0x94,0x7,0x4e,0xb2,0xff,0xdc,0x2,0xfc,0xfd,0xf6,0x24,0xaa, -0xd,0x88,0xb5,0x36,0xf0,0x21,0xd7,0x57,0x6f,0xa9,0x59,0xcd,0xb4,0x5,0xf8,0xc9, -0xf6,0x34,0x31,0x6d,0x3d,0x94,0x83,0xf1,0x3,0x86,0xbe,0x3a,0x25,0x9e,0x39,0xf0, -0xe1,0xf6,0x44,0x18,0xe6,0x5e,0xbb,0xf7,0x1,0xe3,0xff,0x32,0x4c,0x94,0x2,0xbd, -0xdf,0xc,0xa4,0x27,0x3b,0x2,0xe1,0x6e,0xc6,0xc5,0x43,0x6e,0x59,0x7e,0xa3,0xb6, -0x1,0x49,0xda,0x1f,0x28,0x6e,0x38,0xa4,0x6e,0xc5,0x63,0x7c,0x8b,0x23,0xa3,0xb7, -0x1,0x97,0x3b,0x3,0x67,0x1c,0x58,0x14,0x16,0x5f,0x34,0x3,0x17,0x3b,0x3,0x31, -0xbd,0x88,0xa,0x31,0x73,0xdb,0x2,0xf4,0x77,0x6,0x62,0x7a,0xa1,0x3c,0xff,0x74, -0xd3,0xc,0x4c,0x83,0x9d,0x81,0x98,0x23,0xe2,0xa2,0x85,0x3c,0x5a,0x69,0xd5,0xc, -0x24,0x4d,0x65,0x13,0x43,0xe0,0xc,0xa3,0xa2,0xe5,0x4d,0x70,0x18,0x13,0x7b,0xdd, -0xc,0xdc,0x34,0x15,0x86,0x4c,0x5c,0x1b,0x1a,0x46,0xc8,0xae,0x0,0xc8,0x17,0xcb, -0x62,0xeb,0x5a,0x7,0xa2,0x5c,0xc3,0xbc,0x7b,0x6c,0x53,0xfc,0xf7,0x70,0xd1,0x54, -0xfa,0x32,0x4,0x82,0x77,0xb,0x22,0x90,0xdf,0x38,0x6f,0x22,0x71,0x50,0xa3,0x2e, -0xd7,0x20,0xef,0x6,0xb9,0xc6,0x9f,0xb,0x1f,0x4e,0x9b,0x8a,0x7b,0x86,0x40,0xf0, -0x6e,0x41,0x62,0x1d,0x7a,0x11,0xcb,0x4f,0x86,0xd4,0xe5,0x5a,0x78,0x81,0x72,0x8d, -0xc7,0xc3,0xb3,0xa0,0xa9,0x5e,0x6a,0xa,0x8c,0xd3,0x90,0x5a,0x7,0x1,0xda,0x87, -0x3c,0xfb,0x52,0x97,0x6b,0xa1,0x83,0x72,0x6d,0x84,0x87,0x9e,0x9d,0x86,0x4d,0x15, -0x61,0x53,0x20,0x1,0x7f,0x3c,0x39,0xc2,0x7,0xff,0x66,0x6b,0xc0,0x5b,0x81,0x4f, -0xd9,0xde,0x81,0xa0,0xf,0xcf,0x1c,0xd4,0x87,0x4f,0xf1,0xe,0xfc,0xba,0xb1,0xc8, -0x6e,0xa,0x64,0xaf,0xc3,0x6d,0x7d,0x84,0x99,0x60,0x76,0x60,0xaa,0x2e,0x66,0xc4, -0x3c,0x7d,0x8a,0xe7,0xd3,0x7b,0x8d,0xcb,0x8,0xc6,0x40,0x98,0x2e,0x64,0xc4,0x68, -0x90,0x1f,0x9,0xab,0x3,0xc9,0xdb,0xa8,0xf,0x9f,0x42,0xbc,0xc6,0xa,0x56,0xc3, -0x42,0x89,0x31,0x30,0xe1,0x2d,0x63,0x8,0x74,0xe2,0x1a,0xa0,0xd4,0x87,0x93,0x50, -0x14,0xc3,0x47,0xef,0x92,0x5d,0x81,0x2,0x8a,0x40,0xf7,0xf,0xf5,0x40,0xd0,0x87, -0x9b,0xd7,0x85,0x8e,0xe4,0x87,0x58,0xb3,0x5e,0xaf,0x3a,0x20,0x75,0x26,0x61,0x59, -0x1f,0x26,0x58,0xa3,0x39,0x4f,0xee,0x87,0x6c,0x55,0xc8,0xb5,0xe1,0x80,0x56,0x50, -0x91,0x6b,0x2b,0x94,0x6b,0xc9,0x61,0xc8,0xd7,0x73,0x77,0x38,0x8a,0x52,0x7,0xf2, -0x59,0x2a,0x8f,0xd7,0x2e,0xc9,0xb5,0x15,0xca,0xb5,0xe4,0x18,0x82,0x21,0x5f,0xd0, -0x18,0x6,0x88,0xf,0x7,0xa8,0x7,0xd2,0x70,0x85,0x72,0x2d,0x19,0x87,0x14,0xf, -0x6a,0x24,0x56,0xef,0xb3,0x2f,0x75,0x20,0xba,0xb6,0xec,0xc4,0x72,0x5d,0xae,0x85, -0x2b,0x94,0x6b,0xa8,0xd9,0x30,0x4d,0x8c,0xfa,0x9f,0x7d,0xa9,0x1,0x29,0x3a,0xef, -0xec,0x4c,0x76,0x5d,0xae,0x85,0x2b,0x29,0xd7,0x56,0x98,0x26,0xde,0xeb,0xb8,0x9c, -0xa7,0x68,0x19,0xed,0xac,0xd4,0x54,0x6c,0xed,0xb4,0x2a,0x40,0x8,0x4b,0x2b,0x54, -0x4f,0xa7,0x36,0x5b,0x0,0x30,0x3e,0xe9,0xb8,0x9c,0xa7,0x56,0x31,0xb5,0x76,0xa, -0x79,0x88,0xab,0x5b,0x6,0xa2,0x63,0x43,0xe0,0xd8,0x61,0xb8,0x3b,0xcf,0xe9,0xba, -0x9c,0x97,0xbf,0xb0,0x1c,0xa3,0x9e,0xd0,0xc8,0x53,0xc,0xf9,0xe4,0x80,0xfa,0x14, -0x3,0xec,0x26,0x24,0x7e,0xd7,0xd5,0xb5,0xad,0x40,0x9e,0x44,0xc9,0x67,0x23,0xd4, -0x3,0x41,0x63,0x85,0x93,0xce,0xab,0x6b,0x5b,0x81,0xc2,0x8d,0x8b,0xa7,0x3f,0xd4, -0x3,0x97,0x8c,0x8d,0xdd,0x1e,0x67,0x5f,0x2a,0xc0,0xb8,0x74,0xe0,0x6e,0xf6,0x7c, -0x8b,0x7a,0xe0,0x82,0xb1,0x27,0x61,0x8f,0xb3,0x2f,0x95,0x49,0x53,0x7e,0x5,0xf2, -0x9,0x1e,0xf5,0x40,0x8f,0x57,0xe7,0x1b,0x8e,0xa2,0x24,0x56,0xd8,0x2,0xb4,0xab, -0x4b,0x1a,0xdb,0x81,0xf0,0xaf,0xb8,0xd8,0xd8,0x0,0x4c,0x1a,0xd7,0x4e,0x3a,0x3, -0xc1,0xf5,0x9d,0x87,0x8d,0xcf,0xe5,0x8e,0x9b,0xab,0x26,0x5d,0x81,0x33,0xf0,0x46, -0xcd,0xc0,0xa8,0x7c,0xea,0xf2,0x4e,0xc0,0xd8,0x61,0x51,0x18,0x36,0x2f,0xc1,0x58, -0xee,0x70,0xc0,0xd8,0xa,0x52,0x87,0x35,0x3,0x2d,0xcb,0x19,0xc,0x88,0xc3,0x93, -0x4,0xcd,0xc0,0x96,0x4d,0xac,0x37,0x4c,0x7d,0xa0,0x5e,0xb,0x90,0x4f,0x7,0x9b, -0xdd,0x19,0x90,0xf3,0xb0,0xb6,0x32,0x38,0xb0,0xde,0xf0,0x13,0x3e,0xdd,0x23,0xd6, -0xa,0x3c,0xed,0xc,0xac,0x75,0x6d,0x82,0x97,0xba,0xed,0x40,0xda,0x19,0x58,0xe7, -0xbc,0xe5,0xb9,0xfb,0x71,0xd0,0xa,0xb4,0xd3,0xce,0xc0,0x9a,0xf0,0xf4,0xbf,0xa4, -0x35,0xdb,0x6c,0x67,0xe0,0x4d,0x15,0x58,0x13,0x80,0xe5,0xc1,0xa8,0xc4,0xdf,0x7, -0xf0,0xa4,0x92,0x62,0xe4,0xc5,0xbe,0x9,0x63,0x3b,0x8f,0x61,0x15,0x78,0x5c,0x49, -0xa2,0x32,0x20,0x75,0x4d,0x80,0xa7,0x9d,0x81,0x95,0x34,0x31,0x3,0xca,0x87,0x97, -0xed,0x66,0x87,0x35,0xc0,0x4a,0x22,0x2c,0x81,0x7f,0x76,0xd8,0x7e,0x80,0x95,0x54, -0x5f,0x2,0x89,0x6f,0x0,0x6c,0x71,0xde,0x37,0xc4,0x72,0xeb,0x80,0x93,0x5a,0x60, -0x51,0x11,0x8e,0x6b,0x9e,0x36,0x60,0x14,0x9e,0x6e,0x12,0xcb,0xa9,0x3,0x5a,0x2d, -0xc0,0xa8,0xf6,0x89,0xa,0x6,0x1,0xf8,0x86,0x6d,0x3a,0xdc,0xd2,0x2,0xc8,0xb7, -0xd6,0x38,0x3d,0x52,0x8c,0x1b,0xb5,0x39,0xb1,0x3,0x90,0xa7,0x77,0x76,0x8f,0x24, -0xa,0x80,0xa1,0xf1,0x2c,0x2d,0x80,0xa9,0xd2,0xeb,0xd3,0x2d,0x4d,0xbc,0x61,0xff, -0x23,0xac,0xb7,0x43,0x5e,0x72,0xdf,0x6,0xa4,0xca,0xc1,0xd8,0x5d,0x33,0xef,0x8b, -0xa0,0xde,0xd3,0xc4,0x78,0x67,0xb6,0x1,0x89,0xd2,0x3e,0xd5,0x15,0xf8,0x9f,0xfc, -0x7a,0x5f,0x1a,0xe1,0xd8,0x6f,0x3,0xca,0x84,0xdd,0xef,0x3,0xfc,0x8b,0xab,0xfa, -0x68,0x31,0x4f,0x1b,0x80,0x71,0xed,0x63,0x3f,0xcc,0x80,0xef,0x5c,0xc7,0x38,0x18, -0xa9,0x9c,0x76,0xb8,0x2d,0x82,0xc7,0xc3,0x5,0x6b,0x0,0x46,0x5b,0x1e,0x6d,0x62, -0x0,0x4c,0x9f,0x2d,0x62,0x64,0x88,0x8d,0x79,0x20,0xef,0x2d,0x4b,0x44,0xfc,0x46, -0xe0,0x44,0x3e,0xec,0xab,0x7,0x90,0x3c,0x5b,0xf3,0xe,0x33,0x2f,0xb7,0x21,0x99, -0xd3,0x34,0x2,0x73,0x65,0xd7,0x3,0xc8,0x5d,0x5b,0xd6,0xed,0x8d,0x5e,0x42,0x66, -0x6d,0x3f,0x28,0x60,0x9a,0x3f,0xec,0xab,0x3b,0x50,0x38,0xef,0xec,0x18,0x0,0x74, -0xbc,0x32,0x11,0x6e,0x2,0xe6,0xf,0xa9,0xe9,0x6e,0x88,0x37,0xb7,0x3c,0x1e,0x66, -0x3b,0xa0,0x30,0xb4,0x48,0x60,0x93,0x1d,0x92,0xc,0xe8,0xf7,0x30,0x8b,0x3e,0xc0, -0x64,0xcb,0xf3,0x77,0xcc,0x81,0xd9,0xd9,0x11,0x38,0xd3,0xd,0x80,0xf1,0xd6,0x67, -0xc,0xed,0x0,0xd4,0xa2,0xc5,0x37,0x53,0x21,0xed,0xc4,0x43,0x67,0xc3,0x28,0x7f, -0xea,0xde,0xbe,0x80,0x53,0x57,0x94,0x57,0x82,0x88,0x3,0x27,0x19,0xd0,0xde,0x17, -0xf0,0x33,0x57,0x5e,0x21,0xf7,0xbb,0xa1,0x52,0xd3,0xe9,0x53,0x18,0x5a,0xf2,0x8c, -0x41,0xa6,0x78,0x4e,0x66,0x87,0xda,0x18,0x7e,0xf6,0xc,0x7e,0xb9,0x25,0x94,0x9d, -0xe3,0xdf,0xce,0x94,0xa7,0xee,0xd,0x2,0xe4,0xae,0x4d,0x7,0xfe,0x5b,0xcc,0xbb, -0xc9,0x6d,0xfa,0x17,0xf8,0xb7,0x53,0xa5,0x88,0x34,0x8,0x90,0x3b,0x6f,0x1d,0xf8, -0x2b,0x4,0x9e,0x6e,0x8,0x6e,0x4d,0x67,0xa3,0x2,0xe8,0xf,0x2,0x14,0x72,0x2d, -0x9,0x4b,0x93,0x26,0x3d,0xbd,0xd9,0xf0,0x49,0xf3,0x64,0xeb,0x83,0xb0,0xcc,0x6a, -0x6d,0x76,0x19,0x28,0xe4,0x5a,0xac,0xce,0x52,0xfe,0xeb,0xd1,0x5a,0x64,0x78,0xef, -0x35,0x3c,0xec,0xcb,0x14,0xe8,0x4b,0x20,0x71,0x72,0xb9,0x76,0x51,0x1,0x1e,0xac, -0xc5,0xa4,0x51,0xa,0x81,0x3d,0x22,0xa2,0xe5,0x6f,0x0,0x18,0xf2,0x7b,0x95,0x3a, -0xa9,0x93,0xcb,0x35,0xb7,0x2,0xfc,0xfc,0x5a,0x4c,0x1a,0x5,0x68,0xf7,0x5,0x8a, -0x16,0xe1,0xd4,0x85,0xeb,0x92,0x69,0x22,0xf5,0xa,0xa0,0x7c,0xbe,0xd6,0xff,0xbc, -0x12,0xf,0x85,0x12,0xd3,0x25,0x19,0xe,0xc8,0x13,0x61,0xde,0x5d,0xa3,0x3,0xa3, -0xab,0xd,0xcb,0x81,0xe2,0xb7,0xbe,0xc0,0xb,0xb1,0x73,0x6,0x3e,0x78,0x9e,0xa5, -0xfa,0xbc,0x17,0x53,0x7,0xc6,0x1,0xcb,0x81,0x8e,0x10,0x34,0x83,0x1,0x27,0x9a, -0x1d,0x4a,0x60,0xa2,0x0,0x5d,0x21,0xd9,0x6,0x3,0x5a,0x35,0xc0,0x24,0xf3,0x64, -0xd2,0xe2,0xc9,0xb0,0xb7,0xb4,0xa,0x8c,0x33,0x4f,0x26,0x7d,0x1a,0x1d,0x16,0xa8, -0x46,0x8b,0x9a,0x2b,0x94,0x55,0xe1,0x1,0x67,0x69,0x15,0x98,0x47,0xfc,0xc1,0x81, -0x95,0xb2,0xc9,0xf,0x1,0x28,0x7f,0xb7,0x87,0x73,0x6d,0x9b,0x49,0xd8,0x0,0xb4, -0x45,0x8e,0xd7,0x1f,0x58,0x75,0xde,0xcb,0x49,0xb0,0x4f,0x60,0x35,0x3c,0xcd,0x26, -0x7e,0xd9,0x79,0x2b,0x40,0x57,0xe4,0xe9,0x3,0x1,0x79,0x0,0x9e,0x7f,0x76,0x77, -0x40,0xa1,0xf,0xa7,0x77,0x7,0x14,0xfa,0xb0,0x11,0x98,0xb9,0x9e,0x61,0x80,0x42, -0xae,0x69,0x40,0x77,0x60,0x60,0x4d,0x22,0xac,0xc9,0x35,0x9e,0xb5,0xed,0x19,0xa8, -0x55,0x31,0x78,0x22,0x5c,0x7,0xec,0xf8,0x72,0x1b,0x80,0x7a,0x5e,0xea,0xe,0x3, -0xb4,0x1b,0x80,0x5a,0x25,0x6a,0xa8,0x31,0xdc,0x64,0xc0,0x1a,0x41,0xaa,0xd5,0xda, -0xbe,0x99,0xe,0x7,0xe4,0xbf,0xd6,0x0,0x1b,0xaa,0x89,0x3,0x0,0x6b,0x8a,0xa, -0xa6,0x40,0x5c,0x42,0xe1,0x67,0xdc,0xfb,0xfc,0x14,0x8,0x6a,0x61,0xe9,0xf,0x3f, -0x91,0x3f,0xc8,0x18,0x97,0x54,0x59,0xe4,0x88,0x16,0x88,0x89,0x97,0x3,0x6b,0xca, -0x26,0xcd,0xc0,0xc2,0xd3,0xe0,0x3d,0xb1,0x3c,0x5e,0x5a,0xc2,0x87,0xc7,0x10,0x80, -0xe2,0x68,0xc4,0x16,0x16,0xc8,0x70,0xbf,0x39,0x80,0x6c,0xd1,0xe4,0x61,0xb9,0x8, -0x8c,0xc2,0x4d,0x6d,0x25,0xca,0x10,0x48,0xe1,0x93,0x28,0xfc,0x55,0xec,0x10,0xf3, -0xf8,0x22,0x1c,0xfe,0xd8,0xe0,0x1e,0x61,0x80,0xb0,0x48,0x86,0x5f,0xcf,0xdb,0x58, -0x52,0xcb,0xc9,0x27,0x4d,0x76,0xdc,0x4,0xae,0xe2,0xd4,0xae,0xae,0x6d,0x5,0x12, -0x7e,0xf6,0xa2,0xc3,0x7,0x5,0x9b,0x8c,0x63,0xbe,0x17,0xce,0xc3,0x7e,0xe,0x86, -0xa9,0x16,0xe4,0x6,0xf2,0xf1,0xc3,0xb8,0xbf,0x91,0x1f,0x62,0xc0,0x6f,0xac,0xec, -0xf2,0xc2,0xf6,0xd1,0xda,0xd5,0xb5,0xe9,0xb6,0x78,0x8,0x99,0x15,0xc0,0x6c,0x3e, -0xed,0xf0,0x91,0xe,0x11,0x40,0x71,0xea,0x59,0xfc,0xc,0x65,0x3f,0x15,0xf,0x57, -0xe,0xf0,0x11,0x74,0xf0,0xa5,0x62,0xf4,0x4,0x50,0x6c,0x76,0x76,0xd8,0x6d,0xed, -0xea,0xda,0x56,0x20,0xd6,0x3e,0xf1,0x9d,0x3d,0xb4,0x2,0x2d,0x19,0xde,0xd8,0x93, -0x3,0x20,0x8f,0x8a,0xe7,0x3e,0xa0,0x10,0x81,0x91,0xb2,0x9e,0xf2,0xfd,0x16,0x2, -0x18,0x7b,0x19,0x70,0xeb,0xea,0x5a,0x5d,0x4e,0x13,0x79,0x90,0xa4,0xfb,0x56,0x30, -0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0xd,0x79,0x83,0x4d,0x6d,0xe2,0x10,0x3b, -0x71,0x89,0x13,0xbb,0x89,0x1b,0x79,0xb1,0x17,0xe1,0x43,0x43,0x1e,0xf3,0x1d,0x25, -0x2,0xb8,0x58,0x8,0xe0,0x72,0xfb,0xea,0x5a,0x5d,0xd6,0x6,0x9f,0x13,0x44,0x1, -0x1e,0x9d,0xb,0x40,0x6,0x40,0x5c,0x3f,0xa4,0x36,0x6e,0x8,0x1,0xa4,0x4b,0x0, -0x97,0x0,0x2e,0xf6,0xf1,0x79,0x62,0xd1,0x63,0xbe,0x67,0x46,0x0,0xaf,0xd7,0x2, -0x38,0xdb,0xbe,0xba,0x56,0xb,0xc,0xe2,0x20,0xa,0x1,0x9,0xd3,0x1d,0x8c,0x32, -0xb5,0x99,0xd,0xa9,0x98,0x4d,0xdd,0x14,0x70,0xd4,0x25,0x1e,0x20,0x7d,0xe2,0xc5, -0x41,0x2,0x3f,0x59,0xfc,0x98,0xef,0xa,0x92,0x93,0x46,0x2,0xbf,0x68,0x5f,0xb7, -0xf8,0x5e,0x80,0x99,0xb6,0x88,0xc2,0x24,0x80,0xcf,0x8,0xce,0x61,0x70,0x60,0x8e, -0x42,0x9a,0x79,0xe,0xd9,0xad,0xd,0x72,0xd6,0x21,0x5e,0xea,0x12,0x9f,0xba,0x9, -0x88,0xdb,0x38,0x24,0x3e,0x7c,0xe9,0x63,0xde,0xa4,0xaf,0x3,0x6f,0xdb,0x97,0x82, -0x54,0xf5,0xb4,0x3,0xf0,0x5a,0x5,0x4e,0xda,0x80,0x99,0x3e,0x1c,0xa,0x68,0xb5, -0x1,0x33,0x5,0xbc,0x3,0xf0,0x4a,0xbb,0xa5,0xac,0x5,0x98,0x69,0xfc,0xfe,0x40, -0xfe,0x10,0xe9,0xe,0x40,0x59,0xc5,0xe8,0x3f,0x4b,0x79,0x45,0x44,0x0,0x71,0x96, -0xb6,0x2,0x65,0x92,0xd2,0xdf,0xf0,0x6f,0x58,0xe,0xac,0x74,0x41,0x37,0x1,0x7b, -0xbb,0xb6,0x75,0x1,0xac,0xf4,0x79,0x97,0x80,0x4a,0xad,0xad,0xb7,0xf3,0xc6,0xc7, -0x23,0x89,0xd5,0x4d,0xe9,0xbc,0x9b,0x80,0x4a,0x35,0xf1,0xe7,0x7d,0xc3,0x93,0xa, -0xc,0x2a,0x9b,0x3,0x4a,0x40,0xa5,0x5e,0xfa,0x66,0xcf,0x0,0xac,0xa7,0x18,0x95, -0xed,0xf,0x25,0xa0,0x52,0x11,0x7e,0xb7,0x67,0x8a,0xa1,0x3,0x31,0xc5,0x68,0x2, -0x2a,0x35,0xef,0x8f,0x7b,0x26,0x51,0x7a,0xd6,0x86,0x49,0x54,0x13,0x50,0xa9,0xea, -0xdf,0xf6,0x4e,0x13,0xdf,0x17,0xc0,0xd7,0xb2,0x34,0xb1,0x11,0x58,0xac,0x5b,0xdc, -0xf6,0x4c,0x84,0x75,0x20,0x63,0x2d,0xc0,0x62,0x65,0xa6,0x2f,0x50,0x1f,0xc3,0x2a, -0x50,0xec,0xa3,0xcb,0x2a,0xdc,0xca,0xda,0x13,0xe9,0xae,0x9e,0x4,0xf0,0x44,0x2, -0xa9,0x11,0xb0,0x58,0x5d,0xeb,0xb,0x64,0xf,0xc4,0x2,0x4,0x19,0x85,0x26,0xc0, -0x1d,0xd6,0xf,0xb,0xd1,0x96,0xf7,0x51,0xd4,0x1,0x37,0xfc,0x58,0x12,0x7f,0xb1, -0xfb,0xa,0x69,0x6,0x8c,0xd4,0xcc,0xbb,0x15,0xb8,0xc3,0x1a,0x70,0x6,0x94,0xa7, -0xd,0xd0,0xa9,0x11,0x70,0x87,0x55,0xee,0xc,0x28,0x77,0x39,0x53,0x66,0x6,0xec, -0xdf,0x38,0xf0,0x63,0x1,0x1a,0xf6,0x62,0xd0,0x70,0x28,0xa0,0x61,0xb7,0xc9,0x70, -0x40,0xc3,0x7e,0x9a,0xe1,0x80,0x86,0x1d,0x43,0xd,0x40,0xad,0x81,0xa7,0x1d,0x68, -0xd8,0x13,0x35,0x1c,0x30,0x35,0x31,0xc3,0x74,0xdb,0x4f,0x54,0xde,0x91,0x60,0x0, -0x64,0x26,0x8b,0x87,0x83,0x2,0x27,0x6,0x66,0x38,0x28,0x30,0x32,0x31,0x43,0x87, -0xe,0x4,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0xa6,0xaf,0x88,0x76,0x8e,0x26,0xbb,0x1, -0x93,0xbb,0x6,0x92,0xbb,0x6,0xf6,0x78,0xfd,0x90,0x81,0xdc,0x48,0xa6,0xba,0xcb, -0xc2,0xef,0x22,0x4a,0x42,0x3b,0x24,0x30,0xad,0x1,0x7a,0x64,0xf,0x40,0x4c,0xa1, -0xe9,0x7d,0x9f,0x2b,0x28,0x4,0xf2,0xe3,0x2,0x21,0x6c,0x45,0x11,0x4b,0xdd,0xbd, -0x1,0x7f,0x6,0xaa,0xc9,0x65,0x3a,0x70,0x2,0x9e,0x26,0x61,0xc3,0x3,0x9,0xd7, -0x86,0xa0,0xb,0xdf,0x97,0x40,0xf4,0x19,0x3e,0xe3,0xda,0xf0,0x7c,0xb9,0x7,0x60, -0xf2,0x74,0xce,0x92,0xe8,0x92,0xc5,0xb,0x1,0x7c,0xf9,0xd0,0xe7,0xea,0xf7,0xfe, -0xeb,0x1,0x8b,0xe6,0xfc,0x94,0x36,0xda,0x21,0x9d,0xac,0x4f,0xf5,0x35,0xe0,0x66, -0xc5,0x36,0xcb,0x5,0x5b,0x66,0xc0,0x40,0x0,0x1f,0x3e,0x0,0x61,0xea,0xee,0xb, -0xb8,0x5a,0x14,0x57,0x98,0x1,0x4f,0x2,0xdc,0x41,0xb4,0x3f,0x60,0x36,0x86,0x8, -0x9c,0xc1,0x18,0x22,0x10,0xf,0xdb,0x70,0x9,0x9a,0x47,0x67,0xa0,0x2e,0x48,0x7f, -0x10,0xc0,0xcc,0x2c,0x5e,0xfa,0x3e,0xdf,0x88,0x8a,0x40,0x5c,0x8d,0xbf,0x20,0x1c, -0x3a,0x3c,0x10,0xd,0x1f,0xeb,0x33,0xb,0x0,0xe2,0x8a,0x84,0x9f,0x6,0x3c,0xc5, -0x98,0x11,0x1,0x1d,0xe,0xf8,0x1b,0x30,0x8b,0xd9,0x25,0x77,0x6d,0x1c,0x8,0x66, -0x41,0x0,0xe8,0x51,0x1,0x5c,0xc2,0x37,0xcd,0x7,0x5,0xda,0x17,0x30,0xa5,0xc4, -0xd1,0x4f,0x8,0x8c,0xd0,0xcd,0xf1,0xb1,0x13,0xc0,0xd,0x7c,0xd3,0x6a,0x48,0x20, -0x71,0x2e,0xb9,0xa7,0xc9,0xd3,0x8a,0xfb,0x1,0x3f,0x74,0xe1,0x92,0x34,0x7,0xdf, -0xdb,0xe4,0xc3,0x15,0x63,0xe7,0xab,0x97,0x4e,0x47,0x20,0x75,0xa7,0xdc,0x79,0x17, -0x40,0xe1,0x4b,0x17,0x2d,0x57,0x75,0x1b,0xbf,0xbd,0x86,0x8f,0x5f,0xbd,0xb4,0x3a, -0x2,0x7b,0xbe,0xd6,0xcb,0xf5,0x3b,0x0,0x3c,0xfa,0xcd,0xcb,0x71,0xd8,0xf,0x88, -0x75,0xb6,0x4d,0xaa,0xab,0x9b,0xcb,0xd,0x3e,0xf2,0x1b,0xcf,0x4a,0x15,0xe1,0x52, -0xb9,0xf3,0xeb,0xd9,0xfa,0x31,0x4c,0xed,0x71,0xdc,0x1b,0x88,0x95,0xc4,0x65,0xaa, -0xeb,0x37,0x37,0x81,0xe1,0xc4,0x63,0x1a,0xf0,0x11,0xdc,0x8e,0x8c,0xd1,0x12,0xf8, -0xbf,0xd9,0xe3,0x6b,0x10,0x6b,0x7f,0x78,0x79,0xd6,0x19,0x88,0xc7,0x1,0x2e,0x78, -0xad,0x74,0xc6,0xfb,0x6e,0x7c,0x26,0x8e,0xea,0x8,0x52,0x37,0x9,0x53,0x2f,0x82, -0x49,0x3b,0x41,0x7d,0xc7,0xeb,0xb8,0x79,0x42,0x72,0x9b,0xbe,0xcb,0x81,0xff,0xbc, -0x2f,0x70,0xc9,0x5c,0x36,0x67,0x3a,0x10,0x53,0x8c,0x8b,0xb,0xb8,0x52,0x7,0x26, -0x73,0x2,0xc1,0x63,0xa9,0x0,0xe9,0xc7,0x30,0xdb,0x92,0xbf,0xee,0xd,0x5c,0xc1, -0x7b,0xc1,0xbf,0xac,0x0,0x62,0x12,0x35,0x83,0xdb,0xf8,0xef,0x21,0x46,0x9f,0x13, -0x96,0xcc,0xb,0x61,0xb8,0xbe,0x25,0xe4,0xa,0x80,0x1f,0xdd,0x1b,0x1a,0x88,0x6e, -0x2e,0x86,0x48,0x15,0x1,0x70,0xa9,0x2,0x37,0x14,0x80,0xe3,0xe1,0x81,0xd8,0xc4, -0x99,0xc0,0x6f,0xf1,0x29,0x4b,0x12,0x15,0xb8,0x2,0x7f,0x94,0x1e,0x7f,0xf4,0x49, -0xd7,0x59,0x9a,0xf0,0x2,0xbb,0x9b,0x3,0xb1,0x67,0x44,0x16,0xd8,0x39,0x10,0x23, -0x47,0x4,0x57,0x98,0x1c,0xb1,0x4,0xf,0x5d,0x2d,0xc,0xff,0x18,0x1f,0x2b,0xb6, -0xfe,0xa4,0xab,0xe1,0xb7,0x1,0xb3,0x31,0xa4,0x6f,0xb0,0x64,0xfc,0x4b,0x5,0x18, -0x41,0xfc,0x62,0xe7,0xeb,0xce,0xae,0x4d,0x5,0xe2,0x2c,0x55,0x81,0xea,0x2c,0x3d, -0x3,0xb3,0x38,0xb1,0x7,0x70,0xde,0xd4,0x5f,0x81,0x65,0x2f,0xe4,0x9a,0x5,0xc4, -0x42,0x18,0x43,0x74,0x0,0xf3,0x34,0xe0,0xcb,0x7,0x1e,0x18,0xbd,0x1f,0xf1,0x43, -0x91,0xa9,0x41,0xa9,0xcc,0x60,0xd2,0xb8,0x2b,0xf8,0x54,0x1,0xc4,0x2,0x36,0x81, -0x14,0x23,0x39,0x83,0xa8,0xf,0xc0,0x89,0x9d,0x7b,0x9a,0xb4,0xe4,0x69,0x76,0x0, -0x5e,0xc2,0x2c,0x55,0x80,0x14,0x80,0x4,0x80,0x89,0x4,0x6e,0xf1,0xa5,0x3b,0x0, -0x17,0x0,0x9c,0x2e,0x14,0xc9,0x4,0x1,0x18,0x80,0x24,0xed,0x55,0x2d,0xde,0x5b, -0x78,0xda,0x1d,0x48,0x20,0x91,0xd9,0xe8,0xc7,0x3b,0xa3,0x59,0xf0,0xeb,0xb4,0x8, -0xc3,0xff,0x92,0x72,0xcd,0xeb,0x47,0x6,0x4,0xa7,0xb9,0x49,0x82,0xb2,0x20,0x15, -0xc0,0x53,0x46,0x42,0x88,0x16,0xe1,0x72,0x0,0x60,0x92,0x55,0xe9,0x63,0x8,0xc0, -0xe0,0xc7,0x16,0xf2,0x8b,0xd1,0x9b,0xba,0x31,0x7,0xa6,0xd6,0x5b,0x90,0x39,0x46, -0xe0,0xc7,0xcf,0x87,0x0,0x86,0x2,0xba,0x4,0x1f,0x36,0x9f,0x79,0xfc,0x8,0x6b, -0x3c,0x8b,0x1c,0x2d,0xe0,0x7c,0xc6,0x4b,0x93,0xf4,0x18,0xcc,0xc3,0xbb,0x80,0xf7, -0x10,0x76,0x98,0x88,0x68,0xc0,0x56,0x73,0xf0,0xa5,0xf3,0x29,0x3f,0x6e,0x19,0x37, -0x4e,0xe0,0x67,0x47,0x17,0x2,0x78,0xe6,0x8,0x21,0x34,0x88,0x1d,0xe2,0xa6,0x5, -0x4c,0x7c,0x57,0xb,0x0,0x2e,0xa6,0x1c,0x8e,0xd,0xce,0x8,0xce,0xe4,0x5a,0x8, -0xb0,0x48,0x44,0x8d,0x21,0x5c,0x9b,0x68,0x21,0xce,0x80,0x32,0xfe,0x71,0x28,0x46, -0x3c,0xe,0x14,0x41,0x38,0xdb,0xec,0xbe,0x23,0x50,0xde,0xc3,0xc,0x98,0xca,0x2b, -0xe6,0x60,0xaf,0x0,0x76,0xbb,0x42,0xc2,0xab,0xbf,0x51,0x6d,0x19,0x5f,0xde,0xbf, -0xc,0x98,0x5d,0x31,0xde,0xea,0x6c,0xc,0x11,0xd8,0x6d,0xc,0x13,0x5e,0xdf,0x9e, -0xd4,0x2e,0x54,0xc8,0xfb,0xb7,0xbc,0x84,0x59,0xea,0x7a,0xf9,0x8c,0xc1,0xf3,0x2c, -0xb2,0x59,0xa,0xc0,0x8e,0xb3,0xb4,0xe9,0xa,0xe5,0xfd,0x8b,0xef,0x81,0x7a,0xba, -0xe7,0x15,0x33,0xe6,0x9c,0xf1,0xbc,0x34,0xe0,0x9d,0x45,0xdd,0xed,0xb0,0xe1,0x4b, -0xc4,0xa0,0x25,0xf,0x3c,0x16,0xe3,0xb2,0x67,0x36,0x63,0xa2,0xdc,0xd3,0x70,0x60, -0x57,0x4f,0xd3,0xf0,0x12,0xf7,0x90,0x80,0x10,0x4d,0x1e,0x6,0xf2,0x8a,0xf9,0x55, -0x67,0xbe,0x94,0x3,0x3b,0xfa,0xd2,0x48,0x34,0x5d,0xd5,0xa6,0x8,0x99,0x6f,0xc9, -0xbe,0xc5,0x17,0x50,0xba,0x53,0x3c,0x9c,0x88,0xa6,0x2b,0x7b,0x7b,0x5e,0x5a,0xbc, -0xf2,0xbc,0x74,0x17,0x60,0xd3,0x15,0xee,0x27,0x0,0xb7,0xbe,0xca,0xd7,0x29,0xd7, -0x94,0x84,0x59,0x48,0x9f,0x61,0x6f,0x6,0x4,0x2e,0x59,0xe9,0x61,0x7,0x62,0xfe, -0xa6,0x72,0x34,0xc5,0x63,0x79,0xcc,0x67,0x29,0x3f,0x96,0xa6,0xd6,0x17,0x52,0xb0, -0x3d,0x8a,0x59,0x5b,0x28,0xe,0xcb,0x41,0x13,0x9c,0x82,0x59,0x3c,0xb4,0xc4,0x89, -0x59,0xae,0x70,0x3a,0x84,0xbb,0xf,0xf3,0x44,0x98,0x9f,0x93,0x5a,0xeb,0xb,0x79, -0xbd,0xd4,0x5d,0x8,0xdf,0x19,0x8,0xe8,0x34,0xa,0xd9,0x21,0xd6,0x4b,0x8b,0x50, -0xc5,0x81,0x63,0x67,0x80,0x2b,0xe4,0xa9,0xbe,0xb3,0x10,0x97,0xe1,0x89,0x86,0x80, -0x4b,0x98,0xd3,0x7,0x30,0xcd,0x22,0x79,0xd5,0xe7,0x12,0x98,0xba,0x3,0x8c,0x61, -0xf2,0x4,0x2b,0x51,0x8b,0xdc,0x7f,0xe2,0x5d,0x58,0xdc,0x7,0xe0,0x38,0x50,0x43, -0x15,0x97,0xdc,0xa9,0x37,0x4,0x10,0x6b,0x6d,0x58,0x2c,0x9d,0x89,0x1,0x7c,0x89, -0x35,0x1a,0xf0,0x3a,0x7,0x69,0xa0,0x86,0x2a,0x1,0xf4,0x87,0x2,0x62,0xed,0x52, -0x46,0xd8,0x5,0x3e,0x9a,0x43,0x2,0x59,0x36,0x6b,0x5c,0x9,0xc,0x7e,0xb4,0x40, -0x2c,0x96,0xa,0x87,0xcd,0x16,0xe0,0x56,0x97,0x19,0x30,0xcb,0xa8,0x1c,0x39,0x69, -0x6,0x3,0x52,0x71,0x19,0x38,0x55,0x17,0x60,0xfd,0x31,0x2,0xcf,0x64,0x12,0xc3, -0x8f,0xed,0xed,0x6c,0x87,0xd,0xc0,0x70,0x2e,0xe7,0xbb,0xcb,0xb3,0xd1,0x5,0x4e, -0xc9,0x43,0x9f,0x1d,0x8e,0x3,0x7e,0x9a,0x1c,0x4f,0x5a,0xe3,0x21,0x81,0xc1,0x5, -0x40,0x5d,0xe9,0x49,0xa7,0x6c,0x91,0xe0,0xb2,0x10,0x48,0xee,0x23,0xc5,0x8b,0x92, -0x1,0x81,0x24,0xb8,0x84,0xb,0x29,0xe2,0xe1,0x82,0x60,0x6e,0x18,0x2,0x30,0xdc, -0x4f,0xb4,0xa0,0xc1,0x14,0x2e,0xa4,0x88,0x13,0xb,0x34,0x3c,0x6c,0xf,0x3c,0xda, -0x73,0x78,0xba,0xf3,0x78,0x18,0xf3,0xdb,0xa9,0xcf,0xfb,0x89,0x1c,0x43,0x4b,0x9a, -0xc5,0xb0,0x40,0xf8,0xec,0x45,0x52,0x2,0x8e,0xb,0x60,0x58,0x7a,0x54,0xcf,0x8e, -0x63,0xe8,0x73,0x47,0x33,0x7,0x7d,0x28,0x3a,0x2f,0x19,0xef,0xbc,0xb4,0x4,0x10, -0x5b,0x3d,0xd1,0x2d,0x24,0xfe,0xa0,0x40,0x54,0x50,0x33,0x4f,0x5,0xa6,0xf7,0x8f, -0x39,0x90,0x3a,0xb1,0x88,0xfe,0x1e,0x1b,0xcc,0x2c,0x3c,0xf6,0x7b,0x54,0x50,0xa0, -0xf,0x71,0x7f,0x56,0xc4,0x1b,0x59,0xc3,0xf4,0xe4,0x50,0x0,0xff,0x92,0x88,0x83, -0xde,0x1c,0x36,0x94,0xa7,0x81,0xbc,0x14,0x1f,0x86,0xb7,0x4,0x31,0x83,0x5b,0xde, -0x2e,0xc1,0x34,0x70,0x65,0x26,0xb8,0x1f,0x72,0xf5,0xf4,0x84,0x14,0xe9,0xc7,0xee, -0x40,0xc8,0xd7,0x36,0x58,0x2f,0x5,0x27,0x9d,0x0,0x10,0x37,0xf5,0x4d,0x1,0x8a, -0x6b,0x4f,0xc1,0x6f,0x5,0x70,0x74,0xda,0x5d,0x1f,0xb6,0x3,0xe1,0xc7,0x4f,0xdc, -0x12,0x30,0x12,0xc0,0xd3,0xa3,0x42,0x33,0xe,0x7,0x44,0xa7,0x5d,0x6,0xc2,0x25, -0xb9,0x30,0x86,0xe3,0x83,0x22,0x7d,0x1b,0xe,0x98,0xe0,0x99,0xce,0x9e,0x6,0xf4, -0xc0,0xf2,0x2e,0x0,0x78,0x62,0x29,0x95,0x86,0xc1,0x80,0x44,0x74,0x43,0xab,0x40, -0x6c,0x1c,0x98,0x11,0xb9,0x6,0x2c,0xd3,0xb7,0xe1,0x66,0x29,0x6,0x60,0xcb,0x57, -0x81,0xc,0x81,0x4b,0x61,0xf8,0xb2,0x98,0x33,0x84,0x1d,0xca,0xc6,0x81,0x95,0xcc, -0x11,0x95,0x12,0x34,0x98,0x87,0x58,0x3f,0xe4,0x22,0x88,0x30,0xc6,0x86,0xd0,0x16, -0xbc,0x35,0x42,0x91,0xe2,0x2a,0x70,0x3f,0xf1,0xf0,0xae,0x81,0xdf,0x5b,0x3c,0xfc, -0x1e,0x80,0x59,0xe1,0x52,0xbd,0xdf,0x79,0x12,0xc5,0x8b,0xec,0xf7,0xbc,0xbb,0x3, -0xd2,0xae,0xcb,0x8,0xdb,0x27,0x8d,0x9d,0xa9,0x47,0x1,0xc4,0xe7,0xc,0xc6,0x59, -0x5d,0x4d,0x49,0x13,0x4b,0xb,0x96,0xbb,0xd8,0x21,0x63,0xfc,0x29,0x1b,0x12,0x18, -0xbb,0xfc,0xe1,0x4a,0xe2,0xfc,0x51,0x5,0x38,0x4a,0x40,0xd9,0xd,0x61,0xf8,0x89, -0xdc,0xd0,0x91,0x1,0xf9,0x86,0xe,0x47,0x1a,0xbb,0x2,0x4c,0x8,0xa8,0x82,0x21, -0xc,0x3f,0x81,0x94,0x3e,0x21,0x21,0x5f,0x99,0xc1,0x4e,0x85,0x39,0x5c,0xc5,0x25, -0xe8,0xb,0x2c,0xe6,0x89,0xfd,0x32,0xa2,0x12,0x35,0x1c,0x10,0x7c,0x26,0x36,0x30, -0x65,0xc0,0x5,0x7c,0xe8,0x74,0xc5,0x98,0x3f,0xff,0xa9,0x1,0x9,0xa4,0xfb,0x9, -0x8a,0x99,0x2,0xc8,0x2e,0xe0,0xff,0x5f,0xc2,0x18,0x7a,0x30,0x86,0x4f,0x6,0x9b, -0x34,0x12,0x48,0xfd,0x5,0x24,0x9f,0x3a,0x10,0xfb,0x4b,0x65,0x3f,0xd,0xb1,0xa2, -0xa1,0xe4,0x9a,0x4,0xa6,0x0,0xa4,0x25,0x20,0xf6,0x97,0xca,0x7e,0x1a,0x6a,0xcf, -0x7,0x32,0xfc,0x6c,0x49,0x16,0x9b,0xde,0x52,0x5f,0x5b,0x3,0xe6,0xfd,0xa5,0xb2, -0x9f,0x26,0x75,0x16,0x3,0xb9,0xb6,0x1c,0x78,0x57,0xe1,0xe9,0xce,0x81,0x3f,0xe4, -0x7a,0xe9,0xb0,0xfa,0xb0,0xad,0x5e,0x3a,0x98,0x3e,0x54,0x15,0x70,0x49,0xac,0xa4, -0x2e,0x2b,0xca,0x6d,0x83,0xe9,0xc3,0x42,0xb6,0x15,0x7,0x57,0x65,0x2f,0xa5,0x5e, -0x3a,0x9c,0x3e,0xcc,0x3,0xb1,0x5f,0x9c,0xa4,0x9c,0xcf,0x58,0x56,0x54,0xbf,0x6, -0xd3,0x87,0xf9,0xcb,0xcd,0xca,0xb8,0xa5,0xab,0xe,0xb3,0x85,0x9a,0x81,0xf4,0x61, -0xfe,0xba,0xa8,0x5e,0x42,0xbe,0xac,0x17,0xe,0xa8,0xf,0xf3,0xd7,0xac,0x66,0xd6, -0x28,0x6b,0x89,0x83,0xe9,0xc3,0xef,0xf,0x98,0xad,0x3e,0x97,0x6f,0xb3,0x1c,0xdb, -0xc1,0x4,0x69,0x31,0x43,0x6a,0x2e,0x61,0xa6,0x8c,0xed,0x50,0x82,0xb4,0x62,0xe6, -0xba,0x78,0x2c,0xa6,0xe8,0x50,0x82,0x54,0xb3,0xb,0x56,0x2,0x16,0x5,0xda,0xe1, -0x4,0xa9,0x61,0xaa,0x3f,0x9c,0x20,0xfd,0xff,0x49,0xae,0x7d,0xf,0xfa,0xb0,0x7c, -0x38,0x3a,0x46,0xdf,0x73,0x30,0x7,0x47,0x8e,0xa1,0x35,0xb4,0x3e,0x2c,0x1f,0xff, -0x8e,0x40,0xdc,0x16,0x6f,0x2b,0xa2,0x74,0x50,0x60,0xe9,0x80,0xfb,0x22,0xd5,0x17, -0xc0,0x61,0x12,0x61,0xd,0xe8,0x57,0x81,0x7,0x8f,0x18,0x7d,0x74,0x2a,0x80,0xce, -0xd0,0x76,0xf8,0xd2,0x9b,0x56,0x80,0xc7,0xa7,0xa2,0x9a,0x88,0xc0,0xd9,0x90,0x76, -0x88,0xea,0x69,0xe1,0xea,0x86,0xff,0x5a,0xc0,0x38,0x70,0x7c,0x20,0x24,0x77,0x3c, -0x38,0x70,0xae,0x3,0x27,0x12,0x78,0x66,0x9,0x60,0xf2,0x74,0x68,0xe0,0x52,0x7, -0x46,0x12,0x18,0x4a,0x20,0x79,0x3c,0x64,0xd6,0x6,0xfa,0x70,0x9e,0x78,0xe5,0x10, -0x29,0xba,0x2f,0x27,0xf0,0x3b,0x8c,0xe1,0x78,0xc8,0x59,0x8a,0xfa,0xb0,0xfc,0xdc, -0x7,0x12,0xe4,0xfd,0xa5,0x68,0xfc,0xc3,0x9a,0x5,0xea,0xc3,0xb2,0xe1,0x63,0xca, -0xed,0x2d,0xe1,0x9f,0x62,0x2e,0x4a,0x7,0x36,0x7c,0xbf,0xde,0xb5,0x71,0x71,0x2a, -0x37,0x79,0xc,0xec,0xda,0x5e,0x85,0xa7,0x81,0x81,0x24,0xad,0xee,0xb7,0x98,0x14, -0x65,0xb0,0xce,0x3d,0xc2,0x3f,0x42,0xa0,0x33,0xb0,0x59,0x60,0x2b,0x49,0x79,0x47, -0x9,0x3f,0xdb,0xc9,0xe6,0xeb,0x16,0x9d,0x1b,0xcb,0xd,0x24,0x77,0xb6,0xc1,0x43, -0x91,0x16,0x24,0xcc,0x1a,0xcb,0x49,0x18,0x83,0xa7,0x9b,0xd,0x8,0x2c,0xb6,0x3f, -0x28,0x76,0x8f,0x8d,0x74,0xa2,0xb1,0x1c,0xdb,0xe8,0x86,0xea,0xdc,0x33,0x4,0x76, -0xec,0x82,0x7e,0x5,0xbc,0x7b,0x60,0xdd,0x2c,0xdd,0x2b,0x10,0x77,0x76,0x95,0xe2, -0xa1,0x56,0x82,0x1e,0x6c,0xdd,0x22,0xf7,0x34,0xb8,0x9b,0x44,0x8f,0x87,0x3f,0x31, -0xe0,0xab,0x0,0x3c,0x7c,0x0,0x76,0xb1,0x53,0x81,0x95,0x33,0x6f,0x7e,0x4e,0xa9, -0x25,0x3f,0xc8,0x1e,0x12,0x98,0x38,0xe2,0x20,0x31,0x2d,0x3c,0x81,0x95,0xe0,0xd1, -0x5a,0x56,0xc8,0xcf,0x1c,0x33,0xf9,0xb0,0x2e,0xa9,0xbe,0x68,0xda,0xd1,0xbe,0x39, -0x3b,0x59,0xcd,0xaf,0x9b,0xc4,0xbb,0x7a,0x9a,0x4,0x72,0xcf,0xa4,0x54,0x6a,0xbb, -0x84,0x24,0x18,0x80,0x27,0x72,0x2b,0xd4,0x78,0x48,0x20,0x6e,0x2e,0x2e,0x6d,0xc5, -0x4d,0x83,0x5,0xbc,0x45,0x43,0x11,0x61,0xfe,0x40,0xbd,0x89,0xaf,0x80,0xaf,0x80, -0x3b,0x49,0xee,0xad,0x75,0x9a,0x7d,0x44,0x8b,0x9f,0x3e,0xf0,0x55,0x3c,0x7c,0x5, -0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x2c,0x80, -0x7f,0xf,0x8f,0x5b,0x9c,0x1e,0xf,0x3e,0xf1,0xfb,0x0,0x0,0x0,0x0,0x49,0x45, -0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//brd_wiznet.png: 13702 bytes - -const char m1284p_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x4,0xf8,0x0,0x0,0x3,0x3b,0x1,0x3,0x0,0x0,0x0,0xed,0x52,0xbc, -0x4d,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0x12,0x74,0x0, -0x0,0x12,0x74,0x1,0xde,0x66,0x1f,0x78,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54, -0x78,0xda,0xed,0xdd,0x5f,0x8c,0x23,0xc7,0x9d,0x1f,0xf0,0x59,0x4f,0x20,0x26,0xb0, -0xb5,0xf4,0x21,0x2f,0x6,0xbc,0xbb,0xf4,0xc5,0x4f,0x79,0x73,0x5e,0x6e,0x25,0x68, -0xb5,0xb4,0x90,0x7,0x3f,0xfa,0xf1,0x2,0x8,0xd2,0x2a,0x2f,0xf9,0x3,0x45,0x4b, -0x19,0x86,0x96,0xbb,0xe2,0x72,0x7a,0xd6,0x3,0x64,0x1e,0x12,0xdc,0xdc,0x21,0x2f, -0x39,0x48,0xde,0x31,0x70,0x7,0xf8,0xe1,0x60,0xad,0x2,0x45,0xa2,0x6c,0x2e,0xa7, -0x39,0x98,0xb3,0x6,0xc1,0x59,0xe2,0x19,0x4e,0x30,0xb6,0x29,0xb2,0x38,0x37,0x97, -0xa3,0x90,0x11,0xbb,0x38,0x1e,0x2f,0xab,0x67,0x8a,0x5d,0x95,0xfe,0x57,0xfd,0xb7, -0xba,0xd9,0xff,0x48,0xb6,0x70,0x43,0xdc,0x59,0xda,0x9d,0xdd,0x99,0x8f,0xaa,0xbb, -0xab,0xbe,0xfd,0xab,0xea,0xea,0x15,0x9a,0xef,0xcf,0xca,0x85,0xef,0xc2,0xe7,0xfe, -0xf4,0x4b,0xc5,0x5c,0xfb,0x7a,0x12,0xca,0xb5,0xaf,0x3b,0xc9,0xb9,0x8f,0x5e,0xf8, -0xd2,0xf9,0x60,0xce,0x7d,0x60,0x91,0xbe,0xc1,0x5a,0x71,0x73,0x73,0x73,0x5a,0xda, -0x23,0xd7,0xae,0x14,0x89,0x2c,0xcc,0xf6,0x21,0x71,0x91,0x3e,0xd8,0x42,0xb5,0x5a, -0x4d,0xa1,0x2d,0x65,0x34,0x42,0xd3,0x8,0x3f,0xbb,0x7,0x85,0x85,0xfa,0xba,0x58, -0xf5,0x61,0xc3,0x77,0x1e,0xc1,0xd7,0xbf,0x56,0x58,0xac,0x8f,0xaa,0x40,0xb9,0xdc, -0x52,0xe0,0x8,0x11,0xba,0xc0,0x63,0x17,0xd9,0xb7,0xaf,0xb6,0x1f,0xc8,0xaf,0x6f, -0x4f,0x6d,0x3f,0xaa,0xf9,0x3e,0x2d,0x12,0x2a,0xe4,0xcf,0x87,0x71,0xed,0xcd,0x12, -0x68,0x3d,0xd,0x5b,0xd3,0x9b,0x84,0xe6,0xd0,0x57,0x33,0x8f,0x6f,0x9d,0x12,0x25, -0x7f,0x3e,0xbd,0x7f,0xc1,0x62,0x4b,0x91,0x14,0x4a,0xf0,0xec,0xbf,0xd2,0x3e,0x3c, -0x1c,0xb4,0x6f,0x81,0x45,0xf9,0xcc,0xfe,0xf9,0xf9,0x3d,0x72,0xe5,0x69,0x4a,0xc6, -0xe5,0x99,0x7f,0x85,0xf4,0xfb,0x10,0x83,0x85,0xf9,0x62,0x7f,0x94,0x7e,0x1f,0x60, -0x28,0xe6,0xd9,0xb7,0x9b,0x67,0x1f,0x3e,0xec,0xf7,0x31,0xa,0xe8,0x87,0xc6,0xfe, -0x13,0x93,0x90,0xc3,0x8,0xa3,0x7a,0x86,0xbe,0x7e,0x9f,0x4,0xfa,0x10,0xe0,0xf8, -0xfa,0xc9,0x13,0x45,0x52,0xdf,0x79,0xc0,0xb1,0x87,0x9c,0x3,0x5f,0x17,0x2b,0x60, -0x81,0x3e,0xd4,0x57,0x8f,0x6f,0x90,0x6f,0xc0,0xf5,0x41,0xba,0x58,0x5f,0xf,0x2b, -0x41,0xed,0x57,0xf5,0x1f,0xf8,0xe6,0x7c,0x7c,0x2d,0x24,0x15,0x8a,0x9c,0x5b,0x5d, -0x74,0x78,0x78,0x18,0xe4,0x1b,0x94,0x17,0xe7,0xbb,0x81,0x3a,0x93,0xb8,0xb7,0x92, -0xa,0x7d,0xd3,0xff,0x9b,0x7,0x73,0xf1,0x91,0x56,0xf5,0x91,0x14,0xdb,0x7,0xb9, -0xbe,0xb9,0x5c,0x1f,0xad,0x6a,0x5,0xc6,0xf6,0x49,0x9c,0x3,0xf,0xe7,0xd3,0xbf, -0xb4,0x1a,0x15,0x80,0x38,0xe7,0xdf,0x8a,0xfd,0xf1,0x7,0xfd,0x31,0xcf,0x37,0x9f, -0xfe,0xb9,0xf5,0x1,0x4,0xbc,0x52,0x4b,0xa8,0x6f,0x81,0xe3,0x5b,0xeb,0xff,0x40, -0xd0,0x9f,0xa3,0x4f,0xbe,0x1e,0xe1,0xb0,0x7,0xf9,0x56,0xd5,0x1b,0xba,0xff,0x5d, -0x10,0x77,0x38,0xbe,0x92,0xfd,0xaf,0xfb,0x69,0x7c,0xe8,0x0,0x95,0x13,0xfb,0xea, -0xa7,0xb4,0x35,0x84,0xe2,0xda,0x3c,0x7d,0x5d,0x29,0x79,0xfb,0xad,0x1d,0xab,0xfd, -0x33,0xdc,0x29,0xf8,0xaf,0xf,0xe8,0xf0,0x7d,0x54,0x4e,0xe3,0x8b,0x12,0xd2,0x2, -0x7d,0x81,0x41,0xbf,0xe3,0xf0,0xfd,0x3c,0x4d,0x8a,0x96,0x15,0x30,0xf,0xdf,0x23, -0xe7,0xf1,0x4d,0x95,0xf2,0xaf,0xc6,0xf6,0xb5,0x3d,0xbe,0x31,0xe7,0x6f,0xc0,0xcc, -0x7c,0x7d,0x31,0xae,0x6f,0xdd,0x38,0x9f,0x8a,0x44,0x30,0x7c,0x3,0x61,0x2b,0xdc, -0x17,0xe9,0xfc,0x1b,0x6,0xe5,0xa0,0xb8,0x3e,0xb2,0x62,0xfc,0xec,0x55,0xe6,0x1b, -0x92,0x62,0x6,0xed,0x77,0x18,0x14,0xb5,0x85,0x38,0xbe,0x35,0xf5,0x6,0xb3,0x6c, -0x70,0xbe,0x41,0x84,0xba,0xe1,0x93,0xb3,0xf0,0xc9,0x1,0xbf,0x5d,0x8e,0xe5,0x6b, -0xb5,0x94,0xcf,0x69,0xc7,0x48,0x56,0x37,0x85,0x55,0xc3,0x77,0xd8,0xe1,0xf8,0x88, -0x1e,0x9e,0xb1,0x54,0x8e,0x78,0xfd,0x4e,0x53,0xf4,0x42,0x2e,0xdf,0x67,0x6a,0x87, -0xab,0x75,0xb9,0xe5,0xcb,0xe6,0x78,0x3e,0xdc,0x34,0x7d,0x53,0xc1,0xea,0x90,0x2d, -0xdf,0x8,0x58,0xfd,0xdf,0x54,0xf0,0xf7,0xde,0x47,0xf6,0xf,0x29,0x66,0xe1,0xeb, -0x2a,0x54,0xf3,0x6d,0x68,0xbe,0xb6,0xf9,0xf3,0xfe,0xbe,0xd4,0x61,0xc7,0xc2,0xf8, -0xe7,0x86,0x2e,0xb8,0xa3,0x47,0xa9,0x2e,0xb4,0xc6,0xf,0xd9,0x6a,0x21,0xfb,0x84, -0xdd,0xcd,0x64,0x98,0xb1,0x7d,0x43,0x45,0x3d,0x91,0x8f,0xe8,0x25,0xcd,0x37,0x36, -0x7d,0x3,0xc1,0xf4,0x8d,0xcd,0x66,0xb9,0xc4,0xf7,0x8d,0xad,0x56,0x9b,0x5a,0x91, -0x61,0x7d,0xd6,0x5,0xd2,0xd6,0x23,0x46,0x39,0xb2,0xf,0xd3,0x5f,0xd2,0xc1,0xca, -0xec,0x8f,0xc3,0xd7,0x5e,0x89,0xf4,0xb9,0x94,0x85,0xaf,0x8b,0x8a,0xff,0x23,0x62, -0xfb,0xbd,0xa3,0x1f,0xc9,0x66,0x82,0xf6,0x1b,0x8,0x89,0x7d,0x2d,0x48,0xef,0xa9, -0x5d,0xa9,0x7e,0xfe,0xb1,0x6f,0xf3,0xf7,0x65,0xee,0xf9,0xe7,0xf3,0x45,0x3e,0xff, -0x9c,0x23,0x9a,0xfe,0xbb,0x24,0xba,0xf,0x10,0x99,0x5d,0xbf,0xff,0x99,0x5d,0xbf, -0x45,0xff,0xf5,0xab,0xfa,0xfa,0x46,0x4,0x3,0xd6,0xf,0x9e,0x71,0xfd,0xda,0x83, -0x90,0x8,0x12,0xfb,0xd6,0x1e,0x4c,0xbf,0xa2,0xf6,0x7f,0xda,0xad,0xe0,0xcd,0x6b, -0x2,0xac,0xe3,0xbd,0x3d,0x3c,0xdc,0x33,0x7d,0xac,0xec,0xb,0x1d,0xbe,0xb5,0xb2, -0xe5,0x73,0x54,0x85,0xad,0x6,0xb2,0x93,0x23,0xb1,0x7b,0x74,0xb1,0x6f,0xfd,0x97, -0x94,0x4c,0x5f,0x31,0xfa,0xf8,0x36,0x55,0x87,0x5b,0x4d,0xf0,0xcc,0x9a,0xd0,0x79, -0xfe,0xb4,0xd5,0x3a,0x1d,0x8e,0xb9,0x3e,0xdf,0x81,0xb,0xf7,0x39,0x5a,0xd7,0xf6, -0x11,0x68,0xfa,0x4,0xed,0xa4,0xbd,0xb4,0xdb,0x7e,0xa5,0x3c,0x7b,0xfc,0xbd,0x59, -0xd2,0x5,0x7f,0x48,0x84,0x47,0x2f,0x1d,0xb7,0x5a,0xc7,0xc3,0x69,0x31,0x3,0x9f, -0x63,0x7c,0x73,0xf8,0xcc,0xe3,0x7b,0x53,0xeb,0xa,0xb0,0xb0,0x3,0x94,0x68,0xf9, -0x45,0x13,0x14,0x88,0x0,0x5f,0xea,0xb6,0x5a,0x5d,0x2b,0x1f,0xa4,0xf2,0x1d,0x72, -0x7d,0xdb,0xfb,0xac,0x49,0xa2,0xfb,0xda,0x86,0x40,0xcd,0x57,0xf0,0x35,0xdd,0xc7, -0x4e,0xed,0x54,0x3e,0x47,0xbe,0x5a,0xbf,0x66,0xf9,0x2a,0xa6,0xf,0xea,0x3e,0x31, -0x92,0xcf,0x14,0xa8,0x3f,0x3,0xbe,0xd6,0x6c,0xb5,0x9a,0x94,0x4d,0xf5,0xa6,0xf2, -0xb9,0x4e,0x21,0xdf,0xf9,0xa7,0xfb,0x2e,0xed,0xb7,0xeb,0xd1,0x7d,0xda,0x3f,0xde, -0xa8,0xb5,0x5a,0x35,0xfb,0xdb,0xce,0xd5,0x37,0x2d,0x8,0x72,0x9c,0xf6,0xd3,0x7d, -0x97,0x5a,0xad,0x4b,0x72,0x29,0xe3,0xf6,0x73,0x1c,0x5f,0xe8,0x38,0xbe,0x40,0x20, -0x71,0x7d,0xf7,0x70,0xab,0x85,0x31,0xec,0x64,0xdc,0x7e,0x3b,0xbe,0xfe,0x4f,0xbb, -0x3e,0x60,0xc4,0xeb,0xc3,0xe1,0xd3,0xfb,0x67,0x8c,0x1e,0x65,0xeb,0x23,0x6b,0x76, -0x5f,0xb8,0xdf,0x2e,0xd3,0x75,0x7d,0xfc,0x50,0x50,0x6c,0x9f,0xf1,0xc1,0xa8,0x92, -0xad,0xef,0x8c,0x38,0x7c,0xeb,0x45,0xba,0x72,0x53,0xf7,0x61,0xb5,0x7f,0xae,0xe7, -0xc1,0x37,0x24,0xce,0xdc,0x55,0x24,0xee,0xdc,0x16,0xdf,0x37,0xc9,0xf8,0xfa,0x0, -0xdc,0xf6,0x8b,0x53,0x3f,0x70,0xfb,0x9e,0x4,0xf8,0x64,0xf4,0xeb,0x72,0xba,0xeb, -0x37,0x76,0x7e,0xe1,0xfa,0x7e,0x5f,0xe0,0xfb,0xd0,0xf7,0xbb,0x20,0x5d,0xff,0x97, -0x8d,0xf,0x6,0xb4,0x1f,0x7c,0xbf,0xb,0x53,0xfa,0x80,0xdd,0xbf,0x24,0xf6,0x5, -0xf6,0xcf,0xf0,0x49,0x32,0xdf,0xe7,0x6a,0xff,0x22,0xdc,0xbd,0x79,0x59,0xfd,0xd7, -0x6d,0xbb,0x7f,0x26,0xc5,0x4d,0x51,0x48,0xe2,0xb,0x1c,0xdf,0xa4,0x3f,0x4a,0xe6, -0xeb,0xa9,0xfd,0xf3,0xcd,0x6a,0x6f,0x62,0xfb,0xf4,0xf1,0x17,0xd5,0x76,0x68,0xa6, -0x3e,0xd8,0x78,0x31,0x91,0xaf,0xa5,0xe6,0xab,0x9b,0x95,0x91,0xe6,0xbb,0xe5,0xf0, -0x4d,0x94,0x56,0x7e,0x7c,0x2f,0x55,0x46,0xc4,0xe1,0xdb,0x56,0x7d,0x84,0x36,0xb3, -0xf5,0xa1,0xea,0x5b,0x89,0xae,0x5f,0x51,0xf7,0x49,0x6a,0x68,0x26,0xc0,0x6e,0x3f, -0x35,0x44,0x37,0xb2,0xf5,0x25,0xed,0xff,0x34,0xdf,0xab,0x15,0xf8,0x91,0x76,0x4d, -0xd8,0x3e,0xfa,0x11,0xfd,0xab,0x6c,0x7d,0x49,0xc7,0xf,0xd3,0x37,0xb1,0xfb,0x17, -0xed,0xfa,0xa5,0x13,0xfa,0xc3,0x7c,0xf8,0xb4,0xfb,0xf3,0x57,0x8d,0xeb,0xc3,0xd1, -0xff,0x65,0x7f,0x7d,0x24,0xf5,0x69,0x85,0x89,0xaa,0xd1,0xbf,0xb8,0xf2,0x55,0x84, -0xfe,0x45,0xae,0x45,0xf4,0x71,0xe6,0xb7,0xa2,0x8f,0x1f,0xea,0xa7,0x6a,0xf4,0xcf, -0x8e,0x7c,0x10,0xa9,0x7f,0x46,0x8d,0x85,0xf8,0x12,0xe7,0x2b,0x33,0x2a,0x43,0x3a, -0xbe,0x59,0x9a,0x6b,0xfb,0x25,0xcc,0x57,0x68,0xdb,0x14,0xa0,0x1e,0xc,0xf5,0xe9, -0x1f,0x85,0xfb,0x65,0xb7,0xef,0x50,0x19,0x87,0xfa,0xe2,0xe5,0x17,0x73,0xb2,0x53, -0xf5,0x8d,0x78,0xbe,0x43,0xdd,0x0,0x49,0x49,0x6f,0xb3,0x93,0x91,0xf7,0xcb,0xac, -0x88,0x21,0xca,0x77,0x4b,0xa6,0xaf,0x7f,0x16,0xba,0x92,0x36,0xb1,0xf,0xf2,0x7c, -0xfd,0xa9,0xfe,0x55,0xc5,0xf8,0x91,0xd2,0x6b,0xde,0x2f,0xb3,0x5,0x45,0x22,0x32, -0x6b,0x68,0x88,0x8a,0x6f,0x84,0xf9,0xd8,0xfd,0x9b,0x18,0xdf,0xc7,0x3b,0xff,0x44, -0x7d,0xe1,0x3,0xc4,0x13,0xe3,0x4f,0xfd,0xc4,0xfb,0xe5,0xa,0x6b,0x3f,0x68,0xd6, -0x20,0x55,0x9f,0x12,0xb2,0x5a,0xd4,0xba,0x3f,0x57,0x1b,0x50,0x51,0x3e,0xbc,0x59, -0x9c,0xe5,0x1b,0xaf,0x86,0xb6,0x9f,0x38,0x31,0x7c,0x46,0xc5,0x8,0x7e,0xec,0xfd, -0x32,0xb4,0x7c,0x34,0x92,0x8f,0xb2,0xfb,0x73,0xf5,0x4f,0x4f,0xcf,0x1a,0x3d,0x14, -0xb9,0x7f,0x9e,0xe1,0xd3,0xbf,0x11,0xf2,0x9e,0x7f,0xe2,0x67,0xb6,0x4f,0xb0,0x7c, -0xbc,0xd5,0xac,0xc8,0xed,0x2b,0x1b,0xbe,0x2e,0x9e,0xe5,0x3b,0xa5,0xa1,0xd7,0x87, -0x28,0x19,0x3e,0xf3,0xfb,0x7b,0xaf,0x5f,0x71,0x28,0x78,0x7d,0x50,0x54,0x94,0xa0, -0xcb,0xc2,0x31,0xbe,0xa9,0x3e,0xe5,0x8d,0x6,0x9e,0xe9,0x33,0xab,0x9c,0x41,0xfd, -0x8b,0xd8,0xf,0xf7,0x41,0x8e,0xaf,0xce,0xfb,0xa1,0x9b,0x3c,0xdf,0x87,0xb3,0x7d, -0x66,0xa9,0x2f,0xa8,0x7f,0x16,0xbf,0x2d,0x18,0xd7,0x47,0x80,0xaf,0x62,0xf9,0xfa, -0xe6,0x71,0xdc,0xe8,0x2b,0x9c,0x93,0xca,0x2a,0x46,0x8b,0xe,0xdf,0x4f,0xc4,0xaf, -0xcf,0xf6,0x19,0x7,0x18,0x6e,0xf3,0xc7,0xb7,0xbe,0xd1,0xff,0x29,0x12,0xe4,0xfa, -0xfa,0x56,0xfb,0x21,0x73,0xa8,0x47,0xf0,0x50,0x19,0xf8,0xaf,0xf,0x6b,0xa9,0x8e, -0xe0,0xf2,0x75,0x23,0xb7,0x5f,0x80,0xcf,0xea,0x9f,0x8b,0x5c,0xdf,0xe1,0xd8,0xea, -0x9f,0xd7,0x98,0x8f,0xfb,0x3,0xd9,0x9f,0xb3,0xf2,0xa9,0xee,0x8b,0x70,0x7d,0x98, -0xff,0x61,0x41,0xbe,0x4,0xe3,0x1b,0xf7,0xb3,0xc7,0xab,0x5f,0xf5,0x22,0xf4,0x2f, -0xc6,0x1f,0x18,0xf0,0x63,0x44,0x7c,0xdf,0x20,0x60,0x71,0x51,0x91,0x57,0xbf,0xea, -0x45,0xe8,0x9f,0x8d,0xf6,0x6b,0x67,0xe5,0x6b,0xaf,0xac,0x66,0x9b,0xaf,0x8c,0xf3, -0xaf,0xb3,0x4f,0xb3,0xf1,0x75,0x58,0x87,0x1a,0xa1,0xfd,0xa2,0xd5,0x37,0xf4,0xef, -0xd7,0xd9,0x98,0xb3,0x6f,0x3f,0x71,0x7d,0x68,0xcb,0xf4,0xc9,0xcf,0xe1,0xfd,0x4b, -0x68,0xf7,0x50,0x99,0x8b,0xef,0x30,0xa9,0xcf,0x18,0x3f,0x3a,0xdf,0xa4,0xe8,0x37, -0xa7,0x4d,0x38,0x4,0x7d,0xc7,0x12,0xe2,0x81,0x7a,0xae,0x68,0xdf,0x4c,0x3d,0x4b, -0x78,0x3e,0xf3,0xcb,0xda,0x49,0xbc,0xc2,0x4e,0xbb,0xa0,0xf3,0x4f,0x4e,0xea,0x33, -0xff,0x73,0xff,0xa5,0xe6,0x13,0xe0,0x81,0x28,0xbe,0x39,0x17,0x9f,0xbd,0x98,0x23, -0x51,0xfd,0x8f,0xfc,0x47,0x8a,0xce,0x8f,0x5,0x88,0x36,0xc4,0x74,0xed,0x17,0x9c, -0x4b,0x13,0xfa,0x8c,0xfe,0x85,0xfc,0x27,0x2a,0x9f,0x1f,0x7f,0x7,0xa2,0x96,0x88, -0xc2,0xc2,0x79,0xf2,0xe7,0x6c,0x36,0x53,0xe5,0xfb,0xe9,0xe7,0x94,0x7e,0xfd,0xc5, -0xe7,0x20,0x52,0xe6,0xe5,0x1b,0xa6,0xf3,0x49,0x2,0xed,0xbe,0x58,0xd3,0x7c,0x83, -0xf2,0x5c,0x7c,0xe9,0xee,0x8f,0xce,0x24,0x1,0xe9,0xbe,0x96,0x58,0x11,0xd3,0x5d, -0x1f,0x97,0xe6,0xe1,0x3b,0x81,0x65,0xd4,0x6d,0xaa,0xbe,0x66,0xdf,0xf1,0x24,0x47, -0x7e,0x7c,0xa7,0xb0,0x2c,0x3f,0xd7,0xdc,0x84,0x68,0xef,0x30,0x67,0x3e,0xe3,0xfe, -0xed,0x8,0x66,0x96,0xf,0x32,0xf6,0xd1,0x6c,0xf3,0xd5,0x6c,0x5f,0xcc,0xf5,0x43, -0xec,0x2f,0xcd,0xd5,0x7,0x3e,0xb5,0xd7,0xbb,0x24,0xf2,0xc1,0xd9,0xf5,0xb5,0x54, -0xbe,0xae,0xbd,0x62,0x3e,0x91,0x8f,0x66,0xe5,0xa3,0xa7,0x87,0x87,0xb4,0xed,0xed, -0xe2,0x61,0x63,0x84,0x63,0x75,0x92,0x91,0x7d,0x68,0x4f,0x5b,0x91,0x6,0xa7,0x65, -0xa4,0xaf,0x56,0xf3,0xfa,0xf6,0xf6,0xcc,0x5,0x6b,0xe2,0x98,0x2,0xdd,0x75,0xda, -0xef,0xfb,0x1f,0xa4,0x87,0x8d,0x98,0x1d,0x7b,0x64,0xdf,0xb0,0xa5,0x2f,0x3b,0xc1, -0x60,0xa8,0xdf,0xa9,0x78,0x7d,0xad,0x96,0xd9,0x72,0xea,0x8d,0xfa,0xb6,0xee,0x3a, -0xea,0xf7,0xfb,0x3e,0x1f,0xaa,0xce,0xcb,0x77,0xd0,0x6a,0x19,0xbe,0x83,0xbf,0xac, -0x72,0x7d,0x2d,0xcb,0xf7,0xf2,0x9f,0x69,0xae,0xd3,0x59,0x3e,0x54,0x58,0xa5,0x47, -0xf,0xba,0x30,0xa3,0xe3,0xcb,0x7c,0xe8,0xcf,0x1b,0x1c,0x9f,0xa2,0xd8,0xbe,0xfe, -0xbf,0x63,0xbe,0xb6,0xf7,0xfb,0x9c,0x23,0xfb,0x2f,0x4e,0x70,0x9d,0xf6,0x76,0x7e, -0x93,0x9d,0xef,0x81,0xe1,0x6b,0xbe,0x5b,0xe6,0xfa,0x1e,0x58,0x3e,0xa9,0x1d,0xd4, -0x7e,0xe7,0xc8,0xbe,0x3e,0x34,0x9f,0xb8,0xf3,0xdb,0xcc,0xdb,0xaf,0xc9,0x6b,0x3f, -0x8c,0x1d,0xed,0x27,0x5,0x1e,0x5f,0x5,0xdb,0xfd,0xcb,0x84,0x2e,0xd0,0x87,0x50, -0x34,0xdf,0xd4,0xee,0x9f,0x51,0xa9,0x4e,0xff,0x62,0xa7,0x5b,0x59,0x88,0xf,0x42, -0x8e,0xef,0x53,0x10,0xf6,0xa3,0xd1,0xd1,0x2a,0xfd,0xe1,0x83,0xec,0x7c,0x3f,0xd, -0xf3,0x1,0xf0,0x53,0xaf,0xef,0xf0,0xf0,0xef,0xc2,0x7d,0x58,0xa0,0x2d,0xb1,0xfb, -0x28,0xab,0xfe,0xf9,0xe7,0x9a,0x6f,0xfa,0x3c,0xdf,0xf7,0xe0,0xc1,0xcf,0x4d,0xdf, -0x18,0x19,0xbe,0x99,0xf3,0x33,0x93,0x4c,0x7d,0x59,0xd5,0xaf,0x7c,0xbe,0x4e,0x5e, -0x7d,0xa8,0x20,0xd0,0x3d,0x31,0xab,0xfe,0x39,0x7b,0x5f,0xb6,0xe3,0xdb,0x3f,0x4a, -0xdf,0xca,0x45,0xfb,0x5d,0xf8,0xbe,0x38,0xbe,0x76,0xce,0x7d,0xda,0xe3,0x83,0x39, -0xf6,0x11,0xad,0x4a,0x91,0x57,0xdf,0xda,0x1e,0x7d,0xac,0xad,0x2d,0xc8,0xab,0x4f, -0xbd,0x1,0xbb,0xa1,0x4d,0xd9,0xe5,0xd7,0x47,0x1e,0x6b,0x25,0x1b,0xfe,0xfc,0x8c, -0xf3,0xf9,0x23,0xa3,0x50,0xc5,0xfd,0x32,0x75,0x94,0x97,0x33,0xf6,0x75,0x15,0xfa, -0xa1,0xf6,0x4c,0x13,0x7f,0x7e,0xc6,0xf9,0xfc,0x96,0x51,0xed,0x12,0x78,0x5f,0x76, -0x3e,0xbf,0x95,0xb1,0x6f,0xa8,0xd0,0x9f,0x6a,0x3e,0x7e,0xd5,0xc9,0xf9,0xfc,0x9b, -0x51,0xe7,0x2a,0xf3,0xbe,0xec,0x7c,0xfe,0x2d,0x6b,0x1f,0x56,0x7d,0xe3,0x95,0xec, -0x3e,0x85,0x8c,0x8f,0x2f,0x2a,0xfe,0x54,0x9b,0xa3,0xc9,0xac,0xfd,0x68,0xc6,0xd7, -0x7,0x34,0x8e,0x6f,0x66,0xe7,0x5f,0xd6,0x3e,0x40,0x1f,0x6b,0x73,0x13,0x99,0x5d, -0xbf,0x19,0xfb,0xd6,0x1e,0xd0,0xc7,0x31,0x1e,0xd4,0x5d,0xd4,0x3e,0x6d,0xce,0xf1, -0x6d,0x5a,0xde,0xcc,0xb5,0x8f,0xc4,0xd8,0x58,0x77,0x19,0x3e,0xb6,0xfd,0x41,0x6e, -0x7d,0x6d,0x9a,0x6f,0x1f,0xbd,0xf0,0x5d,0xf8,0x2e,0x7c,0x17,0xbe,0xb,0xdf,0x85, -0xef,0xc2,0x77,0xe1,0xcb,0x81,0x6f,0xaa,0xdf,0xec,0xad,0xe6,0xdd,0x27,0x5f,0xdd, -0xc1,0x74,0x33,0xbf,0x3e,0x3c,0x7a,0x78,0x4a,0x6b,0x79,0xf4,0xe9,0xb7,0x7e,0x47, -0x78,0xf4,0xce,0x71,0x2b,0xdf,0x3e,0xdc,0xcd,0xa9,0x6f,0x5f,0xf7,0x7d,0x80,0xbb, -0xdf,0xcf,0x91,0x4f,0x2e,0x15,0x91,0xe9,0x6b,0xaa,0x3e,0xf9,0xea,0x7,0x78,0xf8, -0x5f,0x32,0xf3,0xd,0x56,0x56,0x84,0x74,0x3e,0x2c,0xa1,0xa1,0xc3,0x87,0x95,0x9f, -0xe1,0x21,0xce,0xcc,0xd7,0x9e,0xb9,0x30,0x69,0xa6,0x6f,0x84,0xf,0x3c,0xbe,0x6e, -0x76,0xbe,0xf4,0x1f,0x3c,0x32,0x9e,0x49,0x56,0x7d,0xef,0xe9,0xbe,0xc7,0xb8,0x5b, -0xcd,0xa7,0xef,0x6f,0xe4,0xb2,0xea,0xdb,0xc1,0xad,0xad,0x1c,0xf9,0xe4,0xab,0xb4, -0x6a,0xfa,0x30,0x2,0x47,0x59,0x8f,0x6f,0xe9,0xdb,0x4f,0x21,0xd6,0xf5,0xb,0x61, -0xd6,0xbe,0x5d,0xf8,0x6e,0xda,0xeb,0x43,0x39,0x5f,0x65,0xfd,0x1f,0x40,0x59,0xfb, -0x76,0x86,0xd,0x90,0x2,0x77,0xa2,0xfa,0x8,0x62,0xed,0x47,0x45,0x9c,0xb5,0x4f, -0x78,0xb5,0x91,0xe6,0x25,0x3e,0x3,0xd5,0x47,0x8b,0xf3,0xf4,0x1d,0xa7,0xf3,0xb9, -0x4b,0xfd,0xe5,0xec,0x7d,0xa3,0xb4,0xed,0xe7,0xcc,0x7,0xd9,0xb7,0xdf,0xdd,0xd7, -0xf2,0xed,0x13,0x6e,0xdb,0x3e,0x61,0x75,0x6d,0x90,0xce,0x97,0xfd,0xf5,0xeb,0xf0, -0x11,0x1,0xd7,0x81,0x90,0xc6,0xb7,0x9f,0x7d,0xff,0xb7,0x3,0xaf,0xb3,0xfe,0x45, -0x11,0x50,0x4d,0xfc,0x9f,0x5b,0x71,0x7d,0x6a,0xbe,0xda,0x60,0xfd,0x73,0xf6,0xe3, -0x87,0xa3,0x7f,0xc6,0x2,0xaa,0x8a,0xef,0x5d,0x8f,0xdd,0xbf,0x48,0xe6,0x3,0x27, -0xaa,0x4f,0x1d,0x7f,0xe7,0x37,0xbe,0x61,0x1,0x56,0xc4,0x46,0x35,0xb6,0x6f,0x84, -0x5,0x47,0xbe,0x9a,0x9f,0xf,0x9,0xf0,0x8f,0x13,0xf9,0x68,0xc1,0x91,0xef,0xe7, -0xe7,0x83,0x2,0x7c,0x2e,0x99,0xaf,0xb6,0x90,0xe3,0x3b,0x28,0x83,0x5a,0x2,0x9f, -0x9a,0xaf,0xf0,0xfc,0xae,0xf,0x57,0x5f,0x3,0xea,0xa0,0x1a,0xbf,0xfd,0x14,0xdb, -0x97,0x7d,0xff,0xe2,0xfc,0xd4,0xc0,0xda,0x0,0x25,0xf0,0xe1,0xda,0xfc,0xf2,0x55, -0xda,0x73,0x42,0xcf,0x57,0xd5,0xf9,0x8d,0x6f,0x19,0xf8,0x68,0x71,0x73,0xde,0xbe, -0x69,0x6e,0xf3,0x95,0xf1,0x31,0x9f,0xc5,0x5f,0x99,0xfd,0x50,0xa8,0xbf,0xfd,0xd8, -0xce,0xb4,0xf3,0x6c,0x3f,0xe3,0x59,0x7c,0x12,0xb8,0x3,0x75,0xe8,0xf1,0x45,0xf3, -0xf7,0x6d,0x9a,0x1,0x86,0xd2,0xb3,0xd8,0x3e,0x84,0x3b,0x73,0xcc,0x57,0x6,0xac, -0x94,0x8d,0x6f,0x63,0x4e,0xfd,0x9f,0xb9,0xaa,0x24,0xb5,0xf,0xcd,0x69,0xfc,0x18, -0xd3,0x8c,0x7c,0x73,0x1a,0x7f,0xd9,0x6a,0x2d,0x41,0x7f,0x2e,0x74,0xc5,0x7a,0x48, -0x34,0xae,0xf,0xce,0x29,0xbf,0xf8,0xda,0xcf,0x88,0xfc,0x8f,0x67,0x6c,0x79,0x64, -0xf8,0xc6,0xab,0x73,0xf7,0xf9,0xce,0x3f,0xc3,0xd7,0x4,0xe5,0x8,0x3e,0x4a,0x6d, -0xdf,0x9c,0x8e,0xaf,0xf9,0x6c,0xac,0xd7,0xd7,0x90,0xc4,0x78,0x3e,0x30,0xaf,0x7c, -0x55,0xf4,0xf4,0xcf,0xa6,0x8f,0xc6,0x3c,0xbe,0x60,0x5e,0xf9,0x6a,0x3f,0x85,0x8f, -0xa2,0x8e,0x7e,0x8,0x34,0xdf,0xbc,0xf2,0x95,0xf7,0xbb,0xc6,0xf2,0x75,0x34,0xdf, -0xb4,0x34,0xcf,0xf1,0x6d,0x9c,0xc6,0xa7,0xbf,0x3a,0x41,0x2e,0x2e,0x32,0x5f,0x99, -0x3e,0x18,0xc5,0x37,0x75,0xbc,0xfc,0xa2,0x3c,0xef,0x7c,0x2a,0x1b,0xef,0x1,0x64, -0xfd,0x4b,0x14,0x1f,0xa6,0xf3,0x6f,0x3f,0xfb,0x1e,0xdd,0xd8,0x15,0x2b,0x7e,0xff, -0x3c,0xdf,0xf3,0x8f,0xef,0x8b,0x5a,0x1f,0xb2,0xae,0x5f,0x3a,0xf7,0xfb,0x23,0x8c, -0x12,0xfa,0xa8,0x30,0x9f,0xfa,0x55,0x7a,0x9f,0xb2,0x65,0xf9,0x9a,0x73,0x9f,0xff, -0x90,0x8b,0xd0,0xf6,0xf1,0x97,0x93,0x17,0xbd,0xd7,0x47,0xc3,0xf2,0x89,0x73,0x19, -0x7f,0x15,0x65,0xcf,0xea,0xff,0xb0,0xb1,0xa7,0x23,0x64,0xc3,0xc9,0xac,0xe5,0xee, -0x5a,0xbe,0x6a,0x5a,0xbe,0x1f,0xcf,0x25,0xbf,0x28,0x4a,0xcb,0xda,0x5e,0x12,0x1b, -0x5d,0xa,0x64,0x71,0x81,0xf3,0x19,0x6,0xfb,0xde,0xe2,0xf9,0x48,0x9b,0xa4,0xf3, -0x11,0xbc,0x66,0x75,0x74,0xd8,0x90,0xc6,0xf2,0x61,0xfb,0xfc,0xe3,0x1d,0x5f,0x2, -0xee,0x27,0xf0,0x4d,0xbf,0x2a,0xd8,0x3e,0x1,0xd8,0xfd,0x4b,0x21,0x8d,0x8f,0x77, -0x7d,0x10,0xf0,0x66,0x3a,0x1f,0xad,0xda,0x3e,0x7b,0x7c,0x23,0xc1,0xbe,0x93,0xa3, -0x20,0x1f,0xaf,0x7f,0x21,0xe0,0x4e,0x86,0x3e,0xb2,0xba,0x3e,0x18,0x7c,0xab,0xa8, -0xd,0xab,0x81,0x3e,0xa9,0xc7,0xb9,0x3f,0x17,0x82,0xea,0x57,0xe9,0x7d,0x8f,0x9c, -0x3e,0x45,0x4,0x15,0x2,0x43,0x7d,0xa4,0xc7,0xa9,0x6f,0x8,0x41,0xe3,0x1b,0x69, -0x4b,0x69,0x7d,0xf6,0xf5,0x61,0xfb,0xce,0xa3,0xfa,0xcc,0x4f,0xb0,0xf,0xf4,0x53, -0xfa,0x80,0xdd,0xbf,0xe8,0x3e,0x38,0xc3,0x77,0xc6,0xf3,0x5,0xe6,0x2b,0x9,0xe8, -0x9b,0xb3,0xa4,0xf1,0xd9,0xfd,0xb3,0xea,0x5b,0x3f,0x1a,0x68,0x5b,0x89,0x4f,0xe8, -0x53,0xb1,0xda,0x2f,0xb0,0x3e,0x24,0x1,0x92,0xb2,0xfd,0x5c,0x47,0x63,0x55,0x9c, -0xea,0xc7,0x77,0xbc,0x76,0x9e,0x8d,0xef,0x24,0x5b,0x9f,0x9a,0x99,0x75,0x1f,0x51, -0xa6,0x2,0x29,0xac,0x6e,0x7e,0xc9,0xac,0x8,0xa2,0xbb,0xe5,0x6b,0x5f,0xde,0x85, -0x5,0xdf,0xf5,0xeb,0xf4,0x65,0x97,0xaf,0x2,0x7d,0x48,0xbb,0x3e,0xf6,0xb5,0x5e, -0x9b,0x8,0x6a,0xcf,0x5d,0x63,0xd7,0xb6,0xd4,0xec,0xc3,0x5e,0xff,0x0,0xfa,0xfa, -0x3f,0x87,0x6f,0x2f,0xbb,0x7c,0x15,0xe8,0xc3,0x9a,0x4f,0x9b,0xf0,0x43,0x5e,0xdf, -0x8,0x99,0x3e,0x6f,0xfe,0xa3,0x73,0xb8,0x3f,0xf,0xf4,0x29,0x6a,0xff,0x7c,0xf3, -0x92,0xe5,0x13,0x98,0xaf,0xdf,0x1c,0xd1,0x9d,0xfe,0x1,0xf0,0xfb,0x88,0xe5,0xe3, -0xe6,0x2b,0x73,0x77,0xa7,0x88,0x3e,0x2b,0x34,0x7d,0x95,0x13,0x9d,0x4,0xb6,0xa, -0x52,0xcf,0x51,0x44,0x3f,0xff,0x56,0x4d,0x5f,0xaf,0xab,0xfa,0x76,0x9b,0x40,0x2f, -0x89,0x97,0x9c,0xbe,0xa9,0xe5,0xdb,0xe4,0xe5,0x97,0x98,0xbe,0xb0,0xf6,0xb3,0x7e, -0x8b,0xb5,0x1f,0x14,0xac,0xec,0xf0,0xe9,0xd7,0x55,0x1f,0xd8,0xe0,0xb4,0xdf,0xd8, -0xf2,0x35,0x17,0xe5,0x63,0xe7,0x1f,0xb2,0xcf,0x3f,0xb5,0xfd,0xd0,0x1a,0x68,0x8a, -0x7e,0xdf,0x91,0xe5,0xc3,0xbc,0xe3,0x6b,0xee,0xce,0x96,0xa9,0x4f,0xfb,0x9e,0xd8, -0xed,0xeb,0x1e,0xf7,0xe1,0x1a,0xa8,0x73,0x7c,0xfb,0xb6,0x8f,0x77,0x7d,0xcc,0xc3, -0xa7,0xc7,0x6a,0xb5,0xff,0xc3,0xf6,0xf9,0x77,0xfc,0x59,0xb9,0x54,0x37,0x7c,0x27, -0xc8,0xe5,0xb3,0xe7,0x3f,0xb8,0xf9,0x6a,0x5f,0xfb,0x99,0x73,0xf0,0x11,0xf7,0xf8, -0xa1,0x45,0x56,0xc5,0xcc,0x57,0x5a,0x13,0xb6,0xb1,0x6c,0xf8,0x8c,0xe2,0xa1,0x7e, -0xff,0xeb,0xca,0x57,0x1b,0x87,0x10,0x18,0xbe,0xe9,0x5c,0x7c,0x9e,0xf1,0x57,0x6b, -0x33,0x6c,0x8e,0x6f,0xda,0x7a,0x49,0xf0,0x86,0xb6,0xed,0xe6,0x80,0x15,0x5f,0xfd, -0xf5,0x83,0x7a,0xdf,0x28,0xdf,0xec,0xab,0x51,0x63,0x2e,0xbe,0xe0,0x7c,0x85,0x74, -0x1f,0x34,0xeb,0x1b,0xe6,0x8d,0xa9,0xcf,0x67,0xee,0x14,0x3e,0xaf,0xe3,0x1b,0x92, -0xaf,0xdc,0xbe,0x80,0xf9,0x41,0xc1,0xd8,0x28,0x3e,0x91,0x4f,0x11,0xd2,0xb7,0xdf, -0xed,0xcf,0xc2,0xdb,0x6f,0x4b,0x1c,0x59,0xbe,0x8d,0xc5,0xfb,0xda,0xd2,0x30,0xfc, -0xfc,0x3b,0x11,0xff,0x9f,0xe5,0xab,0xc7,0xf4,0x91,0x95,0xd8,0x3e,0x35,0x5f,0x95, -0xbe,0xbe,0xb,0xb7,0xb4,0xeb,0x57,0x6f,0xbf,0x76,0xc5,0xf0,0x19,0x93,0x77,0xfe, -0xfa,0x95,0x62,0xee,0xf4,0xaf,0xfa,0xd4,0x4f,0xcc,0xf3,0x4f,0x6d,0xbf,0xd7,0x57, -0x63,0xf9,0xd4,0x7c,0x25,0x8d,0xfa,0x7,0x55,0xd6,0xff,0x1,0x60,0xfa,0xcc,0xc9, -0x4f,0xed,0xfe,0x3,0x39,0xfb,0x3f,0xfd,0xfa,0x38,0xd2,0x7d,0xa,0x5d,0x8b,0x7b, -0x7d,0x98,0x9d,0x85,0xfe,0x29,0xa0,0x48,0xbe,0xd1,0x44,0xe9,0x1f,0x8,0x6c,0xfc, -0x0,0xe2,0x23,0xc1,0x39,0xbe,0x69,0xbe,0xa1,0x73,0xfc,0xd0,0xfb,0x97,0x5d,0x7d, -0xfc,0xc0,0x74,0x27,0xa6,0xef,0x81,0x63,0xe1,0x3d,0xc1,0xc3,0x8,0x3e,0x35,0x5f, -0x91,0x87,0xfd,0x83,0xef,0xda,0xbe,0x77,0x5d,0xf9,0x40,0xf7,0x39,0xc7,0x5f,0xbd, -0x7f,0x5e,0x4f,0xe8,0x5b,0x73,0xd5,0x87,0xe,0x22,0xf8,0xd4,0x7c,0x40,0x6e,0xef, -0x36,0xaf,0x7b,0x96,0x1c,0x68,0x97,0x6,0x42,0xc5,0x3d,0xdd,0x77,0xe0,0xc8,0x2f, -0xce,0xea,0xd7,0x6a,0x4a,0x5f,0x94,0xe3,0xab,0xe6,0x2b,0x22,0x81,0x8d,0x2a,0x27, -0x3f,0xa3,0x9,0x6a,0xf9,0x7c,0xc6,0x27,0x9b,0xf6,0x43,0xd1,0xda,0x6f,0x22,0x81, -0x26,0xcf,0x87,0x47,0x78,0x4d,0xf7,0x35,0x7c,0xf9,0x2a,0xe9,0xf9,0xd7,0xd2,0xde, -0xf5,0x19,0xcb,0xa7,0xe6,0x2b,0x49,0x2,0x75,0xbe,0x4f,0xfd,0x9b,0x9a,0x6f,0xc3, -0x97,0xaf,0xf4,0xeb,0x97,0xc6,0xbf,0x7e,0xd5,0x84,0xce,0xd6,0x5d,0x44,0xf4,0x69, -0xf9,0xea,0x2a,0xa8,0x6f,0x71,0xee,0xdf,0x94,0x9e,0xe9,0x43,0xbe,0x7c,0x85,0x74, -0x5f,0xfc,0xfe,0x4f,0xfb,0xab,0xac,0x83,0x51,0x8e,0xa3,0xf8,0x9c,0xf9,0xaa,0xa7, -0xe7,0xab,0xb1,0xe0,0xf3,0xf9,0xee,0x7f,0xd,0x5f,0xec,0xf1,0xc3,0xe5,0x23,0xa7, -0x51,0x7c,0xce,0x7c,0xa5,0x18,0xf9,0x8a,0xb5,0x1f,0x69,0x99,0x3e,0x7f,0xfd,0xc0, -0xf4,0xc5,0x1d,0x7f,0xc9,0x1f,0x3a,0x7c,0xf4,0x9f,0x45,0xf1,0x39,0xc7,0x5f,0xc5, -0x99,0x5f,0x34,0x9f,0x79,0x7d,0x4,0xfa,0x62,0xe7,0x97,0xbe,0xd3,0x17,0x3b,0x5f, -0x61,0xdd,0x37,0xb0,0xee,0xcf,0xd7,0xd4,0xfe,0x85,0x5f,0xbf,0x4a,0xe1,0xc3,0x28, -0x71,0x7e,0xd1,0x7d,0xb7,0x21,0x3b,0xff,0xa8,0xa0,0xf6,0xcf,0x34,0xeb,0xf6,0x9b, -0x16,0x53,0xe6,0x2b,0x2a,0xcc,0xae,0x5f,0xa5,0xf0,0xd1,0xf8,0xf9,0xea,0xcb,0xbb, -0x70,0x53,0xbb,0x7e,0xa1,0x9e,0xaf,0x4,0x61,0x76,0xfd,0x2a,0xa1,0x4f,0xbb,0x3e, -0x62,0xfa,0xb4,0xfa,0x55,0xbd,0x7f,0xa0,0xdf,0x5f,0xee,0xba,0xf2,0x95,0xed,0xdb, -0xf,0xe8,0xff,0x12,0xdc,0x7f,0x24,0xf0,0x79,0xf3,0xd5,0x3b,0xd4,0x5c,0xdf,0xbe, -0x56,0x64,0xf7,0xbf,0xbe,0xf1,0x23,0x1b,0x9f,0x3c,0x58,0x29,0x94,0x22,0xe4,0xab, -0x6b,0xfd,0x83,0xa2,0x2f,0x5f,0x61,0x69,0x27,0xb8,0xbe,0x81,0x92,0xd6,0x5f,0x62, -0xfb,0xb4,0x7c,0x25,0xed,0xaa,0xf9,0xc0,0x9b,0xaf,0xb0,0xd4,0xb2,0x7c,0xbe,0xfc, -0x12,0xc7,0x37,0x2e,0xa7,0xf1,0x69,0xf5,0x2b,0x35,0x5f,0x21,0x5f,0x3e,0xc0,0xd2, -0xe3,0x92,0xe9,0x1b,0xa6,0xf2,0xe9,0xe5,0x6,0xc3,0x37,0x75,0xff,0x69,0xf9,0x88, -0xee,0x47,0x68,0x3f,0xa4,0xe6,0x2b,0x8e,0x6f,0x64,0xbc,0x86,0x2c,0xe8,0xf8,0x46, -0xae,0x9f,0x2,0x68,0x5f,0xbf,0x34,0xb6,0x2f,0x30,0x5f,0xc9,0x57,0x1,0xc,0xac, -0x5f,0xc5,0xf3,0x95,0xed,0xfb,0x37,0x57,0xa5,0x4a,0xf3,0x5d,0x11,0xdc,0xbf,0x3b, -0x16,0x22,0xe6,0x2b,0x6c,0xce,0xb9,0x73,0xeb,0x57,0x49,0x7d,0xae,0xcf,0x99,0xe6, -0xfb,0xba,0xe8,0xf6,0x91,0x99,0xf9,0x8a,0x98,0x3e,0x3c,0x62,0xbe,0x7d,0x5e,0xff, -0x3c,0x7e,0xae,0xae,0x6d,0x53,0x9f,0xc2,0xf7,0x44,0x3f,0xbe,0x33,0x7c,0xfe,0x7c, -0x35,0x35,0x7d,0xe8,0x9,0x8,0x1b,0xdf,0x50,0xf7,0x79,0xba,0x9d,0xca,0xa7,0xf0, -0x7c,0xca,0xcc,0x7c,0x75,0xce,0x7c,0x93,0x52,0xb8,0xef,0xa5,0xda,0xad,0x28,0xbe, -0x76,0x31,0xd4,0x27,0x44,0xf6,0x9d,0x9d,0xea,0x3e,0xed,0x3d,0x8b,0xb3,0xd6,0xb7, -0x1b,0xbe,0x6,0x88,0x36,0xff,0xe1,0xf0,0x9d,0xa7,0xf0,0x19,0xed,0x77,0x7b,0x42, -0x23,0xe5,0x17,0xd4,0x7d,0x2d,0xa1,0x6f,0x8c,0x1c,0xbe,0x6b,0x9e,0xab,0x1a,0xcf, -0xf0,0xb5,0x25,0x29,0x9a,0x6f,0xfc,0xdc,0x6b,0x1d,0x10,0xfb,0xf8,0x4e,0x2f,0xa9, -0x97,0x64,0xd5,0xe1,0xbb,0xca,0xf1,0x29,0xe3,0xa7,0xad,0xe,0x43,0xcb,0x57,0xdd, -0x5d,0x8,0xd9,0xf5,0xb,0xda,0x2f,0xd3,0x48,0xf9,0xa,0xe1,0x37,0xa2,0xf9,0xa8, -0xb6,0x1c,0x97,0x6d,0x40,0xa8,0x39,0x61,0xc3,0xe1,0xfb,0x5a,0xd9,0xfd,0xa,0x19, -0xcd,0x47,0xe0,0x9b,0xb0,0xe7,0xc8,0x57,0x3f,0xec,0x1f,0x74,0x58,0xff,0x7,0xc0, -0xb7,0xa3,0xe5,0x2b,0xd5,0x17,0xf1,0xf8,0x6a,0x6f,0x48,0x95,0x1d,0x6,0x78,0xe0, -0x1e,0x3f,0xa6,0x25,0xcf,0xf8,0xa1,0xf9,0x14,0x3b,0x5f,0x21,0xd3,0x67,0xe6,0x97, -0x1d,0x96,0xaf,0x4,0x10,0x96,0xaf,0x10,0xbe,0x17,0xcd,0x37,0xd5,0xce,0x3f,0x6b, -0x3,0xcc,0x55,0xd5,0x37,0x74,0xfb,0xe4,0xa2,0x77,0x7c,0xbb,0x65,0xfb,0xb4,0xf9, -0xc1,0x97,0xfb,0x7,0x8f,0x7c,0x3e,0x2c,0x89,0xdb,0x61,0xe3,0x2f,0xc2,0xf5,0x5a, -0x24,0xdf,0x29,0x75,0xbc,0x1c,0x50,0x3b,0xc7,0xd5,0xfb,0x5e,0xb3,0xca,0xa4,0xfa, -0xb8,0xd3,0x85,0x62,0xb5,0x82,0xed,0x7c,0x40,0x5f,0xde,0x6d,0x3e,0xe2,0xe4,0x2b, -0xf1,0x56,0x58,0xbe,0x8a,0x3c,0xbe,0x41,0x67,0xfb,0x11,0xc5,0x11,0x14,0x82,0xdb, -0xef,0x75,0xcb,0xa7,0xd5,0xaf,0xfa,0x60,0xa3,0xc2,0xc9,0x57,0x3b,0xec,0xf8,0x22, -0x9e,0x8f,0xb4,0xf5,0x2d,0x42,0x23,0x5e,0xbf,0xec,0xfc,0xe3,0xf9,0x38,0xe7,0x5f, -0xb5,0x82,0x1c,0xf5,0xab,0xcb,0xa0,0x59,0xe0,0xe4,0xab,0xbe,0xe5,0xe3,0x1d,0x5f, -0x2,0xaa,0xd1,0xda,0x4f,0xef,0xff,0xac,0xd,0x44,0x6b,0xda,0x62,0x35,0xb7,0xcf, -0xf3,0xa,0x28,0xcd,0x57,0x79,0x4,0xed,0x7c,0x5,0xfb,0xa0,0xe,0x39,0xf9,0xaa, -0xc7,0x7c,0x90,0x77,0x7d,0x10,0x50,0x89,0xe1,0x23,0x56,0x79,0xb3,0xac,0xbd,0xb8, -0xd4,0xe5,0xf3,0xde,0xa,0x8,0xa,0xaa,0xfc,0xe8,0x5,0x47,0xbe,0xea,0x19,0xbe, -0x13,0xec,0xce,0x57,0x5f,0x66,0x3e,0xc0,0xeb,0x5f,0x8,0x78,0x25,0x9a,0x6f,0x52, -0xf6,0x8c,0xbf,0x10,0xcd,0xf0,0x5,0xe5,0xab,0x53,0xa3,0x7e,0xc5,0xf2,0xd5,0x67, -0xec,0xfe,0x6d,0x83,0xd7,0x3f,0x13,0xfd,0x46,0x34,0x82,0x4f,0x2,0x69,0x7c,0xce, -0x7c,0x65,0xe4,0x3,0xb3,0xbe,0x81,0x11,0xa,0xcd,0x57,0xa4,0x4d,0xa3,0xf9,0xfa, -0xce,0x7c,0x35,0xfd,0xd7,0x31,0x7d,0xce,0xf1,0xf7,0x38,0x96,0xf,0x24,0xf1,0xe1, -0x56,0x72,0xdf,0x99,0xe1,0xd3,0xeb,0x2f,0xb3,0xf3,0x95,0x4,0x60,0x34,0x1f,0xf0, -0xfa,0x66,0x5e,0x1f,0x41,0xed,0xd7,0xd5,0xf3,0x95,0x1c,0x2d,0xbf,0x48,0x20,0xe2, -0xfa,0x3a,0x9f,0x4f,0x2e,0x25,0xf4,0xed,0xc6,0xa9,0x5f,0x9d,0x80,0x71,0x42,0x9f, -0xb7,0x7f,0xe,0xbf,0x3e,0x1c,0xf3,0x83,0x38,0x4e,0xfd,0x2a,0xfa,0xf8,0x6,0xa8, -0xfb,0xfa,0xe0,0xfb,0x84,0xc0,0xfa,0x95,0x35,0x3f,0x88,0x3,0xea,0x57,0x30,0xd5, -0xfd,0x25,0xaf,0xbe,0xc1,0xf1,0x55,0x3,0xeb,0x57,0x48,0xf5,0x21,0xdf,0xfc,0xa0, -0x9a,0xaf,0xd8,0xfd,0x51,0x27,0xd5,0xfd,0x39,0xaf,0x72,0x40,0x5c,0xf5,0x97,0x30, -0x9f,0x96,0xaf,0x24,0x97,0xcf,0xae,0x5f,0xb1,0xfb,0xdf,0x47,0x99,0xd7,0xaf,0xa2, -0xfb,0xb4,0x7c,0xf5,0x70,0xb7,0xd9,0x9,0xab,0x5f,0xc1,0x54,0xf5,0xa1,0x74,0xbe, -0x90,0xfa,0xd5,0x3c,0x7c,0xf2,0xa5,0xa0,0x72,0x60,0x35,0x7e,0xfd,0x8a,0x9d,0x7f, -0x90,0x77,0x7c,0x93,0xd5,0x4f,0x15,0x2a,0x7f,0x83,0xef,0xb3,0xf6,0x3b,0x8b,0x5c, -0xbf,0xfa,0x14,0x86,0xe5,0xab,0x64,0x3e,0x12,0xe8,0x63,0xd,0x1c,0x32,0x3f,0x78, -0xe8,0xce,0x57,0x4f,0xc3,0xb0,0xfe,0x25,0xd9,0xfa,0x1c,0xea,0xf0,0x89,0x57,0x15, -0xd1,0xf7,0x7,0x91,0x10,0x9c,0xaf,0xa0,0x3b,0x5f,0x59,0xf5,0x2b,0xc8,0x9f,0x5f, -0x98,0xa6,0xf4,0xdd,0xfc,0xfc,0xcc,0xe1,0x33,0x5f,0x78,0xe0,0xf5,0x39,0xf3,0x15, -0x70,0xe7,0x97,0x27,0x30,0x7c,0x7e,0xe6,0x3c,0x9d,0x8f,0xb4,0xa6,0x67,0x7f,0x61, -0x2f,0x36,0x1,0xfc,0xf6,0x73,0x8e,0xbf,0x7b,0x6e,0x5f,0x78,0xfd,0x2a,0xfd,0xf1, -0x6d,0x29,0x6f,0xfc,0x10,0x79,0x7d,0xf2,0x8c,0xf5,0xed,0x91,0xf3,0x55,0x6,0xbe, -0xab,0x6f,0xb4,0xec,0x27,0xb6,0x3a,0xb3,0xdb,0xcf,0xa8,0x5f,0x45,0x9e,0x7f,0x8b, -0xbf,0xfe,0xca,0xed,0x7b,0x3c,0xfa,0x89,0xc3,0x17,0x70,0xfe,0xf9,0xeb,0x57,0x84, -0x46,0xf6,0xd5,0xd3,0xb5,0x9f,0xea,0x3,0xbc,0xf3,0x4f,0xab,0x5f,0x21,0x4e,0xbe, -0x32,0xea,0x57,0x75,0x1a,0x71,0x7e,0x90,0x24,0x5a,0x7f,0xa0,0xfb,0xf4,0xdb,0x61, -0xae,0x4f,0x36,0xeb,0x43,0x43,0x4e,0xbe,0x32,0xea,0x57,0x35,0xbf,0x2f,0xa0,0xff, -0x4b,0xb4,0xfe,0x4a,0xf7,0xe9,0xe5,0x84,0xd6,0xa8,0xd7,0x12,0x5d,0x1d,0x9d,0xa3, -0x7e,0x75,0x10,0x98,0xaf,0x1a,0x7e,0x5f,0xc0,0xf8,0x11,0x7f,0xfd,0xb,0xf3,0xe9, -0xe5,0x98,0x9d,0xab,0xbd,0x96,0xdd,0xbf,0xb4,0xcb,0xae,0xfa,0x15,0xa,0xcc,0x57, -0x3f,0xf2,0x5f,0x1f,0x1,0xe3,0x6f,0x1c,0x9f,0xdd,0x19,0x7c,0x63,0xd6,0x8b,0x71, -0xf4,0xfa,0x95,0xa3,0xfe,0x42,0xfb,0xbb,0x4d,0xe8,0x5f,0x7f,0xe5,0xf0,0xf9,0xf2, -0xcb,0x38,0xee,0xfa,0x2b,0xca,0x69,0xbf,0xa0,0xff,0x14,0xbd,0x7e,0x85,0x1c,0xf9, -0xaa,0xf,0x36,0x42,0x9f,0x5f,0xa0,0xbc,0xf5,0xed,0xf1,0xda,0x8f,0x72,0xce,0xbf, -0x40,0x9f,0xa7,0x7e,0x85,0x76,0x40,0x13,0x2c,0xd6,0x37,0x15,0xc2,0x7d,0x95,0x47, -0xc8,0x51,0xbf,0xe2,0xaf,0x6f,0x9f,0xed,0x8b,0x71,0xfd,0x7a,0x7c,0x9e,0xcf,0xdf, -0x95,0x5c,0xf9,0x4f,0xab,0x5f,0x55,0xed,0x7c,0x75,0xed,0x69,0x50,0x2f,0x84,0x3d, -0x3f,0x13,0xe4,0x8b,0xd1,0xff,0x85,0xfb,0xb4,0x99,0x5c,0x71,0x76,0xfd,0xca,0x98, -0x1f,0x54,0x22,0xfb,0x62,0x8c,0x1f,0xb3,0x7d,0x60,0x76,0xfd,0xca,0xc8,0x57,0x67, -0xd1,0x7d,0x1b,0x19,0xfa,0x22,0xd4,0x37,0x7e,0xa5,0xfb,0x9e,0x78,0x7c,0x1,0xfb, -0xb7,0xc7,0xcb,0xf7,0xe1,0x3e,0x10,0xc9,0x77,0xf6,0xb1,0xee,0x53,0x16,0xef,0x1b, -0x6e,0x47,0x6a,0x3f,0x3d,0x1f,0xdc,0x9e,0xbf,0xcf,0x78,0x43,0xfc,0x9e,0x67,0xa5, -0x98,0x18,0xc9,0xd7,0x96,0x3c,0xbe,0xa0,0x4f,0xa,0x9f,0xf1,0x86,0xf8,0xd6,0xe9, -0x30,0x68,0xfc,0xf0,0xd4,0xaf,0x9a,0xbb,0x10,0x4,0xe6,0x2b,0xfa,0x79,0xb1,0x98, -0xb9,0x4f,0x7b,0x43,0xfc,0xda,0xf1,0x81,0x85,0x10,0x3,0x7d,0xda,0xfc,0xe0,0xf3, -0xfd,0x83,0x6d,0x3b,0x5f,0x79,0x7d,0xa3,0x9,0xca,0xd2,0xa7,0xf5,0x69,0xfa,0x1b, -0xe2,0x5,0xfb,0xf8,0x42,0x10,0xe2,0x1b,0x4d,0x5a,0xfd,0x83,0x5b,0x76,0x7e,0x69, -0x2d,0xc2,0x27,0xb5,0x9d,0x3e,0xed,0xfa,0x5d,0x17,0x2,0xeb,0x57,0xce,0xe7,0x7, -0x39,0x3e,0xc4,0xf5,0xc5,0xab,0xbf,0xf8,0x7c,0xc0,0xeb,0x13,0xc4,0xc0,0xfa,0x95, -0xf5,0xfc,0x20,0x2f,0x5f,0x65,0xec,0x93,0x4b,0x2e,0x9f,0x5c,0x9a,0xe1,0xb,0x7e, -0x7e,0xd0,0xbe,0x3e,0x60,0x86,0x3e,0x4,0x99,0x6f,0x4d,0xf3,0x21,0x38,0xbb,0xfd, -0xc2,0xf3,0x15,0x1d,0x51,0x10,0xf2,0xf3,0xe2,0xfa,0xb4,0xe0,0xae,0xf9,0x7e,0x50, -0x6c,0x69,0x3e,0x23,0xc7,0x43,0xf0,0x83,0x62,0x80,0x4f,0xcb,0x57,0x3b,0xa0,0x1e, -0xec,0x23,0xa3,0xd0,0xed,0x8a,0xe2,0xfb,0xb6,0xa9,0xf6,0x86,0xf8,0x1f,0x14,0xf7, -0xc,0xdf,0xb6,0x5e,0xa2,0xfe,0x41,0xd1,0xb8,0x3e,0xa6,0x77,0x39,0xf5,0xab,0x96, -0xe1,0xd3,0xd7,0x77,0xf2,0x7c,0x42,0xc6,0x3e,0xed,0xf3,0x83,0x22,0xef,0x97,0x14, -0x37,0x42,0xea,0x57,0xd8,0x59,0xbf,0xb2,0x3e,0x57,0x9,0xf7,0x95,0x99,0x91,0xd7, -0x5f,0xc5,0xf2,0xd1,0x46,0x48,0xfd,0xa,0x3b,0xeb,0x43,0x33,0x4f,0xf4,0xa8,0xeb, -0xaf,0xd2,0xf9,0x9c,0xe3,0x2f,0x8a,0xe7,0x8b,0xb8,0xfe,0xca,0xfd,0x19,0x14,0x5c, -0x20,0xcf,0x2f,0x29,0xbd,0x23,0xcc,0x7c,0x7e,0x30,0xb2,0xaf,0x1,0x92,0xec,0xff, -0xe2,0x1,0x79,0x7e,0x79,0x6f,0x56,0xfb,0xdd,0x8e,0xec,0x7b,0x6d,0xe,0x3e,0x42, -0x43,0x7c,0x7a,0x7d,0x57,0x8a,0xe8,0x8b,0xbc,0xfe,0x2a,0xd6,0xf1,0x55,0xf4,0xfa, -0xda,0xe3,0xcb,0x4f,0x15,0x39,0xf5,0x2b,0x63,0x7d,0x7b,0x25,0x62,0xfb,0x45,0x5e, -0x7f,0xe5,0xb9,0x40,0xdc,0x20,0xcf,0x2f,0xe5,0x67,0xb4,0xfe,0xef,0xa5,0x9,0xa1, -0x9c,0xfa,0x95,0xee,0x3,0xd1,0x7d,0x89,0x8e,0xef,0xb6,0x1b,0xe4,0xf9,0xa5,0x31, -0x7e,0xb8,0x7c,0xa3,0x89,0xe9,0x33,0xf3,0xcb,0xa3,0xa8,0xbe,0x7b,0x49,0x7c,0x44, -0x70,0x81,0x3c,0xbf,0xf4,0xfb,0xb4,0xf5,0xed,0x92,0xcb,0xf7,0x6e,0xb4,0xfb,0x8f, -0xc8,0xeb,0xaf,0xdc,0x9f,0x33,0xba,0xae,0x7f,0xc3,0x2f,0x19,0x9b,0x6e,0xb9,0x7f, -0x69,0xd6,0xaf,0xc8,0xe7,0x97,0x9f,0x2a,0xd9,0xf9,0x80,0xbf,0xbe,0xdd,0xe3,0xcb, -0xea,0xfd,0x5b,0xc8,0x75,0xc1,0x42,0x44,0x39,0xed,0x47,0x9e,0xee,0x13,0x47,0xbe, -0xa,0x7a,0x7e,0xd0,0xe5,0xf3,0xbd,0x7f,0x8b,0xb4,0xe5,0x24,0x3e,0xf7,0x5,0xb, -0x7d,0xfd,0xb3,0xee,0x1b,0x49,0xc4,0x91,0xaf,0x82,0x9e,0x1f,0x74,0xd5,0xf,0x7c, -0xef,0xdf,0x22,0xa0,0x2a,0xd0,0xb4,0xfd,0x1f,0xa4,0xbc,0xf6,0x53,0x9e,0xd8,0xbe, -0x90,0xe7,0x7,0xbd,0x3e,0xf7,0xfb,0xb7,0x62,0xac,0xbf,0x8a,0xe1,0x9b,0xbe,0xae, -0xd5,0xef,0x9f,0x4c,0x9e,0x72,0xe6,0x2b,0x73,0x7e,0x30,0xd0,0xc7,0x7d,0xff,0x56, -0x42,0x1f,0x2e,0xb9,0x7c,0xee,0x5f,0xaa,0x5f,0xde,0x9,0xae,0x5f,0xb9,0x7d,0x72, -0x69,0xad,0x64,0xfa,0xb8,0xef,0xdf,0x22,0xe0,0x3f,0x24,0xba,0x3e,0x2a,0xee,0xeb, -0xa3,0xe2,0x39,0xbe,0x3b,0xc1,0xf5,0x2b,0xb7,0xf,0x4b,0x2d,0xe8,0xf0,0xf9,0xde, -0xbf,0x45,0xda,0xc3,0x24,0xe7,0x1f,0xac,0xba,0x7c,0xee,0x5f,0x52,0xed,0x9,0xd7, -0x88,0xfb,0xaf,0x71,0x7c,0xae,0xf7,0x6f,0x91,0xa8,0xeb,0x9b,0xe2,0xf9,0xea,0xd1, -0x7d,0x22,0xf3,0x71,0xdf,0xbf,0x25,0x25,0xf4,0x21,0xb7,0xf,0x25,0xf6,0x8d,0x0, -0x3b,0xff,0xb8,0xef,0xdf,0x9a,0x8f,0x8f,0xe0,0xa8,0xbe,0xd0,0xe7,0x67,0x68,0x8c, -0xf5,0x57,0x7c,0xdf,0x4a,0x11,0x43,0x8e,0x4f,0xd1,0x7d,0x8d,0x4f,0xd7,0xca,0x33, -0xdb,0x2f,0xec,0xf9,0x99,0x14,0xe3,0x9b,0x71,0xb3,0x4f,0xbe,0x64,0xf8,0xcc,0x5f, -0xda,0xf9,0xea,0x39,0xcd,0xf7,0xc7,0xdd,0x16,0x98,0xe9,0xb,0x7b,0x7e,0x26,0xb9, -0xcf,0x28,0x68,0x50,0xa5,0xd6,0xed,0x6a,0x3e,0xb9,0xc4,0xab,0xff,0xbd,0xd8,0xe8, -0xc2,0x99,0xbe,0xb0,0xf5,0x7,0xc9,0x7d,0xec,0x63,0xfa,0xf8,0xf5,0xc9,0x17,0x1b, -0x78,0xf6,0xf5,0x11,0xb6,0xfe,0x20,0x5d,0xfd,0xca,0xf0,0xfd,0xba,0x68,0xf9,0xdc, -0x5b,0x8a,0xa,0xe4,0x78,0xa6,0x6f,0xf6,0xfb,0x21,0x52,0xfb,0x1c,0xed,0x47,0xdc, -0xed,0x47,0x9e,0xae,0xce,0x6e,0x3f,0x67,0x3e,0x10,0x17,0xec,0x1b,0x55,0x67,0x9f, -0x7f,0xb3,0x7c,0x29,0xea,0xa7,0xb3,0x7c,0xca,0x4,0xcf,0xbe,0x7e,0x9d,0x3e,0xde, -0xf5,0x9b,0xda,0xf7,0x16,0xcf,0xa7,0xd7,0xaf,0x94,0xc9,0x94,0xd7,0xff,0x9d,0x4, -0xe6,0xab,0xf4,0xfb,0x5f,0xf9,0x3e,0xf7,0x6f,0xbc,0xc8,0xf3,0xe1,0x90,0xfa,0x8b, -0x44,0xc7,0xf7,0x9f,0xc7,0xbc,0x7c,0xe5,0x1c,0x3f,0x84,0xdb,0xc6,0x7b,0xb9,0xe2, -0xad,0xbf,0xa,0x1a,0x4d,0x7c,0xc7,0x37,0xac,0x3e,0x44,0x61,0xb3,0x87,0x78,0xf9, -0xc5,0xb9,0xfe,0xe0,0xe6,0x6b,0xa8,0x6e,0xf8,0xce,0x17,0xef,0x6b,0x18,0x63,0x6, -0x27,0x5f,0x39,0x7c,0xc6,0xcd,0x69,0xca,0xe3,0x1b,0xe4,0xbb,0x1b,0x32,0x3f,0xa8, -0xe,0x87,0xa,0xe0,0xe4,0x2b,0xd7,0xfb,0xb7,0x5e,0x7a,0x8d,0xa4,0xf7,0xad,0x9b, -0x3b,0x4e,0xfb,0x7d,0xd5,0xb0,0xf6,0x3b,0x41,0x8a,0xe8,0xc8,0x57,0xdc,0xe3,0xfb, -0xd2,0xed,0x9b,0x96,0x6f,0x23,0x73,0x1f,0x9,0x5b,0x7f,0x45,0xc9,0x75,0xe5,0x96, -0x23,0x5f,0x1,0xde,0xf5,0xf1,0x6a,0xe5,0x23,0xcb,0x57,0xcf,0xdc,0x67,0xd4,0xaf, -0xc4,0x6b,0xd8,0xaa,0x29,0xbf,0x2b,0xa3,0x4e,0xa1,0xa0,0xef,0x2f,0xaa,0x9e,0x9d, -0x53,0xe8,0xc8,0x57,0x22,0x2f,0x5f,0xbd,0x5a,0xb1,0xce,0xbf,0x44,0xeb,0xf,0x5c, -0xbe,0x7d,0xaf,0xcf,0xa8,0x5f,0xbd,0x2c,0xd5,0xac,0x5b,0xd9,0x4a,0xb5,0xda,0xa8, -0xd5,0xf4,0xe7,0x7b,0xdc,0xd7,0x87,0xb9,0xa7,0xb5,0x37,0x5f,0xbd,0xaa,0x5d,0x1f, -0xb1,0xf7,0xbf,0xa,0xf0,0x6d,0x70,0xc7,0xf,0xfa,0xd2,0xa4,0x59,0xb7,0x7c,0x95, -0x46,0xd5,0xf0,0x51,0x77,0xff,0x82,0x26,0xdc,0xf1,0xad,0xaa,0xf5,0x2f,0xbb,0xc9, -0xd7,0xbf,0xb8,0x7c,0x97,0x2,0x7c,0xc4,0xf2,0x11,0x8,0x27,0xb8,0x56,0x33,0xe6, -0x67,0x9c,0xfd,0x33,0x46,0xbf,0x2f,0x72,0x7d,0x5a,0xff,0xbc,0x9e,0xdc,0xd7,0xe6, -0x2d,0xb9,0x32,0x2a,0xb2,0x56,0xbe,0x1a,0x7d,0xd4,0xb5,0x7c,0x63,0xf8,0x4,0x17, -0x56,0x9d,0xf3,0x83,0xa1,0xf9,0x2a,0xe1,0xfe,0x57,0xf6,0x7,0x70,0xda,0xcf,0xbe, -0x15,0x37,0xf3,0xd5,0xe4,0xd8,0xf2,0xd1,0xca,0xef,0xb0,0x50,0x3,0xf1,0xf2,0x4b, -0x8a,0xf6,0x3,0x9c,0xf3,0xcf,0xeb,0x1b,0x39,0x7c,0xb0,0xd2,0xa8,0x9,0x35,0x31, -0x9e,0x6f,0x37,0x23,0xdf,0x3e,0xd7,0xa7,0x4c,0xa4,0xd3,0x9a,0xe5,0xab,0x56,0x9b, -0xb3,0x7c,0xbe,0x7c,0x75,0x94,0x7c,0xfd,0x95,0xcb,0x47,0xf9,0x3e,0xe4,0xe8,0xff, -0x5e,0x97,0xd1,0x81,0x50,0x10,0xc3,0xf2,0xd5,0x46,0xfa,0xfd,0xaf,0x62,0xf9,0x5c, -0xbf,0x2b,0x98,0x5f,0xd0,0xfa,0x67,0x38,0xda,0xd5,0x1f,0x4a,0x35,0x9f,0x9f,0x61, -0xfd,0x33,0xa,0x7a,0x3e,0xa0,0xbe,0x0,0x9f,0x68,0x8e,0x32,0xda,0xf8,0x36,0xfc, -0x78,0xc7,0xd8,0x3c,0xd4,0xc8,0x7,0x65,0xe6,0xb,0x7a,0xbe,0x62,0x23,0xa9,0x2f, -0xa0,0x34,0xcd,0xf3,0x39,0xc7,0x5f,0xd5,0x67,0xc,0xba,0xc6,0xf3,0x3d,0xac,0xfd, -0xb8,0xcf,0xa7,0x24,0xcd,0xf7,0xc9,0x7d,0xa,0x3d,0xfe,0x89,0xe8,0xf0,0x89,0x73, -0xf5,0x29,0xa4,0x94,0xc0,0xb7,0x6f,0xfb,0x46,0xc0,0xf2,0xa5,0x7f,0x7e,0x86,0xe3, -0x53,0x60,0x4c,0x1f,0xa6,0xa3,0xd7,0x64,0xcb,0xa7,0xe6,0x2b,0xe6,0x3,0xe9,0x9f, -0x9f,0x49,0xec,0x3b,0xc7,0xaf,0xcb,0xb0,0x50,0xd0,0xea,0xe3,0x48,0xf5,0x11,0xbb, -0xfd,0xec,0x7c,0x5,0xd2,0xef,0x2f,0xc5,0xf1,0xd1,0x48,0xbe,0xc9,0xf7,0xd5,0x80, -0x55,0xab,0x69,0xf3,0xb,0x3,0xd5,0xe7,0xb8,0x3e,0x30,0xb4,0x7c,0xe9,0xf7,0xe7, -0x4a,0xe3,0x53,0x7,0xb8,0x9a,0xb1,0xff,0x95,0x34,0x72,0xf4,0x2f,0xc8,0x7a,0x7f, -0x72,0x6,0xfb,0x9b,0xf1,0x7c,0x20,0x8a,0x4f,0xfa,0xab,0xa,0x6c,0xd6,0x6a,0xdf, -0x35,0x7d,0x76,0xff,0x3c,0xcb,0x97,0xb4,0xfe,0x62,0xfb,0xc4,0x68,0xbe,0xd7,0x61, -0xb3,0xb0,0x7a,0x3d,0x6a,0xbe,0xca,0xd0,0x27,0x44,0xf3,0x9,0x15,0x35,0x1f,0x54, -0xe3,0xe5,0x97,0x2c,0x7c,0x84,0x46,0x3c,0xbe,0xc9,0x7c,0x49,0xeb,0xa7,0xcc,0x37, -0xfd,0x27,0x91,0xc6,0x5f,0xa9,0x5b,0xa9,0xd6,0x66,0xf9,0x52,0x3d,0x9f,0x1c,0x6b, -0x7c,0x23,0xde,0xfd,0xaf,0x26,0x5d,0x35,0x60,0x9,0x7a,0xff,0x87,0xa3,0xd7,0xaf, -0xe6,0xe6,0x9b,0xf2,0xf6,0x97,0x32,0xf3,0xd5,0x29,0x85,0xb0,0xb0,0xb,0x66,0xd4, -0xaf,0xd8,0xdf,0x4a,0xb8,0xfe,0x6a,0x86,0xef,0xdc,0xeb,0xc3,0xd4,0xca,0x57,0xc7, -0x74,0xf8,0x9,0xde,0x1,0xfe,0xfa,0x90,0xc8,0xdd,0xff,0x25,0xd9,0xfa,0xab,0x59, -0xc7,0x57,0x9,0x1b,0x7f,0x87,0x1f,0x2b,0x3c,0xdf,0x8f,0x79,0xf9,0x25,0xee,0xfa, -0xab,0xed,0xc,0x7c,0xc7,0x3f,0x51,0x44,0x8e,0xef,0xad,0x0,0x5f,0x9c,0xf5,0x25, -0x56,0x9a,0x4a,0xe9,0xdb,0xb7,0xf3,0x55,0x8f,0x5b,0xbf,0xb2,0x7d,0xb1,0xd6,0x5f, -0xc9,0x42,0x34,0x1f,0xe,0xcf,0x57,0x8a,0x6c,0xe7,0x2b,0xdb,0xc7,0xbf,0x3e,0x62, -0xad,0xbf,0x1a,0xd3,0x64,0xbe,0x73,0xbc,0xbf,0xf7,0xa8,0x50,0xd8,0x64,0x3e,0x62, -0xe7,0xab,0xa7,0x43,0xf7,0xd7,0x8b,0xb9,0xfe,0x6a,0x8f,0xfd,0x8b,0x35,0x47,0x6b, -0xdd,0x2e,0x6a,0xfb,0xe7,0xc8,0x41,0xbe,0xc9,0xf7,0x9b,0x2d,0x35,0xbf,0x88,0xcc, -0x67,0x5f,0x1f,0x33,0xf6,0xd7,0x8b,0xb9,0xfe,0xca,0x62,0x15,0x7c,0x7d,0xac,0xb6, -0xff,0xd0,0x58,0x8,0xcc,0x57,0xf5,0x96,0x9d,0xaf,0x24,0x47,0xff,0x32,0xe3,0xf9, -0xe4,0x78,0xeb,0xaf,0xac,0xcb,0x83,0x58,0x2b,0xa5,0xda,0xcc,0xa1,0xed,0xdf,0xa4, -0x3d,0xbd,0x1a,0x30,0xfe,0xd6,0x45,0x35,0x5f,0x19,0xfb,0x8b,0x4a,0x8e,0xfe,0x79, -0xe6,0xfe,0x7a,0xb1,0xd6,0x5f,0x91,0x95,0xe8,0x1f,0xaf,0x6f,0x4f,0xcd,0x57,0xae, -0xf5,0x57,0x91,0xf2,0x55,0xbc,0xf1,0x2d,0x4d,0xfb,0x29,0x6a,0x7e,0x41,0xb1,0xf3, -0xb,0x69,0xf,0x4,0x3a,0xff,0xf3,0x4f,0xf5,0xb5,0x92,0xf9,0x80,0x10,0xc7,0xb7, -0x1f,0xed,0xfa,0xe5,0xe4,0xab,0x66,0xab,0x99,0x24,0x5f,0x11,0xb0,0x16,0x27,0xbf, -0x1c,0xfa,0xfa,0x3f,0xec,0x2c,0x1,0x29,0xcc,0x27,0xfb,0xf2,0xd5,0xfe,0x5e,0xc3, -0xc8,0x57,0xa,0xe,0xf0,0xed,0xf1,0xf7,0xbf,0x8a,0xe5,0x93,0x23,0xfa,0x70,0x70, -0xbe,0xd2,0xf7,0x9f,0x54,0xcf,0x2a,0xc1,0x18,0x3f,0xae,0x14,0x8b,0x61,0xf7,0xe7, -0x44,0x7f,0x10,0x28,0xb2,0x6f,0x2a,0x44,0xf3,0xa1,0xe0,0x7c,0x65,0xec,0x8f,0x59, -0xd9,0x11,0xcc,0xf1,0xd7,0x78,0xae,0x27,0x28,0x5f,0x91,0xb6,0x12,0xc7,0xe7,0xcf, -0x7,0x7c,0xdf,0x38,0x78,0xfc,0x7d,0xa2,0xef,0x2f,0x55,0x69,0xf9,0x7c,0x9b,0xdc, -0xfd,0xeb,0x40,0x2c,0x9f,0x3f,0x5f,0x5,0xb4,0x9f,0x30,0xcb,0xd7,0xf4,0xf9,0x9a, -0x3c,0x9f,0x4,0x70,0xba,0x7c,0xcf,0xf7,0x85,0xac,0x1f,0x1f,0xe9,0xfb,0x5f,0xbd, -0x52,0x33,0x7d,0x9f,0x5f,0x66,0x3e,0xee,0xfe,0x89,0x8b,0xf7,0xd,0xf4,0xfd,0xaf, -0x60,0xc3,0xbc,0x3e,0xae,0x5a,0xed,0xc7,0xdd,0xbf,0xf8,0x64,0x3e,0x3e,0x7d,0x7f, -0x6,0x54,0x72,0xac,0x44,0xfb,0xf5,0xdd,0x4a,0xa1,0x0,0x59,0xff,0x2,0xa0,0xb9, -0x3e,0x1b,0x2b,0xf6,0xf1,0x9d,0xcb,0xfd,0x9b,0xcb,0x67,0xf5,0xcf,0xb2,0x3e,0xbf, -0x0,0x1d,0x2b,0xf9,0x1a,0xd,0x35,0xbf,0x74,0x6c,0xdf,0x8f,0xca,0x5e,0xdf,0xfe, -0x5c,0xee,0x7f,0x5d,0x3e,0xd7,0xf8,0x46,0x46,0x13,0xcc,0xf1,0x19,0x7f,0x1d,0x8a, -0xbe,0xf6,0x9b,0x4b,0xfd,0xc0,0xed,0x73,0xe5,0x3,0x32,0x72,0xd6,0x3e,0xaa,0x8, -0xd7,0x6a,0xf6,0xfe,0xa2,0xac,0x7f,0xc6,0xd3,0x62,0x31,0xb3,0xfa,0x8b,0xf8,0xe1, -0x5a,0x78,0xff,0x37,0x70,0xad,0xbf,0x72,0xf9,0xee,0xde,0xad,0x15,0x56,0xbd,0xfb, -0x8b,0x66,0x5c,0xbf,0x12,0x1b,0xd6,0x4e,0x2a,0x11,0xda,0x8f,0xbe,0xe4,0xf4,0x9, -0xa2,0x9a,0xf,0x2a,0xf3,0xad,0x5f,0x81,0x4a,0x17,0x45,0x3f,0xff,0xe8,0x4b,0xce, -0xf3,0xaf,0xda,0x50,0x7d,0x85,0xd8,0xbe,0x58,0xf5,0x53,0x60,0xed,0xb7,0x3a,0xeb, -0xfa,0xd5,0x7d,0x3b,0xce,0xeb,0x57,0xf7,0xc1,0xd8,0xf9,0x2a,0x96,0x4f,0x82,0x38, -0x5a,0xff,0x67,0x3c,0x3f,0x28,0x3a,0xfb,0xbf,0xf,0xef,0x56,0x5,0xa3,0xff,0xb, -0xda,0x9f,0x1,0xa5,0xde,0xff,0x2a,0xb2,0x8f,0xb3,0xfe,0x4a,0xb4,0xf2,0x95,0xfe, -0xfc,0xf9,0xe0,0xae,0x95,0xaf,0x80,0xe9,0x1b,0xf2,0xe7,0x3f,0x62,0xac,0xbf,0x7a, -0x12,0xd5,0xc7,0x59,0xdf,0x4,0xac,0x7c,0xa5,0xef,0x8f,0x54,0x69,0x88,0x66,0x3e, -0x30,0x96,0xfe,0x7a,0xdf,0xbf,0x65,0xfb,0xce,0xe3,0xf8,0x66,0x5c,0x1f,0x21,0x3e, -0x3b,0xbf,0x78,0x7d,0xb7,0x4c,0xdf,0x1,0x7f,0xfe,0x2d,0xc6,0xf1,0xc5,0x68,0x46, -0xff,0xc2,0x7c,0x24,0x64,0xfd,0xd5,0x13,0x23,0x9f,0x8a,0x96,0xf,0x64,0xe7,0x93, -0xd7,0x4a,0xa9,0xdb,0x6f,0xa4,0xb7,0xdf,0x2b,0xf7,0x59,0xbe,0xb2,0xce,0xbf,0x6, -0xff,0xf8,0xc6,0x5d,0x7f,0x75,0xa8,0x9e,0xea,0xeb,0x9a,0x6f,0x5a,0x46,0x74,0x5c, -0xd2,0x7c,0x9b,0x44,0xbb,0x21,0x8e,0xe8,0x1b,0xe8,0xfb,0x5f,0x41,0xb3,0xfd,0xe4, -0xab,0x56,0xfb,0x6d,0xf0,0xaf,0x8f,0xb8,0xeb,0xaf,0xfa,0xb4,0xac,0xa,0x81,0xb6, -0xc1,0xb2,0x36,0xd9,0xa7,0xf9,0x6a,0x53,0xed,0x28,0x84,0x5e,0xbf,0xd5,0x46,0xdf, -0x9c,0x1f,0x54,0x7a,0x46,0x3e,0x30,0x8f,0xaf,0x62,0xf9,0x82,0xfa,0x97,0x98,0xeb, -0xf,0xfa,0xa4,0xf5,0x4d,0xd3,0x77,0xf0,0x97,0x55,0xc3,0x77,0xfe,0xfb,0x3f,0xe1, -0xf4,0x7f,0xce,0xfb,0x96,0xe3,0xf7,0x3e,0x45,0xc6,0xfc,0xa0,0xde,0xff,0x1,0xd8, -0xf0,0xfb,0x2,0xf6,0xe7,0x8a,0xb9,0x7e,0xa3,0x4f,0x1f,0x7f,0x6c,0xfa,0xd0,0x9f, -0x37,0xc,0x1f,0x39,0xfd,0x23,0x4f,0x7e,0xf6,0xf9,0xde,0xff,0xad,0xea,0xb3,0xf7, -0x97,0xe2,0xf8,0x82,0xc6,0xb7,0x98,0xeb,0x5f,0xfa,0xb4,0xd5,0x7b,0x60,0xfa,0x9a, -0xef,0x96,0xd,0x1f,0xba,0x53,0x8,0xf5,0x29,0xc7,0xef,0xf7,0xb1,0xd3,0xc7,0xfa, -0x67,0x35,0x5f,0xcd,0xc1,0xc7,0xda,0xaf,0xc9,0xda,0xf,0xdd,0xd1,0xdb,0x6f,0x1a, -0x54,0xbf,0x52,0x7a,0x1f,0xf4,0x71,0x61,0xb5,0x13,0x2f,0x5f,0x25,0xda,0xff,0x2a, -0xcc,0x17,0x38,0xbf,0xa5,0xec,0x36,0x5e,0xc6,0xb1,0xeb,0x43,0x34,0xeb,0xf6,0xb, -0xf6,0xf5,0x72,0xee,0xdb,0x69,0x3c,0xc4,0xb1,0xeb,0x57,0x34,0xc9,0xfa,0xab,0x43, -0x68,0xfa,0xa6,0xcf,0x33,0xdf,0xe6,0xce,0x2c,0x1f,0xd9,0x69,0xf4,0xcd,0xf9,0xc1, -0xc0,0x7c,0x15,0xb0,0xbe,0x3d,0xc5,0xfa,0x2b,0xdf,0xf8,0x16,0xec,0x73,0xd4,0xaf, -0xbc,0xf9,0x2a,0xf8,0xfd,0x5b,0x34,0xe5,0xfa,0xab,0xe8,0x3e,0xed,0x8b,0x1,0xf9, -0x6a,0x12,0x5c,0xdf,0xa0,0x19,0xac,0xbf,0x8a,0xe8,0xb,0xce,0x57,0xb6,0x2f,0x68, -0x7f,0x2e,0xba,0x58,0x1f,0xf6,0xe4,0x2b,0xe6,0x1b,0xe6,0xc3,0x37,0xd2,0x7d,0xaf, -0x8,0x22,0xcb,0x57,0x33,0x8f,0xef,0x62,0x7d,0x3,0x64,0xe4,0x2b,0x56,0xbf,0x42, -0xa1,0xcf,0xf,0x26,0xf3,0xa9,0xe3,0x98,0xb9,0x66,0x77,0x7d,0xc5,0xdc,0x51,0x4f, -0x1d,0x8b,0xa,0x21,0xbe,0x6a,0xe3,0xd3,0x8a,0x99,0xaf,0xf4,0xfd,0xf,0x20,0x7b, -0x7f,0x8a,0x9d,0xf,0x2,0xde,0x1f,0xbf,0x10,0x9f,0x9a,0xaf,0xba,0xd,0x33,0x5f, -0xe9,0xef,0x1f,0x84,0x2d,0xcb,0x27,0x6,0xd6,0xaf,0x16,0xe9,0x7b,0x5f,0xf3,0x39, -0xf2,0x55,0xd3,0xf2,0x9,0x33,0xc6,0xb7,0xf4,0xcf,0xa7,0xf0,0x8a,0x62,0xbe,0x7c, -0xd5,0x6d,0xba,0xf2,0xd5,0xeb,0x66,0xfd,0x6f,0x7a,0xb9,0x10,0xe6,0x4b,0xf9,0xfc, -0x5b,0x64,0x5f,0xef,0x83,0x6e,0xb3,0xb0,0xa,0xe3,0xe5,0xab,0x5,0xfa,0x76,0x1b, -0x2f,0xce,0xac,0xbf,0x64,0xd7,0x7e,0xb1,0xcf,0x3f,0x35,0x5f,0x69,0x3e,0x10,0xdb, -0x97,0xac,0x7e,0x1a,0xdf,0xb7,0xd3,0x78,0x2b,0xfe,0xfa,0xf6,0xb9,0xf9,0x88,0xec, -0xcf,0x57,0x9f,0x56,0x5,0xfd,0xf9,0x1e,0x5,0xc5,0xc9,0x57,0xd9,0xd6,0x9f,0x99, -0x6f,0xea,0x9d,0x3f,0x72,0xe6,0xab,0xa1,0x9e,0xaf,0xd6,0x68,0xa4,0x7c,0x95,0x7a, -0xfd,0x15,0xd7,0x77,0xee,0x9b,0xdf,0x72,0xe4,0xab,0x3,0x3d,0x1f,0x3c,0xa6,0x91, -0xf2,0x55,0xea,0xf5,0x57,0x5c,0x5f,0xd8,0xf3,0x65,0x4f,0xf4,0xfd,0x9b,0x2a,0x3f, -0xda,0x2e,0x9e,0xf,0x0,0x0,0x12,0x4f,0x49,0x44,0x41,0x54,0xa3,0x91,0xf2,0x55, -0xc2,0xfd,0xaf,0x66,0xf9,0x42,0xf6,0x6f,0x37,0x7d,0x6c,0xfc,0xb5,0xf3,0x15,0xa, -0xf0,0x35,0xc0,0x42,0xdb,0x6f,0xa4,0xfb,0x5e,0x31,0xcf,0x3f,0x35,0x5f,0x6d,0x31, -0x1f,0xff,0xf8,0xc6,0xdf,0xff,0x6a,0xf,0x1f,0x9a,0x3e,0xf9,0x7e,0xd9,0xf4,0x15, -0x37,0xa3,0xfa,0xcc,0x7c,0xc5,0xde,0x4f,0x77,0xd5,0x6a,0x3f,0xc8,0xbf,0x3e,0xe2, -0xef,0x7f,0xd5,0x3a,0xed,0x9b,0x3e,0xd4,0x34,0xa6,0x17,0x55,0x50,0x6d,0x86,0x6f, -0x7c,0x19,0x16,0xa,0x80,0xf5,0x2f,0xce,0x7c,0xc5,0x7c,0x80,0xd7,0xbf,0x24,0xd9, -0xff,0x6a,0xed,0x98,0xf9,0x60,0xd7,0xf4,0x29,0xd8,0xf2,0x1d,0xf1,0xcf,0x3f,0x78, -0x1f,0xd5,0x6a,0xdb,0x1c,0x9f,0x75,0x7d,0x6c,0xf0,0xfa,0xe7,0x24,0xfb,0x5f,0x9, -0xd8,0xf2,0x61,0xe6,0xa3,0x96,0x6f,0x97,0x9f,0x9f,0xe1,0x9b,0xaa,0xcf,0xde,0x5f, -0x94,0xe3,0xe3,0x8e,0x6f,0x49,0xf6,0xbf,0x72,0xfa,0xb6,0x99,0xcf,0x3a,0xff,0xd6, -0xf9,0x3e,0xb0,0x66,0x3d,0x3f,0xa8,0xe7,0x2b,0x76,0x7d,0x84,0xcd,0xf,0xd2,0x64, -0xfb,0x5f,0x39,0x7c,0xd3,0x5b,0xbe,0xf6,0x5b,0xe7,0xd5,0xaf,0x74,0x9f,0xfb,0xf9, -0xc1,0x68,0xf9,0x2a,0xc9,0xf8,0xe6,0xf0,0x51,0xff,0xf1,0xd,0x6e,0xbf,0x24,0xf9, -0x85,0xb4,0xe3,0xef,0xaf,0xb2,0x66,0xfb,0x80,0xff,0xfa,0xd8,0xcd,0xd6,0x17,0xf5, -0xfd,0x74,0xce,0xfe,0x5,0xdb,0xfd,0x8b,0xe8,0xeb,0x5f,0x8e,0x12,0xfb,0x78,0xd7, -0x6f,0x12,0x9f,0xb3,0x7f,0x16,0xb8,0xfd,0x33,0xe7,0xfd,0x24,0x70,0xd,0x9,0x46, -0xff,0x17,0x54,0xbf,0x82,0xbc,0xfe,0x2f,0x89,0x2f,0xc2,0xfd,0xb9,0xbf,0x7f,0x86, -0x81,0xf5,0x2b,0x76,0x7f,0xde,0xe1,0x8d,0x1f,0x4,0xbc,0x4e,0xe7,0xe1,0xf3,0xb5, -0x1f,0xb2,0xf2,0x55,0xcf,0x5d,0x1f,0x42,0x1d,0xd3,0xf7,0x88,0x37,0xfe,0x92,0x36, -0x9c,0x47,0xfb,0xfd,0x3e,0x24,0xbf,0x78,0x7d,0x8f,0xd8,0xf1,0xe5,0xe5,0x97,0x84, -0xfb,0x5f,0xcd,0xf2,0x9d,0xa,0xd1,0x7d,0x95,0x30,0x9f,0x34,0x1f,0x5f,0x58,0xbe, -0xd2,0x7d,0xaf,0x54,0xad,0xfa,0x95,0xe5,0xe3,0x1d,0xdf,0xc5,0xfb,0x6,0xfa,0xf5, -0xc1,0xe6,0x8f,0xe4,0xab,0x13,0x18,0x96,0xaf,0x12,0xee,0x7f,0x15,0xc9,0xb7,0x55, -0x77,0x3c,0xf8,0x3d,0xfe,0x4a,0xc5,0x35,0x3f,0x68,0xcd,0x6f,0x3d,0x81,0x61,0xfd, -0x4b,0xf6,0xf7,0x6f,0x47,0x56,0xff,0x57,0x7d,0xbe,0xe5,0xe8,0x5f,0x6a,0xd,0xfe, -0xfc,0xe0,0xef,0x59,0xfd,0x5,0x66,0xb8,0xff,0x55,0x88,0xcf,0x1a,0xdf,0x8,0x7e, -0x69,0x87,0xe3,0x33,0xf3,0x95,0x3d,0x3f,0x38,0x97,0xfd,0xaf,0x82,0x7d,0x56,0x3e, -0x20,0xd4,0xe9,0x3,0xb5,0xa6,0xd3,0xe7,0x98,0x1f,0x84,0xf3,0xa8,0x5f,0x85,0xf8, -0xac,0xf5,0x57,0x47,0xaf,0xb9,0x7d,0x9e,0xf5,0xed,0x73,0xad,0x5f,0x45,0x69,0x3f, -0xfc,0x86,0xdb,0x17,0xfb,0xf9,0xbc,0xb9,0xf8,0x76,0x33,0xf5,0x65,0x5f,0xbf,0xb7, -0xf3,0x55,0xf5,0x5e,0x2b,0x96,0x2f,0xcb,0xfd,0xaf,0x66,0xd4,0x87,0xf4,0xf5,0x7, -0xae,0xfe,0xf,0xde,0xaf,0x1a,0xf3,0x83,0xc1,0xbe,0x2c,0xf7,0xbf,0xa,0xf7,0x71, -0xd6,0x5f,0x59,0xf9,0x2a,0xd8,0xe7,0xda,0xff,0xea,0xee,0xcd,0xcb,0x86,0x6f,0x3a, -0x8f,0xf9,0x19,0xbf,0xcf,0xca,0x57,0xc1,0x3e,0xd7,0xfe,0x57,0xd5,0xde,0xc4,0xf0, -0x9d,0x2f,0xc6,0x67,0x8d,0xbf,0xc1,0x3e,0xd7,0xfe,0x57,0x95,0xd1,0x64,0x7e,0xc7, -0x97,0xdc,0x49,0xeb,0x7b,0xa9,0x32,0x22,0xf3,0xf3,0xd1,0x9f,0xa6,0xf7,0x49,0x37, -0x99,0x6f,0xe,0xf3,0xbf,0x62,0x5a,0xdf,0xab,0x15,0xf8,0x11,0xf3,0xd5,0x17,0x71, -0xfd,0xc6,0xf7,0xb1,0xf3,0x2f,0xdd,0xfa,0x3,0xd7,0xf3,0x47,0xec,0x67,0x4c,0xef, -0xd2,0xd4,0x3e,0xf5,0xfa,0x48,0xb1,0xff,0x15,0xf0,0xfd,0xc,0xed,0xf9,0xad,0x90, -0xfa,0x41,0x4c,0x5f,0x55,0xeb,0x5f,0xd2,0xee,0x3f,0xa4,0xf,0xe0,0xcc,0x21,0x17, -0x43,0xeb,0x2f,0xb3,0x7c,0x9e,0xfd,0xdb,0xab,0x5a,0xff,0x9c,0xf5,0xfe,0x57,0xc1, -0xcf,0xf,0xc6,0xf5,0xa5,0xde,0xff,0x8a,0xce,0xb9,0xfd,0xd8,0xb7,0x4a,0xb5,0xbf, -0x59,0x86,0xe7,0x1f,0xf7,0xb3,0x9b,0x81,0x8f,0x7b,0xfd,0x66,0xe4,0x4b,0xb1,0xff, -0x55,0xf0,0x67,0xd6,0xfa,0xd,0xfe,0xfb,0x7,0xa9,0xb9,0x8e,0xd7,0xfb,0xad,0x92, -0xae,0xbf,0x4a,0xee,0xd3,0xdf,0x5f,0xe6,0xf7,0x99,0xeb,0xc8,0x39,0xbe,0xe4,0xfb, -0x27,0x26,0xf2,0x11,0x10,0xe0,0xbb,0x15,0xe4,0xdb,0x58,0xac,0xef,0x57,0x1,0xbe, -0xa0,0xe3,0xbb,0x88,0xf5,0x1b,0xe,0x9f,0xf2,0x71,0xce,0x7d,0xbd,0x98,0xd7,0xc7, -0x82,0x7d,0x38,0xe0,0xfa,0xa0,0x4b,0xf4,0xad,0x7f,0x6f,0x2c,0xcb,0xfd,0xe2,0x96, -0xb6,0xfe,0x0,0x71,0x7d,0x64,0xa9,0xbe,0x9a,0x4,0xab,0xd5,0xdb,0xa8,0xaa,0xad, -0x7f,0x19,0x1c,0xe5,0xd0,0x7,0x2a,0x15,0xf1,0xf6,0x4,0x7,0xaf,0xcf,0xa1,0x57, -0x97,0xe8,0x23,0x18,0x54,0x20,0xbd,0x33,0xa1,0x20,0xde,0xf8,0x86,0x16,0xb4,0xbe, -0x49,0xf5,0xbd,0xe,0xc9,0xe4,0x32,0x35,0xe6,0x7,0x4b,0x39,0xf4,0x9,0x15,0x32, -0x21,0x39,0x6e,0xbf,0x4a,0xa5,0x35,0x21,0x58,0xc,0xf5,0x61,0xf9,0x2b,0x45,0x7a, -0xa9,0xfd,0xca,0xda,0x83,0x31,0xad,0x6f,0x6e,0xa6,0x7a,0x7e,0x35,0xa6,0x4f,0xbd, -0x7e,0x6b,0x13,0x5a,0x9d,0xe1,0xc3,0xa,0xa2,0x6b,0x0,0xee,0xec,0xc0,0xb5,0xba, -0xb6,0xb5,0xf0,0xa2,0x7c,0xb4,0x76,0x32,0x96,0xc7,0xb7,0xe9,0x96,0xbe,0xbf,0xe8, -0x61,0x88,0xf,0x6b,0xbe,0xde,0xe,0x68,0xd5,0x16,0xea,0x13,0x8c,0xa,0x96,0x91, -0xaf,0x60,0x4,0x1f,0xae,0xe1,0x5a,0xaa,0xfd,0xaf,0xe2,0xf9,0x44,0xeb,0x96,0x2f, -0x30,0x5f,0xe9,0xe7,0xdf,0xd3,0xaa,0xaf,0x5d,0x71,0xfa,0x92,0xae,0xbf,0x4a,0x91, -0xaf,0xf6,0x42,0xdb,0xef,0x12,0x80,0xdd,0x7,0x0,0x55,0x51,0x2d,0xd1,0xfe,0x57, -0x73,0xcb,0x2f,0xcc,0x57,0x55,0x7d,0x22,0x80,0x55,0x58,0x4b,0xb2,0xff,0x55,0x16, -0x3e,0x25,0xd4,0x57,0xd3,0x7d,0x3f,0xba,0xe,0x6a,0x49,0xf6,0xbf,0xca,0x22,0x5f, -0xf1,0x7c,0x97,0x54,0x18,0xd2,0xfb,0x97,0xba,0x36,0xb5,0x4,0x85,0x8a,0x58,0x4b, -0xb2,0xff,0x55,0x8a,0x7c,0xa5,0xa8,0xf9,0x6a,0x2b,0x28,0x5f,0xad,0x9d,0x92,0x1a, -0x94,0xff,0xa9,0xda,0x3f,0xaf,0xb5,0x5f,0xa9,0x8a,0x63,0x5a,0x59,0xdd,0x4c,0xb2, -0xff,0x55,0x8a,0x7c,0x75,0x4f,0x42,0xd5,0x6a,0x50,0xbe,0x5a,0x3b,0x56,0x6a,0xfd, -0xab,0xdf,0xf4,0x7f,0xab,0xa4,0xef,0x1f,0x8c,0x9f,0xaf,0xde,0x97,0x26,0x58,0x8, -0x1a,0x3f,0xd6,0xd4,0xe3,0xdb,0xfa,0xfc,0x63,0x9e,0xef,0x5e,0xb6,0xbe,0x75,0x73, -0x65,0xaf,0x2f,0x5f,0x29,0x93,0x9,0xfd,0x6e,0x98,0xaf,0x3e,0xea,0x51,0x72,0xc9, -0xe7,0x4b,0xf4,0xfe,0xc1,0xe0,0xf,0xdb,0xc6,0xdd,0x97,0xaf,0x14,0x35,0x5f,0x5d, -0xf,0xca,0x57,0xea,0xf5,0xf1,0x66,0x6b,0xd4,0xe3,0x1f,0x8a,0x6c,0xc7,0x37,0x1a, -0x90,0xaf,0x14,0x35,0x5f,0x5,0xce,0x6f,0x55,0x31,0xbd,0xd7,0xf3,0xfa,0xc6,0xd7, -0x93,0xad,0xbf,0x4a,0xe2,0x33,0xf2,0x55,0xa0,0xaf,0xa6,0x1e,0x5f,0xd5,0xa7,0x25, -0x2c,0x7b,0x78,0x86,0x7,0xc9,0xd7,0xf,0xc5,0xf4,0xa9,0xd7,0x6f,0x5d,0xcd,0x57, -0x81,0xbe,0xba,0xea,0x1b,0xa9,0x3e,0xb5,0x7,0xec,0x58,0xbf,0x9,0x86,0xb,0xf2, -0xe9,0xf9,0x4a,0x91,0xa8,0xde,0xff,0x9d,0xe0,0x80,0xeb,0x63,0x72,0x55,0xf3,0xe1, -0x47,0xec,0xf7,0x4e,0xe7,0xe2,0x2b,0xec,0xb4,0x67,0xe4,0x2b,0x7d,0xff,0x2b,0xf9, -0x7e,0xc9,0xdc,0x5f,0xb4,0x88,0xdc,0x23,0x1c,0xf4,0xf8,0x6e,0x67,0xea,0x23,0xf8, -0x21,0x10,0xc2,0xf3,0x95,0xbe,0xbf,0x40,0x95,0x3d,0x7f,0x24,0xa1,0xa1,0x3b,0x61, -0x79,0x7c,0xed,0x93,0x4c,0x7d,0x8a,0xf2,0x8e,0xb1,0x61,0x77,0x70,0xbe,0x32,0xf6, -0x97,0xea,0x9a,0xbe,0x11,0x3e,0x8,0x6f,0x3f,0x9a,0xad,0x8f,0xce,0xf2,0x29,0x86, -0x4f,0x2e,0x9b,0x3e,0xda,0xf0,0xf8,0x36,0x69,0xd9,0xf0,0xb5,0xb,0xda,0xfa,0xa6, -0xac,0x7d,0x1f,0xcc,0xf2,0xe9,0xfb,0x5f,0x55,0x30,0x70,0xfb,0xb4,0x19,0x85,0x82, -0xee,0x7b,0xc0,0x7c,0xc6,0xfe,0x57,0x52,0xa6,0xfd,0x9f,0x72,0x38,0xcb,0x87,0x8d, -0xfd,0xaf,0x28,0x30,0xd7,0x5f,0x51,0x63,0x93,0x98,0xa9,0xfe,0x7a,0x58,0x6d,0xb9, -0xce,0x9f,0xa,0xe,0xdf,0x9,0x38,0xc9,0xd6,0xa7,0xfc,0x2c,0xc8,0x47,0x8a,0x5b, -0xda,0xfe,0xa2,0xc8,0xd8,0x5f,0xca,0xf4,0x61,0x85,0x18,0xd7,0xef,0x54,0x13,0x69, -0x9,0xb,0x3e,0x2c,0x39,0x8e,0x6f,0xd6,0xe3,0x5b,0x98,0xf,0xe9,0xf7,0xbf,0x3, -0xc3,0xd7,0x65,0xbe,0xf3,0x55,0xdb,0xa7,0xff,0xdb,0xf6,0x26,0x6b,0xbf,0x83,0xec, -0x7d,0x4,0x3f,0xe6,0xf4,0x2f,0xc6,0x97,0x1c,0xf9,0xa,0xa0,0xa6,0x68,0xf8,0x8, -0x42,0x5e,0xdf,0x80,0xf9,0xae,0xcf,0x21,0x1f,0x70,0xfb,0x67,0xd3,0x47,0x8b,0x96, -0x4f,0xbe,0x6f,0x5e,0xbf,0xb4,0xe8,0xf3,0xc9,0xa6,0x6f,0x3a,0x97,0xfa,0xb,0xd, -0xba,0xff,0x20,0x97,0x69,0xd8,0xfa,0x2b,0x6a,0xbf,0x5a,0xc7,0x9c,0x17,0x3c,0x5d, -0xb0,0x8f,0xd0,0xe0,0xfd,0xf,0x78,0xed,0x7,0x17,0xed,0xc3,0xd1,0x7c,0x63,0xc7, -0xf5,0x9b,0x7d,0xfd,0x34,0xd8,0x17,0x92,0xaf,0x5c,0xbe,0x3d,0x47,0xff,0xb7,0x50, -0x9f,0x91,0xaf,0xf8,0xf3,0x83,0x53,0x6b,0xfa,0x77,0xbb,0xe8,0xf2,0x91,0x45,0xf9, -0xcc,0xf1,0x43,0x9f,0x1f,0x6c,0xcb,0xe6,0xf3,0xf1,0x1c,0xdf,0xdb,0x65,0xd3,0x37, -0xb9,0x9e,0xd1,0xfb,0x7,0x63,0xf9,0x88,0xbe,0xff,0x41,0x55,0x2c,0x7,0xd5,0x77, -0xff,0x94,0x8d,0xbf,0xd2,0x41,0x46,0xef,0x1f,0x4c,0xe0,0xab,0xf4,0xc5,0x20,0xdf, -0x6,0xf3,0xf5,0x87,0xcb,0x38,0xbe,0x8a,0xb1,0xff,0x95,0x12,0xe8,0xdb,0x5c,0xb2, -0x4f,0x99,0xe1,0x3,0xce,0x7c,0x9a,0xea,0xfd,0x83,0x89,0x7c,0xd8,0xd8,0xff,0xa, -0x8b,0xb3,0xe6,0x17,0x2c,0x5f,0x7d,0x41,0xfd,0x4b,0x71,0xb,0xb2,0xfa,0x15,0x80, -0x28,0xd8,0x87,0xdd,0xbe,0x8c,0xd7,0x1f,0x4,0xfb,0x50,0xb5,0xc3,0xea,0x57,0x0, -0xfe,0x6d,0x29,0xc8,0x67,0x15,0x30,0xe1,0x41,0xca,0xf7,0xf,0xc6,0xf4,0x4d,0xb0, -0xbd,0xbf,0x28,0x12,0x3,0xdb,0x8f,0x10,0x47,0x7d,0x23,0xf5,0xfa,0x97,0x38,0x3e, -0x6a,0xef,0x2f,0xea,0xed,0x9f,0x9d,0xeb,0x87,0x84,0x7f,0x6f,0xd7,0x87,0x16,0xe9, -0xbb,0x4c,0xbd,0xfb,0x8b,0xf2,0x7d,0xef,0x6d,0xb2,0x6,0xcc,0x60,0xfd,0x55,0xac, -0x7c,0x55,0x89,0xb4,0xfe,0x6a,0x6f,0xd3,0xfe,0xfd,0x45,0xb6,0x1f,0xc1,0x85,0x48, -0xeb,0xff,0xf6,0xa,0xcb,0xf1,0xd1,0x2a,0x8c,0xe4,0x7b,0xb0,0xe1,0xf2,0x2d,0xec, -0xfa,0xa5,0x7a,0xff,0x77,0x12,0xf0,0xfc,0x20,0xb2,0xde,0xaf,0xbb,0x7b,0xe8,0xf2, -0x2d,0xaa,0xff,0x73,0xe7,0x2b,0xf3,0xfe,0x48,0x2e,0x15,0x37,0xd,0xdf,0xd0,0xda, -0xdf,0x7b,0x8a,0x5d,0xbe,0x45,0x8d,0x1f,0xee,0x7c,0xd5,0x4,0xac,0x7e,0x55,0x33, -0x7c,0x7,0x81,0xfb,0x4b,0x6d,0x2c,0x23,0x5f,0xb1,0xfb,0xf3,0x11,0x36,0x7d,0x28, -0xd3,0xfd,0xaf,0x52,0xe4,0x17,0x63,0xff,0x2b,0x6a,0xd5,0x87,0xb0,0xe9,0xd3,0xf6, -0x67,0x90,0xaf,0xee,0x60,0xa,0x37,0x73,0xe0,0x23,0x56,0x7d,0x6d,0x9f,0xf9,0xe4, -0xf2,0x11,0x1e,0x3d,0x3c,0xa5,0x9d,0xda,0x32,0x7d,0x18,0x79,0xea,0x57,0xac,0xfd, -0xb4,0xe7,0x7,0xf1,0xe8,0x9d,0xe3,0xd6,0xa3,0xe5,0xf8,0x88,0x39,0x3f,0x8,0xdd, -0xf5,0x2b,0xcb,0xa7,0xed,0xcf,0xa0,0xfa,0x70,0x17,0xe2,0xe5,0xf8,0xcc,0xf9,0xc1, -0x5d,0x77,0xfd,0xca,0xba,0x3e,0xb4,0xfd,0x19,0xf0,0xe8,0x83,0xe5,0xf9,0x26,0x76, -0xfd,0x0,0x20,0xd6,0xbf,0x10,0xd6,0xbf,0xe8,0xcf,0x6f,0xc9,0x57,0x3f,0xc0,0x43, -0x88,0x96,0xe4,0xb3,0xeb,0x2f,0xce,0xfa,0xd5,0xa6,0xc3,0x87,0x95,0x9f,0xa9,0x3e, -0xc7,0x2b,0x17,0x17,0x5b,0xbf,0x9a,0xb9,0xbf,0xa8,0xe6,0xeb,0x42,0xb0,0x1c,0x5f, -0x58,0xfd,0xca,0x6a,0xbf,0xc7,0xaa,0x4f,0x5c,0x92,0xf,0x47,0xf0,0xed,0xe0,0x16, -0x5c,0xf5,0x7d,0xb7,0xa5,0xd7,0xaf,0xb2,0xdd,0xff,0x2a,0x55,0xfd,0x2a,0x60,0xff, -0x2b,0x9c,0xe9,0xf3,0xd3,0x29,0xf2,0xd5,0x90,0x9f,0xaf,0x4e,0x3b,0x59,0xee,0x7f, -0x95,0x22,0xbf,0x1c,0xf0,0xf3,0xd5,0xf1,0xa3,0x2c,0xf7,0xbf,0x4a,0xe1,0x43,0xfc, -0x7c,0x85,0x61,0x96,0xfb,0x5f,0xa5,0xc8,0x2f,0x88,0x9f,0xaf,0x2,0x7d,0xd,0x90, -0x13,0x5f,0x56,0xfb,0x5f,0x65,0x93,0xaf,0x44,0x96,0xaf,0x10,0xf3,0x65,0xb5,0xff, -0x55,0xca,0x7c,0x65,0xec,0x2f,0xa5,0xbf,0x2e,0x44,0xcf,0x57,0x30,0xac,0x7f,0xc9, -0x7e,0xfd,0xd5,0xcc,0x7c,0x65,0xf8,0xfa,0x94,0xe5,0x2b,0xc0,0x7c,0x59,0xed,0x7f, -0x95,0x49,0xbe,0x62,0xeb,0xf,0x48,0xc8,0xfb,0x93,0xe9,0x1c,0xd6,0x5f,0x45,0xcd, -0x57,0x77,0x4b,0x2c,0x5f,0xad,0x86,0xfb,0x32,0x5e,0x7f,0x15,0x9a,0xaf,0xe0,0x42, -0xf6,0xbf,0x4a,0x9e,0xaf,0xe0,0x82,0xf6,0xef,0x4c,0x9a,0xaf,0x40,0xae,0x7d,0x61, -0xeb,0xdb,0xf3,0x91,0xaf,0xa,0xa1,0xf5,0xab,0x9c,0xe4,0x2b,0x73,0x7e,0x50,0x60, -0xf9,0xa,0xb2,0xfa,0x15,0x6f,0xfc,0x58,0xbc,0x8f,0xe8,0xf3,0x1f,0x55,0xf6,0xfe, -0x41,0x89,0xed,0x7f,0x75,0xd0,0xe4,0x8d,0xbf,0xcb,0xf2,0x55,0x7a,0x2,0xcb,0x57, -0xe6,0xfe,0x57,0xa8,0xc9,0xcb,0x2f,0x8b,0xf7,0x19,0xfb,0x23,0x55,0xd8,0xf8,0x3b, -0x62,0xe3,0x6f,0xfe,0x7d,0xf9,0x38,0xbe,0xd8,0xd8,0xff,0xca,0xf4,0xa9,0xf9,0xca, -0xf2,0x2d,0xf9,0xfa,0x50,0xf3,0x15,0xb0,0xe7,0x7,0x7d,0xf9,0xa,0x35,0x97,0xdc, -0xbf,0xa8,0xf9,0x6a,0xdb,0x9e,0x1f,0x4,0xcc,0x87,0x99,0x6f,0x7f,0xd9,0xfd,0xf3, -0x4,0xdf,0x72,0xcc,0xf,0xa,0x2c,0x5f,0xcd,0x65,0xff,0xab,0x64,0xf9,0xa,0x38, -0xe6,0x7,0x5,0x96,0xaf,0x72,0xe3,0x63,0xcf,0xf,0xe6,0x37,0x5f,0x81,0x8b,0x7c, -0x95,0x2a,0x5f,0x81,0x9c,0xe7,0x2b,0xcd,0x87,0x63,0xbd,0x1f,0x67,0xf1,0xe3,0xc7, -0x69,0xc0,0xfc,0x20,0xcd,0x49,0xbe,0x3a,0xee,0xf1,0xeb,0x57,0x34,0x4f,0xe3,0x2f, -0xa7,0x7e,0x45,0x73,0x92,0x5f,0xf0,0x6f,0xa8,0x7b,0xfd,0x38,0xf3,0xbd,0x97,0x13, -0xdf,0xff,0xd,0xf0,0xfd,0x4d,0x4e,0x8e,0xaf,0xb9,0xfe,0xa,0xb0,0x7c,0xc5,0x7c, -0x78,0xf9,0xf9,0x6a,0xcb,0x3a,0xff,0x98,0xf,0x2b,0x96,0x2f,0x7,0xf9,0xaa,0xca, -0xfa,0x3f,0xce,0xfc,0x20,0xcd,0x41,0xbe,0xaa,0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa, -0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa,0xe6,0x3c,0x5f,0x55,0x73,0x9e,0xaf,0xaa,0x39, -0xcf,0x57,0x5f,0x84,0xf9,0xc1,0x40,0x5f,0x4e,0xf2,0x95,0xdb,0x27,0x5f,0xb1,0xea, -0xcf,0x39,0xc9,0x57,0x6e,0x1f,0x1e,0x21,0x9c,0xaf,0x7c,0xe5,0xf5,0x61,0x94,0xaf, -0x7c,0x15,0xe8,0xdb,0xcf,0xa9,0xf,0xe6,0xf9,0xf8,0xca,0x57,0x6d,0x5f,0x2e,0xaf, -0xf,0xc5,0xf6,0xe5,0xb1,0x7f,0xb1,0xe7,0x7,0x97,0x9e,0xaf,0x2,0x7c,0x21,0xef, -0x77,0xce,0x83,0x2f,0xec,0xfd,0xce,0x4b,0xf7,0xe5,0x2a,0x5f,0x71,0xdb,0x2f,0x47, -0xf9,0xe5,0xb,0xef,0xcb,0xc7,0xf5,0x1b,0x58,0xbf,0xda,0xc8,0x53,0xfd,0x6a,0x70, -0xb7,0xc4,0xf2,0x95,0xb9,0xbe,0x98,0xa2,0x9c,0xd4,0xaf,0x80,0x5e,0xdf,0x10,0x59, -0x7d,0x43,0x9b,0xd7,0xa,0x7e,0x3f,0xdd,0x12,0x8e,0xef,0xaf,0x74,0x9f,0xf6,0x94, -0xba,0x91,0xf,0x4,0xd3,0x7,0x73,0x52,0x1f,0xfa,0x38,0xe7,0x3e,0xa3,0xfe,0xc7, -0xe6,0x8f,0x46,0xf8,0x3b,0xcc,0x97,0xab,0xf9,0x41,0xd3,0xa7,0xe6,0xab,0xe7,0x4c, -0x1f,0x58,0xe6,0xf5,0xf1,0x3d,0x59,0xee,0x5f,0x2e,0x16,0xec,0xfa,0x95,0x3d,0xff, -0xc6,0xea,0x2f,0x60,0x89,0xfd,0xb,0x91,0x50,0xf5,0xf6,0x4,0x41,0xbb,0x7e,0x65, -0xaf,0xbf,0xb2,0x7c,0x4b,0xec,0x9f,0x9,0x70,0xef,0x2f,0xea,0x7c,0x7f,0x63,0x1e, -0xea,0x57,0xa,0xa8,0xd0,0x3b,0x13,0xcc,0x7d,0xff,0xe0,0x66,0x3e,0x7c,0x64,0x72, -0x19,0xe7,0x76,0x7e,0x50,0xf7,0xe5,0x78,0xfe,0x4d,0xf5,0x85,0xef,0x2f,0xba,0x6c, -0x9f,0x84,0x6a,0x13,0x6d,0x29,0x62,0x4e,0xf3,0x15,0x39,0x91,0xc7,0xb7,0x49,0x51, -0xf3,0xe1,0xc3,0x1c,0xd6,0xaf,0xb4,0x47,0x8e,0xcd,0xfd,0xaf,0x4e,0xa1,0x9e,0xaf, -0xd6,0xca,0x2c,0x5f,0x6d,0xe4,0xe1,0xfe,0x5c,0xb0,0xf6,0xbf,0x32,0xf3,0x55,0xcb, -0xca,0x57,0xa2,0xe9,0x13,0x73,0x32,0xfe,0xee,0x51,0xf7,0xfe,0x57,0x2c,0xbf,0xfc, -0x38,0x57,0xf9,0xc5,0xf6,0xb1,0xf7,0xbf,0xbd,0x95,0x13,0x9f,0xf1,0xfc,0xe5,0x6f, -0xcb,0xbe,0xf9,0xd5,0x5c,0xcd,0xf,0xfe,0x6,0xb0,0x7c,0x85,0xf3,0x70,0x7d,0x9c, -0x9f,0xc,0xd4,0x7c,0xe5,0x98,0x1f,0xb4,0xe7,0xdf,0x70,0x1e,0xea,0x57,0x13,0x9, -0xaa,0xf9,0x2a,0xbf,0xf3,0x83,0x13,0x50,0xb9,0xed,0xdc,0xff,0xa,0xb2,0xf9,0x41, -0x5,0x55,0xf3,0x50,0x3f,0x90,0x0,0x54,0xf3,0xd5,0x77,0xed,0x7c,0xc5,0xe6,0x7, -0xf3,0x91,0xaf,0x54,0xdf,0x40,0xcd,0x57,0xd7,0x73,0x3b,0x3f,0xa8,0xb6,0xdf,0x24, -0xcf,0xf3,0x6f,0x12,0xa8,0xe4,0xdb,0x27,0xa9,0xed,0x87,0xf2,0x3b,0x3f,0x38,0x39, -0x81,0x12,0x31,0xfa,0x3f,0x1c,0xe0,0xdb,0x5b,0x66,0xff,0x87,0xec,0x7c,0xa5,0xef, -0x2f,0x3a,0xb8,0x6f,0xd5,0xaf,0x50,0x1e,0xee,0xcf,0xb1,0x9d,0xaf,0x8c,0xfd,0x9b, -0xd8,0xf3,0x3d,0x23,0x63,0x7f,0xd1,0x1c,0xe5,0x2b,0xee,0xfe,0xa2,0xaa,0x6f,0x33, -0x27,0xf9,0xc5,0xf0,0xfd,0xda,0xca,0x2f,0xd,0x36,0xfe,0xe6,0xc4,0x67,0xec,0x2f, -0x6a,0xaf,0x5f,0x63,0x3e,0x9c,0x93,0xe3,0x6b,0xec,0x2f,0xa,0xac,0x7c,0xc5,0xc6, -0xdf,0x65,0xae,0xbf,0xfa,0x70,0xba,0xa6,0xa8,0xf9,0x6a,0x93,0xf5,0x2f,0x80,0xf9, -0xb0,0x72,0x8e,0x72,0x90,0xaf,0xaa,0xb5,0xc7,0xe7,0xd2,0x44,0xbf,0xff,0xc5,0xdc, -0xfd,0x45,0x97,0x9c,0xaf,0x2a,0x8d,0xdf,0x9e,0x4b,0xee,0x7c,0x25,0xb2,0x7c,0x85, -0x96,0x3f,0xbe,0x11,0xd8,0x20,0xe7,0x93,0x9,0x2e,0xf2,0xf2,0x55,0x4e,0x7c,0xe8, -0xce,0x65,0x9c,0xd7,0xf5,0x57,0x9a,0x6f,0x7c,0x27,0xc2,0xfe,0x7,0xcb,0xf3,0xf5, -0x51,0x9e,0x7d,0xa8,0xb6,0x3,0x3f,0xc8,0x71,0xbe,0xba,0x3b,0x5d,0x83,0xef,0x98, -0xf9,0x2a,0x68,0x7e,0x10,0x2d,0xb1,0xff,0x13,0x1c,0xf5,0x2b,0x63,0x7e,0xd0,0xdc, -0xbf,0x4e,0xcd,0x57,0xec,0xfe,0x68,0xb8,0xc4,0xf1,0x43,0xab,0x51,0xb1,0x7c,0x65, -0xd4,0x37,0x44,0x96,0xf,0xac,0xfa,0xfd,0x30,0x47,0xf5,0xd,0x6b,0x7f,0x51,0x47, -0xfd,0xe5,0x20,0x27,0xf9,0xc5,0xc8,0xa7,0x3d,0xcb,0x87,0x73,0xe6,0x53,0x3c,0x3e, -0x36,0x3f,0xdd,0xc8,0x55,0xfd,0xaa,0x2b,0x7a,0xeb,0x57,0x1b,0x4b,0xbc,0x3e,0xbe, -0x27,0x2b,0x5a,0xfd,0xa,0xda,0xf5,0xab,0x3,0xd1,0x5b,0xbf,0x5a,0x62,0xff,0x42, -0x24,0x74,0x4f,0xab,0x5f,0x75,0xec,0xfa,0x95,0xb9,0xbf,0xa8,0xa3,0x7e,0x85,0x96, -0xd7,0x3f,0x13,0x50,0x79,0x5f,0xf5,0x39,0xf6,0x17,0x85,0xa2,0x98,0xa3,0xf9,0x41, -0x5,0x54,0x14,0xad,0x7e,0x65,0xef,0x2f,0xca,0xfa,0xe7,0x7c,0xd4,0xaf,0x34,0xdf, -0x40,0xcd,0x57,0x8f,0x72,0x9a,0xaf,0x8c,0xf6,0x23,0xb8,0x92,0xd3,0xfc,0xa2,0x4d, -0xf,0x6a,0xbe,0x42,0x5e,0x7d,0x12,0xaa,0xab,0x3e,0x4,0x73,0x9a,0xaf,0xc8,0x89, -0xda,0xff,0x49,0xa4,0x8,0x73,0xfa,0xfc,0xa0,0xbe,0x23,0xb1,0x3b,0x5f,0xb1,0xe7, -0x7,0xaf,0xe4,0xe2,0xf9,0x41,0xc1,0x97,0xaf,0x58,0xfd,0xde,0xce,0x57,0x38,0x57, -0xf9,0xca,0xff,0xfc,0x20,0xce,0x49,0x7e,0x31,0xf6,0xef,0x4,0xc0,0x9b,0xaf,0x86, -0xb9,0xf2,0xf5,0xcb,0x5e,0x5f,0x5e,0x8e,0x2f,0xf2,0xd4,0xaf,0x50,0xe,0xea,0x57, -0xa4,0xf1,0xb7,0x57,0xd9,0xfc,0x20,0x74,0xd7,0xaf,0x72,0xb1,0xbe,0x5d,0x79,0xaf, -0x7f,0x26,0x99,0xf3,0x83,0xde,0xfd,0x45,0x41,0xe,0xea,0x57,0xca,0xfb,0xfd,0x27, -0x92,0x73,0xff,0x2b,0xc7,0xfc,0xa0,0xb8,0xfc,0xf1,0x8d,0xe2,0xf7,0xfb,0xca,0xc4, -0xe9,0x73,0xd4,0xaf,0x56,0xf3,0xe0,0xfb,0x40,0xf5,0x5d,0xc6,0x9d,0xbc,0xce,0xf, -0xe2,0xc6,0xcb,0xca,0x24,0xbf,0xf5,0xa1,0x2f,0x80,0xef,0xa1,0x92,0xe7,0xf9,0x41, -0xa5,0xd1,0x57,0xd8,0xfc,0x20,0xcc,0x5f,0xbe,0xa2,0x8a,0x23,0x5f,0x75,0x3c,0xf9, -0x2a,0xf,0xcf,0x47,0x11,0x47,0xbe,0x7a,0xe4,0xc9,0x57,0x9d,0x9c,0x8d,0xbf,0xd0, -0x93,0xaf,0x1e,0xe5,0x2c,0x5f,0x41,0x4f,0xbe,0x62,0xc7,0x17,0xe5,0xdd,0x97,0xa3, -0xe3,0xab,0xe6,0x2b,0xd1,0xfb,0xfc,0x20,0x5c,0x6e,0xbe,0xfa,0x9a,0x27,0x5f,0x9, -0xde,0x7c,0x5,0x96,0x9b,0xaf,0x10,0x5b,0x7f,0x65,0xf8,0xec,0xf5,0xed,0xcc,0xb7, -0xb1,0xdc,0x7c,0xa5,0xfa,0x9c,0xf9,0x8a,0xad,0x3f,0x50,0x72,0xb1,0xff,0x95,0x9a, -0xaf,0xd0,0x1d,0x57,0xbe,0xba,0x5b,0x62,0xf9,0x2a,0x17,0xbe,0xf,0xfa,0xda,0xfc, -0x20,0xcc,0x71,0xbe,0xd2,0xe6,0xdf,0x60,0x8e,0xf3,0x95,0xe6,0x3,0x39,0xce,0x57, -0xaa,0x2f,0xbf,0xeb,0xdb,0xd5,0x7c,0x25,0xab,0xf9,0xaa,0x10,0x56,0xbf,0x82,0x39, -0xc9,0x57,0xe6,0xfc,0xa0,0xe0,0xad,0x5f,0x75,0x72,0x92,0xaf,0x8c,0xf5,0xd9,0x6c, -0x7f,0x51,0xbb,0x7e,0xf5,0x28,0x57,0xfb,0x5f,0xd9,0xfb,0x8b,0x32,0x5f,0x5e,0x9f, -0xcf,0xfb,0xc2,0xf8,0x96,0x79,0x7c,0xdb,0xa5,0x17,0xd4,0xfc,0x2,0x78,0xcf,0xf, -0xd6,0x72,0x90,0xaf,0x68,0x4b,0xea,0x4b,0x13,0xb4,0x1d,0xf6,0xfc,0xe0,0x52,0xdf, -0xf,0xd1,0x92,0xc0,0x6d,0x63,0xff,0x4e,0x7c,0x14,0xe4,0x5b,0xe6,0xfa,0xd8,0xfa, -0x13,0xe0,0x7a,0x3e,0xf,0xb2,0xfd,0x45,0xf3,0xf1,0xfc,0x20,0xad,0x63,0x70,0xe7, -0xb2,0xf3,0xf9,0x41,0xb6,0xbf,0x68,0x4e,0xd6,0xb7,0x6b,0xed,0x47,0xf2,0xfb,0xfc, -0x20,0xad,0x4b,0x20,0xcf,0xf9,0x45,0xf5,0xf5,0x27,0x4,0xe5,0xd7,0xd7,0x2,0x2f, -0xa8,0xf9,0x25,0xbf,0xfb,0x8b,0x8a,0x56,0x7e,0x39,0x9,0xf4,0x2d,0xb3,0xff,0x3, -0x56,0x7e,0x91,0xa8,0xb3,0x7e,0xe5,0xf4,0xe5,0x63,0x7f,0x6,0xdd,0x67,0xd5,0xaf, -0x9c,0xbe,0x7c,0xe4,0x2b,0xd3,0xd7,0x5,0x81,0xef,0xbf,0x5c,0xae,0xef,0xf3,0x9c, -0xfb,0x7e,0x97,0x4b,0xdf,0xb7,0xc1,0xb,0x66,0x7d,0x48,0x9f,0x4b,0x6f,0xc3,0x7c, -0xf9,0x8,0xb8,0xdd,0x37,0xe7,0xdf,0x8c,0xf3,0x2f,0x7f,0x3e,0x2d,0x5f,0x55,0x59, -0xff,0x97,0x37,0x9f,0x2,0xde,0xd0,0xf2,0x55,0xd5,0x37,0x3f,0x98,0x17,0x5f,0x5b, -0xcf,0x57,0x55,0xdf,0xfc,0xa0,0xe5,0x73,0xbc,0x9f,0x78,0x19,0xbe,0x9e,0x9e,0xaf, -0xaa,0x91,0xde,0xef,0xbc,0xc,0x5f,0x5f,0x32,0x7c,0x51,0xde,0xef,0xbc,0x1c,0x5f, -0xdf,0x3f,0xff,0x76,0x12,0xf9,0xbb,0xcd,0xff,0xfa,0xbd,0xf5,0x82,0x39,0xff,0x96, -0xe8,0xb3,0xc0,0xfd,0xf,0x2,0x3e,0x9f,0x17,0x8b,0x4b,0xf4,0x39,0xf6,0x3f,0x8, -0xf8,0x8c,0x26,0x68,0x99,0x3e,0x7b,0xfc,0xfd,0xa2,0xfa,0x50,0xde,0x7d,0x5b,0xb9, -0xf6,0x7d,0x5e,0xcc,0x79,0xfb,0xd1,0x5c,0xfb,0xc8,0x88,0x5c,0xf8,0xd2,0x1c,0xdf, -0xab,0x74,0xc1,0xfd,0x33,0xbf,0x6,0x54,0xc8,0xcd,0xf8,0x96,0x73,0x5f,0xb6,0x9f, -0xb,0xdf,0x85,0x2f,0xe6,0x7,0xad,0x83,0x5f,0x17,0xb,0x8,0x9f,0x4c,0xae,0x95, -0xbe,0xa7,0x28,0x68,0xe7,0x5a,0x9,0xe4,0xc9,0x77,0x8c,0x3a,0x6f,0x11,0x7c,0x7c, -0x2a,0x3d,0x19,0xc1,0xdb,0x67,0x67,0xe8,0xf9,0x11,0xdc,0xce,0x9b,0x4f,0x51,0x8e, -0x8f,0xc1,0x68,0x24,0x81,0x27,0x4f,0xa4,0xd6,0x8,0xde,0xca,0x97,0xef,0xe0,0x45, -0x85,0x1e,0x63,0x0,0xa1,0xa4,0x1a,0xa1,0xa8,0x32,0xf3,0xe4,0xeb,0xa1,0x83,0x7f, -0xf3,0x34,0xed,0xe1,0x5f,0xc2,0x92,0xf4,0x4b,0xcd,0x27,0x5d,0xcb,0x99,0xef,0xb7, -0x5d,0xe5,0xb0,0x87,0x3f,0x1,0xb0,0xf7,0x49,0xaf,0x7,0xc4,0xde,0x28,0x57,0xbe, -0x75,0xcd,0xa7,0xac,0xe3,0x3e,0x80,0xad,0x7e,0xab,0x5,0xc4,0xd6,0x71,0xae,0x7c, -0x3b,0xba,0x6f,0x7,0xf7,0x7b,0xb0,0xde,0x5f,0x5f,0x7,0x62,0xfd,0xb3,0x62,0x9e, -0x7c,0x42,0xb5,0xd7,0x25,0x58,0xa8,0xf5,0x5b,0x12,0xee,0x2b,0x8a,0xb8,0xa3,0x40, -0x90,0x33,0x9f,0xda,0x3f,0xb,0xb5,0xc3,0x9d,0x2b,0x5f,0x3e,0x54,0x7d,0x8f,0x2f, -0xe7,0xab,0x7f,0xbe,0x18,0x7f,0x2f,0x7c,0x17,0xbe,0xb,0xdf,0x85,0xef,0xc2,0x77, -0xe1,0xbb,0xf0,0x5d,0xf8,0x2e,0x7c,0x5f,0x28,0x1f,0x21,0x14,0x62,0xfd,0xc9,0x79, -0xee,0x7,0xd2,0xc3,0xe5,0xfa,0xa6,0xf7,0xe9,0xd6,0x29,0x11,0xa8,0xfe,0x7c,0x99, -0x59,0xe,0x3e,0x33,0xbe,0xd4,0xd1,0xff,0xbf,0xbd,0x64,0xdf,0x33,0xa4,0x78,0x34, -0xd,0xf4,0x6d,0xd1,0xff,0x2a,0x2c,0xd7,0xf7,0xd5,0x69,0x79,0xcf,0xe5,0x1b,0x3a, -0x7d,0x45,0x7a,0x6d,0xc9,0xbe,0x75,0x99,0x6e,0xc8,0x2,0x6d,0xb,0x9d,0xdd,0xe9, -0xb5,0xfa,0x58,0xa0,0x7b,0x54,0x2e,0xe,0x48,0xf1,0x4c,0x2e,0x52,0x48,0x8a,0xf4, -0xc6,0x92,0x7d,0x7f,0x7d,0x42,0xff,0xf9,0xef,0x54,0xdf,0x8d,0xcd,0x75,0xf9,0xf2, -0xf7,0x6,0xcf,0x9e,0x3e,0xa0,0x72,0xa1,0x7d,0xbf,0xf0,0xad,0x71,0x91,0xe,0xdf, -0xfe,0x2e,0x7d,0x66,0xc9,0xbe,0xe9,0xe0,0xe6,0xea,0xa0,0x4c,0x3b,0x57,0x4a,0x6f, -0xb,0x1f,0xbd,0xb0,0xff,0xec,0xa9,0x7a,0x7c,0x8f,0x3e,0x29,0x1f,0xad,0x1e,0x75, -0xe8,0x70,0xbb,0x43,0xbf,0xb5,0x6c,0x5f,0xfb,0x2b,0x97,0xda,0x25,0xda,0x79,0xbb, -0xbc,0x72,0xff,0xa9,0xc2,0x96,0xee,0x3b,0xdd,0xba,0xb9,0x5a,0xdc,0xef,0xd0,0x23, -0xd5,0xf7,0x2f,0x96,0xed,0xeb,0x18,0xfd,0xcb,0xdb,0xc2,0xca,0xdd,0xa7,0x4a,0xdb, -0x86,0x6f,0xfb,0xc6,0x6a,0xa9,0xd3,0xa1,0xa7,0xe5,0xe,0x7d,0x6a,0xe9,0xbe,0x8e, -0xe1,0xa3,0xe5,0x93,0x7f,0x28,0x5a,0x3e,0x95,0xd6,0xa1,0x67,0xe5,0xce,0xf0,0xf2, -0xb2,0x7d,0xfb,0xcc,0x57,0x3a,0xfa,0x87,0xef,0x6c,0x3d,0x73,0x7a,0xa4,0x1d,0xdf, -0x67,0x4e,0xcb,0xea,0xf1,0x95,0x85,0xce,0xde,0xb5,0xa5,0x5f,0x1f,0x45,0xcd,0xd7, -0xbe,0x42,0x37,0xc6,0x4f,0xfd,0xdb,0xf6,0x8d,0xd5,0x13,0x2a,0xaf,0xaa,0xff,0x28, -0xf,0x8a,0x74,0xba,0xb6,0xba,0xb7,0xbe,0x6c,0xdf,0xb8,0xa4,0xfb,0x6e,0xd0,0x7, -0xf2,0x53,0xf7,0xd4,0x8b,0xf9,0x4c,0xef,0x5f,0x56,0xcb,0x6a,0xff,0x32,0xbd,0x7f, -0x69,0x6f,0xc9,0xe3,0x9b,0xe3,0x3,0xb4,0xff,0x31,0x5a,0xb,0x12,0x23,0x3c,0x5c, -0xe4,0xab,0xb,0xdf,0x85,0xef,0xc2,0x77,0xe1,0xcb,0x9b,0xaf,0x9c,0x17,0xdf,0x86, -0x5c,0x56,0x73,0xc0,0x26,0xa5,0x85,0xb1,0x0,0xd4,0x31,0x64,0xcf,0xe9,0x23,0xca, -0xd2,0xef,0x7f,0x57,0x6,0xc5,0xb3,0xc1,0xb5,0x4b,0xf4,0xa1,0x9a,0x52,0xb7,0xa7, -0x25,0xfa,0x60,0xdb,0xe1,0x9b,0xde,0x5b,0xb6,0x6f,0xfa,0xcc,0xde,0xd6,0xd9,0xde, -0x95,0x7f,0x45,0xdf,0xfe,0xde,0xe6,0xb5,0x92,0x5c,0x52,0x33,0xbd,0xf3,0xab,0x7f, -0xb0,0xf4,0xf6,0x9b,0xc2,0xce,0x69,0xe7,0xda,0x19,0x2d,0x9f,0x6d,0x5f,0x29,0x9d, -0xa8,0xb7,0x97,0xeb,0x74,0x7b,0x4f,0x2e,0xad,0x3d,0x27,0xdf,0x24,0x74,0x7a,0x69, -0xe9,0xe7,0xdf,0x94,0x76,0x8e,0x3e,0x29,0x9d,0x91,0xf2,0xd9,0xc3,0x2b,0xdb,0x47, -0x9a,0xef,0x5e,0xf1,0xc1,0xf8,0xf2,0x8d,0x3f,0x18,0x5f,0xbb,0x4f,0xa7,0xbb,0x4b, -0xf7,0xc9,0xa4,0xb8,0xff,0x49,0x69,0x77,0x2a,0x9c,0xbc,0x5d,0xda,0x6e,0xb,0x74, -0xf8,0xf0,0x99,0xb2,0x7c,0xda,0xb9,0xb1,0x7e,0xf4,0x27,0xaa,0xef,0x6c,0xe9,0xbe, -0x93,0x69,0xa9,0xf3,0x8b,0xed,0x8d,0x29,0x3d,0xfa,0xef,0xdb,0xdb,0xeb,0x65,0xf5, -0xfc,0x7b,0x46,0x98,0x1e,0x75,0x6e,0xfc,0xf5,0xfe,0x27,0xcf,0xe6,0xc1,0x77,0x44, -0xb7,0xb6,0xfe,0xd7,0xf6,0x89,0x4c,0xf7,0xff,0x6c,0x7b,0x7b,0x5b,0xbb,0x3e,0x9e, -0xa1,0xed,0x61,0xe7,0xc6,0x2f,0x3a,0x9d,0x5c,0xf8,0xb6,0x68,0xa7,0xb4,0xbb,0x7d, -0x76,0x42,0xb7,0x36,0x54,0xdf,0xb6,0xee,0x5b,0x37,0x7c,0xff,0x2d,0xf,0xbe,0x12, -0xec,0x94,0xf7,0x1e,0x9e,0x9d,0xd2,0xd2,0xa6,0xe9,0x7b,0x96,0x5e,0x31,0x7c,0x1b, -0xaa,0x6f,0xb8,0xec,0xfe,0xe5,0xd2,0xe0,0xb2,0xd0,0xbe,0x76,0x69,0x48,0x56,0xd7, -0xaf,0xac,0xae,0x97,0xe8,0xde,0xfa,0xb3,0x5a,0x9f,0x7d,0xe5,0x17,0xed,0xe2,0xbe, -0xea,0xdb,0x5b,0x76,0xff,0xbc,0xa2,0xfa,0xd4,0xf1,0x63,0x38,0xbd,0xd4,0xfe,0x9a, -0x56,0xe8,0x78,0xb0,0xfe,0x2c,0x5d,0x19,0x5f,0xfe,0xca,0x2f,0x6,0xb9,0xf0,0x51, -0x8a,0x45,0x8a,0x5,0xed,0xf5,0x2e,0x48,0xd0,0xfe,0x4f,0xbb,0x69,0x3,0x5a,0xed, -0xf,0x8b,0x30,0xbf,0xf9,0xa5,0x93,0xef,0x7c,0x45,0x8a,0xf9,0xf6,0xa9,0x39,0xe6, -0x22,0x3f,0xff,0xa3,0xf3,0xfd,0x7f,0x6e,0x69,0x1,0x55,0x8,0x9e,0xa1,0x2b,0x0, -0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//m1284p.png: 12987 bytes - -#endif diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/.cproject b/11_m644p_WIZNET_HTTPServer_FLASH_pages/.cproject deleted file mode 100644 index a9150f2..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/.cproject +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/.project b/11_m644p_WIZNET_HTTPServer_FLASH_pages/.project deleted file mode 100644 index f3ab3f4..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 11_m644p_WIZNET_HTTPServer_FLASH_pages - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webpages.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webpages.h deleted file mode 100644 index 47f7c72..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webpages.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * webpages.h - * - * Created on: 05 . 2018 . - * Author: maxx - */ - -#ifndef WEBPAGES_H_ -#define WEBPAGES_H_ - -#define index_page \ -"\n"\ -"

W5500 Simple Web Server


\n"\ -"

AVR Mega1284p and WIZ5500


\n"\ -"

\n"\ -"Uptime: sec\n"\ -"

LED1 OFF\n"\ -"
LED1 ON\n"\ -"

\n"\ -"\n"\ -"

\n" - -#define page_404 \ -"HTTP/1.0 404 Not Found\r\n"\ -"Content-Type: text/html\r\n"\ -"\r\n"\ -"

404 Not Found

" - -#endif /* WEBPAGES_H_ */ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.c deleted file mode 100644 index 8879627..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.c +++ /dev/null @@ -1,257 +0,0 @@ -#include -#include -#include "webserver_simple.h" -#include "socket.h" -#include "wizchip_conf.h" - - -int strindex(char *s,char *t) -{ - uint16_t i,n; - - n=strlen(t); - for(i=0; *(s+i); i++) - { - if (strncmp(s+i,t,n) == 0) - return i; - } - return -1; -} -void SetAutoKeepAlive(sn, time) // time > 0 -{ - setSn_KPALVTR(sn, time); - printf("Sn:%d - kpalvtime: %u sec\r\n",sn, 5*getSn_KPALVTR(sn)); -} - -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0; - int getidx, postidx, getidx_htm, postidx_htm; - char radiostat0[10],radiostat1[10],temp[12]; - - static uint32_t httpd_active_millis; - -#ifdef _WEBSRV_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _WEBSRV_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:WEB Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - //Get timetick to open socket - httpd_active_millis = millis(); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > WEBSRV_DATA_BUF_SIZE) size = WEBSRV_DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - - //Get timetick to read data from socket - httpd_active_millis = millis(); - - size = (uint16_t) ret; - buf[size] = 0x0;// insert null-terminate symbol to correct parse data - -#ifdef _WEBSRV_DEBUG_ - PRINTF("\r\n>>HTTP REQUEST %u bytes:\r\n%s\rn\n",size, buf); -#endif - - // Check the HTTP Request Header - getidx=strindex((char *)buf,"GET / "); - getidx_htm=strindex((char *)buf,"GET /index.htm"); - postidx=strindex((char *)buf,"POST / "); - postidx_htm=strindex((char *)buf,"POST /index.htm"); - - if (getidx >= 0 || postidx >= 0 || getidx_htm >= 0 || postidx_htm >= 0) - { -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. ROOT check!\n"); -#endif - // Now check the Radio Button for POST request - if (postidx >= 0 || postidx_htm >= 0) - { - if (strindex((char *)buf,"radio=0") > 0) - { - //ledmode=0; - //PRINTF("++LED=0\r\n"); - led1_low(); - } - - if (strindex((char *)buf,"radio=1") > 0) - { - //ledmode=1; - //PRINTF("++LED=1\r\n"); - led1_high(); - } - - } -#ifdef _WEBSRV_DEBUG_ - PRINTF(">>Req. Send!\n"); -#endif - //Old method with every string fill - /* - // Create the HTTP Response Header - strcpy_P((char *)buf,PSTR("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n")); - strcat_P((char *)buf,PSTR(""\ - ""\ - )); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

W5500 Simple Web Server


\r\n")); - strcat_P((char *)buf,PSTR("

AVR Mega1284p and WIZ5500


\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - - // Now Send the HTTP Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - // Create the HTTP Temperature Response - sprintf((char *)temp,"%lu",(millis()/1000)); // Convert temperature value to string - - strcpy_P((char *)buf,PSTR("Uptime: OC\r\n")); // for celsius - strcat_P((char *)buf,PSTR("\"> sec\r\n")); // for seconds - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - // Create the HTTP Radio Button 0 Response - strcat_P((char *)buf,PSTR("

LED1 OFF\r\n")); - strcat_P((char *)buf,PSTR("
LED1 ON\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - strcat_P((char *)buf,PSTR("\r\n")); - strcat_P((char *)buf,PSTR("

\r\n")); - */ - - //New method, send page at once, (no more then ~1500 bytes content!!) - //Prepare additional data to send - if (led1_read()) - { - strcpy(radiostat0,""); - strcpy_P(radiostat1,PSTR("checked")); - } - else - { - strcpy_P(radiostat0,PSTR("checked")); - strcpy(radiostat1,""); - } - - //copy page to buffer and send to http client, without additional data - //strcpy_P((char *)buf,PSTR(index_page)); - - //copy page to buffer and send to http client, with additional data - sprintf_P((char *)buf,PSTR(index_page), millis()/1000, radiostat0, radiostat1); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - - } - else - { - //Page not found - /* - strcpy_P((char *)buf,PSTR(\ - "HTTP/1.0 404 Not Found\r\n" - "Content-Type: text/html\r\n" - "\r\n" - //" " // Redirect 5 - "

404 Not Found

"\ - )); - */ - - //copy page to buffer and send to http client, without additional data - strcpy_P((char *)buf,PSTR(page_404)); - - // Now Send the HTTP Remaining Response - if (send(sn,buf,strlen((char *)buf)) <= 0) break; - } - // Disconnect the socket - disconnect(sn); - } - else - { - //here when opened socket connection but no data received - if((millis()-httpd_active_millis) > HTTPD_OPEN_TIMEOUT) - { - //Force close socket, after 3 sec idle (To beat Chrome "persistent connection") -#ifdef _WEBSRV_DEBUG_ - PRINTF("!!HTTPD timeout, Force close socket\r\n"); -#endif - close(sn); - } - } - break; - /* - case SOCK_FIN_WAIT: - case SOCK_CLOSING: - case SOCK_TIME_WAIT: - case SOCK_LAST_ACK: - //case SOCK_CLOSE_WAIT: - //Force close socket - close(sn); - */ - - break; - case SOCK_CLOSE_WAIT : -#ifdef _WEBSRV_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _WEBSRV_DEBUG_ - printf("%d:WEB Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _WEBSRV_DEBUG_ - printf("%d:Listen, WEB server, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _WEBSRV_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; - //This is not helped with Chrome keep-alive sessions - //SetAutoKeepAlive(sn, 1); // set Auto keepalive 5sec(1*5) (This is for TCP IP only!) -#ifdef _WEBSRV_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.h deleted file mode 100644 index b851fbc..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Application/webserver_simple/webserver_simple.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _WEBSERVER_SIMPLE_H_ -#define _WEBSERVER_SIMPLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../../globals.h" -#include "webpages.h" - -/* Loopback test debug message printout enable */ -#define _WEBSRV_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef WEBSRV_DATA_BUF_SIZE - #define WEBSRV_DATA_BUF_SIZE 2048 -#endif - -//Timeout (ms) to close too long opened socket (Help from freeze with work with Chrome browser (keep persistent connection on WIN7 ~ 120 sec)) -#define HTTPD_OPEN_TIMEOUT 3000 - -/* WEB SERVER test example */ -int32_t websrv_simple(uint8_t sn, uint8_t* buf, uint16_t port); - -int strindex(char *s,char *t); - - -#ifdef __cplusplus -} -#endif - -#endif //_WEBSERVER_SIMPLE_H_ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.c deleted file mode 100644 index 0aead49..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - @file httpd.c - @brief functions associated http processing - */ - -#include -#include -#include "socket.h" -#include "httpParser.h" - -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -//uint8_t BUFPUB[2048]; -uint8_t BUFPUB[256]; - -/***************************************************************************** - * Private functions - ****************************************************************************/ -static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */ -static uint8_t C2D(uint8_t c); /* Convert a character to HEX */ - -/** - @brief convert escape characters(%XX) to ASCII character - */ -void unescape_http_url( - char * url /**< pointer to be converted ( escape characters )*/ - ) -{ - int x, y; - - for (x = 0, y = 0; url[y]; ++x, ++y) { - if ((url[x] = url[y]) == '%') { - url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]); - y+=2; - } - } - url[x] = '\0'; -} - - -/** - @brief make response header such as html, gif, jpeg,etc. - */ -void make_http_response_head( - char * buf, /**< pointer to response header to be made */ - char type, /**< response type */ - uint32_t len /**< size of response header */ - ) -{ - const char * head; - char tmp[10]; - - /* file type*/ - if (type == PTYPE_HTML) head = PSTR(RES_HTMLHEAD_OK); - else if (type == PTYPE_GIF) head = PSTR(RES_GIFHEAD_OK); - else if (type == PTYPE_TEXT) head = PSTR(RES_TEXTHEAD_OK); - else if (type == PTYPE_JPEG) head = PSTR(RES_JPEGHEAD_OK); - else if (type == PTYPE_FLASH) head = PSTR(RES_FLASHHEAD_OK); - else if (type == PTYPE_XML) head = PSTR(RES_XMLHEAD_OK); - else if (type == PTYPE_CSS) head = PSTR(RES_CSSHEAD_OK); - else if (type == PTYPE_JSON) head = PSTR(RES_JSONHEAD_OK); - else if (type == PTYPE_JS) head = PSTR(RES_JSHEAD_OK); - else if (type == PTYPE_CGI) head = PSTR(RES_CGIHEAD_OK); - else if (type == PTYPE_PNG) head = PSTR(RES_PNGHEAD_OK); - else if (type == PTYPE_ICO) head = PSTR(RES_ICOHEAD_OK); - else if (type == PTYPE_TTF) head = PSTR(RES_TTFHEAD_OK); - else if (type == PTYPE_OTF) head = PSTR(RES_OTFHEAD_OK); - else if (type == PTYPE_WOFF) head = PSTR(RES_WOFFHEAD_OK); - else if (type == PTYPE_EOT) head = PSTR(RES_EOTHEAD_OK); - else if (type == PTYPE_SVG) head = PSTR(RES_SVGHEAD_OK); -#ifdef _HTTPPARSER_DEBUG_ - else - { - head = NULL; - PRINTF("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n"); - } -#else - else head = NULL; -#endif - - sprintf(tmp, "%ld", len); - strcpy_P(buf, head); - strcat(buf, tmp); - strcat(buf, "\r\n\r\n"); -} - - -/** - @brief find MIME type of a file - */ -void find_http_uri_type( - uint8_t * type, /**< type to be returned */ - uint8_t * buff /**< file name */ - ) -{ - /* Decide type according to extension*/ - - char * buf; - buf = (char *)buff; - - if (strstr_P(buf, PSTR(".htm")) || strstr_P(buf, PSTR(".html"))) *type = PTYPE_HTML; - else if (strstr_P(buf, PSTR(".gif"))) *type = PTYPE_GIF; - else if (strstr_P(buf, PSTR(".text")) || strstr_P(buf,PSTR(".txt"))) *type = PTYPE_TEXT; - else if (strstr_P(buf, PSTR(".jpeg")) || strstr_P(buf,PSTR(".jpg"))) *type = PTYPE_JPEG; - else if (strstr_P(buf, PSTR(".swf"))) *type = PTYPE_FLASH; - else if (strstr_P(buf, PSTR(".cgi")) || strstr_P(buf,PSTR(".CGI"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".json")) || strstr_P(buf,PSTR(".JSON"))) *type = PTYPE_JSON; - else if (strstr_P(buf, PSTR(".js")) || strstr_P(buf,PSTR(".JS"))) *type = PTYPE_JS; - else if (strstr_P(buf, PSTR(".CGI")) || strstr_P(buf,PSTR(".cgi"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".xml")) || strstr_P(buf,PSTR(".XML"))) *type = PTYPE_XML; - else if (strstr_P(buf, PSTR(".css")) || strstr_P(buf,PSTR(".CSS"))) *type = PTYPE_CSS; - else if (strstr_P(buf, PSTR(".png")) || strstr_P(buf,PSTR(".PNG"))) *type = PTYPE_PNG; - else if (strstr_P(buf, PSTR(".ico")) || strstr_P(buf,PSTR(".ICO"))) *type = PTYPE_ICO; - else if (strstr_P(buf, PSTR(".ttf")) || strstr_P(buf,PSTR(".TTF"))) *type = PTYPE_TTF; - else if (strstr_P(buf, PSTR(".otf")) || strstr_P(buf,PSTR(".OTF"))) *type = PTYPE_OTF; - else if (strstr_P(buf, PSTR(".woff")) || strstr_P(buf,PSTR(".WOFF"))) *type = PTYPE_WOFF; - else if (strstr_P(buf, PSTR(".eot")) || strstr_P(buf,PSTR(".EOT"))) *type = PTYPE_EOT; - else if (strstr_P(buf, PSTR(".svg")) || strstr_P(buf,PSTR(".SVG"))) *type = PTYPE_SVG; - else *type = PTYPE_ERR; -} - - -/** - @brief parse http request from a peer - */ -void parse_http_request( - st_http_request * request, /**< request to be returned */ - uint8_t * buf /**< pointer to be parsed */ - ) -{ - char * nexttok; - nexttok = strtok((char*)buf," "); - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - if(!strcmp_P(nexttok, PSTR("GET")) || !strcmp_P(nexttok,PSTR("get"))) - { - request->METHOD = METHOD_GET; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("HEAD")) || !strcmp_P(nexttok,PSTR("head"))) - { - request->METHOD = METHOD_HEAD; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("POST")) || !strcmp_P(nexttok,PSTR("post"))) - { - nexttok = strtok(NULL,"\0"); - request->METHOD = METHOD_POST; - } - else - { - request->METHOD = METHOD_ERR; - } - - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - strcpy((char *)request->URI, nexttok); -} - -#ifdef _OLD_ -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value( - char* uri, - char* param_name - ) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * name = 0; - - - if(!uri || !param_name) return 0; - - strcpy((char*)tempURI,uri); - if((name = (uint8_t*)strstr(tempURI, param_name))) - { - name += strlen(param_name) + 1; // strlen(para_name) + strlen("=") - if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0"))) - { - unescape_http_url((char *)name); - replacetochar(name, '+', ' '); - } - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s",param_name,name); -#endif - - return name; -} -#else -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value(char* uri, char* param_name) -{ - - uint8_t * name = 0; - uint8_t * ret = BUFPUB; - uint8_t * pos2; - uint16_t len = 0, content_len = 0; - uint8_t tmp_buf[10]={0x00, }; - - if(!uri || !param_name) return 0; - - /***************/ - mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf); - content_len = ATOI(tmp_buf, 10); - uri = strstr(uri, "\r\n\r\n"); - uri += 4; - uri[content_len] = 0; - /***************/ - - if((name = (uint8_t *)strstr(uri, param_name))) - { - name += strlen(param_name) + 1; - pos2 = (uint8_t*)strstr((char*)name, "&"); - if(!pos2) - { - pos2 = name + strlen((char*)name); - } - len = pos2 - name; - - if(len) - { - ret[len] = 0; - strncpy((char*)ret,(char*)name, len); - unescape_http_url((char *)ret); - replacetochar(ret, '+' ,' '); - //ret[len] = 0; - //ret[strlen((int8*)ret)] = 0; - //printf("len=%d\r\n",len); - } - else - { - ret[0] = 0; - } - } - else - { - return 0; - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s\r\n", param_name, ret); -#endif - return ret; -} -#endif - -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * uri_name; - - if(!uri) return 0; - - strcpy(tempURI, (char *)uri); - - uri_name = (uint8_t *)strtok(tempURI, " ?"); - - if(strcmp((char *)uri_name,"/")) uri_name++; - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_name); -#endif - - return uri_name; -} -#else - -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf) -{ - uint8_t * uri_ptr; - if(!uri) return 0; - - strcpy((char *)uri_buf, (char *)uri); - - uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?"); - - if(strcmp((char *)uri_ptr,"/")) uri_ptr++; - strcpy((char *)uri_buf, (char *)uri_ptr); - -#ifdef _HTTPPARSER_DEBUG_ - PRINTF(" uri_name = %s\r\n", uri_buf); -#endif - - return 1; -} - -#endif - -void inet_addr_(uint8_t * addr, uint8_t *ip) -{ - uint8_t i; - uint8_t taddr[30]; - uint8_t * nexttok; - uint8_t num; - - strcpy((char *)taddr, (char *)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (uint8_t *)strtok((char *)nexttok, "."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10); - else num = ATOI(nexttok,10); - ip[i] = num; - nexttok = NULL; - } -} - - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; -// debug_2013_11_25 -// while (*str !=0) - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -/** - * @brief Check strings and then execute callback function by each string. - * @param src The information of URI - * @param s1 The start string to be researched - * @param s2 The end string to be researched - * @param sub The string between s1 and s2 - * @return The length value atfer working - */ -void mid(char* src, char* s1, char* s2, char* sub) -{ - char* sub1; - char* sub2; - uint16_t n; - - sub1=strstr((char*)src,(char*)s1); - sub1+=strlen((char*)s1); - sub2=strstr((char*)sub1,(char*)s2); - - n=sub2-sub1; - strncpy((char*)sub,(char*)sub1,n); - sub[n]='\0'; -} - -//////////////////////////////////////////////////////////////////// -// Static functions -//////////////////////////////////////////////////////////////////// - -/** -@brief replace the specified character in a string with new character -*/ -static void replacetochar( - uint8_t * str, /**< pointer to be replaced */ - uint8_t oldchar, /**< old character */ - uint8_t newchar /**< new character */ - ) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == oldchar) str[x] = newchar; -} - -/** -@brief CONVERT CHAR INTO HEX -@return HEX - -This function converts HEX(0-F) to a character -*/ -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - - - diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.h deleted file mode 100644 index c289c2e..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpParser.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - @file httpd.h - @brief Define Constants and fucntions associated with HTTP protocol. - */ - -#include -#include "../../globals.h" - -#ifndef __HTTPPARSER_H__ -#define __HTTPPARSER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#define _HTTPPARSER_DEBUG_ - -#define HTTP_SERVER_PORT 80 /**< HTTP server well-known port number */ - -/* HTTP Method */ -#define METHOD_ERR 0 /**< Error Method. */ -#define METHOD_GET 1 /**< GET Method. */ -#define METHOD_HEAD 2 /**< HEAD Method. */ -#define METHOD_POST 3 /**< POST Method. */ - -/* HTTP GET Method */ -#define PTYPE_ERR 0 /**< Error file. */ -#define PTYPE_HTML 1 /**< HTML file. */ -#define PTYPE_GIF 2 /**< GIF file. */ -#define PTYPE_TEXT 3 /**< TEXT file. */ -#define PTYPE_JPEG 4 /**< JPEG file. */ -#define PTYPE_FLASH 5 /**< FLASH file. */ -#define PTYPE_MPEG 6 /**< MPEG file. */ -#define PTYPE_PDF 7 /**< PDF file. */ -#define PTYPE_CGI 8 /**< CGI file. */ -#define PTYPE_XML 9 /**< XML file. */ -#define PTYPE_CSS 10 /**< CSS file. */ -#define PTYPE_JS 11 /**< JavaScript file. */ -#define PTYPE_JSON 12 /**< JSON (JavaScript Standard Object Notation) file. */ -#define PTYPE_PNG 13 /**< PNG file. */ -#define PTYPE_ICO 14 /**< ICON file. */ - -#define PTYPE_TTF 20 /**< Font type: TTF file. */ -#define PTYPE_OTF 21 /**< Font type: OTF file. */ -#define PTYPE_WOFF 22 /**< Font type: WOFF file. */ -#define PTYPE_EOT 23 /**< Font type: EOT file. */ -#define PTYPE_SVG 24 /**< Font type: SVG file. */ - - -/* HTTP response */ -#define STATUS_OK 200 -#define STATUS_CREATED 201 -#define STATUS_ACCEPTED 202 -#define STATUS_NO_CONTENT 204 -#define STATUS_MV_PERM 301 -#define STATUS_MV_TEMP 302 -#define STATUS_NOT_MODIF 304 -#define STATUS_BAD_REQ 400 -#define STATUS_UNAUTH 401 -#define STATUS_FORBIDDEN 403 -#define STATUS_NOT_FOUND 404 -#define STATUS_INT_SERR 500 -#define STATUS_NOT_IMPL 501 -#define STATUS_BAD_GATEWAY 502 -#define STATUS_SERV_UNAVAIL 503 - -/* HTML Doc. for ERROR */ -static const char PROGMEM ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n\r\n\r\nSorry, the page you requested was not found.\r\n\r\n\r\n\0"; -static const char PROGMEM ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n\r\n\r\nInvalid request.\r\n\r\n\r\n\0"; - -/* HTML Doc. for CGI result */ -#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response header for HTML*/ -#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for TEXT */ -#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " - -/* Response head for GIF */ -#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: " - -/* Response head for JPEG */ -#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: " - -/* Response head for PNG */ -#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: " - -/* Response head for FLASH */ -#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: " - -/* Response head for XML */ -#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for CSS */ -#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: " - -/* Response head for JavaScript */ -#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: " - -/* Response head for JSON */ -#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " - -/* Response head for ICO */ -#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: " - -/* Response head for CGI */ -#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response head for TTF, Font */ -#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: " - -/* Response head for OTF, Font */ -#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: " - -/* Response head for WOFF, Font */ -#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: " - -/* Response head for EOT, Font */ -#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: " - -/* Response head for SVG, Font */ -#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: " - -/** - @brief Structure of HTTP REQUEST - */ - -//#define MAX_URI_SIZE 1461 -#define MAX_URI_SIZE 512 - -typedef struct _st_http_request -{ - uint8_t METHOD; /**< request method(METHOD_GET...). */ - uint8_t TYPE; /**< request type(PTYPE_HTML...). */ - uint8_t URI[MAX_URI_SIZE]; /**< request file name. */ -}st_http_request; - -// HTTP Parsing functions -void unescape_http_url(char * url); /* convert escape character to ascii */ -void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */ -void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */ -void make_http_response_head(char *, char, uint32_t); /* make response header */ -uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */ -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */ -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri); -#endif - -// Utility functions -uint16_t ATOI(uint8_t * str, uint8_t base); -void mid(char* src, char* s1, char* s2, char* sub); -void inet_addr_(uint8_t * addr, uint8_t * ip); - -#ifdef __cplusplus -} -#endif - -#endif /* end of __HTTPPARSER_H__ */ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.c deleted file mode 100644 index 8df7015..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.c +++ /dev/null @@ -1,1399 +0,0 @@ -#include -#include -#include - -#include "socket.h" -#include "wizchip_conf.h" - -#include "httpServer.h" -#include "httpParser.h" -#include "httpUtil.h" -//Find Content -/* -#include -#include -#include "avr/wdt.h" // WatchDog -#ifndef PRINTF - #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#endif -*/ -#include "../../globals.h" //add AVR specific useful headers - -#ifdef _USE_SDCARD_ -#include "ff.h" // header file for FatFs library (FAT file system) -#endif - -/* -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif -*/ -#define DATA_BUF_SIZE HTTPD_MAX_BUF_SIZE -/***************************************************************************** - * Private types/enumerations/variables - ****************************************************************************/ -static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, }; -static st_http_request * http_request; /**< Pointer to received HTTP request */ -static st_http_request * parsed_http_request; /**< Pointer to parsed HTTP request */ -static uint8_t * http_response; /**< Pointer to HTTP response */ - -// ## For Debugging -//static uint8_t uri_buf[128]; - -// Number of registered web content in code flash memory -static uint16_t total_content_cnt = 0; -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -uint8_t * pHTTP_TX; -uint8_t * pHTTP_RX; - -volatile uint32_t httpServer_tick_1s = 0; -st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }; -httpServer_webContent web_content[MAX_CONTENT_CALLBACK]; - -#ifdef _USE_SDCARD_ -FIL fs; // FatFs: File object -FRESULT fr; // FatFs: File function return code -#endif - -/***************************************************************************** - * Private functions - ****************************************************************************/ -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist); -static uint8_t getHTTPSocketNum(uint8_t seqnum); -static int8_t getHTTPSequenceNum(uint8_t socket); -static int8_t http_disconnect(uint8_t sn); - -//static void http_process_handler(uint8_t s, st_http_request * p_http_request); -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request); - -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status); - -//static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len); - -/***************************************************************************** - * Public functions - ****************************************************************************/ -// Callback functions definition: MCU Reset / WDT Reset -void default_mcu_reset(void) {;} -void default_wdt_reset(void) {;} -void (*HTTPServer_ReStart)(void) = default_mcu_reset; -void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset; - -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist) -{ - uint8_t i; - - for(i = 0; i < cnt; i++) - { - // Mapping the H/W socket numbers to the sequential index numbers - HTTPSock_Num[i] = socklist[i]; - } -} - -static uint8_t getHTTPSocketNum(uint8_t seqnum) -{ - // Return the 'H/W socket number' corresponding to the index number - return HTTPSock_Num[seqnum]; -} - -static int8_t getHTTPSequenceNum(uint8_t socket) -{ - uint8_t i; - - for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++) - if(HTTPSock_Num[i] == socket) return i; - - return -1; -} - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist) -{ - // User's shared buffer - pHTTP_TX = tx_buf; - pHTTP_RX = rx_buf; - - // H/W Socket number mapping - httpServer_Sockinit(cnt, socklist); -} - - -/* Register the call back functions for HTTP Server */ -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)) -{ - // Callback: HW Reset and WDT reset function for each MCU platforms - if(mcu_reset) HTTPServer_ReStart = mcu_reset; - if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset; -} - - -//void httpServer_run(uint8_t seqnum) -//{ -// uint8_t s; // socket number -// uint16_t len; -// uint32_t gettime = 0; -// -//#ifdef _HTTPSERVER_DEBUG_ -// uint8_t destip[4] = {0, }; -// uint16_t destport = 0; -//#endif -// -// http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request -// parsed_http_request = (st_http_request *)pHTTP_TX; -// -// // Get the H/W socket number -// s = getHTTPSocketNum(seqnum); -// -// /* HTTP Service Start */ -// switch(getSn_SR(s)) -// { -// case SOCK_ESTABLISHED: -// // Interrupt clear -// if(getSn_IR(s) & Sn_IR_CON) -// { -// setSn_IR(s, Sn_IR_CON); -// } -// -// // HTTP Process states -// switch(HTTPSock_Status[seqnum].sock_status) -// { -// -// case STATE_HTTP_IDLE : -// if ((len = getSn_RX_RSR(s)) > 0) -// { -// if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; -// len = recv(s, (uint8_t *)http_request, len); -// -// *(((uint8_t *)http_request) + len) = '\0'; -// -// parse_http_request(parsed_http_request, (uint8_t *)http_request); -//#ifdef _HTTPSERVER_DEBUG_ -// getSn_DIPR(s, destip); -// destport = getSn_DPORT(s); -// printf("\r\n"); -// printf("> HTTPSocket[%d] : HTTP Request received ", s); -// printf("from %d.%d.%d.%d : %d\r\n", destip[0], destip[1], destip[2], destip[3], destport); -//#endif -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -//#endif -// // HTTP 'response' handler; includes send_http_response_header / body function -// http_process_handler(s, parsed_http_request); -// -// gettime = get_httpServer_timecount(); -// // Check the TX socket buffer for End of HTTP response sends -// while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) -// { -// if((get_httpServer_timecount() - gettime) > 3) -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -//#endif -// break; -// } -// } -// -// if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; -// else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end -// } -// break; -// -// case STATE_HTTP_RES_INPROC : -// /* Repeat: Send the remain parts of HTTP responses */ -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); -//#endif -// // Repeatedly send remaining data to client -// send_http_response_body(s, 0, http_response, 0, 0); -// -// if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; -// break; -// -// case STATE_HTTP_RES_DONE : -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -//#endif -// // Socket file info structure re-initialize -// HTTPSock_Status[seqnum].file_len = 0; -// HTTPSock_Status[seqnum].file_offset = 0; -// HTTPSock_Status[seqnum].file_start = 0; -// HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; -// -////#ifdef _USE_SDCARD_ -//// f_close(&fs); -////#endif -//#ifdef _USE_WATCHDOG_ -// HTTPServer_WDT_Reset(); -//#endif -// http_disconnect(s); -// break; -// -// default : -// break; -// } -// break; -// -// case SOCK_CLOSE_WAIT: -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -//#endif -// disconnect(s); -// break; -// -// case SOCK_CLOSED: -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : CLOSED\r\n", s); -//#endif -// if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : OPEN\r\n", s); -//#endif -// } -// break; -// -// case SOCK_INIT: -// listen(s); -// break; -// -// case SOCK_LISTEN: -// break; -// -// default : -// break; -// -// } // end of switch -// -//#ifdef _USE_WATCHDOG_ -// HTTPServer_WDT_Reset(); -//#endif -//} - -void httpServer_run_avr(uint8_t seqnum) -{ - uint8_t s; // socket number - uint16_t len; - uint32_t gettime = 0; - -#ifdef _HTTPSERVER_DEBUG_ - uint8_t destip[4] = {0, }; - uint16_t destport = 0; -#endif - - http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request - parsed_http_request = (st_http_request *)pHTTP_TX; - - // Get the H/W socket number - s = getHTTPSocketNum(seqnum); - - /* HTTP Service Start */ - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - } - - // HTTP Process states - switch(HTTPSock_Status[seqnum].sock_status) - { - - case STATE_HTTP_IDLE : - if ((len = getSn_RX_RSR(s)) > 0) - { - if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; - len = recv(s, (uint8_t *)http_request, len); - - *(((uint8_t *)http_request) + len) = '\0'; - - parse_http_request(parsed_http_request, (uint8_t *)http_request); -#ifdef _HTTPSERVER_DEBUG_ - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("\r\n"); - PRINTF("> HTTPSocket[%d] : HTTP Request received ", s); - PRINTF("from %d.%d.%d.%d : %u\r\n", destip[0], destip[1], destip[2], destip[3], destport); -#endif -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -#endif - // HTTP 'response' handler; includes send_http_response_header / body function - http_process_handler_avr(s, parsed_http_request); - - gettime = get_httpServer_timecount(); - // Check the TX socket buffer for End of HTTP response sends - while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) - { - if((get_httpServer_timecount() - gettime) > 3) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -#endif - break; - } - } - - if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; - else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end - } - break; - - case STATE_HTTP_RES_INPROC : - /* Repeat: Send the remain parts of HTTP responses */ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); -#endif - // Repeatedly send remaining data to client - send_http_response_body_avr(s, 0, http_response, 0, 0); - - if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - - case STATE_HTTP_RES_DONE : -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -#endif - // Socket file info structure re-initialize - HTTPSock_Status[seqnum].file_len = 0; - HTTPSock_Status[seqnum].file_offset = 0; - HTTPSock_Status[seqnum].file_start = 0; - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; - -//#ifdef _USE_SDCARD_ -// f_close(&fs); -//#endif -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif - http_disconnect(s); - break; - - default : - break; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : CLOSED\r\n", s); -#endif - if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: - listen(s); - break; - - case SOCK_LISTEN: - break; - - default : - break; - - } // end of switch - -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif -} - -//////////////////////////////////////////// -// Private Functions -//////////////////////////////////////////// -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status) -{ - switch(http_status) - { - case STATUS_OK: // HTTP/1.1 200 OK - if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s); -#endif - make_http_response_head((char*)http_response, content_type, body_len); - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s); -#endif - // CGI/XML type request does not respond HTTP header to client - http_status = 0; - } - break; - case STATUS_BAD_REQ: // HTTP/1.1 400 OK -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s); -#endif - memcpy_P(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE)); - break; - case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s); -#endif - memcpy_P(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE)); - break; - default: - break; - } - - // Send the HTTP Response 'header' - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response)); -#endif - send(s, http_response, strlen((char *)http_response)); - } -} - - -//static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -//{ -// int8_t get_seqnum; -// uint32_t send_len; -// -// uint8_t flag_datasend_end = 0; -// -//#ifdef _USE_SDCARD_ -// uint16_t blocklen; -//#endif -//#ifdef _USE_FLASH_ -// uint32_t addr = 0; -//#endif -// -// if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number -// -// // Send the HTTP Response 'body'; requested file -// if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### -// { -// if (file_len > DATA_BUF_SIZE - 1) -// { -// HTTPSock_Status[get_seqnum].file_start = start_addr; -// HTTPSock_Status[get_seqnum].file_len = file_len; -// send_len = DATA_BUF_SIZE - 1; -// -/////////////////////////////////////////////////////////////////////////////////////////////////// -//// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -// memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); -// strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -//#endif -/////////////////////////////////////////////////////////////////////////////////////////////////// -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -//#endif -// } -// else -// { -// // Send process end -// send_len = file_len; -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -//#endif -// } -//#ifdef _USE_FLASH_ -// if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -//#endif -// } -// else // remained parts -// { -//#ifdef _USE_FLASH_ -// if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) -// { -// addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; -// } -//#endif -// send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; -// -// if(send_len > DATA_BUF_SIZE - 1) -// { -// send_len = DATA_BUF_SIZE - 1; -// //HTTPSock_Status[get_seqnum]->file_offset += send_len; -// } -// else -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -//#endif -// // Send process end -// flag_datasend_end = 1; -// } -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -//#endif -// } -// -///*****************************************************/ -// //HTTPSock_Status[get_seqnum]->storage_type == NONE -// //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH -// //HTTPSock_Status[get_seqnum]->storage_type == SDCARD -// //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -///*****************************************************/ -// -// if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) -// { -// if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; -// read_userReg_webContent(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); -// } -//#ifdef _USE_SDCARD_ -// else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) -// { -// // Data read from SD Card -// fr = f_read(&fs, &buf[0], send_len, (void *)&blocklen); -// if(fr != FR_OK) -// { -// send_len = 0; -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -//#endif -// } -// else -// { -// *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) -// } -// } -//#endif -// -//#ifdef _USE_FLASH_ -// else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) -// { -// // Data read from external data flash memory -// read_from_flashbuf(addr, &buf[0], send_len); -// *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) -// } -//#endif -// else -// { -// send_len = 0; -// } -// // Requested content send to HTTP client -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -//#endif -// -// if(send_len) send(s, buf, send_len); -// else flag_datasend_end = 1; -// -// if(flag_datasend_end) -// { -// HTTPSock_Status[get_seqnum].file_start = 0; -// HTTPSock_Status[get_seqnum].file_len = 0; -// HTTPSock_Status[get_seqnum].file_offset = 0; -// flag_datasend_end = 0; -// } -// else -// { -// HTTPSock_Status[get_seqnum].file_offset += send_len; -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -//#endif -// } -// -//// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -//#ifdef _USE_SDCARD_ -// f_close(&fs); -//#endif -//// ## 20141219 added end -//} - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -{ - int8_t get_seqnum; - uint32_t send_len; - - uint8_t flag_datasend_end = 0; - -#ifdef _USE_SDCARD_ - uint16_t blocklen; -#endif -#ifdef _USE_FLASH_ - uint32_t addr = 0; -#endif - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - // Send the HTTP Response 'body'; requested file - if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### - { - if (file_len > DATA_BUF_SIZE - 1) - { - HTTPSock_Status[get_seqnum].file_start = start_addr; - HTTPSock_Status[get_seqnum].file_len = file_len; - send_len = DATA_BUF_SIZE - 1; - -///////////////////////////////////////////////////////////////////////////////////////////////// -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) - memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); - strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -#endif -///////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -#endif - } - else - { - // Send process end - send_len = file_len; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -#endif - } -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -#endif - } - else // remained parts - { -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; - } -#endif - send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; - - if(send_len > DATA_BUF_SIZE - 1) - { - send_len = DATA_BUF_SIZE - 1; - //HTTPSock_Status[get_seqnum]->file_offset += send_len; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -#endif - // Send process end - flag_datasend_end = 1; - } -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -#endif - } - -/*****************************************************/ - //HTTPSock_Status[get_seqnum]->storage_type == NONE - //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH - //HTTPSock_Status[get_seqnum]->storage_type == SDCARD - //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -/*****************************************************/ - - if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) - { - if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; - read_userReg_webContent_avr(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); - } -#ifdef _USE_SDCARD_ - else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) - { - // Data read from SD Card - fr = f_read(&fs, &buf[0], send_len, (void *)&blocklen); - if(fr != FR_OK) - { - send_len = 0; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -#endif - } - else - { - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } - } -#endif - -#ifdef _USE_FLASH_ - else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - // Data read from external data flash memory - read_from_flashbuf(addr, &buf[0], send_len); - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } -#endif - else - { - send_len = 0; - } - // Requested content send to HTTP client -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -#endif - - if(send_len) send(s, buf, send_len); - else flag_datasend_end = 1; - - if(flag_datasend_end) - { - HTTPSock_Status[get_seqnum].file_start = 0; - HTTPSock_Status[get_seqnum].file_len = 0; - HTTPSock_Status[get_seqnum].file_offset = 0; - flag_datasend_end = 0; - } - else - { - HTTPSock_Status[get_seqnum].file_offset += send_len; -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -#endif - } - -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -#ifdef _USE_SDCARD_ - f_close(&fs); -#endif -// ## 20141219 added end -} - - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len) -{ - uint16_t send_len = 0; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s); -#endif - //send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body); - send_len = sprintf_P((char *)buf, PSTR("%S%d\r\n\r\n%s"), PSTR(RES_CGIHEAD_OK), file_len, http_body); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len); -#endif - - send(s, buf, send_len); -} - - -static int8_t http_disconnect(uint8_t sn) -{ - setSn_CR(sn,Sn_CR_DISCON); - /* wait to process the command... */ - while(getSn_CR(sn)); - - return SOCK_OK; -} - - -//static void http_process_handler(uint8_t s, st_http_request * p_http_request) -//{ -// uint8_t * uri_name; -// uint32_t content_addr = 0; -// uint16_t content_num = 0; -// uint32_t file_len = 0; -// -// uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; -// -// uint16_t http_status; -// int8_t get_seqnum; -// uint8_t content_found; -// -// if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number -// -// http_status = 0; -// http_response = pHTTP_RX; -// file_len = 0; -// -// //method Analyze -// switch (p_http_request->METHOD) -// { -// case METHOD_ERR : -// http_status = STATUS_BAD_REQ; -// send_http_response_header(s, 0, 0, http_status); -// break; -// -// case METHOD_HEAD : -// case METHOD_GET : -// get_http_uri_name(p_http_request->URI, uri_buf); -// uri_name = uri_buf; -// -// if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html -// if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); -// if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); -// find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); -// printf("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); -// printf("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -//#endif -// -// if(p_http_request->TYPE == PTYPE_CGI) -// { -// content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); -// if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) -// { -// send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); -// } -// else -// { -// send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); -// } -// } -// else -// { -// // Find the User registered index for web content -// if(find_userReg_webContent(uri_buf, &content_num, &file_len)) -// { -// content_found = 1; // Web content found in code flash memory -// content_addr = (uint32_t)content_num; -// HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; -// } -// // Not CGI request, Web content in 'SD card' or 'Data flash' requested -//#ifdef _USE_SDCARD_ -//#ifdef _HTTPSERVER_DEBUG_ -// printf("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); -//#endif -// if((fr = f_open(&fs, (const char *)uri_name, FA_READ)) == 0) -// { -// content_found = 1; // file open succeed -// -// file_len = fs.fsize; -// content_addr = fs.sclust; -// HTTPSock_Status[get_seqnum].storage_type = SDCARD; -// } -//#elif _USE_FLASH_ -// else if(/* Read content from Dataflash */) -// { -// content_found = 1; -// HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; -// ; // To do -// } -//#endif -// else -// { -// content_found = 0; // fail to find content -// } -// -// if(!content_found) -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -//#endif -// http_status = STATUS_NOT_FOUND; -// } -// else -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -//#endif -// http_status = STATUS_OK; -// } -// -// // Send HTTP header -// if(http_status) -// { -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -//#endif -// send_http_response_header(s, p_http_request->TYPE, file_len, http_status); -// } -// -// // Send HTTP body (content) -// if(http_status == STATUS_OK) -// { -// send_http_response_body(s, uri_name, http_response, content_addr, file_len); -// } -// } -// break; -// -// case METHOD_POST : -// mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); -// uri_name = uri_buf; -// find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) -// -//#ifdef _HTTPSERVER_DEBUG_ -// printf("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); -// printf("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); -// printf("Type = %d\r\n", p_http_request->TYPE); -//#endif -// -// if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process -// { -// content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -//#ifdef _HTTPSERVER_DEBUG_ -// printf("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -//#endif -// if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) -// { -// send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); -// -// // Reset the H/W for apply to the change configuration information -// if(content_found == HTTP_RESET) HTTPServer_ReStart(); -// } -// else -// { -// send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); -// } -// } -// else // HTTP POST Method; Content not found -// { -// send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); -// } -// break; -// -// default : -// http_status = STATUS_BAD_REQ; -// send_http_response_header(s, 0, 0, http_status); -// break; -// } -//} - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request) -{ - uint8_t * uri_name; - uint32_t content_addr = 0; - uint16_t content_num = 0; - uint32_t file_len = 0; - - uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; - - uint16_t http_status; - int8_t get_seqnum; - uint8_t content_found; - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - http_status = 0; - http_response = pHTTP_RX; - file_len = 0; - - //method Analyze - switch (p_http_request->METHOD) - { - case METHOD_ERR : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - - case METHOD_HEAD : - case METHOD_GET : - get_http_uri_name(p_http_request->URI, uri_buf); - uri_name = uri_buf; - - if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html - if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); - if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); - find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); - PRINTF("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); - PRINTF("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) - { - content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else - { - // Find the User registered index for web content - if(find_userReg_webContent_avr(uri_buf, &content_num, &file_len)) - { - content_found = 1; // Web content found in code flash memory - content_addr = (uint32_t)content_num; - HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; - } - // Not CGI request, Web content in 'SD card' or 'Data flash' requested -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - printf("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); -#endif - if((fr = f_open(&fs, (const char *)uri_name, FA_READ)) == 0) - { - content_found = 1; // file open succeed - - file_len = fs.fsize; - content_addr = fs.sclust; - HTTPSock_Status[get_seqnum].storage_type = SDCARD; - } -#elif _USE_FLASH_ - else if(/* Read content from Dataflash */) - { - content_found = 1; - HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; - ; // To do - } -#endif - else - { - content_found = 0; // fail to find content - } - - if(!content_found) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -#endif - http_status = STATUS_NOT_FOUND; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -#endif - http_status = STATUS_OK; - } - - // Send HTTP header - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -#endif - send_http_response_header(s, p_http_request->TYPE, file_len, http_status); - } - - // Send HTTP body (content) - if(http_status == STATUS_OK) - { - send_http_response_body_avr(s, uri_name, http_response, content_addr, file_len); - } - } - break; - - case METHOD_POST : - mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); - uri_name = uri_buf; - find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); - PRINTF("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); - PRINTF("Type = %d\r\n", p_http_request->TYPE); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process - { - content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -#endif - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); - - // Reset the H/W for apply to the change configuration information - if(content_found == HTTP_RESET) HTTPServer_ReStart(); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else // HTTP POST Method; Content not found - { - send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); - } - break; - - default : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - } -} - - -void httpServer_time_handler(void) -{ - httpServer_tick_1s++; -} - -uint32_t get_httpServer_timecount(void) -{ - return httpServer_tick_1s; -} -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content) -{ - uint16_t name_len; - uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - content_len = strlen_P((const char *)content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len) -{ - uint16_t name_len; - //uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - //content_len = (uint32_t) sizeof(content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -//void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content) -//{ -// uint16_t name_len; -// uint32_t content_len; -// -// if(content_name == NULL || content == NULL) -// { -// return; -// } -// else if(total_content_cnt >= MAX_CONTENT_CALLBACK) -// { -// return; -// } -// -// name_len = strlen((char *)content_name); -// content_len = strlen((char *)content); -// -// web_content[total_content_cnt].content_name = malloc(name_len+1); -// strcpy((char *)web_content[total_content_cnt].content_name, (const char *)content_name); -// web_content[total_content_cnt].content_len = content_len; -// web_content[total_content_cnt].content = content; -// -// total_content_cnt++; -//} - -//uint8_t display_reg_webContent_list(void) -//{ -// uint16_t i; -// uint8_t ret; -// -// if(total_content_cnt == 0) -// { -// printf(">> Web content file not found\r\n"); -// ret = 0; -// } -// else -// { -// printf("\r\n=== List of Web content in code flash ===\r\n"); -// for(i = 0; i < total_content_cnt; i++) -// { -// printf(" [%d] ", i+1); -// printf("%s, ", web_content[i].content_name); -// printf("%ld byte, ", web_content[i].content_len); -// -// if(web_content[i].content_len < 30) printf("[%s]\r\n", web_content[i].content); -// else printf("[ ... ]\r\n"); -// } -// printf("=========================================\r\n\r\n"); -// ret = 1; -// } -// -// return ret; -//} - -uint8_t display_reg_webContent_list_avr(void) -{ - uint16_t i; - uint8_t ret; - - if(total_content_cnt == 0) - { - PRINTF(">> Web content file not found\r\n"); - ret = 0; - } - else - { - PRINTF("\r\n=== List of Web content in code flash ===\r\n"); - for(i = 0; i < total_content_cnt; i++) - { - PRINTF(" [%d] ", i+1); - PRINTF("%s, ", web_content[i].content_name); - PRINTF("%ld byte\r\n", web_content[i].content_len); - - - if(web_content[i].content_len < 30) - { - PRINTF("[%s]\r\n", web_content[i].content); - } - else - { - PRINTF("[ ... ]\r\n"); - } - //Dump head 16 bytes every file.. - /* - else - { - const char PROGMEM * tst_char = web_content[i].content; - if(strstr_P(web_content[i].content_name,PSTR("favicon.ico"))==NULL) - { - //ASCII Dump first 0x10 symbols, for all files without - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - else - { - //HEX dump first 0x10 symbols, for - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - } - */ - wdt_reset(); // WDT reset at least every sec - - } - PRINTF("=========================================\r\n\r\n"); - ret = 1; - } - - return ret; -} - -//uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -//{ -// uint16_t i; -// uint8_t ret = 0; // '0' means 'File Not Found' -// -// for(i = 0; i < total_content_cnt; i++) -// { -// if(!strcmp((char *)content_name, (char *)web_content[i].content_name)) -// { -// *file_len = web_content[i].content_len; -// *content_num = i; -// ret = 1; // If the requested content found, ret set to '1' (Found) -// break; -// } -// } -// return ret; -//} - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -{ - uint16_t i; - uint8_t ret = 0; // '0' means 'File Not Found' - - for(i = 0; i < total_content_cnt; i++) - { - if(!strcmp((const char *)content_name, (const char *)web_content[i].content_name)) - { - *file_len = web_content[i].content_len; - *content_num = i; - ret = 1; // If the requested content found, ret set to '1' (Found) - break; - } - } - return ret; -} - - -//uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -//{ -// uint16_t ret = 0; -// uint8_t * ptr; -// -// if(content_num > total_content_cnt) return 0; -// -// ptr = web_content[content_num].content; -// if(offset) ptr += offset; -// -// strncpy((char *)buf, (char *)ptr, size); -// *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) -// -// ret = strlen((void *)buf); -// return ret; -//} - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -{ - uint16_t ret = 0; - uint8_t * ptr; - - if(content_num > total_content_cnt) return 0; - - ptr = web_content[content_num].content; - if(offset) ptr += offset; - - //strncpy_P((char *)buf, (const char *)ptr, size); //not suit for case binary data - memcpy_P((char *)buf, (const char *)ptr, size); - *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - - //ret = strlen((void *)buf); //Useless for memcpy_P - ret = 0; //All ok - return ret; -} diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.h deleted file mode 100644 index 0ca80c2..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpServer.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - @file httpServer.h - @brief Define constants and functions related HTTP Web server. - */ - -#include - -#ifndef __HTTPSERVER_H__ -#define __HTTPSERVER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -// HTTP Server debug message enable -#define _HTTPSERVER_DEBUG_ - -#define INITIAL_WEBPAGE "index.html" -#define M_INITIAL_WEBPAGE "m/index.html" -#define MOBILE_INITIAL_WEBPAGE "mobile/index.html" - -/* Web Server Content Storage Select */ -//#define _USE_SDCARD_ -#ifndef _USE_SDCARD_ -//#define _USE_FLASH_ -#endif - -#if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_) -#define _NOTUSED_STORAGE_ -#endif - - -/* Watchdog timer */ -//#define _USE_WATCHDOG_ - -/********************************************* -* HTTP Process states list -*********************************************/ -#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */ -#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */ -#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */ -#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */ -#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */ - -/********************************************* -* HTTP Simple Return Value -*********************************************/ -#define HTTP_FAILED 0 -#define HTTP_OK 1 -#define HTTP_RESET 2 - -/********************************************* -* HTTP Content NAME length -*********************************************/ -//#define MAX_CONTENT_NAME_LEN 128 ? Wastefull -#define MAX_CONTENT_NAME_LEN 16 - -/********************************************* -* HTTP Timeout -*********************************************/ -#define HTTP_MAX_TIMEOUT_SEC 3 // Sec. - -typedef enum -{ - NONE, ///< Web storage none - CODEFLASH, ///< Code flash memory - SDCARD, ///< SD card - DATAFLASH ///< External data flash memory -}StorageType; - -typedef struct _st_http_socket -{ - uint8_t sock_status; - uint8_t file_name[MAX_CONTENT_NAME_LEN]; - uint32_t file_start; - uint32_t file_len; - uint32_t file_offset; // (start addr + sent size...) - uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ... -}st_http_socket; - -// Web content structure for file in code flash memory -#define MAX_CONTENT_CALLBACK 20 - -typedef struct _httpServer_webContent -{ - uint8_t * content_name; - uint32_t content_len; - uint8_t * content; -}httpServer_webContent; - - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist); -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)); - -//void httpServer_run(uint8_t seqnum); -void httpServer_run_avr(uint8_t seqnum); - -//void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content); -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content); - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len); - -//uint8_t find_userReg_webContent(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); - -//uint16_t read_userReg_webContent(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); - -//uint8_t display_reg_webContent_list(void); -uint8_t display_reg_webContent_list_avr(void); - -/* - * @brief HTTP Server 1sec Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void httpServer_time_handler(void); -uint32_t get_httpServer_timecount(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.c deleted file mode 100644 index 77c9a9d..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file httpUtil.c - * @brief HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -#include "httpUtil.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - - if(predefined_get_cgi_processor(uri_name, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - ; - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} - -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - uint8_t val = 0; - - if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - val = 1; - len = sprintf((char *)buf, "%d", val); - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.h deleted file mode 100644 index f2c384a..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/Internet/httpServer_avr/httpUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file httpUtil.h - * @brief Header File for HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __HTTPUTIL_H__ -#define __HTTPUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "httpServer.h" -#include "httpParser.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len); -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/bin2hex_v2.py b/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/bin2hex_v2.py deleted file mode 100644 index cfd3991..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/bin2hex_v2.py +++ /dev/null @@ -1,52 +0,0 @@ -# -- coding: utf-8 -- -#Reading file in binary & print in HEX AVR PROGCHAR ARRAY every symbol & to ***.h -#Ethercard helper utilites for something like: -#(c) Ibragimov M. Russia Togliatty 19/08/2014 -# .PS used for build <***.h> from images(*.gif, *.jpg), *.css, static htm(l) pages, javascript etc.. -import sys, os -if len(sys.argv) < 2: - sys.exit('Usage: %s file-name' % sys.argv[0]) - -file_name = sys.argv[1] -if not os.path.exists(sys.argv[1]): - sys.exit('ERROR: Filename %s was not found!' % file_name) -else: - print('File %s is OK!' % file_name) -file_out = file_name.replace(".", "_") + ".h" -print('File_to_write is: %s' % file_out) -fhex = open(file_out, "w") -fhex_str = 'const char %s[] PROGMEM = {' % file_name.replace(".", "_") -print(fhex_str) -fhex.write(fhex_str + '\n') -with open(file_name, "rb") as f: - byte = f.read(1) - i = 0 - fhex_size = 0 - _str = "" - while byte != "": - # Do stuff with byte. - _byte = f.read(1) - fhex_size = fhex_size + 1 - if _byte != "": - #print ('%s, ' % hex(ord(byte))) - _str = _str + "%s," % hex(ord(byte)) - else: - #Last byte wo <,> - #print hex(ord(byte)) - _str = _str + "%s" % hex(ord(byte)) - if i < 15: - print _str - fhex.write(_str + '\n') - byte = _byte; - i = i + 1; - if i > 15: - i = 0; - print _str - fhex.write(_str + '\n') - _str = "" -print'};' -fhex.write('};\n') -_str = '%s: %d bytes' % (file_name, fhex_size) -print(_str); -fhex.write('//' + _str + '\n'); -fhex.close() diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet.png b/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet.png deleted file mode 100644 index 90d075a..0000000 Binary files a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet.png and /dev/null differ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet_png.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet_png.h deleted file mode 100644 index a316c18..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/brd_wiznet_png.h +++ /dev/null @@ -1,860 +0,0 @@ -const char brd_wiznet_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x3,0x7f,0x0,0x0,0x3,0x91,0x1,0x3,0x0,0x0,0x0,0x78,0x37,0x89, -0x3e,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54,0x78,0xda,0xed,0x9d,0x4f, -0x88,0x24,0x47,0xbe,0xdf,0x33,0x95,0x62,0x72,0x17,0x86,0x49,0x2d,0xef,0xd2,0x82, -0x66,0x52,0x8b,0x6c,0xf6,0x62,0xcc,0xc,0xc2,0xb8,0x5,0xed,0x4e,0x3d,0x16,0x2c, -0x1e,0x6,0xeb,0x6c,0xf0,0x61,0x16,0xc1,0xd3,0xc1,0x97,0x1a,0xe6,0xe0,0x16,0x2e, -0x3a,0xab,0xdd,0x8b,0xda,0x7,0xa1,0x32,0xf8,0x22,0xc1,0xb0,0x7d,0xf4,0xd5,0xe0, -0xcb,0x33,0x98,0x37,0x59,0x2e,0x31,0xe5,0x83,0x50,0xfb,0xea,0x93,0xb2,0xb6,0x96, -0xad,0x8b,0xb0,0xb2,0xdc,0x87,0x8d,0xf6,0x8b,0xcd,0x78,0xbf,0x5f,0x44,0x64,0x66, -0x44,0x66,0x56,0x66,0x64,0x56,0x56,0xeb,0x8f,0xa7,0x44,0xcd,0x1f,0x4d,0x77,0x7d, -0x3a,0x33,0xe2,0xf7,0xe7,0xfb,0x8b,0x5f,0x44,0x5a,0xec,0x6e,0x5f,0xa9,0xf5,0xa, -0xf8,0xa,0xf8,0xa,0xf8,0xe3,0x6,0xde,0x5e,0xde,0x31,0x70,0x73,0x71,0xc7,0xc0, -0xd5,0xe3,0x3b,0x6,0xae,0xdf,0xfd,0xa9,0x3,0xff,0xf8,0xf1,0x5d,0x3,0x9f,0xde, -0x31,0x30,0xf9,0xf0,0x8e,0x81,0x64,0xfd,0x3d,0x7b,0x1a,0x3a,0xb6,0x1e,0x1c,0x38, -0x71,0xe8,0xaf,0x67,0xcb,0x74,0xe4,0x3d,0xf,0xae,0xbe,0xb6,0xf7,0xa,0x24,0x1c, -0x38,0x39,0xf1,0xd7,0x93,0x88,0x8e,0xdc,0xbf,0xf1,0xfd,0xcf,0xac,0x61,0x5d,0xdb, -0x77,0x25,0x60,0x70,0xfd,0xe0,0x4d,0xf6,0xd9,0x43,0xef,0xf2,0xf9,0x57,0xe3,0x67, -0x8b,0x77,0x0,0x78,0x3a,0xac,0x6b,0x9b,0x97,0x7e,0x80,0xe0,0xfa,0x1f,0xbf,0xc9, -0xfc,0x93,0xf,0xdc,0xe7,0x5f,0x9f,0x3e,0x5b,0xbf,0x93,0xfa,0xf,0xc6,0xc3,0xba, -0xb6,0x55,0xe9,0x7,0x8,0xae,0xff,0xd1,0x17,0x2c,0xa0,0x1f,0x7c,0x44,0xbf,0x1a, -0x3d,0x5b,0x3c,0x3a,0x7e,0xf8,0x60,0xd8,0x2b,0x5c,0x6f,0xf4,0xbf,0xdf,0xf8,0xd7, -0xff,0xe0,0x73,0x37,0xa0,0x8b,0x35,0x89,0xff,0xef,0xc8,0x1d,0x1d,0xfe,0xee,0x5f, -0xe,0x3b,0x86,0xeb,0xdb,0x12,0xf0,0xa,0x81,0xc7,0x87,0xeb,0xf5,0x26,0xfe,0xe3, -0xe8,0xe1,0xb3,0x37,0x9f,0x7f,0xed,0xec,0x15,0x18,0xfb,0xd7,0xff,0xf0,0xb,0x76, -0x7c,0xe0,0xae,0x57,0x5f,0xfd,0xf5,0xb3,0xf4,0xd9,0x17,0xcf,0xbf,0xe,0xf7,0x7a, -0x4b,0x63,0xef,0xfa,0x9f,0x7c,0xc1,0xfc,0x3,0x67,0xbd,0xf8,0xfa,0xbd,0xbf,0x48, -0x9f,0xfd,0x47,0xeb,0xb5,0x61,0x81,0x37,0xa5,0x49,0xb3,0xbe,0xbe,0x7e,0xfc,0x5, -0x9b,0xbe,0x79,0xb3,0x9e,0x7e,0x5,0xc0,0xcd,0x1b,0x43,0x3,0x89,0xab,0xff,0x7d, -0x1,0xc0,0xcf,0x9d,0xc9,0xe3,0x1b,0x30,0xfc,0xb3,0x67,0x94,0x80,0xa7,0x19,0x16, -0x48,0xbd,0x12,0x70,0x81,0xc0,0xf8,0xe9,0x66,0x6d,0xc5,0xe9,0x33,0x4a,0xc3,0x3e, -0x40,0x7a,0xcf,0x83,0xf,0x5e,0xe0,0xc7,0xb1,0xc4,0xa,0xf6,0x9f,0xb5,0x11,0xcb, -0x85,0x5b,0x27,0x80,0xb1,0xe5,0x97,0xfe,0xf5,0xc5,0xf0,0xc0,0xc4,0x72,0x58,0x22, -0x81,0x91,0xe5,0xdd,0x1,0xf0,0xc9,0x9c,0x25,0x73,0x9,0xf4,0x3d,0x96,0xfe,0x66, -0xdf,0xc0,0xcd,0x8a,0x6d,0x96,0x2,0xf8,0xa5,0x37,0x65,0xf4,0xc9,0x5d,0x0,0x13, -0x1c,0x3f,0x97,0xbd,0x74,0xa7,0x8c,0x7c,0x15,0xde,0x1,0x90,0xbc,0xcf,0x81,0xb, -0x67,0xca,0x6e,0xbf,0xbe,0xb,0x20,0x75,0x5,0x70,0xd6,0xa,0x4c,0xc0,0x5b,0xa7, -0x87,0x60,0x3d,0xdf,0xf4,0x6,0x32,0x0,0xa6,0x2e,0x4b,0xc2,0x5,0x5b,0xc4,0x0, -0xfc,0x9d,0x19,0xf0,0x6a,0x30,0xe0,0xf3,0xe6,0x5b,0x1a,0xec,0xc,0xc,0xc1,0x2c, -0x18,0x18,0x7f,0xb0,0x60,0xf3,0x4,0xbc,0xce,0x81,0xe2,0xac,0x6b,0xbe,0x3e,0xf0, -0x7e,0x99,0xfe,0xeb,0xe3,0xe3,0x4f,0xee,0x79,0x3f,0x9f,0xf7,0xf3,0x34,0xc1,0x25, -0x23,0xe1,0x25,0xa3,0xbe,0xf0,0x34,0xe9,0xbb,0xcd,0xc0,0x13,0xd7,0x4a,0xff,0xd5, -0xd1,0xe1,0x6b,0xaf,0xdf,0xb3,0xcf,0x7b,0x1,0x69,0x0,0xb6,0x7,0xc0,0xd4,0xaf, -0xfa,0xd2,0x3a,0xe0,0xf1,0x87,0x7,0xe9,0x5f,0x3d,0xfe,0xf4,0xc3,0xe7,0x2f,0x1f, -0x3f,0xdf,0x1,0x8,0x86,0x6f,0xa,0xbc,0x39,0x4e,0xff,0xea,0x9d,0xaf,0x6e,0xae, -0x3e,0xf9,0xd8,0x1a,0x24,0xf3,0x4e,0xff,0x9d,0x12,0xe1,0xed,0x7a,0xe0,0xbf,0x0, -0xe0,0xf3,0x7b,0x3,0x1,0xe9,0xa8,0x1d,0xf8,0x6f,0x10,0xf8,0xf2,0x63,0xbf,0x1f, -0x30,0x2,0xcb,0x9a,0x40,0x68,0x7,0xc3,0x4f,0x21,0x5a,0x10,0xa2,0xdf,0xd2,0xe9, -0x45,0x75,0xc,0x3f,0x7c,0xfc,0xe9,0xcd,0xe7,0x7d,0xc7,0x90,0x4d,0x1c,0x9,0x73, -0x19,0x5,0xe0,0x2d,0xd,0x75,0x60,0x29,0x11,0x3c,0x86,0x59,0xfa,0xe1,0xa3,0xc3, -0x9b,0xdf,0xf6,0x9d,0xa5,0xc,0xe2,0xa1,0x80,0x81,0x2d,0x22,0x30,0xd5,0x81,0xf, -0xec,0xb2,0x1d,0xbe,0x9d,0x7e,0x78,0x7c,0x7c,0xf3,0xdb,0x5f,0xf5,0xb4,0x43,0xa, -0x1f,0x48,0x1d,0x91,0x30,0x25,0xf0,0x2e,0x1,0xd3,0xc3,0x37,0x6a,0x7c,0x8d,0x48, -0xfc,0x7b,0xa6,0x18,0xbf,0x80,0xf7,0xdb,0x0,0x7b,0x1f,0x26,0x9,0x58,0x87,0x7a, -0x4b,0xf1,0x3,0x8e,0x8f,0xb6,0x0,0x53,0xa7,0xa7,0x6b,0x7b,0x2c,0xa4,0x35,0xc2, -0x66,0xf0,0xa6,0x44,0xab,0x62,0xa4,0xc7,0xa7,0xdb,0xae,0xd0,0xed,0x9,0x7c,0xa, -0x6f,0x48,0x78,0x31,0xe8,0x63,0xa6,0x91,0xda,0x6d,0xc0,0x5d,0xe3,0x61,0xe9,0xa, -0x99,0xb3,0x67,0x60,0x79,0xc,0x4b,0x85,0xa1,0xe1,0x81,0xe5,0x59,0xca,0xd8,0x77, -0x1a,0xf0,0x60,0x34,0x74,0x15,0xa3,0x64,0x87,0x65,0xa0,0xf5,0x64,0x68,0x60,0xc9, -0xd3,0x94,0x80,0xcc,0x5a,0xe,0xd,0x2c,0xf9,0x52,0x15,0x88,0xce,0xfb,0x7c,0xb5, -0xf7,0xc2,0xd0,0x77,0x8d,0xd1,0x62,0xaf,0xc0,0xbd,0xa8,0xa7,0x3b,0x7,0x26,0xd2, -0xd,0xaf,0xb8,0xba,0xa8,0xde,0xd2,0xe9,0xc5,0xd0,0xc0,0x50,0x40,0x71,0x32,0xce, -0x6b,0x80,0x9e,0xbd,0x77,0xa0,0xf2,0x5a,0xee,0x3,0x18,0x8,0x68,0xc,0x7f,0x9e, -0x31,0xdd,0x97,0x32,0xc8,0x1e,0xef,0x5b,0x43,0xbb,0x36,0x30,0x3d,0xea,0x63,0x42, -0x2c,0xe0,0x54,0xfd,0xe,0xd0,0xa7,0x87,0x8f,0x86,0x9e,0xa5,0x60,0xf3,0x69,0x6, -0xc5,0x37,0x55,0x73,0xd6,0x3d,0x38,0x6f,0x7e,0x1f,0x2f,0x24,0xb8,0x94,0x62,0x90, -0x70,0x1f,0xc0,0x58,0x81,0x3a,0x3a,0x70,0xc9,0xf6,0x1,0x54,0x67,0xcc,0x4c,0x7, -0x82,0x59,0xec,0x1,0xa8,0xce,0x18,0x80,0xef,0x1f,0xa8,0xcd,0x98,0x40,0x3,0xe2, -0xbf,0xe,0x1f,0x80,0xd5,0x19,0x3,0x70,0x62,0xe9,0xe5,0xb3,0xe1,0xe3,0x21,0xf7, -0x2f,0x97,0x32,0xed,0xd3,0x81,0xab,0xdb,0xbd,0xc4,0xc3,0xcc,0x6d,0xe3,0x7b,0xaa, -0x7b,0xb6,0xdb,0x3b,0x9,0xc0,0x8a,0xc5,0xdc,0xde,0x41,0x3c,0x54,0x6b,0x6d,0xf1, -0x3e,0x96,0xf3,0x78,0xbd,0xd4,0xf2,0x61,0xec,0x7c,0x7e,0x4b,0xd5,0x5a,0xdb,0x1f, -0xdf,0x64,0x69,0x30,0x38,0xf0,0x75,0x1d,0xa8,0xd6,0xda,0xd6,0x3f,0x67,0xa9,0x3f, -0x34,0x90,0xc8,0x7c,0x34,0xe1,0x19,0x9b,0x5e,0xfa,0x5a,0x9f,0x73,0x2b,0x1d,0xba, -0x5e,0xfa,0x6b,0x10,0x33,0x97,0x2c,0xf6,0xdd,0x2a,0x70,0x29,0xac,0x74,0x58,0x20, -0x48,0xa7,0xcd,0x6a,0xc1,0x7e,0xef,0x9,0xb3,0xd0,0x6a,0x6d,0x1b,0x19,0x94,0x7, -0xaf,0x26,0x2,0x70,0xe5,0x8a,0x12,0xb4,0x5e,0x6b,0x13,0xbe,0x7d,0x3f,0xc0,0xb, -0x1,0x54,0x6b,0x6d,0xa2,0x34,0xb6,0x2f,0xe0,0x4c,0x0,0xd5,0x5a,0x1b,0x66,0x6d, -0xd4,0xdf,0x17,0x10,0xc4,0x61,0x5c,0x72,0x6d,0x3c,0xd5,0x77,0x7,0x9f,0xa5,0x58, -0xd5,0xbf,0x64,0x4b,0x10,0x87,0x49,0x30,0xad,0xd6,0xda,0x2e,0xee,0x10,0x18,0x87, -0xfb,0x0,0xe2,0x42,0x89,0x23,0x6a,0xde,0xc4,0x2f,0x1,0x3d,0x99,0xf3,0xc,0xee, -0x69,0x5c,0xe1,0x69,0x68,0x9,0xc8,0x2b,0x1a,0x89,0x2e,0x5f,0xad,0x86,0x97,0x6d, -0xbe,0xd8,0x25,0x7c,0x69,0x5a,0x2,0xf2,0xfc,0x9f,0xe8,0x9,0x40,0xe3,0x6b,0xe7, -0xc6,0x81,0xaa,0xae,0xd8,0x2f,0x90,0x54,0x3d,0x77,0xa3,0x55,0x92,0x9d,0x23,0x7e, -0xb8,0x7,0x20,0x75,0x57,0x7c,0xc1,0x92,0x1c,0xf8,0x2c,0x39,0xc8,0xa,0x77,0x3e, -0x8b,0x20,0xf4,0x62,0x3a,0xa3,0xd7,0xfa,0x6,0x0,0x12,0x67,0xc5,0x17,0x2c,0x71, -0x96,0xe6,0xb,0x96,0x0,0x9c,0x9c,0x5,0xfc,0xa,0x7,0x7,0x26,0xf6,0xa,0xec, -0x50,0xac,0xae,0xe5,0xb,0x96,0x0,0xb4,0x4e,0x2,0x1c,0xc3,0xd4,0xb2,0x86,0x6, -0x3e,0x1,0x20,0x38,0xee,0xe5,0x85,0xcb,0xe6,0x4e,0x1,0xbc,0xff,0x20,0xc0,0x59, -0xba,0x7,0x60,0xf2,0x21,0xdb,0x80,0xe3,0x5e,0x2d,0x16,0x6c,0xb1,0x98,0xe6,0xc0, -0x87,0xf7,0x2,0xb4,0xc3,0x3d,0x0,0xc9,0xdb,0x6c,0x93,0xbc,0xaf,0x1,0x27,0x30, -0x96,0xfe,0x6b,0x1,0xf7,0x34,0xaf,0x6b,0x63,0x18,0x5b,0x2c,0xdc,0x15,0x48,0x1d, -0xb6,0x21,0x6e,0x15,0x38,0x81,0x49,0x3,0xa1,0x69,0x52,0x2,0x36,0x5,0x64,0x33, -0x60,0xea,0xf0,0x5,0xcb,0xa,0x30,0x12,0xb3,0x34,0x2a,0x1,0xa3,0x9d,0xaf,0x30, -0x84,0x68,0x1,0xca,0x69,0x9,0x91,0x76,0xce,0xc4,0xa4,0x59,0xc2,0x18,0x7a,0xa0, -0x17,0xd7,0x15,0xe3,0x5f,0x95,0xc5,0x55,0xf,0x60,0x70,0x1,0x50,0x8,0x4f,0x0, -0x9d,0xc9,0x2c,0x34,0x39,0xf3,0x99,0x2b,0xef,0x5d,0x52,0x2,0xfe,0x97,0x5d,0x81, -0x24,0x98,0xf3,0xf5,0xc3,0x4,0x60,0x4b,0x99,0x67,0x13,0x0,0x5e,0xd2,0x20,0x2b, -0x2c,0x68,0xc0,0x78,0x67,0xd7,0x16,0xac,0xf8,0x72,0x1e,0x1,0xd8,0x46,0x2a,0x9, -0xa,0xc0,0x45,0xf6,0xe7,0x12,0xf0,0xcb,0x7d,0x3a,0xef,0x1a,0x2d,0x49,0x3e,0xbd, -0x13,0x20,0xe8,0x80,0x8,0x26,0xee,0x1c,0x80,0x6f,0xde,0xd,0xf0,0x81,0x1d,0xf9, -0xa9,0x7f,0x1,0xc0,0x7f,0xb6,0xb3,0xa7,0x29,0xd5,0x4b,0x33,0xe1,0xd,0xd3,0x7, -0x47,0x51,0x8c,0xe4,0xfa,0xd3,0x8f,0x29,0x8,0xa9,0x77,0x1,0x18,0xee,0xc,0x2c, -0x95,0x2f,0xb3,0x12,0x83,0x27,0xa,0x2a,0x62,0xde,0xae,0xbf,0xa2,0x0,0xfc,0x0, -0x22,0x24,0x61,0x77,0x3,0xfc,0x14,0x80,0xf4,0x3,0xf0,0x47,0xc9,0xee,0xc0,0xa0, -0x52,0xfd,0x2a,0x55,0x6e,0x70,0xc,0xef,0x23,0x70,0x61,0x83,0x20,0xd8,0x3d,0xc5, -0xf0,0x2a,0xd5,0xaf,0x1c,0x7e,0x9e,0x25,0xde,0xf1,0x31,0x2,0xd7,0x30,0x86,0xd1, -0xee,0x49,0x94,0x5b,0xa9,0x7e,0xe5,0xd0,0x28,0xab,0x12,0xaf,0x29,0x0,0x89,0xb, -0xc0,0xff,0xb0,0x3b,0xb0,0xe6,0x1e,0x66,0x57,0x9c,0xc1,0x1,0x48,0x0,0xe8,0x0, -0xf0,0x60,0x77,0x60,0xa9,0x5e,0x9a,0x5f,0xb1,0x2,0x6,0x20,0x98,0xc5,0xed,0xcd, -0xbb,0xec,0xf7,0x47,0xbb,0x3,0x5b,0x66,0xc,0x17,0xa4,0xeb,0xd4,0xa6,0x6c,0x73, -0x73,0xc1,0xe2,0xd3,0xdd,0x81,0x6d,0x33,0xc6,0xe5,0x42,0xd1,0xa5,0xec,0x66,0x3, -0xb9,0xdd,0xee,0x76,0xd8,0x3a,0x63,0x34,0x7d,0xb8,0x1c,0x0,0x58,0x3b,0x63,0x4a, -0xf0,0x5c,0x2c,0xae,0x86,0x0,0xea,0xf5,0x52,0xee,0x5b,0x10,0x8a,0x1,0x98,0x84, -0x85,0x3e,0xe4,0xc0,0xf9,0x10,0xc0,0x3a,0xb7,0x2d,0x5d,0x37,0x46,0x5f,0xd,0x71, -0x31,0x4,0xb0,0xcb,0xcb,0xb9,0x63,0x60,0xfa,0xf6,0x1d,0x3,0xe9,0x87,0xbb,0x3, -0xcb,0xd,0xad,0x9,0x26,0x9e,0x52,0x1f,0x4e,0x66,0xa5,0x24,0x8a,0xc,0x30,0x4b, -0xcb,0xd,0xad,0x31,0x36,0x62,0x49,0x7d,0x88,0x42,0x46,0x3,0x6e,0x86,0x8,0xc0, -0xbc,0x4e,0x53,0x34,0xb4,0x46,0x96,0x9f,0xe9,0x43,0x50,0x4e,0xa1,0xae,0x9e,0x56, -0xb1,0x35,0x80,0x3e,0x9c,0x73,0x7d,0x98,0x35,0xb4,0x46,0x27,0x7e,0xa6,0xf,0xd3, -0xfb,0x7,0x39,0x50,0xd4,0x67,0xdc,0x21,0x80,0x58,0xdc,0x8b,0x5,0xf0,0xa5,0x37, -0x65,0x2f,0x7d,0x3f,0xd3,0x87,0xe9,0xc9,0x71,0xe,0xbc,0xe2,0xbf,0x7e,0x37,0x14, -0x30,0x91,0xfd,0xa5,0xee,0x94,0x2d,0x3c,0x3f,0xd3,0x87,0x8,0xcc,0xf4,0xe1,0xd5, -0x70,0x82,0x94,0x37,0xb4,0xca,0xfe,0xd2,0x39,0x0,0x2f,0xfd,0x4c,0x1f,0x72,0xe0, -0x64,0x2f,0xc0,0xac,0xa1,0x75,0x9,0xc0,0xb9,0x9f,0xe9,0x43,0xe,0x8c,0x6,0x7, -0x62,0xbb,0x27,0x44,0xa,0x12,0x8a,0x76,0xcf,0x79,0xec,0x67,0xfa,0x30,0xf5,0xc0, -0x79,0xc7,0x3f,0x7e,0xa0,0x14,0xa4,0xd8,0x5f,0x9a,0xd9,0xa1,0x14,0xa4,0xa9,0xb, -0xf1,0x30,0x19,0x1a,0x98,0x35,0xb4,0xa6,0x7e,0xe1,0x69,0x32,0x41,0xea,0x26,0xb9, -0x20,0x1d,0xe,0x58,0xee,0x2f,0x45,0x5f,0x9a,0x9,0xd2,0xcb,0x4d,0xee,0xda,0x86, -0x3,0x1a,0xbe,0x5e,0x1,0x3b,0x0,0x4b,0x4d,0x58,0xc9,0x23,0x30,0x85,0x27,0xf0, -0xbf,0x21,0x4d,0xc4,0x78,0x78,0x7e,0x31,0x34,0xb0,0xd4,0x66,0x96,0xbc,0x5,0xc0, -0xf7,0x0,0x38,0x81,0x7f,0x82,0x64,0xf8,0xdc,0x19,0x1a,0x58,0x6a,0xa4,0x43,0xb3, -0x88,0x60,0xa6,0x4e,0xe0,0x8d,0x91,0xc2,0xb2,0x87,0x36,0x8b,0x52,0xab,0xe0,0xfc, -0x35,0x9f,0x7d,0xf2,0x3a,0xc4,0xc3,0xd7,0x21,0x1e,0xfe,0x2c,0x4c,0xf,0xde,0x18, -0xda,0xf0,0x4b,0xcd,0x90,0x18,0x2d,0xa6,0xf,0x20,0x1e,0x42,0x0,0x3e,0x39,0xc, -0xb3,0x86,0xd6,0x1,0x5d,0x5b,0xa9,0xdd,0x73,0x31,0x5,0xe0,0x43,0x0,0x9e,0x88, -0x0,0x2c,0x9b,0x3f,0x6,0x4,0x96,0x1a,0x5a,0xf7,0xf,0xbc,0xeb,0x2b,0xac,0x8c, -0xe1,0xbe,0x81,0xe5,0x59,0xba,0x77,0x60,0xd9,0xe,0x31,0x1e,0x62,0x8a,0x61,0x59, -0x5a,0x5e,0xba,0x3f,0x4f,0xb3,0x7f,0x60,0xc9,0x97,0xee,0x1f,0xf8,0x2a,0x1e,0xb2, -0x3d,0x9b,0x5,0x64,0x8a,0xc,0x32,0x45,0x16,0x81,0x6a,0x9b,0x4,0x6c,0xf8,0xcc, -0xfb,0xce,0x81,0x4,0xbe,0x82,0xd8,0x62,0x8f,0x58,0x8c,0x6f,0x80,0x46,0x0,0x9d, -0xc0,0x1b,0xa5,0xa2,0xdc,0x28,0x34,0xa0,0x2f,0x95,0xa9,0x21,0xa,0xb1,0x8,0xdf, -0xb6,0x34,0x4d,0xe1,0xf,0x52,0xb9,0x86,0x39,0x20,0x70,0xc,0x40,0xc8,0x76,0x97, -0x90,0xf4,0xce,0xf1,0xbd,0x64,0xec,0x72,0xce,0x98,0x77,0xc1,0x52,0xf,0xf3,0xe3, -0xc1,0x81,0x90,0xf0,0x6e,0x20,0xdb,0x45,0xf5,0xbe,0xc0,0x37,0x24,0xbf,0x53,0x8, -0x57,0xfe,0x9c,0xa5,0xc1,0x2,0xde,0xd3,0x57,0xc0,0x9f,0x8,0xf0,0x7a,0x40,0xb3, -0x70,0xe0,0xed,0xe6,0xeb,0xf8,0x5b,0xa2,0xc5,0x2b,0xe0,0xe0,0xd1,0xe2,0x15,0xf0, -0x15,0xf0,0xa7,0xe,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0x21,0x6,0x77,0x2c,0xf0,0xee, -0x7e,0x85,0x44,0xf6,0xb3,0xf1,0x6d,0xe6,0x4d,0x40,0x5e,0x52,0x76,0x76,0x7,0x26, -0x1c,0x18,0xb6,0x3,0xb3,0x5e,0xc2,0x5d,0x81,0x71,0x76,0x3f,0x5b,0x80,0x69,0xd6, -0xda,0xb7,0x2b,0x90,0xf,0xd,0x66,0x77,0x2d,0x40,0x6a,0x65,0xb7,0x62,0x47,0xa0, -0xa8,0xf6,0x7b,0x3f,0x3c,0x20,0x29,0xe6,0xf2,0x6e,0x40,0xf1,0x39,0x6e,0x2b,0x50, -0x4c,0x2e,0xcb,0xdf,0x15,0x28,0xe7,0x82,0xd3,0xa,0x14,0x93,0xcb,0xf2,0x76,0x5, -0xd2,0xbc,0x75,0xb6,0x5,0x18,0xe5,0xb7,0x62,0x37,0x20,0xc9,0x3b,0x59,0x5b,0x80, -0x93,0xfc,0x56,0xec,0x6,0x94,0x43,0x3,0xb3,0xaf,0xa,0x4c,0x8b,0x11,0xb,0x59, -0xd1,0x63,0xbb,0x1b,0x30,0xce,0x3d,0x69,0x33,0x30,0xb5,0xac,0x8e,0x76,0xb1,0x5, -0x28,0x87,0x6,0x3e,0xba,0xf9,0x96,0x52,0xd5,0xc7,0x77,0x2,0x2a,0xf1,0xc1,0x67, -0x45,0x17,0xb6,0xd7,0x2,0x24,0xea,0x37,0xf5,0x5,0x7a,0xb9,0x55,0xe0,0xec,0xab, -0x1,0x16,0xc7,0x3c,0x86,0x89,0xf2,0x4d,0xdd,0x80,0x13,0xd,0x98,0xdf,0x29,0xa7, -0x6e,0xc,0x8b,0x29,0x19,0xc6,0xc5,0x4f,0xd6,0x11,0xa8,0xbc,0xa6,0x85,0x55,0x80, -0x21,0xd6,0x0,0xdf,0x29,0x80,0x51,0xf1,0x93,0xed,0x4,0x4c,0x8a,0x96,0xf2,0x1a, -0xe0,0xb3,0x2,0x38,0x51,0xba,0xeb,0x77,0x1,0xc6,0x45,0x86,0xd1,0xc,0x54,0x9b, -0xdd,0x77,0x1,0x46,0xc5,0x94,0x6d,0x4,0x9e,0x15,0xc0,0x70,0x27,0x60,0x31,0x85, -0xbc,0x46,0xe0,0xa9,0x9e,0x6c,0xf5,0x7,0x16,0x9f,0xe3,0x36,0x7a,0x9a,0x91,0x6e, -0xbd,0xbd,0x81,0x69,0xf1,0x39,0x4e,0x23,0xf0,0x89,0x66,0x4c,0xfd,0x81,0x54,0xd9, -0xdb,0xd1,0xe8,0x69,0xde,0x53,0x6e,0xc5,0x2e,0x40,0xa2,0xf8,0x9d,0x17,0x86,0x99, -0xb7,0xb3,0xb,0x30,0x69,0xce,0xbc,0x3f,0xf,0x6b,0x80,0xf6,0x2e,0xc0,0xb8,0x19, -0x78,0x10,0x68,0x40,0x3f,0x19,0x6,0xe8,0xa4,0x5b,0x80,0xe9,0x3b,0xbe,0x6,0x14, -0xbf,0xed,0xe,0xf4,0x85,0xf9,0xd7,0x0,0x9f,0x5d,0x7d,0xaf,0x40,0x47,0x75,0x4c, -0x6d,0x7b,0x7d,0x9a,0x80,0x32,0xe7,0xac,0x1,0x7e,0xa4,0x1,0x5d,0xa6,0x8d,0x79, -0xd3,0x2b,0x6c,0x2,0xda,0x32,0x48,0xd5,0x1,0xb5,0x31,0xf4,0xc5,0x17,0x1a,0xdc, -0xd2,0xb4,0x11,0xe8,0xca,0xb8,0x5f,0x33,0x4b,0xef,0x69,0xb3,0x34,0x10,0xf1,0x7a, -0x67,0xa0,0x57,0x7c,0x5e,0x19,0xf8,0x99,0x66,0x87,0xa1,0xf8,0xc9,0x76,0x6,0xfa, -0x32,0x77,0xb,0xda,0x3c,0x4d,0xe,0x94,0xe5,0x7b,0x74,0xb5,0x14,0xbe,0x8d,0x5a, -0x21,0xaf,0xf4,0x27,0xf8,0xb6,0xb1,0xd2,0xdf,0x1f,0xf8,0x77,0x2a,0x50,0xfe,0x6e, -0x67,0x8b,0x5c,0xb8,0xb2,0x46,0xf8,0x6,0xe4,0xac,0xca,0x1f,0xca,0x2a,0x7f,0x33, -0x30,0x90,0xe9,0x70,0x1b,0xd0,0x96,0x29,0x98,0x4d,0xc1,0x40,0xc4,0xda,0xa1,0xcb, -0x37,0x5b,0x25,0xbc,0xc5,0x5,0x8d,0x2b,0xe0,0x6b,0xf9,0x13,0xab,0x19,0x18,0xca, -0x84,0xdf,0x18,0x48,0xe0,0x8f,0x84,0x97,0x30,0x1d,0x5e,0xc2,0x8c,0x79,0x9,0xd3, -0xcb,0x4a,0x98,0xf0,0x3e,0x1b,0x4,0xe8,0xca,0x44,0xdd,0x86,0x2f,0x86,0x6f,0xb0, -0xe1,0x9b,0x6d,0xf8,0xbb,0x3,0x6f,0x17,0x60,0x2e,0x7c,0x8d,0x7,0x63,0xec,0xc3, -0xfb,0xa4,0x11,0x98,0x69,0x28,0x63,0x20,0x7c,0x13,0xa6,0xa9,0x98,0x39,0x2,0x8, -0x86,0x14,0xa0,0xc2,0x23,0xbb,0x60,0x36,0x1e,0xbc,0x1f,0xe,0xb,0x8c,0xbc,0x49, -0x10,0xf9,0x56,0x30,0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0x9d,0x5a,0xc4,0xa6, -0x36,0x71,0x88,0x9d,0xb8,0xc4,0x89,0xef,0xd,0x2,0xf4,0xa4,0xd8,0xb2,0x23,0x3f, -0xa,0xa2,0x60,0x12,0x4c,0x42,0x0,0x32,0x0,0xa6,0x76,0xa,0x38,0xea,0x50,0x7, -0x90,0x2e,0x71,0x93,0x46,0xa0,0x9d,0xe9,0x60,0x73,0x60,0x10,0x7,0x51,0x8,0x48, -0x16,0x85,0x60,0x94,0xa9,0xcd,0xec,0xd4,0x1,0xa4,0x9b,0x2,0x8e,0xba,0xc4,0x23, -0x43,0x3,0xc3,0x24,0x88,0x58,0x1c,0x9c,0xb3,0x38,0x84,0x29,0x3,0xa,0xe4,0x3c, -0x75,0x99,0x4d,0x3d,0xe6,0x10,0x2f,0x75,0x89,0x4f,0xfb,0x3,0xd9,0x4e,0xc0,0x54, -0x8b,0x20,0x9e,0x1,0x30,0xda,0xd,0x48,0x35,0xa0,0x6b,0x0,0xb4,0x82,0xdd,0x80, -0xda,0x4d,0x5a,0xb7,0x3,0xd3,0xe0,0xae,0x81,0xe1,0xd5,0x4e,0xb3,0x74,0x30,0xa0, -0xa9,0x1d,0xee,0x8,0xec,0xee,0x69,0xea,0x81,0xd,0x9e,0x66,0xb,0xd0,0xd8,0x97, -0xfe,0x8,0x80,0x96,0xbf,0x53,0x78,0xda,0x11,0xd8,0x3d,0x0,0x6f,0x1,0x36,0x5, -0x60,0xb6,0x53,0x8a,0xb1,0x23,0xb0,0x7b,0x12,0xb5,0x5,0xd8,0x90,0x44,0x7d,0x1e, -0xee,0x94,0x26,0x6e,0x1,0x36,0xa4,0x89,0xba,0x3e,0xec,0x9c,0x8,0x53,0x55,0x8b, -0x84,0x6,0xc0,0x92,0x3e,0xec,0x9c,0xea,0x53,0xf5,0x6c,0xbc,0x2,0xb8,0x3d,0xd5, -0x2f,0xc9,0x35,0x9f,0x69,0x35,0x81,0x76,0xf5,0x44,0xd9,0xff,0x29,0x82,0x53,0x18, -0xb7,0x8b,0x99,0x12,0xb0,0xb3,0x5c,0xa3,0xec,0xdb,0xa2,0x14,0x11,0xc6,0xa1,0x81, -0x5c,0xab,0x13,0xa4,0xe6,0xa,0x18,0x80,0xf9,0xdf,0x6e,0x42,0x1a,0x1a,0x8,0xd2, -0xdd,0x34,0xfe,0x36,0xe0,0x56,0xc9,0x5d,0xd2,0x87,0x9d,0xab,0x18,0xdb,0x80,0x5b, -0xab,0x18,0x25,0x7d,0xd8,0xb9,0x4e,0xb3,0xd,0x68,0xb2,0x24,0xdb,0xab,0x12,0x55, -0x3,0xac,0xaf,0x44,0x25,0x76,0xe2,0xe0,0xb6,0x7d,0x30,0xa7,0xf4,0x71,0x7a,0x2, -0xbe,0x8c,0x58,0x7d,0x6a,0x6d,0x35,0xc0,0xfa,0x5a,0x5b,0x62,0x25,0x36,0x7,0x82, -0xcf,0x7c,0x44,0x8f,0x21,0xa6,0x9f,0x5a,0x7d,0xaa,0x89,0x35,0xc0,0xfa,0x6a,0x62, -0x62,0x8d,0x0,0x11,0xfe,0x19,0x92,0x24,0xfa,0x68,0x74,0x64,0x3d,0xb2,0x8e,0xac, -0x3e,0xf5,0xd2,0x1a,0x60,0x7d,0xbd,0x74,0x43,0x9e,0x92,0x53,0xc6,0x6e,0x19,0xf5, -0xc9,0xe8,0xad,0xa3,0xf1,0xa3,0xf1,0xc9,0x51,0x9f,0x8a,0x70,0xd,0xb0,0xbe,0x22, -0xbc,0xa1,0x4f,0xe9,0x29,0xdf,0xab,0xfd,0x4d,0x92,0x58,0x47,0xe9,0xa3,0xf4,0xe4, -0xa4,0x4f,0xcd,0xbb,0xe,0x58,0x5b,0xf3,0xe6,0xc0,0x73,0xb6,0x84,0x49,0xb3,0xe1, -0x40,0x48,0x89,0xfb,0x54,0xf5,0xeb,0x80,0xb5,0x55,0x7d,0x0,0x92,0x53,0x8b,0xcd, -0x0,0xb8,0xdc,0xbc,0x6,0xc0,0x30,0xd,0xfa,0xac,0x5b,0xd4,0x1,0x6b,0xd7,0x2d, -0x36,0x94,0x4f,0x9a,0xb,0x0,0xae,0x36,0x9f,0x1,0xd0,0x4a,0x83,0x3e,0x2b,0x33, -0x75,0xc0,0xda,0x95,0x19,0x0,0xda,0xe4,0x28,0xbc,0x4,0xe0,0x7a,0x93,0x1e,0xa5, -0x90,0xec,0x6,0x13,0x93,0x20,0xe1,0x37,0x1,0x93,0x70,0xeb,0xda,0x53,0xe,0xb4, -0xfc,0x3b,0x2,0x92,0x91,0x45,0x68,0xe8,0x66,0xc0,0xc0,0x3a,0xb,0x8c,0xc2,0xa0, -0xd7,0x4,0xe4,0xf1,0xb0,0x7e,0x39,0x2f,0xb1,0x36,0x49,0x48,0xcf,0x7c,0xb8,0xa5, -0xdf,0x71,0x20,0x3d,0x9,0x8c,0x16,0x2c,0xe7,0x5b,0x80,0xde,0x1a,0x80,0x3c,0xc5, -0xa8,0x5f,0xb0,0x4c,0xec,0xd,0x9,0xe9,0x38,0xc0,0xd4,0x84,0x3,0xd3,0x93,0xc0, -0x68,0x49,0x76,0x53,0xf,0x4c,0x9d,0x2,0x58,0xbb,0x24,0xb,0x40,0x7a,0x4a,0xc7, -0x61,0x6,0x4,0xc3,0xf,0x8c,0x16,0x9d,0xb5,0x13,0x29,0xa,0x20,0x79,0xaa,0x0, -0xeb,0x16,0x9d,0x37,0x30,0x8a,0xa7,0xa7,0xa7,0x19,0x10,0x5d,0x5b,0x60,0xb4,0xac, -0xae,0x1d,0x99,0x28,0x80,0x98,0xa6,0x13,0xaa,0x0,0xeb,0x96,0xd5,0x37,0x30,0x8a, -0xa7,0x96,0x38,0x14,0x14,0x80,0xe8,0xbc,0x5d,0xb3,0xc6,0x1,0xaf,0x1e,0x98,0x7e, -0x54,0x0,0xeb,0x1a,0x7,0x0,0x8,0x2,0x62,0xc3,0xb3,0xb6,0x4d,0xca,0xc3,0x93, -0x6b,0xd6,0x1a,0xb1,0xa8,0xde,0x52,0xb8,0x68,0xd,0x58,0xd7,0x1a,0x1,0x40,0xd0, -0xec,0x19,0x90,0x7,0x60,0xd7,0xac,0xf9,0x63,0x59,0xf,0x64,0xbf,0x2a,0x80,0x4d, -0xcd,0x1f,0x4a,0x5e,0x6a,0xd8,0xde,0x42,0xaa,0xc0,0x2b,0xc6,0x37,0x2b,0xe6,0xc0, -0xa6,0xf6,0x16,0xd,0x68,0xd4,0xc0,0x43,0x83,0xa,0xf0,0x1b,0xc6,0x1b,0x79,0x73, -0x60,0x53,0x3,0x8f,0x6,0x34,0x6b,0x51,0xf2,0x6a,0xd,0x3f,0x50,0x66,0x69,0x53, -0x8b,0x92,0x6,0x34,0xeb,0xfa,0xba,0xd8,0xee,0xda,0x32,0x60,0x43,0xd7,0x97,0x6, -0x34,0xeb,0x6b,0xdb,0xb4,0x3,0x1b,0xfa,0xda,0xb4,0x7e,0x1a,0xb3,0xce,0x3d,0xc5, -0xd7,0x6c,0x3,0x36,0x74,0xee,0xe9,0x40,0xa3,0xde,0x44,0xc5,0xd7,0x6c,0x3,0x1a, -0xf7,0x26,0xc6,0x46,0x49,0xa9,0xa7,0x2,0xc3,0x12,0xf0,0x32,0xab,0x7a,0xf1,0xa1, -0x69,0x3,0x9a,0xbd,0x16,0xa,0x30,0x2d,0x3,0xf5,0x53,0xbf,0xda,0x6e,0xa9,0xd9, -0x6b,0xd9,0x4,0xd4,0xcf,0x1c,0x1c,0x6,0x48,0x9a,0x80,0xec,0xbc,0x19,0xa8,0x1c, -0x98,0x6b,0xc,0x2c,0x7c,0x4d,0x1d,0x30,0x9,0x9a,0x81,0xc5,0x24,0x37,0x6,0x16, -0x3f,0xa3,0x0,0x62,0x15,0x10,0xf7,0xa,0x9,0xa0,0xf6,0x94,0x92,0x17,0x9a,0x5c, -0xe3,0x3b,0xb2,0x13,0x94,0x6b,0x47,0x2e,0xd6,0x63,0xcb,0x1f,0x1c,0x1b,0x64,0x54, -0x39,0x10,0x86,0x46,0x0,0xb5,0x69,0xa3,0xcb,0x35,0xbe,0xab,0x7e,0x8e,0x72,0xed, -0xc8,0x9d,0xf8,0x13,0x9f,0x31,0x56,0x5a,0x16,0x30,0x7,0x62,0x9d,0x4c,0x2,0xd5, -0x47,0xdd,0xd5,0x0,0x2f,0xb7,0x3,0x7d,0x83,0xcc,0xad,0x6,0xc8,0x26,0xf5,0xc0, -0x91,0x15,0x4e,0xc2,0x3f,0xc3,0x78,0xa0,0x3e,0xbc,0x67,0xb9,0xc2,0xe0,0x53,0x93, -0x91,0x4c,0xaa,0x40,0x2c,0x3b,0x66,0xc0,0xc4,0xaf,0x1,0xa2,0x3e,0xc,0xcf,0xd9, -0x2d,0x98,0x5,0xe8,0xc3,0x93,0x13,0xff,0xd2,0x33,0x7,0x2a,0xde,0x34,0x3,0x62, -0x61,0x35,0x3,0x2a,0x8f,0x19,0xd0,0xe5,0x5a,0x88,0xc7,0xdb,0x59,0x3e,0xe8,0xc3, -0x93,0x93,0x60,0xe1,0x9b,0x3,0x95,0xb3,0xa7,0x33,0xa0,0x28,0x1d,0xcb,0xd9,0x1f, -0x7,0xf5,0xc0,0x33,0x9f,0x3b,0x8d,0xd,0x7,0xb2,0xe,0x40,0xe5,0x50,0x5f,0xe, -0xf4,0x27,0x61,0xe4,0x5b,0x5,0x90,0xba,0xb5,0x40,0x32,0xe,0xf8,0x81,0x48,0xa0, -0xf,0xe1,0x96,0x76,0x2,0xce,0x75,0x60,0xb6,0xa6,0x92,0xc7,0xee,0xa8,0xe,0x8, -0xfa,0xd0,0x66,0x17,0x69,0x70,0x5,0xfa,0x10,0xe4,0x76,0xd0,0x5,0x18,0xeb,0x40, -0x10,0x31,0x80,0x54,0x80,0xc4,0xaf,0x3,0xda,0xc4,0x66,0x97,0xa9,0x7f,0x5,0xea, -0xe9,0x24,0x98,0xf8,0xbe,0x67,0x2e,0xd7,0x28,0x36,0xbf,0xf2,0x8d,0xf2,0xf5,0xc0, -0xfc,0x98,0xda,0x92,0x5c,0xb3,0x98,0x9b,0x7a,0x2,0x18,0x79,0xbe,0x67,0x2e,0xd7, -0x52,0x5c,0x48,0xe0,0xfb,0x83,0x68,0x3d,0x30,0x9b,0x36,0xba,0x5c,0x3b,0x25,0x20, -0xd7,0xdc,0xab,0xef,0x10,0xc8,0x5c,0xc3,0x5b,0x2a,0x82,0xe1,0x14,0xae,0xd1,0xa7, -0x21,0xa8,0x3c,0x56,0xb,0x4c,0xdd,0xaa,0x2f,0x5,0x31,0x83,0x72,0xed,0x37,0x3c, -0xf3,0xe,0xd8,0xa5,0x21,0x50,0x1c,0xa8,0x8f,0x47,0x51,0x4d,0xe1,0xed,0x6f,0x1, -0x66,0xe,0xb5,0x46,0xae,0x8d,0x38,0xd0,0xdc,0xe,0x45,0xce,0xb6,0x81,0xdf,0xae, -0xc1,0xa6,0xae,0x38,0xb0,0x32,0x4b,0xf3,0x38,0x5c,0x23,0xd7,0x4e,0x7d,0xe,0x34, -0xf0,0x34,0xc4,0x2a,0xa2,0x2f,0xf9,0x30,0x72,0xd6,0xf3,0xc8,0xbd,0xe6,0x40,0x69, -0x87,0xf3,0x50,0x39,0x7b,0xef,0x9c,0xaf,0x37,0x54,0xe5,0x5a,0x7a,0x86,0x40,0x23, -0x5f,0xca,0x8f,0x6e,0x92,0x39,0x5b,0xea,0x4e,0xec,0x9b,0xcb,0x89,0xb3,0xc2,0x74, -0x29,0xf3,0x34,0x1a,0x10,0xe2,0x70,0x6c,0xd5,0xc8,0x35,0x6c,0x99,0x6,0x60,0x11, -0x2d,0xb6,0x3,0xe5,0xf1,0xbe,0xc2,0xc4,0x60,0x4a,0x6f,0x7c,0xcb,0x5e,0x22,0xf0, -0x89,0xf4,0xa5,0x1a,0x30,0xc5,0x15,0xb2,0xa0,0x2a,0xd7,0xa4,0x20,0xcd,0x3,0x70, -0x3,0x50,0x1e,0xef,0x2b,0x76,0x1e,0xde,0xb3,0xac,0xd3,0x13,0xcb,0x4a,0x28,0x7c, -0xcb,0x13,0x19,0x2d,0x34,0x20,0x4c,0x9b,0x49,0x5d,0x43,0x6b,0x39,0x4d,0x6c,0x0, -0x4e,0x44,0x8a,0xcc,0xed,0x22,0x7d,0xcb,0xb2,0x8e,0xc7,0x96,0x35,0xce,0x80,0x18, -0xf,0x75,0x20,0xf5,0xea,0x1b,0x5a,0x4b,0x59,0x5b,0x3,0x50,0x8a,0x0,0x6e,0x17, -0xe9,0xa9,0x65,0x1d,0x42,0x7e,0x7d,0x9c,0x1,0x31,0xc5,0xd0,0x81,0xa8,0x1b,0xdc, -0x5d,0x80,0xa9,0x94,0x39,0x7c,0x18,0xd2,0x91,0x13,0xdf,0x8f,0xdd,0xe8,0x30,0x7, -0x42,0x12,0x55,0x2,0x26,0xf5,0xd,0xad,0x21,0xeb,0x8,0x24,0x2,0xe8,0x26,0xf7, -0x63,0x2f,0xe6,0xc0,0xec,0x5b,0x4a,0x40,0xa,0x79,0x5a,0xd,0xd0,0x35,0x7,0x8e, -0x6c,0xe9,0xb8,0xf9,0x15,0x92,0xfb,0xb1,0x9f,0x34,0x2,0xad,0xd3,0xda,0x96,0x5d, -0x73,0x20,0xb1,0x73,0x2d,0x93,0x8e,0x7e,0x49,0xef,0xc7,0x1,0x69,0x4,0xbe,0x7e, -0x5c,0x3,0xe4,0x9b,0xde,0xcd,0x80,0x36,0x15,0xc0,0x4b,0xe,0x3c,0x1a,0xb7,0x2, -0x5d,0xea,0xe0,0x36,0xfa,0xe6,0x54,0xdf,0x0,0x38,0xe7,0xc0,0x13,0x23,0xa0,0x15, -0x54,0x80,0x49,0x67,0xe0,0x86,0x3,0x3,0x6a,0x2,0x7c,0x51,0x5,0x4e,0xd8,0xdd, -0x2,0xbb,0xcc,0x52,0x39,0x69,0xc8,0x6e,0xc0,0xa0,0xab,0x59,0x70,0xbb,0x48,0x47, -0x7e,0xbb,0x59,0x38,0x64,0xc7,0x2b,0x94,0x5,0x15,0x7e,0xae,0xaf,0xa9,0xe1,0xef, -0x32,0x86,0x79,0x5,0xc7,0x2f,0xb9,0xb6,0x10,0x23,0x5b,0xd5,0xb5,0x51,0x74,0x6d, -0x41,0x79,0x39,0xf,0x66,0x29,0x56,0xf4,0xed,0x24,0xd,0xc,0x9d,0xb7,0x28,0x6b, -0xab,0xce,0x3b,0xb4,0x44,0x97,0x41,0x9,0x88,0xad,0x29,0xa,0x50,0x2e,0xe7,0x61, -0xc6,0x77,0x6c,0x8d,0x21,0xb0,0x5,0x86,0xe1,0x89,0xc7,0x8b,0x74,0x8c,0x30,0x19, -0x9e,0xce,0x64,0x1f,0x45,0x9,0x88,0xad,0x29,0x2a,0x50,0x2e,0xe7,0xc5,0x3e,0xc5, -0xa5,0xbc,0x47,0xa4,0x15,0x98,0x9f,0xaf,0xf,0x76,0x1,0x77,0xc5,0x1a,0x9f,0x59, -0x16,0xa5,0x1c,0xee,0x30,0x19,0x80,0x43,0xfd,0x27,0xf4,0xb,0x20,0x97,0x6b,0x24, -0x4,0xb9,0x16,0x92,0x11,0x3d,0x1a,0x3f,0x4a,0xc2,0x36,0x60,0xfe,0x4,0x1,0xb4, -0xb,0xdf,0xb2,0x48,0x60,0xd9,0x3c,0xe2,0x9f,0xc2,0xe0,0x8a,0x14,0x43,0x3f,0x13, -0x1a,0x53,0x8c,0x40,0x93,0x6b,0x24,0x5c,0xe2,0x73,0x9b,0x79,0x55,0x3f,0x6e,0xd, -0xc0,0x49,0x56,0xd7,0x44,0xbb,0x98,0x4e,0xec,0x8d,0x3f,0x71,0x96,0x8,0x1c,0x41, -0x7a,0x28,0x92,0x28,0x1d,0x88,0x49,0x94,0xe,0x4c,0xc4,0x72,0xde,0x6,0xfe,0x5f, -0x32,0x6b,0x5,0x12,0x4b,0xb1,0xdd,0x45,0xe4,0xac,0x2e,0x23,0x77,0xce,0x3,0x70, -0x9e,0x26,0xea,0x40,0x4c,0x13,0x55,0x20,0x5c,0x9f,0x90,0x6b,0x9,0x2,0x2f,0x5a, -0x81,0xc5,0xcb,0xe7,0xe3,0xb8,0x58,0x62,0xca,0x7f,0x1b,0xa5,0x4f,0x8a,0x44,0xb8, -0xfc,0xdd,0x2a,0x10,0x34,0xfe,0x9c,0x17,0x5b,0x57,0x89,0x45,0xf0,0x88,0x16,0x73, -0xe0,0x94,0x7f,0x8a,0x48,0xf5,0x37,0x93,0x93,0x27,0x45,0xaa,0xdf,0x8,0x4,0xb1, -0xc6,0x63,0xdb,0x9a,0x22,0xd0,0x53,0x36,0x5a,0xb5,0xc9,0xb5,0x5,0xb7,0x6a,0x1f, -0xde,0x1,0x5d,0xf9,0x86,0x40,0x90,0x6b,0x10,0xbb,0xf9,0xf9,0xc3,0xa9,0x75,0xca, -0xaf,0xd0,0x58,0xae,0xdd,0x70,0xab,0x16,0x72,0x6d,0x1d,0xfc,0xce,0x8,0x88,0x72, -0xd,0xc4,0x1a,0xfe,0xbc,0xdf,0x31,0x7a,0x84,0x7,0xd1,0x98,0xdd,0xd2,0x85,0xbe, -0x92,0x60,0xe,0x4,0xb9,0x36,0xe,0x64,0x99,0x2e,0x5,0xe0,0x5f,0x1a,0x2,0x4b, -0xf,0xc,0xe9,0x2,0xa4,0xa7,0xa1,0xf8,0x4e,0x43,0x3b,0x2c,0xe4,0x9a,0x12,0xd3, -0xe8,0xfa,0xc5,0xef,0xcc,0x66,0x29,0xca,0x35,0x69,0x37,0x49,0xe1,0x69,0xd2,0x86, -0x65,0x12,0xe1,0x4b,0x6f,0xb,0x41,0xc3,0x81,0x9b,0xab,0x93,0x27,0x45,0xd9,0x24, -0xa4,0xca,0xf7,0x73,0x3b,0x8c,0x1c,0x45,0xae,0xc9,0x1a,0x56,0x52,0xf8,0xd2,0xb4, -0x61,0x99,0x44,0x0,0x69,0x96,0xb8,0x49,0x20,0xb1,0xce,0x32,0x4f,0x13,0x71,0x51, -0xe3,0xeb,0x9e,0x26,0xb2,0xb,0xb9,0x46,0xa4,0x9c,0xa5,0x4a,0xb4,0x68,0x5,0xf2, -0x7b,0x5e,0xd4,0x69,0x68,0x6a,0xe5,0xbe,0x14,0x97,0xd5,0x13,0xa5,0x46,0xcf,0x7d, -0x69,0x64,0x15,0x72,0x2d,0x3,0xa6,0x4a,0x3c,0x6c,0x58,0x97,0x91,0xc0,0x40,0xab, -0x7a,0xab,0xd1,0x2,0x57,0xb9,0x63,0x65,0x15,0x42,0x44,0xb,0x6c,0xf9,0x68,0x90, -0x6b,0x93,0x36,0x20,0x1f,0x3f,0xa2,0x1,0xb3,0x78,0x88,0xab,0xdc,0x91,0xb2,0xce, -0x22,0xe2,0x21,0x3e,0xee,0xab,0x9,0x68,0xb7,0x1,0xa7,0xda,0x34,0x55,0x23,0x3e, -0x56,0x13,0x27,0xc5,0x4a,0x92,0x8c,0xf8,0x69,0x33,0x30,0xba,0x73,0xa0,0x63,0xa4, -0x80,0x7d,0xd,0x28,0x93,0x28,0x4,0x2a,0x8b,0x73,0x32,0x89,0x6a,0xb9,0xa5,0x71, -0x2b,0x70,0x55,0x8,0xfd,0xc,0xa8,0x2c,0x23,0xa8,0x40,0x91,0x26,0x92,0xa3,0x66, -0xa0,0xdb,0x6,0xdc,0x68,0xab,0x41,0x15,0xe0,0x91,0x55,0x4a,0x84,0x93,0xd3,0xbe, -0xc0,0x2b,0x71,0x5d,0xb7,0x45,0x1,0xac,0xe,0x38,0xb6,0xf4,0x54,0x3f,0xb3,0xc3, -0x2d,0xc0,0xa6,0xf5,0x4a,0x9,0xa4,0xe2,0x32,0x65,0xf9,0xb2,0x2,0x64,0x1a,0x70, -0x92,0x7b,0x9a,0x7a,0x60,0xda,0xb4,0x22,0x2b,0x81,0xfc,0xf3,0x49,0x1e,0xf,0x9b, -0x81,0x56,0xee,0x4b,0xb7,0x0,0x43,0xe2,0xd1,0x36,0x20,0x9a,0x4,0x1d,0xe7,0xe5, -0xcb,0x46,0x60,0x8d,0xb6,0x28,0x3,0xfd,0x36,0xa0,0xd0,0xf8,0x47,0x79,0xf9,0xb2, -0x65,0xc,0xdb,0x80,0xb4,0x1d,0x78,0x29,0x8b,0x85,0xb2,0x7c,0xd9,0x36,0x4b,0x5b, -0x80,0x91,0xdb,0xa,0xe4,0xa1,0x62,0x9e,0x97,0x2f,0x5b,0xec,0x70,0x31,0x39,0x6d, -0x4,0x4e,0x9c,0x56,0x20,0x37,0xc4,0x79,0x56,0xbe,0x6c,0xf3,0x34,0xb,0xeb,0x54, -0xa6,0x18,0xd8,0xb6,0x18,0xaa,0xdd,0x31,0x1c,0x8,0xfa,0xa4,0x4d,0x3d,0xf1,0x50, -0x71,0x9e,0x95,0x2f,0xdb,0x7c,0xe9,0x4b,0xeb,0x48,0x66,0x6d,0x90,0x22,0xc6,0x15, -0x20,0x8,0xa2,0x71,0x1b,0x90,0xff,0x44,0x7,0x4a,0xf9,0xb2,0x8,0x4f,0x6b,0x56, -0x9,0x4f,0x5f,0x3e,0x3c,0x90,0xc0,0x33,0x87,0x4d,0x42,0x7a,0x2,0x60,0x7c,0xa2, -0x70,0xb0,0xe4,0x40,0x94,0x7d,0x6d,0x40,0x1c,0x33,0xd0,0x94,0xb2,0x7c,0x9,0xf7, -0xb0,0x8,0xc0,0x6b,0x56,0x9,0xc0,0x5f,0x6,0x7,0x32,0x11,0x1e,0xdb,0x30,0xd5, -0xc8,0x99,0x35,0xb6,0x1,0x48,0x21,0xe9,0xa,0xa5,0xb0,0x6d,0x15,0xa4,0x81,0xaa, -0x80,0x1,0x58,0xa4,0x18,0x6b,0x56,0x49,0x31,0xbe,0xc,0x25,0x90,0x9e,0xbe,0x5, -0x16,0x15,0xa7,0x30,0x8f,0x11,0xe8,0x3f,0xf,0x79,0x71,0xc2,0x8d,0xee,0xb7,0x2, -0x75,0x8d,0xff,0x2d,0xd6,0x29,0x79,0x12,0x85,0xc0,0x4a,0x12,0x55,0x0,0x47,0x23, -0x5c,0x5d,0x4b,0x4f,0x1e,0x11,0xf8,0x4,0xea,0xfb,0xfc,0xa,0x47,0x5e,0xdc,0xe, -0x9c,0x72,0x60,0x56,0xc5,0x28,0xaa,0xfa,0x8,0xac,0xa4,0x89,0xf9,0x2d,0xa5,0x23, -0xbe,0xba,0x96,0x9e,0x3c,0xa6,0xa1,0xcf,0xc8,0x95,0x2d,0x80,0x7e,0xd2,0xe,0x5c, -0xe0,0x17,0xda,0x59,0x9d,0xa6,0x58,0xb7,0xc8,0x17,0x2c,0xd5,0x44,0xf8,0x65,0x1, -0x14,0xab,0x6b,0x2,0x78,0x3b,0xb5,0x4,0x30,0x20,0xed,0xc0,0x15,0xaf,0x26,0x66, -0x95,0xa8,0x62,0x65,0xa6,0x16,0xb8,0x78,0xa8,0x1,0x2f,0x53,0xeb,0x1d,0x1,0x3c, -0x34,0x7,0x62,0x51,0x61,0x74,0x3c,0x36,0x3,0x46,0xf7,0x8f,0x72,0xb9,0x76,0x8a, -0xab,0x6b,0xd6,0x33,0x4,0x6e,0xae,0xf,0xc3,0x36,0xa0,0xda,0x1a,0xa1,0x94,0x2f, -0x5b,0x81,0xa7,0x99,0x5c,0xa3,0x7c,0x75,0xd,0x7e,0x7,0x60,0xe2,0x76,0x0,0x82, -0x4,0x52,0x8a,0x7b,0xa6,0x40,0xb1,0xd8,0x15,0xa4,0x1,0x7,0xc6,0x5d,0x80,0x69, -0x17,0x60,0x69,0x75,0xd,0x80,0x9,0x9a,0x45,0xec,0xdc,0x11,0x10,0x9c,0x29,0xb1, -0x0,0xb8,0x5a,0x7d,0xda,0x6a,0x16,0xc5,0x2b,0x50,0xcb,0x97,0x2d,0x66,0xa1,0xe8, -0x43,0xca,0x97,0xf3,0x2,0x6a,0x3,0x70,0xb1,0x9a,0xb4,0x1a,0xbe,0x1a,0xa8,0x94, -0xf2,0x65,0x8b,0xe1,0x6b,0x40,0x5c,0xce,0xb,0x20,0x6a,0x0,0x70,0x33,0x63,0x6d, -0xae,0x4d,0x2d,0x9b,0x98,0xbb,0x36,0x9e,0x89,0x48,0xe0,0xd8,0xda,0x94,0x3,0x70, -0x93,0xf3,0x56,0xb,0xb,0x4a,0xf9,0xf2,0x5b,0x46,0x9a,0x9c,0xb7,0xa,0x3c,0xb3, -0x2b,0xc0,0xa6,0xf0,0xa4,0x16,0x16,0x94,0xf2,0xa5,0xec,0x2f,0xdd,0x16,0x9e,0x32, -0x60,0xa9,0xd8,0x1b,0x18,0x4,0x60,0xb5,0xb0,0xa0,0x94,0x2f,0xbf,0xcd,0xcf,0xdd, -0xad,0xd,0xc0,0x2d,0xc0,0xa6,0x14,0x43,0x73,0x35,0x45,0xf9,0xf2,0x5b,0xf8,0xe4, -0x86,0x14,0x23,0xb1,0x7a,0x27,0x51,0x9a,0xab,0x29,0xca,0x97,0x0,0x6c,0x4a,0xa2, -0xda,0x80,0xd,0x69,0xa2,0x66,0xf9,0x45,0xf9,0x52,0xef,0xfa,0xaa,0xa4,0x89,0x6d, -0x40,0xc6,0xc,0x80,0x60,0xf9,0x79,0xf9,0xb2,0xc,0xac,0x24,0xc2,0x53,0x32,0x0, -0xf0,0x8a,0xa9,0x9d,0xa,0xac,0x31,0xd5,0x1f,0x4,0x78,0x59,0x94,0x2f,0xcb,0xc0, -0xb2,0x5c,0x1b,0x6,0x38,0x2f,0xca,0x97,0xcd,0x40,0x6b,0x20,0xa0,0x5a,0x18,0x6a, -0x4,0xe,0x75,0x4b,0xc9,0x76,0x60,0x57,0xb9,0x66,0x6,0x2c,0xa,0xa6,0xed,0xb3, -0xb4,0xbf,0x5c,0x53,0xd,0x31,0xd8,0xa,0xac,0x94,0x4d,0x5a,0x80,0x46,0x9e,0x86, -0x67,0xfb,0xed,0xc0,0xd2,0xea,0x1a,0x44,0x35,0x74,0xc2,0x36,0x81,0xe9,0x16,0x2c, -0xe0,0x7f,0x9b,0xfb,0xd2,0xe2,0x98,0xeb,0xa,0xb0,0x5a,0xfa,0xca,0x8b,0xec,0xc, -0x1f,0xbe,0xb,0x2a,0x88,0x3,0x2f,0x58,0xd2,0x21,0x5a,0x28,0xc7,0x45,0x94,0x81, -0xd5,0x68,0x91,0x3,0x41,0xae,0xcd,0x18,0x3d,0x82,0xec,0x34,0xa0,0x81,0xcd,0xe2, -0xe,0xf1,0x90,0xef,0x30,0xae,0x7,0x56,0xe3,0x61,0xbe,0x6e,0x21,0xe4,0x1a,0xa4, -0x35,0x34,0x48,0xce,0x2c,0x16,0x75,0x88,0xf8,0x5a,0x25,0x4a,0x7,0x56,0x23,0x7e, -0xbe,0x32,0x3,0x72,0xd,0xae,0x8b,0xd0,0x90,0x4,0x31,0x7d,0x23,0x9c,0x74,0xc8, -0x69,0x94,0xf6,0xf9,0x32,0xb0,0x9a,0xd3,0x7c,0x7f,0x40,0xd0,0x87,0x36,0x4c,0x1b, -0x1a,0x26,0xe1,0x92,0x1c,0x5,0x3f,0xeb,0x90,0x26,0x2a,0xae,0xa6,0xc,0xdc,0x9e, -0x26,0xa2,0x3e,0xfc,0x5,0x4c,0x1b,0x12,0xc6,0x6c,0x46,0xc6,0xc7,0x7,0x1d,0x12, -0x61,0xc5,0xd5,0x54,0x7a,0xf5,0x9b,0x96,0xf3,0x70,0x77,0x1e,0x4b,0xc2,0x19,0xbb, -0x20,0xd6,0x23,0x2b,0x30,0x4e,0xf5,0x55,0x57,0xd3,0x15,0x78,0x9,0xe6,0x70,0x1, -0xe,0xbd,0x2b,0x10,0x93,0x28,0x59,0xbe,0xd4,0xf6,0xae,0xb1,0xc6,0xe5,0x3c,0x0, -0xba,0x70,0x53,0x5d,0xe6,0x75,0x7,0xfe,0xae,0x36,0x1e,0xc6,0x8d,0xcb,0x79,0x34, -0xdc,0xa4,0x3e,0x88,0x6e,0x2f,0xf5,0x9,0x68,0x1a,0xd6,0x9,0xf8,0x95,0xd2,0x7d, -0x59,0x0,0x69,0xf3,0xea,0x5a,0xb8,0xc1,0x87,0x9a,0x51,0x9f,0x6,0xdd,0x81,0x71, -0x6d,0x4e,0xd3,0xe,0xc,0x53,0x8f,0x4,0x60,0x8a,0x39,0xb0,0x76,0x96,0xa6,0x9e, -0x13,0x27,0x67,0x9e,0x1b,0x27,0xa7,0x81,0x7b,0x91,0xc5,0xfc,0xbc,0xfb,0xd2,0x8, -0x88,0xda,0x22,0xc4,0x1d,0x81,0x3e,0xf6,0xf,0x14,0xc0,0x5a,0x3b,0xac,0x3,0x2a, -0xdd,0x97,0xc2,0x53,0xfb,0x1c,0xd8,0x28,0xd7,0xc2,0x4d,0x2,0x9e,0x1,0x17,0xf5, -0xa,0x60,0xad,0xa7,0xa9,0x1,0x46,0x79,0xf9,0x52,0xee,0x3f,0xe4,0xda,0x82,0x86, -0xdb,0x3d,0xd,0x7,0x6e,0x38,0x70,0x53,0x0,0xeb,0x9d,0x77,0xd,0xf0,0xd3,0xbc, -0x7c,0x29,0xf7,0x1f,0x72,0xf5,0x54,0xb3,0x9c,0xd7,0x2,0xac,0xf,0x4f,0x35,0xc0, -0x87,0x79,0xf9,0xf2,0x5b,0xb9,0xe8,0x29,0xd6,0xf,0xb7,0x86,0xa7,0x2d,0x29,0x46, -0x7d,0x0,0xae,0x2,0x8b,0xf2,0xa5,0x4,0xa,0x5,0x4c,0xc3,0xad,0x1,0x78,0x5b, -0x4e,0x53,0x9b,0x62,0xd4,0x0,0x55,0x5,0x2c,0x6e,0x9f,0xc5,0x81,0x5b,0x53,0x8c, -0x4e,0x49,0x54,0xd,0x50,0xd5,0xf8,0xe2,0xf6,0x59,0x21,0x2,0xb7,0x26,0x51,0x9d, -0xd2,0xc4,0x5a,0x60,0x51,0xc5,0xd8,0x6,0x34,0x4a,0x13,0x6b,0x13,0xe1,0x3a,0xa0, -0x52,0xbe,0xe4,0xc0,0x7,0x12,0xd8,0x35,0x11,0x36,0x6,0x2a,0xe5,0x4b,0xe,0xf4, -0x25,0x70,0x90,0x54,0xbf,0xe,0x58,0x94,0x2f,0x95,0xa3,0x46,0x92,0xb0,0x2a,0xd7, -0x86,0x2,0x9e,0xd4,0x1,0xe3,0xb0,0x2a,0xd7,0x86,0x2,0xe6,0xc5,0x3d,0x71,0x5c, -0xc,0x9e,0x61,0xc5,0x6a,0xe4,0x1a,0xdb,0x1b,0x10,0xc6,0x90,0xd5,0xc8,0x35,0x36, -0x8c,0x5c,0x53,0xab,0x89,0xfa,0x9,0x3c,0xe5,0x59,0xca,0x86,0x91,0x6b,0x5a,0x33, -0x64,0x6e,0x87,0xa8,0x0,0xca,0x76,0xf8,0xc3,0x3,0x1a,0xea,0x43,0xb5,0xfb,0x72, -0x2b,0x50,0x6b,0x2c,0x47,0x7d,0x48,0xac,0x10,0x77,0x71,0xa7,0xa8,0xf,0x13,0x91, -0xb5,0x99,0xea,0x43,0xb5,0xfb,0x32,0x77,0xde,0x8,0x2c,0x3b,0x6f,0xa6,0xea,0x43, -0x4,0x1e,0xc3,0x1f,0x51,0x1f,0x4a,0xa0,0xa9,0x3e,0x54,0xbb,0x2f,0xf3,0xf0,0x84, -0xc0,0x72,0x78,0x62,0xaa,0x3e,0x4,0x20,0xe8,0xc3,0x30,0x42,0x7d,0x28,0x81,0xa6, -0xfa,0x50,0xed,0xbe,0xcc,0x3,0x30,0x2,0xcb,0x1,0x98,0xa9,0xfa,0x10,0xfe,0x84, -0xfa,0x70,0xc2,0x40,0x1f,0x26,0xac,0x93,0x3e,0x54,0xbb,0x2f,0xf3,0x14,0x3,0x81, -0xe5,0x14,0x83,0xa9,0x72,0xd,0xfe,0x84,0x72,0xcd,0x65,0x20,0xd7,0x46,0xac,0x93, -0x5c,0x53,0xbb,0x2f,0xf3,0x24,0xa,0x81,0xe5,0x24,0x8a,0xa9,0x72,0xd,0xf,0x53, -0x61,0xf4,0xcc,0x63,0x20,0xd7,0x1e,0x45,0xdb,0xd2,0xc4,0xb4,0xdc,0x2c,0x91,0xe2, -0xdd,0x53,0xba,0x2f,0xf3,0x34,0x11,0x81,0xe5,0x34,0x51,0x5,0xf2,0xc3,0x54,0x18, -0x19,0xfb,0x28,0xd7,0x1e,0x59,0xe1,0x96,0x44,0xb8,0x1e,0x58,0x94,0x2f,0x6b,0xa5, -0x7f,0x9e,0x8,0xb3,0xaa,0x5c,0xc3,0x45,0xbd,0x26,0x31,0x53,0xf,0x2c,0xca,0x97, -0x5d,0x80,0x47,0x28,0xd7,0x88,0xc5,0xe5,0xda,0x61,0x37,0x60,0x5e,0xbe,0x2c,0x1f, -0x45,0xb9,0x15,0x88,0x72,0xd,0x27,0xcc,0xc,0x8c,0x3,0xe5,0x5a,0xda,0xd,0x98, -0x97,0x2f,0x9b,0x8e,0x3e,0x29,0x6d,0x96,0xa3,0x78,0xb6,0x9,0xdc,0x4e,0x72,0x82, -0x72,0x2d,0xed,0xa6,0xf,0xb7,0xad,0x69,0xda,0x5b,0x81,0xa8,0x9e,0xe8,0x18,0xe4, -0x1a,0xa1,0xc7,0xc1,0x40,0x40,0xea,0xe9,0x1b,0xab,0x6b,0x37,0xcb,0x79,0x24,0x3d, -0x6,0xf5,0x94,0xdd,0x52,0xc3,0xa2,0x42,0xfd,0x2b,0x9,0x21,0x56,0x6f,0x1b,0x43, -0xb9,0xba,0x6,0x72,0x6d,0x7c,0x84,0xc0,0x71,0xd0,0xa5,0x6c,0xb2,0xbd,0x50,0x7c, -0xd9,0x4,0xb4,0x46,0x28,0x66,0xac,0x47,0x20,0x66,0x32,0xb3,0xa8,0x7a,0x9a,0xfa, -0x49,0xb3,0xa5,0xf6,0x3e,0x61,0x71,0x3,0x10,0x57,0xd7,0x88,0xc5,0x7f,0x5,0x67, -0x1c,0x6e,0xf1,0xa5,0x1d,0x80,0x60,0x28,0x81,0xde,0xea,0xad,0x3,0x71,0x75,0x8d, -0x58,0xfc,0xd7,0x34,0xb0,0xb6,0xc9,0xb5,0x16,0x60,0xe4,0x2b,0xc5,0x1b,0xf0,0xa4, -0x34,0xa8,0x7,0x9a,0xcb,0xb5,0x66,0x60,0xaa,0x74,0x89,0x9,0x39,0x7a,0xd5,0x9, -0x58,0x13,0xf1,0x9b,0x81,0x89,0x5f,0x6c,0x9c,0xba,0xe5,0xd1,0xf0,0xba,0x1b,0xd0, -0x30,0xa7,0x29,0x4c,0x3d,0x3f,0x61,0x0,0x93,0xc,0x8c,0xf7,0xeb,0x6e,0x40,0xc3, -0xac,0x2d,0x7f,0x81,0xf7,0x9c,0x69,0xc0,0xeb,0x9b,0x6e,0x40,0xc3,0x44,0x58,0x2d, -0xf2,0x91,0x2,0x38,0x39,0xb4,0xaf,0x37,0x54,0x19,0x83,0x1f,0x3a,0xb0,0xfd,0x6c, -0x3a,0x2c,0x3d,0xc9,0xf2,0x13,0x7,0x9e,0xd8,0xce,0xed,0x5e,0x81,0x31,0x8b,0x7d, -0xb9,0xdd,0x8e,0x3,0x71,0x96,0xef,0x2,0xc,0x22,0xbf,0xd9,0x2c,0xe6,0xd4,0x8f, -0x65,0x7f,0x9d,0x0,0xda,0xd7,0xe0,0xc0,0x8a,0x9e,0xd1,0xc1,0x81,0x53,0x98,0x93, -0xc1,0x42,0x3,0xa2,0xb7,0xca,0xf,0xe,0x1a,0x1c,0xe8,0x83,0x3a,0xfc,0x66,0xa5, -0x8e,0xe1,0x35,0x24,0xf3,0x76,0xde,0xf3,0x3f,0x38,0x30,0xf8,0x86,0xb1,0xef,0x6e, -0x90,0xe6,0xc8,0x59,0xca,0xd8,0xb1,0xf8,0x6,0xbf,0x8b,0xe1,0x4f,0x3c,0x33,0x60, -0x1a,0xc2,0x75,0xdc,0xdc,0x72,0x20,0xdc,0x4b,0xa1,0x2c,0x24,0x70,0xda,0xc5,0xb5, -0xc9,0xf4,0x8b,0x3,0x1b,0xad,0xe2,0xc,0x7e,0xf9,0x33,0x11,0x40,0x42,0x5,0xf0, -0xb9,0x0,0x5e,0x37,0x1,0x23,0x7b,0xbe,0x51,0x9c,0x77,0x76,0xd,0xed,0xc0,0x3f, -0xe3,0x65,0xd2,0x1c,0xc8,0xa5,0x4c,0x27,0xa0,0x8,0x4f,0x54,0xc6,0x9c,0x56,0x20, -0x41,0x20,0x1b,0x87,0x19,0x90,0x4b,0x99,0x76,0x20,0xd,0x73,0xa0,0x8,0xc0,0x44, -0x4e,0xea,0x56,0xe0,0x2d,0xf7,0xd4,0x67,0x2,0xb8,0xa1,0x42,0xca,0x7c,0x65,0x0, -0x5c,0x30,0x9,0x14,0x29,0x46,0x22,0x27,0x75,0xeb,0xa4,0xb9,0xf9,0x4e,0x56,0xd2, -0x25,0x90,0x4b,0x99,0x4e,0x40,0x91,0x44,0xc5,0xd2,0xa5,0xb5,0x2,0x57,0x1c,0xf8, -0x4d,0xe,0xe4,0xfb,0x35,0x4d,0x80,0x2f,0xbd,0xc,0xc8,0xd3,0x44,0x63,0xe0,0xfa, -0x1b,0xfc,0xf5,0xbb,0xab,0x1c,0xc8,0xc,0x81,0x20,0xf4,0x36,0xca,0xba,0x45,0xec, -0x76,0x5,0x5e,0xb3,0x75,0x7,0x60,0x64,0xe7,0x93,0x46,0xa4,0xfa,0xb1,0x37,0xd9, -0x37,0x70,0xa9,0x3,0x7d,0x31,0x3b,0x5b,0xc3,0xd3,0xfa,0x45,0x4f,0xe0,0x62,0xd3, -0xf,0xb8,0x50,0x81,0xeb,0xe,0x63,0xc8,0xb6,0x0,0xdb,0xec,0xf0,0x9a,0x3,0xff, -0xd4,0xf5,0xa,0x11,0x38,0x5b,0xea,0x63,0xf8,0xd0,0xe8,0xd8,0xd4,0xde,0xc0,0xc5, -0x26,0x9a,0xe9,0xb3,0xd4,0x10,0x18,0xf6,0x4,0xce,0x97,0xb1,0xab,0xdb,0x61,0x1, -0x6c,0x9a,0xa5,0xbd,0x81,0x91,0x8d,0x5b,0x3a,0x55,0x4f,0x63,0x6,0x9c,0x66,0xc0, -0xcc,0xf0,0xd1,0x7,0x7f,0x25,0xfc,0xe2,0xf,0x9,0x8,0xde,0xda,0xa5,0xbe,0xee, -0xbc,0x4f,0x0,0x98,0x72,0xb3,0x68,0x2,0x5e,0x95,0x80,0xd2,0x79,0xe3,0xe1,0xb2, -0x7e,0x23,0x90,0x78,0x90,0x42,0x6b,0xe1,0xe9,0xac,0x17,0x50,0x86,0x27,0x3c,0x2, -0xd9,0xbd,0xee,0xa0,0xf,0x21,0x0,0x53,0xe,0xc,0xa3,0x56,0x20,0xfc,0x45,0x2, -0x8b,0x0,0x7c,0x8c,0x8b,0x18,0x66,0xc0,0x3c,0xc5,0x80,0x5f,0x6f,0x4,0xb0,0xe9, -0x75,0x85,0xf,0xda,0xc,0xa,0xa0,0x4c,0x31,0xf0,0x54,0x69,0xdb,0x10,0x98,0x25, -0x51,0xa6,0x40,0x18,0x6e,0xbf,0x0,0xca,0x24,0xea,0x91,0xe5,0x4f,0x2c,0x43,0x60, -0x96,0x26,0x9a,0x2,0x61,0x42,0x7b,0x12,0x8,0x69,0x22,0xaf,0x44,0x1d,0x63,0xa5, -0x30,0x32,0x5,0x66,0x89,0xb0,0x29,0x30,0x72,0x2d,0x57,0x0,0x95,0x44,0xf8,0x2d, -0x3c,0x73,0xe8,0x83,0xbe,0xc0,0xe6,0x49,0x13,0x79,0x13,0x15,0x88,0x8b,0x4,0x8, -0x84,0xe9,0xb3,0xf,0x20,0x8c,0x5f,0xe4,0x47,0x8,0x2c,0xc4,0xc,0x9a,0xd6,0x3e, -0x81,0x93,0xa,0x90,0x8e,0xef,0xf8,0xa,0x41,0x90,0xee,0x15,0x28,0xc6,0xb0,0x90, -0x6b,0xec,0x76,0x57,0x60,0xc3,0xb,0x81,0x62,0x96,0x16,0x45,0x5,0xb6,0xa1,0x9d, -0x66,0x69,0x56,0xa7,0x31,0x5,0x4a,0x3b,0xcc,0x80,0x70,0x37,0x56,0xb4,0x93,0x1d, -0x66,0x95,0x28,0x53,0xa0,0xf4,0x34,0x6a,0x25,0x8a,0x1a,0x78,0x9a,0x92,0x5c,0xeb, -0x0,0x94,0xbe,0x54,0xad,0xb5,0x51,0x3,0x5f,0x5a,0x92,0x6b,0x39,0xd0,0x7a,0xaf, -0x6d,0xd2,0xc8,0xf0,0x24,0xbf,0x7,0xa3,0x85,0x4f,0x5b,0xa3,0x45,0x45,0xae,0x15, -0xc0,0xe6,0x78,0x78,0x75,0x15,0xa8,0x40,0x59,0x2f,0xa5,0xad,0xf1,0xb0,0x22,0xd7, -0x4c,0xcd,0xa2,0x4,0x94,0x15,0x61,0xda,0x1a,0xf1,0x2b,0x72,0x4d,0x2,0x5b,0x73, -0x9a,0x32,0xf0,0x12,0x72,0x9a,0x38,0x5b,0xef,0xea,0x22,0xd7,0xfa,0x2,0x45,0x55, -0x9f,0x76,0x97,0x6b,0x1a,0xb0,0x29,0x3a,0x95,0x80,0x62,0xdd,0x82,0x76,0x97,0x6b, -0x7d,0x81,0x62,0x65,0xe6,0x87,0x9,0x5c,0xe,0x2,0x14,0x29,0x6,0xed,0xae,0xf, -0x7b,0x3,0x13,0xf1,0xe0,0xf1,0xce,0xfa,0xd0,0x14,0x58,0xf2,0x34,0x79,0x87,0x42, -0x67,0x7d,0x68,0x6a,0x16,0xfd,0x81,0x25,0x7d,0xb8,0x7f,0x60,0x49,0x1f,0xf6,0x1, -0x16,0xd5,0x0,0xda,0x5d,0x1f,0xf6,0x0,0xa6,0xc5,0xea,0x2f,0xed,0x2e,0xd7,0x7a, -0x0,0x49,0xb1,0xc2,0x4d,0xbb,0xcb,0x35,0x36,0xc1,0xe5,0x72,0xbb,0xcb,0x2c,0x4d, -0x8a,0xec,0x98,0x76,0x97,0x6b,0x8c,0xaf,0xd1,0x77,0x2,0xc6,0xc5,0x97,0xd3,0x3e, -0x72,0xcd,0x4b,0x3b,0x2,0x23,0xb5,0x53,0x48,0xa4,0x18,0x69,0xed,0xd9,0x97,0xb5, -0x49,0x14,0xb5,0x5c,0x23,0x60,0xa1,0x80,0x65,0x8b,0x92,0x4,0x8a,0x24,0xca,0xc, -0x88,0x69,0xe2,0x9f,0x88,0xe5,0xfc,0x3f,0xa3,0xa2,0xc2,0x56,0x20,0xa6,0x89,0x66, -0x40,0x9c,0x9f,0x2b,0xc8,0xfd,0x12,0x4,0x62,0xb3,0x85,0x29,0xf0,0x81,0x2,0x14, -0x89,0xb0,0x39,0x70,0x1e,0xfb,0x78,0xcc,0x6b,0x37,0xa0,0xaf,0x1,0x31,0xd5,0x37, -0x7,0x5e,0xc4,0xc1,0x64,0x14,0xf2,0x6f,0x35,0x7,0x62,0x6f,0x62,0x5f,0xa0,0x1b, -0x87,0xd1,0x69,0x70,0x97,0xc0,0x28,0x8c,0x8e,0xfd,0xc,0x68,0x38,0x4b,0x2b,0xc0, -0xd2,0x13,0xad,0x1a,0x80,0xa9,0x37,0x9,0xa3,0x87,0x5e,0x47,0x60,0x65,0xc,0xcd, -0x81,0x14,0xbe,0x37,0xf2,0xdc,0x8e,0xc0,0xca,0x2c,0x45,0x3b,0x59,0x1b,0xd9,0x21, -0x3d,0x7e,0x2b,0x8c,0x3e,0xb8,0xec,0x8,0xac,0xd8,0xa1,0x21,0x10,0x3c,0xd,0x39, -0x7a,0x12,0x4c,0xde,0xbf,0xd8,0x9,0xe8,0x4f,0x9a,0x80,0x89,0x7,0x11,0xdf,0xcd, -0x7d,0x29,0x19,0x81,0x1d,0x7e,0x38,0xe7,0x81,0x12,0xb7,0xde,0x1b,0xcd,0xd2,0x8a, -0x2f,0xfd,0x41,0x1,0x63,0x7,0x80,0x4e,0x1e,0x9e,0xc8,0x33,0x98,0x62,0x37,0x1d, -0x81,0x95,0xf0,0xd4,0x4,0xc4,0xbc,0x3b,0xb2,0xf3,0x0,0x9c,0x7c,0x4,0xce,0xfb, -0x76,0x66,0xe,0x8c,0xe5,0xf6,0x78,0x2d,0x0,0x37,0x1,0xe7,0xb3,0xd9,0x66,0xbe, -0xcc,0x53,0x8c,0x4,0x54,0xba,0x7b,0xbb,0xec,0x6,0xac,0xa4,0x18,0x6f,0x34,0x0, -0x17,0xcb,0xd9,0x46,0xd1,0x87,0x31,0x4,0x16,0x8f,0xc6,0xdd,0x80,0x95,0x24,0xea, -0xe6,0x9a,0x6c,0x7,0xb2,0x68,0xa3,0xe8,0xc3,0xe5,0x14,0x53,0x8c,0x51,0x6,0x6c, -0x37,0xb,0x3e,0x7e,0xe5,0x34,0xb1,0x5,0xf8,0x54,0xd1,0x87,0xcb,0x2b,0xf0,0x8c, -0x69,0x57,0x60,0x39,0x11,0x6e,0x2,0x7e,0x69,0x7f,0xf9,0x58,0xd1,0x16,0x4b,0xcc, -0x6b,0xf7,0xc,0x7c,0xb9,0x5,0x68,0xe6,0x69,0xfa,0x0,0x7f,0xb1,0x1d,0x68,0x36, -0x69,0x3a,0x1,0x17,0xcb,0x85,0x7d,0xd7,0xc0,0x73,0x5,0x38,0xeb,0xa,0x5c,0x5f, -0xdd,0x74,0x6,0xce,0xf4,0x59,0x3a,0x0,0x30,0x69,0xf4,0x34,0x0,0x5c,0x16,0x76, -0xb8,0x77,0x20,0x68,0xfc,0xa5,0xf4,0xa5,0xe8,0x69,0x3a,0xcf,0xd2,0xa,0x30,0x68, -0x1,0x2a,0xd1,0x2,0x7d,0xa9,0x0,0x3e,0xd9,0x5,0xd8,0xe2,0x4b,0x95,0x78,0x88, -0xd1,0x2,0x5c,0x1b,0xc8,0xb5,0xdf,0xec,0x0,0x6c,0x8b,0x16,0x25,0xb9,0xb6,0xbc, -0x46,0x5f,0xba,0x64,0x6,0x2f,0xb1,0xba,0x56,0x1,0x1e,0x9b,0x3,0x31,0xe2,0x2f, -0xd7,0xe0,0xfa,0x6f,0xd,0x81,0x58,0x11,0xae,0x0,0x8f,0x3a,0x0,0x21,0x89,0x8a, -0x79,0x3c,0x9c,0x99,0x1,0x13,0x5e,0x68,0x2f,0x19,0xbe,0x4c,0xa2,0x4c,0xe5,0x5a, -0xf2,0xc,0x22,0xfe,0xcd,0xdc,0xc,0x88,0x55,0xfd,0x1a,0xa0,0x7c,0xa6,0xa9,0x59, -0x22,0x9c,0x8c,0xe0,0xc7,0x5e,0x5d,0x98,0x1,0x71,0xdd,0xa2,0x2,0xec,0x28,0xd7, -0x20,0x2f,0xf5,0xad,0xf7,0xd5,0xb6,0xfb,0x9a,0x2d,0x9d,0xea,0xea,0x5a,0xd,0xb0, -0x93,0x98,0xa1,0x87,0x6f,0x5,0x93,0xf,0x4c,0x81,0x7e,0xb4,0x33,0x30,0xf5,0x2c, -0x29,0x66,0xc,0x80,0x93,0x1f,0x27,0x10,0xe4,0xda,0xa1,0x7f,0x77,0xb7,0x54,0x28, -0x60,0xff,0xee,0x26,0xd,0x68,0xfc,0x30,0x1a,0x5,0x86,0xc0,0x5d,0xcd,0x2,0xeb, -0x34,0x11,0x0,0xdf,0xb,0xcd,0x80,0xc5,0x72,0x5e,0xd9,0xf0,0x3b,0x2c,0xe7,0xc5, -0xa0,0xf,0xb5,0xaf,0x68,0x0,0x16,0xcb,0x79,0x65,0xd7,0xd6,0x0,0x2c,0xc9,0x35, -0x96,0xbc,0xe5,0xeb,0x1b,0xe,0x1a,0x80,0xea,0x72,0x5e,0xa9,0xd6,0xb6,0x1d,0x58, -0x92,0x6b,0x8c,0xbc,0x51,0xda,0xdf,0xd3,0x0,0xac,0x2d,0x41,0xb7,0x55,0x13,0x4b, -0x72,0x8d,0xd1,0x3,0xcb,0xf1,0x76,0x1,0xb6,0xd5,0x4b,0x4b,0x72,0x8d,0xb1,0xc3, -0xd2,0x6,0xa6,0xae,0xc0,0xb6,0x8a,0x70,0x49,0xae,0x69,0x5,0xec,0x7e,0xc0,0x96, -0x9a,0x77,0x49,0xae,0x69,0x25,0xfa,0x66,0xe0,0x34,0xec,0xb5,0x8c,0x50,0x92,0x6b, -0xbc,0xe6,0x6d,0x6,0xbc,0xee,0x7,0x2c,0xc9,0x35,0x66,0x1f,0xb8,0x77,0x17,0x0, -0x0,0x15,0x2f,0x49,0x44,0x41,0x54,0xfe,0x52,0x80,0xc5,0x73,0x1d,0x4d,0x80,0x2f, -0xfb,0x2,0x5f,0xf4,0x5a,0x28,0x29,0xc9,0xb5,0x5e,0x40,0x4d,0xe3,0xb7,0x8e,0xa1, -0x2e,0xd7,0x3a,0x0,0xf3,0xfe,0x52,0xbd,0x8a,0xa1,0x3,0x37,0x6d,0x72,0xad,0x17, -0x30,0xf1,0x9d,0x6d,0xc0,0x55,0x9b,0x5c,0xeb,0x2,0xfc,0x26,0x3,0xc6,0xe1,0x6c, -0x1b,0x70,0xd1,0x26,0xd7,0xfa,0x1,0x8b,0x23,0xd5,0x4,0x70,0x95,0x3,0xaf,0xdb, -0xe4,0x5a,0x7,0x60,0xde,0xe7,0xcd,0xa2,0x62,0x97,0x9c,0x0,0x4e,0x72,0xe0,0x55, -0x9b,0x5c,0xeb,0x0,0xcc,0x3b,0xd9,0xd9,0xac,0x78,0x56,0x68,0x19,0x18,0xb4,0xc9, -0xb5,0xe,0x40,0xd1,0xab,0xff,0xb7,0x61,0xd,0xf0,0x7e,0xd6,0x31,0xc4,0xf,0x56, -0xee,0x78,0xb6,0xc9,0xd6,0x57,0xbe,0x1b,0x41,0x2,0xff,0xae,0x0,0x1e,0x66,0x40, -0x7a,0xd7,0x40,0xfe,0x3c,0xaa,0x8e,0x87,0xa9,0x6c,0x7d,0xe5,0x1b,0x3c,0x10,0xb8, -0xe6,0xcd,0x18,0x15,0xe0,0x2d,0x6b,0x5f,0xce,0x4b,0xda,0xa4,0x76,0xe,0xcc,0xb6, -0xb0,0x20,0x30,0x96,0x4f,0x1c,0x2b,0x4d,0x9a,0x1b,0xd6,0xde,0xf5,0x65,0xc,0xcc, -0x37,0xe9,0xa0,0x59,0x44,0x1,0x5b,0xb9,0x55,0xe0,0x9a,0xb5,0xf7,0xb5,0x19,0x3, -0xf3,0x6d,0x48,0x68,0xf8,0x91,0xc7,0xd6,0xb3,0xc2,0xf0,0xb3,0x5d,0x41,0xd7,0x83, -0x2,0xf3,0x8d,0x56,0xe0,0xda,0x26,0xe,0x5b,0xe0,0x2,0x14,0xd5,0xf7,0x3d,0x4d, -0x7,0x5,0xe6,0x5b,0xc9,0xc0,0x79,0x43,0xf2,0x7c,0x8d,0xdb,0x26,0xa8,0xf2,0xd0, -0xfb,0x17,0x2,0x3c,0x1c,0x70,0x4e,0x43,0xca,0xaf,0x1,0xc2,0x13,0x7c,0xd3,0xd4, -0xba,0xcc,0x81,0x4c,0x2,0x83,0x41,0x81,0x31,0xbb,0xbc,0x48,0xc5,0x35,0xe0,0x13, -0x24,0xaf,0xec,0x65,0x7e,0x4b,0x25,0x90,0xd7,0x94,0x87,0x3,0xe2,0x53,0xb1,0xc4, -0x86,0x47,0xec,0x7d,0x77,0x9e,0xdb,0x24,0x2c,0x1,0x29,0x1b,0x14,0x58,0x6c,0xe9, -0xc4,0x87,0x72,0x5a,0xc7,0xe,0x3e,0x23,0x5a,0x3,0xde,0x32,0x3,0x3b,0x5c,0x2b, -0x67,0x4d,0xb6,0xbc,0x8a,0x5d,0xb2,0xd8,0xe1,0x7f,0xe4,0x54,0x36,0x8f,0x6f,0x98, -0x81,0xa7,0xe9,0x0,0xcc,0xf7,0x1,0x47,0x28,0xa4,0x4e,0xdd,0xca,0xe6,0xf1,0x95, -0x2,0x8c,0x1d,0xea,0x24,0x16,0xa3,0x63,0x9b,0x4f,0xb4,0xc2,0x97,0x76,0x0,0x26, -0xd9,0xb6,0x1a,0xf8,0xcd,0xb2,0x46,0x2e,0x23,0x81,0xe,0x5c,0xab,0x40,0x9b,0xd8, -0x8,0x3c,0xb5,0xf8,0x33,0x2b,0x8a,0x68,0xd1,0x1,0x98,0xed,0xe5,0xc6,0x34,0x31, -0xb2,0x12,0x4f,0x3c,0xfe,0x42,0x1,0x5e,0xab,0x40,0x2b,0xb6,0x46,0x16,0x23,0x23, -0xeb,0x2c,0x3,0x8a,0x0,0xdc,0x1,0x98,0x7,0x2a,0x48,0x13,0x13,0x2b,0xf6,0xb4, -0xc7,0x92,0x23,0xf0,0x4a,0x1,0x2e,0x93,0x25,0x79,0xa,0x77,0x25,0x49,0xc6,0x19, -0x50,0xa4,0x18,0x3d,0x80,0x98,0x26,0x52,0x1b,0x81,0x49,0xa8,0x1,0x7d,0x15,0x48, -0x56,0xf4,0x29,0x3e,0x26,0x9b,0x9e,0x66,0x40,0x91,0x44,0xf5,0x0,0xf2,0x34,0xd1, -0xc6,0x86,0x5b,0xaa,0x2a,0xaf,0x17,0xf2,0x69,0xbe,0x39,0x90,0x6d,0x1c,0x98,0x47, -0x74,0x94,0x3,0x79,0x9a,0xd8,0x7,0x88,0x69,0xe2,0x3c,0xf2,0x53,0x8f,0xb9,0x1a, -0x30,0x2c,0x1,0x13,0x1b,0x6e,0x7a,0x32,0xca,0x66,0xa9,0x48,0x84,0x7b,0x0,0x79, -0x9a,0x78,0x33,0x9,0x0,0xa8,0x96,0x76,0x5f,0x50,0x56,0x6,0x5a,0x60,0xaa,0xf1, -0xd3,0x1c,0xc8,0x53,0xfd,0x1e,0x40,0x9e,0xd3,0xac,0x1,0x18,0x6a,0x83,0xf8,0xe2, -0xb6,0x2,0x1c,0x81,0xd,0x46,0x6c,0x20,0x20,0x7f,0xd0,0x8d,0x3a,0x88,0x2f,0x6e, -0x34,0x60,0x2,0x63,0x48,0xc0,0x70,0xce,0xb,0xe0,0x3f,0xdd,0x5,0x78,0x6d,0x8d, -0xc7,0xec,0x4f,0x4c,0x5,0xae,0x98,0x66,0xf8,0x2b,0x7c,0x8,0x8f,0xcf,0x9c,0x2, -0xe8,0xee,0x2,0xfc,0xda,0xa2,0x6f,0x26,0xae,0x7a,0x8c,0xc3,0x8b,0x45,0x1b,0xd0, -0x1b,0x18,0x78,0xad,0x1,0x1d,0x4,0x52,0x9c,0x59,0xc3,0x8c,0xe1,0x67,0x16,0x7f, -0x26,0x85,0xa,0xbc,0x2a,0x1,0xe9,0x53,0x2,0x49,0x82,0xcf,0xda,0xcd,0x22,0x6d, -0xde,0xfc,0xc8,0xcd,0xe2,0xb9,0xc5,0x62,0x77,0xad,0x7e,0xef,0x8b,0x40,0x9b,0x34, -0x30,0x4f,0x47,0x9,0x9,0xc1,0xc1,0x4f,0x5b,0xd,0xbf,0x5,0xc8,0xd,0xff,0xd0, -0x61,0x49,0x70,0xad,0x7e,0xef,0xdf,0x86,0x3a,0x10,0x9d,0x77,0xcc,0x1f,0x11,0x1a, -0xa,0xe0,0x93,0xad,0xae,0xad,0xd,0x88,0xae,0xd,0xe2,0x6f,0xe2,0x5d,0xab,0x2b, -0xe3,0xff,0xbd,0x4,0x24,0x10,0xa0,0x96,0x2a,0xf0,0x67,0x5b,0x9d,0x77,0xb,0x90, -0x6b,0xfc,0x3,0x97,0xfd,0xe1,0xd7,0x57,0x2a,0xf0,0x6f,0x98,0xe,0xa4,0x10,0x82, -0x35,0xe0,0xe1,0xd6,0xf0,0xd4,0x2,0xe4,0x55,0xc,0x78,0xff,0x71,0xa4,0x1d,0xac, -0xf4,0xdf,0x34,0x60,0x35,0xc5,0xa0,0xdb,0x3,0x70,0xb,0x90,0xd7,0x69,0x20,0xd9, -0xbf,0x3e,0xd6,0x80,0xff,0xb5,0x5,0x98,0x6c,0x4f,0x31,0x5a,0x80,0xbc,0x12,0x5, -0x1,0xff,0xda,0x77,0x94,0x7,0x4e,0xb2,0xff,0xdc,0x2,0xfc,0xfd,0xf6,0x24,0xaa, -0xd,0x88,0xb5,0x36,0xf0,0x21,0xd7,0x57,0x6f,0xa9,0x59,0xcd,0xb4,0x5,0xf8,0xc9, -0xf6,0x34,0x31,0x6d,0x3d,0x94,0x83,0xf1,0x3,0x86,0xbe,0x3a,0x25,0x9e,0x39,0xf0, -0xe1,0xf6,0x44,0x18,0xe6,0x5e,0xbb,0xf7,0x1,0xe3,0xff,0x32,0x4c,0x94,0x2,0xbd, -0xdf,0xc,0xa4,0x27,0x3b,0x2,0xe1,0x6e,0xc6,0xc5,0x43,0x6e,0x59,0x7e,0xa3,0xb6, -0x1,0x49,0xda,0x1f,0x28,0x6e,0x38,0xa4,0x6e,0xc5,0x63,0x7c,0x8b,0x23,0xa3,0xb7, -0x1,0x97,0x3b,0x3,0x67,0x1c,0x58,0x14,0x16,0x5f,0x34,0x3,0x17,0x3b,0x3,0x31, -0xbd,0x88,0xa,0x31,0x73,0xdb,0x2,0xf4,0x77,0x6,0x62,0x7a,0xa1,0x3c,0xff,0x74, -0xd3,0xc,0x4c,0x83,0x9d,0x81,0x98,0x23,0xe2,0xa2,0x85,0x3c,0x5a,0x69,0xd5,0xc, -0x24,0x4d,0x65,0x13,0x43,0xe0,0xc,0xa3,0xa2,0xe5,0x4d,0x70,0x18,0x13,0x7b,0xdd, -0xc,0xdc,0x34,0x15,0x86,0x4c,0x5c,0x1b,0x1a,0x46,0xc8,0xae,0x0,0xc8,0x17,0xcb, -0x62,0xeb,0x5a,0x7,0xa2,0x5c,0xc3,0xbc,0x7b,0x6c,0x53,0xfc,0xf7,0x70,0xd1,0x54, -0xfa,0x32,0x4,0x82,0x77,0xb,0x22,0x90,0xdf,0x38,0x6f,0x22,0x71,0x50,0xa3,0x2e, -0xd7,0x20,0xef,0x6,0xb9,0xc6,0x9f,0xb,0x1f,0x4e,0x9b,0x8a,0x7b,0x86,0x40,0xf0, -0x6e,0x41,0x62,0x1d,0x7a,0x11,0xcb,0x4f,0x86,0xd4,0xe5,0x5a,0x78,0x81,0x72,0x8d, -0xc7,0xc3,0xb3,0xa0,0xa9,0x5e,0x6a,0xa,0x8c,0xd3,0x90,0x5a,0x7,0x1,0xda,0x87, -0x3c,0xfb,0x52,0x97,0x6b,0xa1,0x83,0x72,0x6d,0x84,0x87,0x9e,0x9d,0x86,0x4d,0x15, -0x61,0x53,0x20,0x1,0x7f,0x3c,0x39,0xc2,0x7,0xff,0x66,0x6b,0xc0,0x5b,0x81,0x4f, -0xd9,0xde,0x81,0xa0,0xf,0xcf,0x1c,0xd4,0x87,0x4f,0xf1,0xe,0xfc,0xba,0xb1,0xc8, -0x6e,0xa,0x64,0xaf,0xc3,0x6d,0x7d,0x84,0x99,0x60,0x76,0x60,0xaa,0x2e,0x66,0xc4, -0x3c,0x7d,0x8a,0xe7,0xd3,0x7b,0x8d,0xcb,0x8,0xc6,0x40,0x98,0x2e,0x64,0xc4,0x68, -0x90,0x1f,0x9,0xab,0x3,0xc9,0xdb,0xa8,0xf,0x9f,0x42,0xbc,0xc6,0xa,0x56,0xc3, -0x42,0x89,0x31,0x30,0xe1,0x2d,0x63,0x8,0x74,0xe2,0x1a,0xa0,0xd4,0x87,0x93,0x50, -0x14,0xc3,0x47,0xef,0x92,0x5d,0x81,0x2,0x8a,0x40,0xf7,0xf,0xf5,0x40,0xd0,0x87, -0x9b,0xd7,0x85,0x8e,0xe4,0x87,0x58,0xb3,0x5e,0xaf,0x3a,0x20,0x75,0x26,0x61,0x59, -0x1f,0x26,0x58,0xa3,0x39,0x4f,0xee,0x87,0x6c,0x55,0xc8,0xb5,0xe1,0x80,0x56,0x50, -0x91,0x6b,0x2b,0x94,0x6b,0xc9,0x61,0xc8,0xd7,0x73,0x77,0x38,0x8a,0x52,0x7,0xf2, -0x59,0x2a,0x8f,0xd7,0x2e,0xc9,0xb5,0x15,0xca,0xb5,0xe4,0x18,0x82,0x21,0x5f,0xd0, -0x18,0x6,0x88,0xf,0x7,0xa8,0x7,0xd2,0x70,0x85,0x72,0x2d,0x19,0x87,0x14,0xf, -0x6a,0x24,0x56,0xef,0xb3,0x2f,0x75,0x20,0xba,0xb6,0xec,0xc4,0x72,0x5d,0xae,0x85, -0x2b,0x94,0x6b,0xa8,0xd9,0x30,0x4d,0x8c,0xfa,0x9f,0x7d,0xa9,0x1,0x29,0x3a,0xef, -0xec,0x4c,0x76,0x5d,0xae,0x85,0x2b,0x29,0xd7,0x56,0x98,0x26,0xde,0xeb,0xb8,0x9c, -0xa7,0x68,0x19,0xed,0xac,0xd4,0x54,0x6c,0xed,0xb4,0x2a,0x40,0x8,0x4b,0x2b,0x54, -0x4f,0xa7,0x36,0x5b,0x0,0x30,0x3e,0xe9,0xb8,0x9c,0xa7,0x56,0x31,0xb5,0x76,0xa, -0x79,0x88,0xab,0x5b,0x6,0xa2,0x63,0x43,0xe0,0xd8,0x61,0xb8,0x3b,0xcf,0xe9,0xba, -0x9c,0x97,0xbf,0xb0,0x1c,0xa3,0x9e,0xd0,0xc8,0x53,0xc,0xf9,0xe4,0x80,0xfa,0x14, -0x3,0xec,0x26,0x24,0x7e,0xd7,0xd5,0xb5,0xad,0x40,0x9e,0x44,0xc9,0x67,0x23,0xd4, -0x3,0x41,0x63,0x85,0x93,0xce,0xab,0x6b,0x5b,0x81,0xc2,0x8d,0x8b,0xa7,0x3f,0xd4, -0x3,0x97,0x8c,0x8d,0xdd,0x1e,0x67,0x5f,0x2a,0xc0,0xb8,0x74,0xe0,0x6e,0xf6,0x7c, -0x8b,0x7a,0xe0,0x82,0xb1,0x27,0x61,0x8f,0xb3,0x2f,0x95,0x49,0x53,0x7e,0x5,0xf2, -0x9,0x1e,0xf5,0x40,0x8f,0x57,0xe7,0x1b,0x8e,0xa2,0x24,0x56,0xd8,0x2,0xb4,0xab, -0x4b,0x1a,0xdb,0x81,0xf0,0xaf,0xb8,0xd8,0xd8,0x0,0x4c,0x1a,0xd7,0x4e,0x3a,0x3, -0xc1,0xf5,0x9d,0x87,0x8d,0xcf,0xe5,0x8e,0x9b,0xab,0x26,0x5d,0x81,0x33,0xf0,0x46, -0xcd,0xc0,0xa8,0x7c,0xea,0xf2,0x4e,0xc0,0xd8,0x61,0x51,0x18,0x36,0x2f,0xc1,0x58, -0xee,0x70,0xc0,0xd8,0xa,0x52,0x87,0x35,0x3,0x2d,0xcb,0x19,0xc,0x88,0xc3,0x93, -0x4,0xcd,0xc0,0x96,0x4d,0xac,0x37,0x4c,0x7d,0xa0,0x5e,0xb,0x90,0x4f,0x7,0x9b, -0xdd,0x19,0x90,0xf3,0xb0,0xb6,0x32,0x38,0xb0,0xde,0xf0,0x13,0x3e,0xdd,0x23,0xd6, -0xa,0x3c,0xed,0xc,0xac,0x75,0x6d,0x82,0x97,0xba,0xed,0x40,0xda,0x19,0x58,0xe7, -0xbc,0xe5,0xb9,0xfb,0x71,0xd0,0xa,0xb4,0xd3,0xce,0xc0,0x9a,0xf0,0xf4,0xbf,0xa4, -0x35,0xdb,0x6c,0x67,0xe0,0x4d,0x15,0x58,0x13,0x80,0xe5,0xc1,0xa8,0xc4,0xdf,0x7, -0xf0,0xa4,0x92,0x62,0xe4,0xc5,0xbe,0x9,0x63,0x3b,0x8f,0x61,0x15,0x78,0x5c,0x49, -0xa2,0x32,0x20,0x75,0x4d,0x80,0xa7,0x9d,0x81,0x95,0x34,0x31,0x3,0xca,0x87,0x97, -0xed,0x66,0x87,0x35,0xc0,0x4a,0x22,0x2c,0x81,0x7f,0x76,0xd8,0x7e,0x80,0x95,0x54, -0x5f,0x2,0x89,0x6f,0x0,0x6c,0x71,0xde,0x37,0xc4,0x72,0xeb,0x80,0x93,0x5a,0x60, -0x51,0x11,0x8e,0x6b,0x9e,0x36,0x60,0x14,0x9e,0x6e,0x12,0xcb,0xa9,0x3,0x5a,0x2d, -0xc0,0xa8,0xf6,0x89,0xa,0x6,0x1,0xf8,0x86,0x6d,0x3a,0xdc,0xd2,0x2,0xc8,0xb7, -0xd6,0x38,0x3d,0x52,0x8c,0x1b,0xb5,0x39,0xb1,0x3,0x90,0xa7,0x77,0x76,0x8f,0x24, -0xa,0x80,0xa1,0xf1,0x2c,0x2d,0x80,0xa9,0xd2,0xeb,0xd3,0x2d,0x4d,0xbc,0x61,0xff, -0x23,0xac,0xb7,0x43,0x5e,0x72,0xdf,0x6,0xa4,0xca,0xc1,0xd8,0x5d,0x33,0xef,0x8b, -0xa0,0xde,0xd3,0xc4,0x78,0x67,0xb6,0x1,0x89,0xd2,0x3e,0xd5,0x15,0xf8,0x9f,0xfc, -0x7a,0x5f,0x1a,0xe1,0xd8,0x6f,0x3,0xca,0x84,0xdd,0xef,0x3,0xfc,0x8b,0xab,0xfa, -0x68,0x31,0x4f,0x1b,0x80,0x71,0xed,0x63,0x3f,0xcc,0x80,0xef,0x5c,0xc7,0x38,0x18, -0xa9,0x9c,0x76,0xb8,0x2d,0x82,0xc7,0xc3,0x5,0x6b,0x0,0x46,0x5b,0x1e,0x6d,0x62, -0x0,0x4c,0x9f,0x2d,0x62,0x64,0x88,0x8d,0x79,0x20,0xef,0x2d,0x4b,0x44,0xfc,0x46, -0xe0,0x44,0x3e,0xec,0xab,0x7,0x90,0x3c,0x5b,0xf3,0xe,0x33,0x2f,0xb7,0x21,0x99, -0xd3,0x34,0x2,0x73,0x65,0xd7,0x3,0xc8,0x5d,0x5b,0xd6,0xed,0x8d,0x5e,0x42,0x66, -0x6d,0x3f,0x28,0x60,0x9a,0x3f,0xec,0xab,0x3b,0x50,0x38,0xef,0xec,0x18,0x0,0x74, -0xbc,0x32,0x11,0x6e,0x2,0xe6,0xf,0xa9,0xe9,0x6e,0x88,0x37,0xb7,0x3c,0x1e,0x66, -0x3b,0xa0,0x30,0xb4,0x48,0x60,0x93,0x1d,0x92,0xc,0xe8,0xf7,0x30,0x8b,0x3e,0xc0, -0x64,0xcb,0xf3,0x77,0xcc,0x81,0xd9,0xd9,0x11,0x38,0xd3,0xd,0x80,0xf1,0xd6,0x67, -0xc,0xed,0x0,0xd4,0xa2,0xc5,0x37,0x53,0x21,0xed,0xc4,0x43,0x67,0xc3,0x28,0x7f, -0xea,0xde,0xbe,0x80,0x53,0x57,0x94,0x57,0x82,0x88,0x3,0x27,0x19,0xd0,0xde,0x17, -0xf0,0x33,0x57,0x5e,0x21,0xf7,0xbb,0xa1,0x52,0xd3,0xe9,0x53,0x18,0x5a,0xf2,0x8c, -0x41,0xa6,0x78,0x4e,0x66,0x87,0xda,0x18,0x7e,0xf6,0xc,0x7e,0xb9,0x25,0x94,0x9d, -0xe3,0xdf,0xce,0x94,0xa7,0xee,0xd,0x2,0xe4,0xae,0x4d,0x7,0xfe,0x5b,0xcc,0xbb, -0xc9,0x6d,0xfa,0x17,0xf8,0xb7,0x53,0xa5,0x88,0x34,0x8,0x90,0x3b,0x6f,0x1d,0xf8, -0x2b,0x4,0x9e,0x6e,0x8,0x6e,0x4d,0x67,0xa3,0x2,0xe8,0xf,0x2,0x14,0x72,0x2d, -0x9,0x4b,0x93,0x26,0x3d,0xbd,0xd9,0xf0,0x49,0xf3,0x64,0xeb,0x83,0xb0,0xcc,0x6a, -0x6d,0x76,0x19,0x28,0xe4,0x5a,0xac,0xce,0x52,0xfe,0xeb,0xd1,0x5a,0x64,0x78,0xef, -0x35,0x3c,0xec,0xcb,0x14,0xe8,0x4b,0x20,0x71,0x72,0xb9,0x76,0x51,0x1,0x1e,0xac, -0xc5,0xa4,0x51,0xa,0x81,0x3d,0x22,0xa2,0xe5,0x6f,0x0,0x18,0xf2,0x7b,0x95,0x3a, -0xa9,0x93,0xcb,0x35,0xb7,0x2,0xfc,0xfc,0x5a,0x4c,0x1a,0x5,0x68,0xf7,0x5,0x8a, -0x16,0xe1,0xd4,0x85,0xeb,0x92,0x69,0x22,0xf5,0xa,0xa0,0x7c,0xbe,0xd6,0xff,0xbc, -0x12,0xf,0x85,0x12,0xd3,0x25,0x19,0xe,0xc8,0x13,0x61,0xde,0x5d,0xa3,0x3,0xa3, -0xab,0xd,0xcb,0x81,0xe2,0xb7,0xbe,0xc0,0xb,0xb1,0x73,0x6,0x3e,0x78,0x9e,0xa5, -0xfa,0xbc,0x17,0x53,0x7,0xc6,0x1,0xcb,0x81,0x8e,0x10,0x34,0x83,0x1,0x27,0x9a, -0x1d,0x4a,0x60,0xa2,0x0,0x5d,0x21,0xd9,0x6,0x3,0x5a,0x35,0xc0,0x24,0xf3,0x64, -0xd2,0xe2,0xc9,0xb0,0xb7,0xb4,0xa,0x8c,0x33,0x4f,0x26,0x7d,0x1a,0x1d,0x16,0xa8, -0x46,0x8b,0x9a,0x2b,0x94,0x55,0xe1,0x1,0x67,0x69,0x15,0x98,0x47,0xfc,0xc1,0x81, -0x95,0xb2,0xc9,0xf,0x1,0x28,0x7f,0xb7,0x87,0x73,0x6d,0x9b,0x49,0xd8,0x0,0xb4, -0x45,0x8e,0xd7,0x1f,0x58,0x75,0xde,0xcb,0x49,0xb0,0x4f,0x60,0x35,0x3c,0xcd,0x26, -0x7e,0xd9,0x79,0x2b,0x40,0x57,0xe4,0xe9,0x3,0x1,0x79,0x0,0x9e,0x7f,0x76,0x77, -0x40,0xa1,0xf,0xa7,0x77,0x7,0x14,0xfa,0xb0,0x11,0x98,0xb9,0x9e,0x61,0x80,0x42, -0xae,0x69,0x40,0x77,0x60,0x60,0x4d,0x22,0xac,0xc9,0x35,0x9e,0xb5,0xed,0x19,0xa8, -0x55,0x31,0x78,0x22,0x5c,0x7,0xec,0xf8,0x72,0x1b,0x80,0x7a,0x5e,0xea,0xe,0x3, -0xb4,0x1b,0x80,0x5a,0x25,0x6a,0xa8,0x31,0xdc,0x64,0xc0,0x1a,0x41,0xaa,0xd5,0xda, -0xbe,0x99,0xe,0x7,0xe4,0xbf,0xd6,0x0,0x1b,0xaa,0x89,0x3,0x0,0x6b,0x8a,0xa, -0xa6,0x40,0x5c,0x42,0xe1,0x67,0xdc,0xfb,0xfc,0x14,0x8,0x6a,0x61,0xe9,0xf,0x3f, -0x91,0x3f,0xc8,0x18,0x97,0x54,0x59,0xe4,0x88,0x16,0x88,0x89,0x97,0x3,0x6b,0xca, -0x26,0xcd,0xc0,0xc2,0xd3,0xe0,0x3d,0xb1,0x3c,0x5e,0x5a,0xc2,0x87,0xc7,0x10,0x80, -0xe2,0x68,0xc4,0x16,0x16,0xc8,0x70,0xbf,0x39,0x80,0x6c,0xd1,0xe4,0x61,0xb9,0x8, -0x8c,0xc2,0x4d,0x6d,0x25,0xca,0x10,0x48,0xe1,0x93,0x28,0xfc,0x55,0xec,0x10,0xf3, -0xf8,0x22,0x1c,0xfe,0xd8,0xe0,0x1e,0x61,0x80,0xb0,0x48,0x86,0x5f,0xcf,0xdb,0x58, -0x52,0xcb,0xc9,0x27,0x4d,0x76,0xdc,0x4,0xae,0xe2,0xd4,0xae,0xae,0x6d,0x5,0x12, -0x7e,0xf6,0xa2,0xc3,0x7,0x5,0x9b,0x8c,0x63,0xbe,0x17,0xce,0xc3,0x7e,0xe,0x86, -0xa9,0x16,0xe4,0x6,0xf2,0xf1,0xc3,0xb8,0xbf,0x91,0x1f,0x62,0xc0,0x6f,0xac,0xec, -0xf2,0xc2,0xf6,0xd1,0xda,0xd5,0xb5,0xe9,0xb6,0x78,0x8,0x99,0x15,0xc0,0x6c,0x3e, -0xed,0xf0,0x91,0xe,0x11,0x40,0x71,0xea,0x59,0xfc,0xc,0x65,0x3f,0x15,0xf,0x57, -0xe,0xf0,0x11,0x74,0xf0,0xa5,0x62,0xf4,0x4,0x50,0x6c,0x76,0x76,0xd8,0x6d,0xed, -0xea,0xda,0x56,0x20,0xd6,0x3e,0xf1,0x9d,0x3d,0xb4,0x2,0x2d,0x19,0xde,0xd8,0x93, -0x3,0x20,0x8f,0x8a,0xe7,0x3e,0xa0,0x10,0x81,0x91,0xb2,0x9e,0xf2,0xfd,0x16,0x2, -0x18,0x7b,0x19,0x70,0xeb,0xea,0x5a,0x5d,0x4e,0x13,0x79,0x90,0xa4,0xfb,0x56,0x30, -0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0xd,0x79,0x83,0x4d,0x6d,0xe2,0x10,0x3b, -0x71,0x89,0x13,0xbb,0x89,0x1b,0x79,0xb1,0x17,0xe1,0x43,0x43,0x1e,0xf3,0x1d,0x25, -0x2,0xb8,0x58,0x8,0xe0,0x72,0xfb,0xea,0x5a,0x5d,0xd6,0x6,0x9f,0x13,0x44,0x1, -0x1e,0x9d,0xb,0x40,0x6,0x40,0x5c,0x3f,0xa4,0x36,0x6e,0x8,0x1,0xa4,0x4b,0x0, -0x97,0x0,0x2e,0xf6,0xf1,0x79,0x62,0xd1,0x63,0xbe,0x67,0x46,0x0,0xaf,0xd7,0x2, -0x38,0xdb,0xbe,0xba,0x56,0xb,0xc,0xe2,0x20,0xa,0x1,0x9,0xd3,0x1d,0x8c,0x32, -0xb5,0x99,0xd,0xa9,0x98,0x4d,0xdd,0x14,0x70,0xd4,0x25,0x1e,0x20,0x7d,0xe2,0xc5, -0x41,0x2,0x3f,0x59,0xfc,0x98,0xef,0xa,0x92,0x93,0x46,0x2,0xbf,0x68,0x5f,0xb7, -0xf8,0x5e,0x80,0x99,0xb6,0x88,0xc2,0x24,0x80,0xcf,0x8,0xce,0x61,0x70,0x60,0x8e, -0x42,0x9a,0x79,0xe,0xd9,0xad,0xd,0x72,0xd6,0x21,0x5e,0xea,0x12,0x9f,0xba,0x9, -0x88,0xdb,0x38,0x24,0x3e,0x7c,0xe9,0x63,0xde,0xa4,0xaf,0x3,0x6f,0xdb,0x97,0x82, -0x54,0xf5,0xb4,0x3,0xf0,0x5a,0x5,0x4e,0xda,0x80,0x99,0x3e,0x1c,0xa,0x68,0xb5, -0x1,0x33,0x5,0xbc,0x3,0xf0,0x4a,0xbb,0xa5,0xac,0x5,0x98,0x69,0xfc,0xfe,0x40, -0xfe,0x10,0xe9,0xe,0x40,0x59,0xc5,0xe8,0x3f,0x4b,0x79,0x45,0x44,0x0,0x71,0x96, -0xb6,0x2,0x65,0x92,0xd2,0xdf,0xf0,0x6f,0x58,0xe,0xac,0x74,0x41,0x37,0x1,0x7b, -0xbb,0xb6,0x75,0x1,0xac,0xf4,0x79,0x97,0x80,0x4a,0xad,0xad,0xb7,0xf3,0xc6,0xc7, -0x23,0x89,0xd5,0x4d,0xe9,0xbc,0x9b,0x80,0x4a,0x35,0xf1,0xe7,0x7d,0xc3,0x93,0xa, -0xc,0x2a,0x9b,0x3,0x4a,0x40,0xa5,0x5e,0xfa,0x66,0xcf,0x0,0xac,0xa7,0x18,0x95, -0xed,0xf,0x25,0xa0,0x52,0x11,0x7e,0xb7,0x67,0x8a,0xa1,0x3,0x31,0xc5,0x68,0x2, -0x2a,0x35,0xef,0x8f,0x7b,0x26,0x51,0x7a,0xd6,0x86,0x49,0x54,0x13,0x50,0xa9,0xea, -0xdf,0xf6,0x4e,0x13,0xdf,0x17,0xc0,0xd7,0xb2,0x34,0xb1,0x11,0x58,0xac,0x5b,0xdc, -0xf6,0x4c,0x84,0x75,0x20,0x63,0x2d,0xc0,0x62,0x65,0xa6,0x2f,0x50,0x1f,0xc3,0x2a, -0x50,0xec,0xa3,0xcb,0x2a,0xdc,0xca,0xda,0x13,0xe9,0xae,0x9e,0x4,0xf0,0x44,0x2, -0xa9,0x11,0xb0,0x58,0x5d,0xeb,0xb,0x64,0xf,0xc4,0x2,0x4,0x19,0x85,0x26,0xc0, -0x1d,0xd6,0xf,0xb,0xd1,0x96,0xf7,0x51,0xd4,0x1,0x37,0xfc,0x58,0x12,0x7f,0xb1, -0xfb,0xa,0x69,0x6,0x8c,0xd4,0xcc,0xbb,0x15,0xb8,0xc3,0x1a,0x70,0x6,0x94,0xa7, -0xd,0xd0,0xa9,0x11,0x70,0x87,0x55,0xee,0xc,0x28,0x77,0x39,0x53,0x66,0x6,0xec, -0xdf,0x38,0xf0,0x63,0x1,0x1a,0xf6,0x62,0xd0,0x70,0x28,0xa0,0x61,0xb7,0xc9,0x70, -0x40,0xc3,0x7e,0x9a,0xe1,0x80,0x86,0x1d,0x43,0xd,0x40,0xad,0x81,0xa7,0x1d,0x68, -0xd8,0x13,0x35,0x1c,0x30,0x35,0x31,0xc3,0x74,0xdb,0x4f,0x54,0xde,0x91,0x60,0x0, -0x64,0x26,0x8b,0x87,0x83,0x2,0x27,0x6,0x66,0x38,0x28,0x30,0x32,0x31,0x43,0x87, -0xe,0x4,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0xa6,0xaf,0x88,0x76,0x8e,0x26,0xbb,0x1, -0x93,0xbb,0x6,0x92,0xbb,0x6,0xf6,0x78,0xfd,0x90,0x81,0xdc,0x48,0xa6,0xba,0xcb, -0xc2,0xef,0x22,0x4a,0x42,0x3b,0x24,0x30,0xad,0x1,0x7a,0x64,0xf,0x40,0x4c,0xa1, -0xe9,0x7d,0x9f,0x2b,0x28,0x4,0xf2,0xe3,0x2,0x21,0x6c,0x45,0x11,0x4b,0xdd,0xbd, -0x1,0x7f,0x6,0xaa,0xc9,0x65,0x3a,0x70,0x2,0x9e,0x26,0x61,0xc3,0x3,0x9,0xd7, -0x86,0xa0,0xb,0xdf,0x97,0x40,0xf4,0x19,0x3e,0xe3,0xda,0xf0,0x7c,0xb9,0x7,0x60, -0xf2,0x74,0xce,0x92,0xe8,0x92,0xc5,0xb,0x1,0x7c,0xf9,0xd0,0xe7,0xea,0xf7,0xfe, -0xeb,0x1,0x8b,0xe6,0xfc,0x94,0x36,0xda,0x21,0x9d,0xac,0x4f,0xf5,0x35,0xe0,0x66, -0xc5,0x36,0xcb,0x5,0x5b,0x66,0xc0,0x40,0x0,0x1f,0x3e,0x0,0x61,0xea,0xee,0xb, -0xb8,0x5a,0x14,0x57,0x98,0x1,0x4f,0x2,0xdc,0x41,0xb4,0x3f,0x60,0x36,0x86,0x8, -0x9c,0xc1,0x18,0x22,0x10,0xf,0xdb,0x70,0x9,0x9a,0x47,0x67,0xa0,0x2e,0x48,0x7f, -0x10,0xc0,0xcc,0x2c,0x5e,0xfa,0x3e,0xdf,0x88,0x8a,0x40,0x5c,0x8d,0xbf,0x20,0x1c, -0x3a,0x3c,0x10,0xd,0x1f,0xeb,0x33,0xb,0x0,0xe2,0x8a,0x84,0x9f,0x6,0x3c,0xc5, -0x98,0x11,0x1,0x1d,0xe,0xf8,0x1b,0x30,0x8b,0xd9,0x25,0x77,0x6d,0x1c,0x8,0x66, -0x41,0x0,0xe8,0x51,0x1,0x5c,0xc2,0x37,0xcd,0x7,0x5,0xda,0x17,0x30,0xa5,0xc4, -0xd1,0x4f,0x8,0x8c,0xd0,0xcd,0xf1,0xb1,0x13,0xc0,0xd,0x7c,0xd3,0x6a,0x48,0x20, -0x71,0x2e,0xb9,0xa7,0xc9,0xd3,0x8a,0xfb,0x1,0x3f,0x74,0xe1,0x92,0x34,0x7,0xdf, -0xdb,0xe4,0xc3,0x15,0x63,0xe7,0xab,0x97,0x4e,0x47,0x20,0x75,0xa7,0xdc,0x79,0x17, -0x40,0xe1,0x4b,0x17,0x2d,0x57,0x75,0x1b,0xbf,0xbd,0x86,0x8f,0x5f,0xbd,0xb4,0x3a, -0x2,0x7b,0xbe,0xd6,0xcb,0xf5,0x3b,0x0,0x3c,0xfa,0xcd,0xcb,0x71,0xd8,0xf,0x88, -0x75,0xb6,0x4d,0xaa,0xab,0x9b,0xcb,0xd,0x3e,0xf2,0x1b,0xcf,0x4a,0x15,0xe1,0x52, -0xb9,0xf3,0xeb,0xd9,0xfa,0x31,0x4c,0xed,0x71,0xdc,0x1b,0x88,0x95,0xc4,0x65,0xaa, -0xeb,0x37,0x37,0x81,0xe1,0xc4,0x63,0x1a,0xf0,0x11,0xdc,0x8e,0x8c,0xd1,0x12,0xf8, -0xbf,0xd9,0xe3,0x6b,0x10,0x6b,0x7f,0x78,0x79,0xd6,0x19,0x88,0xc7,0x1,0x2e,0x78, -0xad,0x74,0xc6,0xfb,0x6e,0x7c,0x26,0x8e,0xea,0x8,0x52,0x37,0x9,0x53,0x2f,0x82, -0x49,0x3b,0x41,0x7d,0xc7,0xeb,0xb8,0x79,0x42,0x72,0x9b,0xbe,0xcb,0x81,0xff,0xbc, -0x2f,0x70,0xc9,0x5c,0x36,0x67,0x3a,0x10,0x53,0x8c,0x8b,0xb,0xb8,0x52,0x7,0x26, -0x73,0x2,0xc1,0x63,0xa9,0x0,0xe9,0xc7,0x30,0xdb,0x92,0xbf,0xee,0xd,0x5c,0xc1, -0x7b,0xc1,0xbf,0xac,0x0,0x62,0x12,0x35,0x83,0xdb,0xf8,0xef,0x21,0x46,0x9f,0x13, -0x96,0xcc,0xb,0x61,0xb8,0xbe,0x25,0xe4,0xa,0x80,0x1f,0xdd,0x1b,0x1a,0x88,0x6e, -0x2e,0x86,0x48,0x15,0x1,0x70,0xa9,0x2,0x37,0x14,0x80,0xe3,0xe1,0x81,0xd8,0xc4, -0x99,0xc0,0x6f,0xf1,0x29,0x4b,0x12,0x15,0xb8,0x2,0x7f,0x94,0x1e,0x7f,0xf4,0x49, -0xd7,0x59,0x9a,0xf0,0x2,0xbb,0x9b,0x3,0xb1,0x67,0x44,0x16,0xd8,0x39,0x10,0x23, -0x47,0x4,0x57,0x98,0x1c,0xb1,0x4,0xf,0x5d,0x2d,0xc,0xff,0x18,0x1f,0x2b,0xb6, -0xfe,0xa4,0xab,0xe1,0xb7,0x1,0xb3,0x31,0xa4,0x6f,0xb0,0x64,0xfc,0x4b,0x5,0x18, -0x41,0xfc,0x62,0xe7,0xeb,0xce,0xae,0x4d,0x5,0xe2,0x2c,0x55,0x81,0xea,0x2c,0x3d, -0x3,0xb3,0x38,0xb1,0x7,0x70,0xde,0xd4,0x5f,0x81,0x65,0x2f,0xe4,0x9a,0x5,0xc4, -0x42,0x18,0x43,0x74,0x0,0xf3,0x34,0xe0,0xcb,0x7,0x1e,0x18,0xbd,0x1f,0xf1,0x43, -0x91,0xa9,0x41,0xa9,0xcc,0x60,0xd2,0xb8,0x2b,0xf8,0x54,0x1,0xc4,0x2,0x36,0x81, -0x14,0x23,0x39,0x83,0xa8,0xf,0xc0,0x89,0x9d,0x7b,0x9a,0xb4,0xe4,0x69,0x76,0x0, -0x5e,0xc2,0x2c,0x55,0x80,0x14,0x80,0x4,0x80,0x89,0x4,0x6e,0xf1,0xa5,0x3b,0x0, -0x17,0x0,0x9c,0x2e,0x14,0xc9,0x4,0x1,0x18,0x80,0x24,0xed,0x55,0x2d,0xde,0x5b, -0x78,0xda,0x1d,0x48,0x20,0x91,0xd9,0xe8,0xc7,0x3b,0xa3,0x59,0xf0,0xeb,0xb4,0x8, -0xc3,0xff,0x92,0x72,0xcd,0xeb,0x47,0x6,0x4,0xa7,0xb9,0x49,0x82,0xb2,0x20,0x15, -0xc0,0x53,0x46,0x42,0x88,0x16,0xe1,0x72,0x0,0x60,0x92,0x55,0xe9,0x63,0x8,0xc0, -0xe0,0xc7,0x16,0xf2,0x8b,0xd1,0x9b,0xba,0x31,0x7,0xa6,0xd6,0x5b,0x90,0x39,0x46, -0xe0,0xc7,0xcf,0x87,0x0,0x86,0x2,0xba,0x4,0x1f,0x36,0x9f,0x79,0xfc,0x8,0x6b, -0x3c,0x8b,0x1c,0x2d,0xe0,0x7c,0xc6,0x4b,0x93,0xf4,0x18,0xcc,0xc3,0xbb,0x80,0xf7, -0x10,0x76,0x98,0x88,0x68,0xc0,0x56,0x73,0xf0,0xa5,0xf3,0x29,0x3f,0x6e,0x19,0x37, -0x4e,0xe0,0x67,0x47,0x17,0x2,0x78,0xe6,0x8,0x21,0x34,0x88,0x1d,0xe2,0xa6,0x5, -0x4c,0x7c,0x57,0xb,0x0,0x2e,0xa6,0x1c,0x8e,0xd,0xce,0x8,0xce,0xe4,0x5a,0x8, -0xb0,0x48,0x44,0x8d,0x21,0x5c,0x9b,0x68,0x21,0xce,0x80,0x32,0xfe,0x71,0x28,0x46, -0x3c,0xe,0x14,0x41,0x38,0xdb,0xec,0xbe,0x23,0x50,0xde,0xc3,0xc,0x98,0xca,0x2b, -0xe6,0x60,0xaf,0x0,0x76,0xbb,0x42,0xc2,0xab,0xbf,0x51,0x6d,0x19,0x5f,0xde,0xbf, -0xc,0x98,0x5d,0x31,0xde,0xea,0x6c,0xc,0x11,0xd8,0x6d,0xc,0x13,0x5e,0xdf,0x9e, -0xd4,0x2e,0x54,0xc8,0xfb,0xb7,0xbc,0x84,0x59,0xea,0x7a,0xf9,0x8c,0xc1,0xf3,0x2c, -0xb2,0x59,0xa,0xc0,0x8e,0xb3,0xb4,0xe9,0xa,0xe5,0xfd,0x8b,0xef,0x81,0x7a,0xba, -0xe7,0x15,0x33,0xe6,0x9c,0xf1,0xbc,0x34,0xe0,0x9d,0x45,0xdd,0xed,0xb0,0xe1,0x4b, -0xc4,0xa0,0x25,0xf,0x3c,0x16,0xe3,0xb2,0x67,0x36,0x63,0xa2,0xdc,0xd3,0x70,0x60, -0x57,0x4f,0xd3,0xf0,0x12,0xf7,0x90,0x80,0x10,0x4d,0x1e,0x6,0xf2,0x8a,0xf9,0x55, -0x67,0xbe,0x94,0x3,0x3b,0xfa,0xd2,0x48,0x34,0x5d,0xd5,0xa6,0x8,0x99,0x6f,0xc9, -0xbe,0xc5,0x17,0x50,0xba,0x53,0x3c,0x9c,0x88,0xa6,0x2b,0x7b,0x7b,0x5e,0x5a,0xbc, -0xf2,0xbc,0x74,0x17,0x60,0xd3,0x15,0xee,0x27,0x0,0xb7,0xbe,0xca,0xd7,0x29,0xd7, -0x94,0x84,0x59,0x48,0x9f,0x61,0x6f,0x6,0x4,0x2e,0x59,0xe9,0x61,0x7,0x62,0xfe, -0xa6,0x72,0x34,0xc5,0x63,0x79,0xcc,0x67,0x29,0x3f,0x96,0xa6,0xd6,0x17,0x52,0xb0, -0x3d,0x8a,0x59,0x5b,0x28,0xe,0xcb,0x41,0x13,0x9c,0x82,0x59,0x3c,0xb4,0xc4,0x89, -0x59,0xae,0x70,0x3a,0x84,0xbb,0xf,0xf3,0x44,0x98,0x9f,0x93,0x5a,0xeb,0xb,0x79, -0xbd,0xd4,0x5d,0x8,0xdf,0x19,0x8,0xe8,0x34,0xa,0xd9,0x21,0xd6,0x4b,0x8b,0x50, -0xc5,0x81,0x63,0x67,0x80,0x2b,0xe4,0xa9,0xbe,0xb3,0x10,0x97,0xe1,0x89,0x86,0x80, -0x4b,0x98,0xd3,0x7,0x30,0xcd,0x22,0x79,0xd5,0xe7,0x12,0x98,0xba,0x3,0x8c,0x61, -0xf2,0x4,0x2b,0x51,0x8b,0xdc,0x7f,0xe2,0x5d,0x58,0xdc,0x7,0xe0,0x38,0x50,0x43, -0x15,0x97,0xdc,0xa9,0x37,0x4,0x10,0x6b,0x6d,0x58,0x2c,0x9d,0x89,0x1,0x7c,0x89, -0x35,0x1a,0xf0,0x3a,0x7,0x69,0xa0,0x86,0x2a,0x1,0xf4,0x87,0x2,0x62,0xed,0x52, -0x46,0xd8,0x5,0x3e,0x9a,0x43,0x2,0x59,0x36,0x6b,0x5c,0x9,0xc,0x7e,0xb4,0x40, -0x2c,0x96,0xa,0x87,0xcd,0x16,0xe0,0x56,0x97,0x19,0x30,0xcb,0xa8,0x1c,0x39,0x69, -0x6,0x3,0x52,0x71,0x19,0x38,0x55,0x17,0x60,0xfd,0x31,0x2,0xcf,0x64,0x12,0xc3, -0x8f,0xed,0xed,0x6c,0x87,0xd,0xc0,0x70,0x2e,0xe7,0xbb,0xcb,0xb3,0xd1,0x5,0x4e, -0xc9,0x43,0x9f,0x1d,0x8e,0x3,0x7e,0x9a,0x1c,0x4f,0x5a,0xe3,0x21,0x81,0xc1,0x5, -0x40,0x5d,0xe9,0x49,0xa7,0x6c,0x91,0xe0,0xb2,0x10,0x48,0xee,0x23,0xc5,0x8b,0x92, -0x1,0x81,0x24,0xb8,0x84,0xb,0x29,0xe2,0xe1,0x82,0x60,0x6e,0x18,0x2,0x30,0xdc, -0x4f,0xb4,0xa0,0xc1,0x14,0x2e,0xa4,0x88,0x13,0xb,0x34,0x3c,0x6c,0xf,0x3c,0xda, -0x73,0x78,0xba,0xf3,0x78,0x18,0xf3,0xdb,0xa9,0xcf,0xfb,0x89,0x1c,0x43,0x4b,0x9a, -0xc5,0xb0,0x40,0xf8,0xec,0x45,0x52,0x2,0x8e,0xb,0x60,0x58,0x7a,0x54,0xcf,0x8e, -0x63,0xe8,0x73,0x47,0x33,0x7,0x7d,0x28,0x3a,0x2f,0x19,0xef,0xbc,0xb4,0x4,0x10, -0x5b,0x3d,0xd1,0x2d,0x24,0xfe,0xa0,0x40,0x54,0x50,0x33,0x4f,0x5,0xa6,0xf7,0x8f, -0x39,0x90,0x3a,0xb1,0x88,0xfe,0x1e,0x1b,0xcc,0x2c,0x3c,0xf6,0x7b,0x54,0x50,0xa0, -0xf,0x71,0x7f,0x56,0xc4,0x1b,0x59,0xc3,0xf4,0xe4,0x50,0x0,0xff,0x92,0x88,0x83, -0xde,0x1c,0x36,0x94,0xa7,0x81,0xbc,0x14,0x1f,0x86,0xb7,0x4,0x31,0x83,0x5b,0xde, -0x2e,0xc1,0x34,0x70,0x65,0x26,0xb8,0x1f,0x72,0xf5,0xf4,0x84,0x14,0xe9,0xc7,0xee, -0x40,0xc8,0xd7,0x36,0x58,0x2f,0x5,0x27,0x9d,0x0,0x10,0x37,0xf5,0x4d,0x1,0x8a, -0x6b,0x4f,0xc1,0x6f,0x5,0x70,0x74,0xda,0x5d,0x1f,0xb6,0x3,0xe1,0xc7,0x4f,0xdc, -0x12,0x30,0x12,0xc0,0xd3,0xa3,0x42,0x33,0xe,0x7,0x44,0xa7,0x5d,0x6,0xc2,0x25, -0xb9,0x30,0x86,0xe3,0x83,0x22,0x7d,0x1b,0xe,0x98,0xe0,0x99,0xce,0x9e,0x6,0xf4, -0xc0,0xf2,0x2e,0x0,0x78,0x62,0x29,0x95,0x86,0xc1,0x80,0x44,0x74,0x43,0xab,0x40, -0x6c,0x1c,0x98,0x11,0xb9,0x6,0x2c,0xd3,0xb7,0xe1,0x66,0x29,0x6,0x60,0xcb,0x57, -0x81,0xc,0x81,0x4b,0x61,0xf8,0xb2,0x98,0x33,0x84,0x1d,0xca,0xc6,0x81,0x95,0xcc, -0x11,0x95,0x12,0x34,0x98,0x87,0x58,0x3f,0xe4,0x22,0x88,0x30,0xc6,0x86,0xd0,0x16, -0xbc,0x35,0x42,0x91,0xe2,0x2a,0x70,0x3f,0xf1,0xf0,0xae,0x81,0xdf,0x5b,0x3c,0xfc, -0x1e,0x80,0x59,0xe1,0x52,0xbd,0xdf,0x79,0x12,0xc5,0x8b,0xec,0xf7,0xbc,0xbb,0x3, -0xd2,0xae,0xcb,0x8,0xdb,0x27,0x8d,0x9d,0xa9,0x47,0x1,0xc4,0xe7,0xc,0xc6,0x59, -0x5d,0x4d,0x49,0x13,0x4b,0xb,0x96,0xbb,0xd8,0x21,0x63,0xfc,0x29,0x1b,0x12,0x18, -0xbb,0xfc,0xe1,0x4a,0xe2,0xfc,0x51,0x5,0x38,0x4a,0x40,0xd9,0xd,0x61,0xf8,0x89, -0xdc,0xd0,0x91,0x1,0xf9,0x86,0xe,0x47,0x1a,0xbb,0x2,0x4c,0x8,0xa8,0x82,0x21, -0xc,0x3f,0x81,0x94,0x3e,0x21,0x21,0x5f,0x99,0xc1,0x4e,0x85,0x39,0x5c,0xc5,0x25, -0xe8,0xb,0x2c,0xe6,0x89,0xfd,0x32,0xa2,0x12,0x35,0x1c,0x10,0x7c,0x26,0x36,0x30, -0x65,0xc0,0x5,0x7c,0xe8,0x74,0xc5,0x98,0x3f,0xff,0xa9,0x1,0x9,0xa4,0xfb,0x9, -0x8a,0x99,0x2,0xc8,0x2e,0xe0,0xff,0x5f,0xc2,0x18,0x7a,0x30,0x86,0x4f,0x6,0x9b, -0x34,0x12,0x48,0xfd,0x5,0x24,0x9f,0x3a,0x10,0xfb,0x4b,0x65,0x3f,0xd,0xb1,0xa2, -0xa1,0xe4,0x9a,0x4,0xa6,0x0,0xa4,0x25,0x20,0xf6,0x97,0xca,0x7e,0x1a,0x6a,0xcf, -0x7,0x32,0xfc,0x6c,0x49,0x16,0x9b,0xde,0x52,0x5f,0x5b,0x3,0xe6,0xfd,0xa5,0xb2, -0x9f,0x26,0x75,0x16,0x3,0xb9,0xb6,0x1c,0x78,0x57,0xe1,0xe9,0xce,0x81,0x3f,0xe4, -0x7a,0xe9,0xb0,0xfa,0xb0,0xad,0x5e,0x3a,0x98,0x3e,0x54,0x15,0x70,0x49,0xac,0xa4, -0x2e,0x2b,0xca,0x6d,0x83,0xe9,0xc3,0x42,0xb6,0x15,0x7,0x57,0x65,0x2f,0xa5,0x5e, -0x3a,0x9c,0x3e,0xcc,0x3,0xb1,0x5f,0x9c,0xa4,0x9c,0xcf,0x58,0x56,0x54,0xbf,0x6, -0xd3,0x87,0xf9,0xcb,0xcd,0xca,0xb8,0xa5,0xab,0xe,0xb3,0x85,0x9a,0x81,0xf4,0x61, -0xfe,0xba,0xa8,0x5e,0x42,0xbe,0xac,0x17,0xe,0xa8,0xf,0xf3,0xd7,0xac,0x66,0xd6, -0x28,0x6b,0x89,0x83,0xe9,0xc3,0xef,0xf,0x98,0xad,0x3e,0x97,0x6f,0xb3,0x1c,0xdb, -0xc1,0x4,0x69,0x31,0x43,0x6a,0x2e,0x61,0xa6,0x8c,0xed,0x50,0x82,0xb4,0x62,0xe6, -0xba,0x78,0x2c,0xa6,0xe8,0x50,0x82,0x54,0xb3,0xb,0x56,0x2,0x16,0x5,0xda,0xe1, -0x4,0xa9,0x61,0xaa,0x3f,0x9c,0x20,0xfd,0xff,0x49,0xae,0x7d,0xf,0xfa,0xb0,0x7c, -0x38,0x3a,0x46,0xdf,0x73,0x30,0x7,0x47,0x8e,0xa1,0x35,0xb4,0x3e,0x2c,0x1f,0xff, -0x8e,0x40,0xdc,0x16,0x6f,0x2b,0xa2,0x74,0x50,0x60,0xe9,0x80,0xfb,0x22,0xd5,0x17, -0xc0,0x61,0x12,0x61,0xd,0xe8,0x57,0x81,0x7,0x8f,0x18,0x7d,0x74,0x2a,0x80,0xce, -0xd0,0x76,0xf8,0xd2,0x9b,0x56,0x80,0xc7,0xa7,0xa2,0x9a,0x88,0xc0,0xd9,0x90,0x76, -0x88,0xea,0x69,0xe1,0xea,0x86,0xff,0x5a,0xc0,0x38,0x70,0x7c,0x20,0x24,0x77,0x3c, -0x38,0x70,0xae,0x3,0x27,0x12,0x78,0x66,0x9,0x60,0xf2,0x74,0x68,0xe0,0x52,0x7, -0x46,0x12,0x18,0x4a,0x20,0x79,0x3c,0x64,0xd6,0x6,0xfa,0x70,0x9e,0x78,0xe5,0x10, -0x29,0xba,0x2f,0x27,0xf0,0x3b,0x8c,0xe1,0x78,0xc8,0x59,0x8a,0xfa,0xb0,0xfc,0xdc, -0x7,0x12,0xe4,0xfd,0xa5,0x68,0xfc,0xc3,0x9a,0x5,0xea,0xc3,0xb2,0xe1,0x63,0xca, -0xed,0x2d,0xe1,0x9f,0x62,0x2e,0x4a,0x7,0x36,0x7c,0xbf,0xde,0xb5,0x71,0x71,0x2a, -0x37,0x79,0xc,0xec,0xda,0x5e,0x85,0xa7,0x81,0x81,0x24,0xad,0xee,0xb7,0x98,0x14, -0x65,0xb0,0xce,0x3d,0xc2,0x3f,0x42,0xa0,0x33,0xb0,0x59,0x60,0x2b,0x49,0x79,0x47, -0x9,0x3f,0xdb,0xc9,0xe6,0xeb,0x16,0x9d,0x1b,0xcb,0xd,0x24,0x77,0xb6,0xc1,0x43, -0x91,0x16,0x24,0xcc,0x1a,0xcb,0x49,0x18,0x83,0xa7,0x9b,0xd,0x8,0x2c,0xb6,0x3f, -0x28,0x76,0x8f,0x8d,0x74,0xa2,0xb1,0x1c,0xdb,0xe8,0x86,0xea,0xdc,0x33,0x4,0x76, -0xec,0x82,0x7e,0x5,0xbc,0x7b,0x60,0xdd,0x2c,0xdd,0x2b,0x10,0x77,0x76,0x95,0xe2, -0xa1,0x56,0x82,0x1e,0x6c,0xdd,0x22,0xf7,0x34,0xb8,0x9b,0x44,0x8f,0x87,0x3f,0x31, -0xe0,0xab,0x0,0x3c,0x7c,0x0,0x76,0xb1,0x53,0x81,0x95,0x33,0x6f,0x7e,0x4e,0xa9, -0x25,0x3f,0xc8,0x1e,0x12,0x98,0x38,0xe2,0x20,0x31,0x2d,0x3c,0x81,0x95,0xe0,0xd1, -0x5a,0x56,0xc8,0xcf,0x1c,0x33,0xf9,0xb0,0x2e,0xa9,0xbe,0x68,0xda,0xd1,0xbe,0x39, -0x3b,0x59,0xcd,0xaf,0x9b,0xc4,0xbb,0x7a,0x9a,0x4,0x72,0xcf,0xa4,0x54,0x6a,0xbb, -0x84,0x24,0x18,0x80,0x27,0x72,0x2b,0xd4,0x78,0x48,0x20,0x6e,0x2e,0x2e,0x6d,0xc5, -0x4d,0x83,0x5,0xbc,0x45,0x43,0x11,0x61,0xfe,0x40,0xbd,0x89,0xaf,0x80,0xaf,0x80, -0x3b,0x49,0xee,0xad,0x75,0x9a,0x7d,0x44,0x8b,0x9f,0x3e,0xf0,0x55,0x3c,0x7c,0x5, -0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x2c,0x80, -0x7f,0xf,0x8f,0x5b,0x9c,0x1e,0xf,0x3e,0xf1,0xfb,0x0,0x0,0x0,0x0,0x49,0x45, -0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//brd_wiznet.png: 13702 bytes diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon.ico b/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon.ico deleted file mode 100644 index f63da06..0000000 Binary files a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon.ico and /dev/null differ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon_ico.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon_ico.h deleted file mode 100644 index f890e90..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/favicon_ico.h +++ /dev/null @@ -1,107 +0,0 @@ -const char favicon_ico[] PROGMEM = { -0x0,0x0,0x1,0x0,0x1,0x0,0x30,0x30,0x10,0x0,0x1,0x0,0x4,0x0,0x68,0x6, -0x0,0x0,0x16,0x0,0x0,0x0,0x28,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x60,0x0, -0x0,0x0,0x1,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x0, -0x0,0x0,0x48,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x22, -0x24,0x0,0x8c,0x96,0x4,0x0,0xcb,0xd2,0x8d,0x0,0x57,0x5d,0x11,0x0,0xaa,0xb5, -0x4b,0x0,0x41,0x44,0x17,0x0,0xf0,0xf0,0xdc,0x0,0x6f,0x7b,0x9,0x0,0xbf,0xc5, -0x70,0x0,0xdc,0xe2,0xb4,0x0,0xfc,0xfe,0xfc,0x0,0x60,0x6e,0xc,0x0,0x4c,0x53, -0x14,0x0,0x99,0xa7,0x26,0x0,0x31,0x31,0x1c,0x0,0x7c,0x88,0x4,0x0,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa6,0x8d,0x14,0x8a,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11, -0x11,0x11,0x11,0x11,0x11,0x16,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11,0x11,0x11,0x35,0x5,0xb1,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0xe0, -0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa1,0x11,0x11,0x11,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11, -0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb1,0x11,0x11,0x4a,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa1,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x11,0x11,0x19,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x91,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x18,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0xf,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x11,0x11,0x2a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0x51,0x11,0x1a,0xaa,0xaa,0xa8,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x1,0x11,0x14,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x61,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41, -0x11,0xc0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xd1,0x11,0xe0,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x11, -0x11,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41,0x11,0x50,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x81, -0x11,0x30,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0xe,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x1c,0xa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xaa,0xaa,0x1,0x11,0x12,0xaa,0xaa,0xa6,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0xf1,0x11,0x1a,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x13,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xad,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x1a,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa2,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb, -0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xd1,0x11,0x11,0xf0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa4,0x11,0x11,0x11,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf1,0x11, -0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x21,0x11,0x11,0x11,0xf0, -0x0,0x0,0x0,0x0,0xe,0x11,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x41, -0x11,0x11,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 -}; -//favicon.ico: 1662 bytes diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p.png b/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p.png deleted file mode 100644 index a6dc8a3..0000000 Binary files a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p.png and /dev/null differ diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p_png.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p_png.h deleted file mode 100644 index c1be58d..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/WWW/m1284p_png.h +++ /dev/null @@ -1,815 +0,0 @@ -const char m1284p_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x4,0xf8,0x0,0x0,0x3,0x3b,0x1,0x3,0x0,0x0,0x0,0xed,0x52,0xbc, -0x4d,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0x12,0x74,0x0, -0x0,0x12,0x74,0x1,0xde,0x66,0x1f,0x78,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54, -0x78,0xda,0xed,0xdd,0x5f,0x8c,0x23,0xc7,0x9d,0x1f,0xf0,0x59,0x4f,0x20,0x26,0xb0, -0xb5,0xf4,0x21,0x2f,0x6,0xbc,0xbb,0xf4,0xc5,0x4f,0x79,0x73,0x5e,0x6e,0x25,0x68, -0xb5,0xb4,0x90,0x7,0x3f,0xfa,0xf1,0x2,0x8,0xd2,0x2a,0x2f,0xf9,0x3,0x45,0x4b, -0x19,0x86,0x96,0xbb,0xe2,0x72,0x7a,0xd6,0x3,0x64,0x1e,0x12,0xdc,0xdc,0x21,0x2f, -0x39,0x48,0xde,0x31,0x70,0x7,0xf8,0xe1,0x60,0xad,0x2,0x45,0xa2,0x6c,0x2e,0xa7, -0x39,0x98,0xb3,0x6,0xc1,0x59,0xe2,0x19,0x4e,0x30,0xb6,0x29,0xb2,0x38,0x37,0x97, -0xa3,0x90,0x11,0xbb,0x38,0x1e,0x2f,0xab,0x67,0x8a,0x5d,0x95,0xfe,0x57,0xfd,0xb7, -0xba,0xd9,0xff,0x48,0xb6,0x70,0x43,0xdc,0x59,0xda,0x9d,0xdd,0x99,0x8f,0xaa,0xbb, -0xab,0xbe,0xfd,0xab,0xea,0xea,0x15,0x9a,0xef,0xcf,0xca,0x85,0xef,0xc2,0xe7,0xfe, -0xf4,0x4b,0xc5,0x5c,0xfb,0x7a,0x12,0xca,0xb5,0xaf,0x3b,0xc9,0xb9,0x8f,0x5e,0xf8, -0xd2,0xf9,0x60,0xce,0x7d,0x60,0x91,0xbe,0xc1,0x5a,0x71,0x73,0x73,0x73,0x5a,0xda, -0x23,0xd7,0xae,0x14,0x89,0x2c,0xcc,0xf6,0x21,0x71,0x91,0x3e,0xd8,0x42,0xb5,0x5a, -0x4d,0xa1,0x2d,0x65,0x34,0x42,0xd3,0x8,0x3f,0xbb,0x7,0x85,0x85,0xfa,0xba,0x58, -0xf5,0x61,0xc3,0x77,0x1e,0xc1,0xd7,0xbf,0x56,0x58,0xac,0x8f,0xaa,0x40,0xb9,0xdc, -0x52,0xe0,0x8,0x11,0xba,0xc0,0x63,0x17,0xd9,0xb7,0xaf,0xb6,0x1f,0xc8,0xaf,0x6f, -0x4f,0x6d,0x3f,0xaa,0xf9,0x3e,0x2d,0x12,0x2a,0xe4,0xcf,0x87,0x71,0xed,0xcd,0x12, -0x68,0x3d,0xd,0x5b,0xd3,0x9b,0x84,0xe6,0xd0,0x57,0x33,0x8f,0x6f,0x9d,0x12,0x25, -0x7f,0x3e,0xbd,0x7f,0xc1,0x62,0x4b,0x91,0x14,0x4a,0xf0,0xec,0xbf,0xd2,0x3e,0x3c, -0x1c,0xb4,0x6f,0x81,0x45,0xf9,0xcc,0xfe,0xf9,0xf9,0x3d,0x72,0xe5,0x69,0x4a,0xc6, -0xe5,0x99,0x7f,0x85,0xf4,0xfb,0x10,0x83,0x85,0xf9,0x62,0x7f,0x94,0x7e,0x1f,0x60, -0x28,0xe6,0xd9,0xb7,0x9b,0x67,0x1f,0x3e,0xec,0xf7,0x31,0xa,0xe8,0x87,0xc6,0xfe, -0x13,0x93,0x90,0xc3,0x8,0xa3,0x7a,0x86,0xbe,0x7e,0x9f,0x4,0xfa,0x10,0xe0,0xf8, -0xfa,0xc9,0x13,0x45,0x52,0xdf,0x79,0xc0,0xb1,0x87,0x9c,0x3,0x5f,0x17,0x2b,0x60, -0x81,0x3e,0xd4,0x57,0x8f,0x6f,0x90,0x6f,0xc0,0xf5,0x41,0xba,0x58,0x5f,0xf,0x2b, -0x41,0xed,0x57,0xf5,0x1f,0xf8,0xe6,0x7c,0x7c,0x2d,0x24,0x15,0x8a,0x9c,0x5b,0x5d, -0x74,0x78,0x78,0x18,0xe4,0x1b,0x94,0x17,0xe7,0xbb,0x81,0x3a,0x93,0xb8,0xb7,0x92, -0xa,0x7d,0xd3,0xff,0x9b,0x7,0x73,0xf1,0x91,0x56,0xf5,0x91,0x14,0xdb,0x7,0xb9, -0xbe,0xb9,0x5c,0x1f,0xad,0x6a,0x5,0xc6,0xf6,0x49,0x9c,0x3,0xf,0xe7,0xd3,0xbf, -0xb4,0x1a,0x15,0x80,0x38,0xe7,0xdf,0x8a,0xfd,0xf1,0x7,0xfd,0x31,0xcf,0x37,0x9f, -0xfe,0xb9,0xf5,0x1,0x4,0xbc,0x52,0x4b,0xa8,0x6f,0x81,0xe3,0x5b,0xeb,0xff,0x40, -0xd0,0x9f,0xa3,0x4f,0xbe,0x1e,0xe1,0xb0,0x7,0xf9,0x56,0xd5,0x1b,0xba,0xff,0x5d, -0x10,0x77,0x38,0xbe,0x92,0xfd,0xaf,0xfb,0x69,0x7c,0xe8,0x0,0x95,0x13,0xfb,0xea, -0xa7,0xb4,0x35,0x84,0xe2,0xda,0x3c,0x7d,0x5d,0x29,0x79,0xfb,0xad,0x1d,0xab,0xfd, -0x33,0xdc,0x29,0xf8,0xaf,0xf,0xe8,0xf0,0x7d,0x54,0x4e,0xe3,0x8b,0x12,0xd2,0x2, -0x7d,0x81,0x41,0xbf,0xe3,0xf0,0xfd,0x3c,0x4d,0x8a,0x96,0x15,0x30,0xf,0xdf,0x23, -0xe7,0xf1,0x4d,0x95,0xf2,0xaf,0xc6,0xf6,0xb5,0x3d,0xbe,0x31,0xe7,0x6f,0xc0,0xcc, -0x7c,0x7d,0x31,0xae,0x6f,0xdd,0x38,0x9f,0x8a,0x44,0x30,0x7c,0x3,0x61,0x2b,0xdc, -0x17,0xe9,0xfc,0x1b,0x6,0xe5,0xa0,0xb8,0x3e,0xb2,0x62,0xfc,0xec,0x55,0xe6,0x1b, -0x92,0x62,0x6,0xed,0x77,0x18,0x14,0xb5,0x85,0x38,0xbe,0x35,0xf5,0x6,0xb3,0x6c, -0x70,0xbe,0x41,0x84,0xba,0xe1,0x93,0xb3,0xf0,0xc9,0x1,0xbf,0x5d,0x8e,0xe5,0x6b, -0xb5,0x94,0xcf,0x69,0xc7,0x48,0x56,0x37,0x85,0x55,0xc3,0x77,0xd8,0xe1,0xf8,0x88, -0x1e,0x9e,0xb1,0x54,0x8e,0x78,0xfd,0x4e,0x53,0xf4,0x42,0x2e,0xdf,0x67,0x6a,0x87, -0xab,0x75,0xb9,0xe5,0xcb,0xe6,0x78,0x3e,0xdc,0x34,0x7d,0x53,0xc1,0xea,0x90,0x2d, -0xdf,0x8,0x58,0xfd,0xdf,0x54,0xf0,0xf7,0xde,0x47,0xf6,0xf,0x29,0x66,0xe1,0xeb, -0x2a,0x54,0xf3,0x6d,0x68,0xbe,0xb6,0xf9,0xf3,0xfe,0xbe,0xd4,0x61,0xc7,0xc2,0xf8, -0xe7,0x86,0x2e,0xb8,0xa3,0x47,0xa9,0x2e,0xb4,0xc6,0xf,0xd9,0x6a,0x21,0xfb,0x84, -0xdd,0xcd,0x64,0x98,0xb1,0x7d,0x43,0x45,0x3d,0x91,0x8f,0xe8,0x25,0xcd,0x37,0x36, -0x7d,0x3,0xc1,0xf4,0x8d,0xcd,0x66,0xb9,0xc4,0xf7,0x8d,0xad,0x56,0x9b,0x5a,0x91, -0x61,0x7d,0xd6,0x5,0xd2,0xd6,0x23,0x46,0x39,0xb2,0xf,0xd3,0x5f,0xd2,0xc1,0xca, -0xec,0x8f,0xc3,0xd7,0x5e,0x89,0xf4,0xb9,0x94,0x85,0xaf,0x8b,0x8a,0xff,0x23,0x62, -0xfb,0xbd,0xa3,0x1f,0xc9,0x66,0x82,0xf6,0x1b,0x8,0x89,0x7d,0x2d,0x48,0xef,0xa9, -0x5d,0xa9,0x7e,0xfe,0xb1,0x6f,0xf3,0xf7,0x65,0xee,0xf9,0xe7,0xf3,0x45,0x3e,0xff, -0x9c,0x23,0x9a,0xfe,0xbb,0x24,0xba,0xf,0x10,0x99,0x5d,0xbf,0xff,0x99,0x5d,0xbf, -0x45,0xff,0xf5,0xab,0xfa,0xfa,0x46,0x4,0x3,0xd6,0xf,0x9e,0x71,0xfd,0xda,0x83, -0x90,0x8,0x12,0xfb,0xd6,0x1e,0x4c,0xbf,0xa2,0xf6,0x7f,0xda,0xad,0xe0,0xcd,0x6b, -0x2,0xac,0xe3,0xbd,0x3d,0x3c,0xdc,0x33,0x7d,0xac,0xec,0xb,0x1d,0xbe,0xb5,0xb2, -0xe5,0x73,0x54,0x85,0xad,0x6,0xb2,0x93,0x23,0xb1,0x7b,0x74,0xb1,0x6f,0xfd,0x97, -0x94,0x4c,0x5f,0x31,0xfa,0xf8,0x36,0x55,0x87,0x5b,0x4d,0xf0,0xcc,0x9a,0xd0,0x79, -0xfe,0xb4,0xd5,0x3a,0x1d,0x8e,0xb9,0x3e,0xdf,0x81,0xb,0xf7,0x39,0x5a,0xd7,0xf6, -0x11,0x68,0xfa,0x4,0xed,0xa4,0xbd,0xb4,0xdb,0x7e,0xa5,0x3c,0x7b,0xfc,0xbd,0x59, -0xd2,0x5,0x7f,0x48,0x84,0x47,0x2f,0x1d,0xb7,0x5a,0xc7,0xc3,0x69,0x31,0x3,0x9f, -0x63,0x7c,0x73,0xf8,0xcc,0xe3,0x7b,0x53,0xeb,0xa,0xb0,0xb0,0x3,0x94,0x68,0xf9, -0x45,0x13,0x14,0x88,0x0,0x5f,0xea,0xb6,0x5a,0x5d,0x2b,0x1f,0xa4,0xf2,0x1d,0x72, -0x7d,0xdb,0xfb,0xac,0x49,0xa2,0xfb,0xda,0x86,0x40,0xcd,0x57,0xf0,0x35,0xdd,0xc7, -0x4e,0xed,0x54,0x3e,0x47,0xbe,0x5a,0xbf,0x66,0xf9,0x2a,0xa6,0xf,0xea,0x3e,0x31, -0x92,0xcf,0x14,0xa8,0x3f,0x3,0xbe,0xd6,0x6c,0xb5,0x9a,0x94,0x4d,0xf5,0xa6,0xf2, -0xb9,0x4e,0x21,0xdf,0xf9,0xa7,0xfb,0x2e,0xed,0xb7,0xeb,0xd1,0x7d,0xda,0x3f,0xde, -0xa8,0xb5,0x5a,0x35,0xfb,0xdb,0xce,0xd5,0x37,0x2d,0x8,0x72,0x9c,0xf6,0xd3,0x7d, -0x97,0x5a,0xad,0x4b,0x72,0x29,0xe3,0xf6,0x73,0x1c,0x5f,0xe8,0x38,0xbe,0x40,0x20, -0x71,0x7d,0xf7,0x70,0xab,0x85,0x31,0xec,0x64,0xdc,0x7e,0x3b,0xbe,0xfe,0x4f,0xbb, -0x3e,0x60,0xc4,0xeb,0xc3,0xe1,0xd3,0xfb,0x67,0x8c,0x1e,0x65,0xeb,0x23,0x6b,0x76, -0x5f,0xb8,0xdf,0x2e,0xd3,0x75,0x7d,0xfc,0x50,0x50,0x6c,0x9f,0xf1,0xc1,0xa8,0x92, -0xad,0xef,0x8c,0x38,0x7c,0xeb,0x45,0xba,0x72,0x53,0xf7,0x61,0xb5,0x7f,0xae,0xe7, -0xc1,0x37,0x24,0xce,0xdc,0x55,0x24,0xee,0xdc,0x16,0xdf,0x37,0xc9,0xf8,0xfa,0x0, -0xdc,0xf6,0x8b,0x53,0x3f,0x70,0xfb,0x9e,0x4,0xf8,0x64,0xf4,0xeb,0x72,0xba,0xeb, -0x37,0x76,0x7e,0xe1,0xfa,0x7e,0x5f,0xe0,0xfb,0xd0,0xf7,0xbb,0x20,0x5d,0xff,0x97, -0x8d,0xf,0x6,0xb4,0x1f,0x7c,0xbf,0xb,0x53,0xfa,0x80,0xdd,0xbf,0x24,0xf6,0x5, -0xf6,0xcf,0xf0,0x49,0x32,0xdf,0xe7,0x6a,0xff,0x22,0xdc,0xbd,0x79,0x59,0xfd,0xd7, -0x6d,0xbb,0x7f,0x26,0xc5,0x4d,0x51,0x48,0xe2,0xb,0x1c,0xdf,0xa4,0x3f,0x4a,0xe6, -0xeb,0xa9,0xfd,0xf3,0xcd,0x6a,0x6f,0x62,0xfb,0xf4,0xf1,0x17,0xd5,0x76,0x68,0xa6, -0x3e,0xd8,0x78,0x31,0x91,0xaf,0xa5,0xe6,0xab,0x9b,0x95,0x91,0xe6,0xbb,0xe5,0xf0, -0x4d,0x94,0x56,0x7e,0x7c,0x2f,0x55,0x46,0xc4,0xe1,0xdb,0x56,0x7d,0x84,0x36,0xb3, -0xf5,0xa1,0xea,0x5b,0x89,0xae,0x5f,0x51,0xf7,0x49,0x6a,0x68,0x26,0xc0,0x6e,0x3f, -0x35,0x44,0x37,0xb2,0xf5,0x25,0xed,0xff,0x34,0xdf,0xab,0x15,0xf8,0x91,0x76,0x4d, -0xd8,0x3e,0xfa,0x11,0xfd,0xab,0x6c,0x7d,0x49,0xc7,0xf,0xd3,0x37,0xb1,0xfb,0x17, -0xed,0xfa,0xa5,0x13,0xfa,0xc3,0x7c,0xf8,0xb4,0xfb,0xf3,0x57,0x8d,0xeb,0xc3,0xd1, -0xff,0x65,0x7f,0x7d,0x24,0xf5,0x69,0x85,0x89,0xaa,0xd1,0xbf,0xb8,0xf2,0x55,0x84, -0xfe,0x45,0xae,0x45,0xf4,0x71,0xe6,0xb7,0xa2,0x8f,0x1f,0xea,0xa7,0x6a,0xf4,0xcf, -0x8e,0x7c,0x10,0xa9,0x7f,0x46,0x8d,0x85,0xf8,0x12,0xe7,0x2b,0x33,0x2a,0x43,0x3a, -0xbe,0x59,0x9a,0x6b,0xfb,0x25,0xcc,0x57,0x68,0xdb,0x14,0xa0,0x1e,0xc,0xf5,0xe9, -0x1f,0x85,0xfb,0x65,0xb7,0xef,0x50,0x19,0x87,0xfa,0xe2,0xe5,0x17,0x73,0xb2,0x53, -0xf5,0x8d,0x78,0xbe,0x43,0xdd,0x0,0x49,0x49,0x6f,0xb3,0x93,0x91,0xf7,0xcb,0xac, -0x88,0x21,0xca,0x77,0x4b,0xa6,0xaf,0x7f,0x16,0xba,0x92,0x36,0xb1,0xf,0xf2,0x7c, -0xfd,0xa9,0xfe,0x55,0xc5,0xf8,0x91,0xd2,0x6b,0xde,0x2f,0xb3,0x5,0x45,0x22,0x32, -0x6b,0x68,0x88,0x8a,0x6f,0x84,0xf9,0xd8,0xfd,0x9b,0x18,0xdf,0xc7,0x3b,0xff,0x44, -0x7d,0xe1,0x3,0xc4,0x13,0xe3,0x4f,0xfd,0xc4,0xfb,0xe5,0xa,0x6b,0x3f,0x68,0xd6, -0x20,0x55,0x9f,0x12,0xb2,0x5a,0xd4,0xba,0x3f,0x57,0x1b,0x50,0x51,0x3e,0xbc,0x59, -0x9c,0xe5,0x1b,0xaf,0x86,0xb6,0x9f,0x38,0x31,0x7c,0x46,0xc5,0x8,0x7e,0xec,0xfd, -0x32,0xb4,0x7c,0x34,0x92,0x8f,0xb2,0xfb,0x73,0xf5,0x4f,0x4f,0xcf,0x1a,0x3d,0x14, -0xb9,0x7f,0x9e,0xe1,0xd3,0xbf,0x11,0xf2,0x9e,0x7f,0xe2,0x67,0xb6,0x4f,0xb0,0x7c, -0xbc,0xd5,0xac,0xc8,0xed,0x2b,0x1b,0xbe,0x2e,0x9e,0xe5,0x3b,0xa5,0xa1,0xd7,0x87, -0x28,0x19,0x3e,0xf3,0xfb,0x7b,0xaf,0x5f,0x71,0x28,0x78,0x7d,0x50,0x54,0x94,0xa0, -0xcb,0xc2,0x31,0xbe,0xa9,0x3e,0xe5,0x8d,0x6,0x9e,0xe9,0x33,0xab,0x9c,0x41,0xfd, -0x8b,0xd8,0xf,0xf7,0x41,0x8e,0xaf,0xce,0xfb,0xa1,0x9b,0x3c,0xdf,0x87,0xb3,0x7d, -0x66,0xa9,0x2f,0xa8,0x7f,0x16,0xbf,0x2d,0x18,0xd7,0x47,0x80,0xaf,0x62,0xf9,0xfa, -0xe6,0x71,0xdc,0xe8,0x2b,0x9c,0x93,0xca,0x2a,0x46,0x8b,0xe,0xdf,0x4f,0xc4,0xaf, -0xcf,0xf6,0x19,0x7,0x18,0x6e,0xf3,0xc7,0xb7,0xbe,0xd1,0xff,0x29,0x12,0xe4,0xfa, -0xfa,0x56,0xfb,0x21,0x73,0xa8,0x47,0xf0,0x50,0x19,0xf8,0xaf,0xf,0x6b,0xa9,0x8e, -0xe0,0xf2,0x75,0x23,0xb7,0x5f,0x80,0xcf,0xea,0x9f,0x8b,0x5c,0xdf,0xe1,0xd8,0xea, -0x9f,0xd7,0x98,0x8f,0xfb,0x3,0xd9,0x9f,0xb3,0xf2,0xa9,0xee,0x8b,0x70,0x7d,0x98, -0xff,0x61,0x41,0xbe,0x4,0xe3,0x1b,0xf7,0xb3,0xc7,0xab,0x5f,0xf5,0x22,0xf4,0x2f, -0xc6,0x1f,0x18,0xf0,0x63,0x44,0x7c,0xdf,0x20,0x60,0x71,0x51,0x91,0x57,0xbf,0xea, -0x45,0xe8,0x9f,0x8d,0xf6,0x6b,0x67,0xe5,0x6b,0xaf,0xac,0x66,0x9b,0xaf,0x8c,0xf3, -0xaf,0xb3,0x4f,0xb3,0xf1,0x75,0x58,0x87,0x1a,0xa1,0xfd,0xa2,0xd5,0x37,0xf4,0xef, -0xd7,0xd9,0x98,0xb3,0x6f,0x3f,0x71,0x7d,0x68,0xcb,0xf4,0xc9,0xcf,0xe1,0xfd,0x4b, -0x68,0xf7,0x50,0x99,0x8b,0xef,0x30,0xa9,0xcf,0x18,0x3f,0x3a,0xdf,0xa4,0xe8,0x37, -0xa7,0x4d,0x38,0x4,0x7d,0xc7,0x12,0xe2,0x81,0x7a,0xae,0x68,0xdf,0x4c,0x3d,0x4b, -0x78,0x3e,0xf3,0xcb,0xda,0x49,0xbc,0xc2,0x4e,0xbb,0xa0,0xf3,0x4f,0x4e,0xea,0x33, -0xff,0x73,0xff,0xa5,0xe6,0x13,0xe0,0x81,0x28,0xbe,0x39,0x17,0x9f,0xbd,0x98,0x23, -0x51,0xfd,0x8f,0xfc,0x47,0x8a,0xce,0x8f,0x5,0x88,0x36,0xc4,0x74,0xed,0x17,0x9c, -0x4b,0x13,0xfa,0x8c,0xfe,0x85,0xfc,0x27,0x2a,0x9f,0x1f,0x7f,0x7,0xa2,0x96,0x88, -0xc2,0xc2,0x79,0xf2,0xe7,0x6c,0x36,0x53,0xe5,0xfb,0xe9,0xe7,0x94,0x7e,0xfd,0xc5, -0xe7,0x20,0x52,0xe6,0xe5,0x1b,0xa6,0xf3,0x49,0x2,0xed,0xbe,0x58,0xd3,0x7c,0x83, -0xf2,0x5c,0x7c,0xe9,0xee,0x8f,0xce,0x24,0x1,0xe9,0xbe,0x96,0x58,0x11,0xd3,0x5d, -0x1f,0x97,0xe6,0xe1,0x3b,0x81,0x65,0xd4,0x6d,0xaa,0xbe,0x66,0xdf,0xf1,0x24,0x47, -0x7e,0x7c,0xa7,0xb0,0x2c,0x3f,0xd7,0xdc,0x84,0x68,0xef,0x30,0x67,0x3e,0xe3,0xfe, -0xed,0x8,0x66,0x96,0xf,0x32,0xf6,0xd1,0x6c,0xf3,0xd5,0x6c,0x5f,0xcc,0xf5,0x43, -0xec,0x2f,0xcd,0xd5,0x7,0x3e,0xb5,0xd7,0xbb,0x24,0xf2,0xc1,0xd9,0xf5,0xb5,0x54, -0xbe,0xae,0xbd,0x62,0x3e,0x91,0x8f,0x66,0xe5,0xa3,0xa7,0x87,0x87,0xb4,0xed,0xed, -0xe2,0x61,0x63,0x84,0x63,0x75,0x92,0x91,0x7d,0x68,0x4f,0x5b,0x91,0x6,0xa7,0x65, -0xa4,0xaf,0x56,0xf3,0xfa,0xf6,0xf6,0xcc,0x5,0x6b,0xe2,0x98,0x2,0xdd,0x75,0xda, -0xef,0xfb,0x1f,0xa4,0x87,0x8d,0x98,0x1d,0x7b,0x64,0xdf,0xb0,0xa5,0x2f,0x3b,0xc1, -0x60,0xa8,0xdf,0xa9,0x78,0x7d,0xad,0x96,0xd9,0x72,0xea,0x8d,0xfa,0xb6,0xee,0x3a, -0xea,0xf7,0xfb,0x3e,0x1f,0xaa,0xce,0xcb,0x77,0xd0,0x6a,0x19,0xbe,0x83,0xbf,0xac, -0x72,0x7d,0x2d,0xcb,0xf7,0xf2,0x9f,0x69,0xae,0xd3,0x59,0x3e,0x54,0x58,0xa5,0x47, -0xf,0xba,0x30,0xa3,0xe3,0xcb,0x7c,0xe8,0xcf,0x1b,0x1c,0x9f,0xa2,0xd8,0xbe,0xfe, -0xbf,0x63,0xbe,0xb6,0xf7,0xfb,0x9c,0x23,0xfb,0x2f,0x4e,0x70,0x9d,0xf6,0x76,0x7e, -0x93,0x9d,0xef,0x81,0xe1,0x6b,0xbe,0x5b,0xe6,0xfa,0x1e,0x58,0x3e,0xa9,0x1d,0xd4, -0x7e,0xe7,0xc8,0xbe,0x3e,0x34,0x9f,0xb8,0xf3,0xdb,0xcc,0xdb,0xaf,0xc9,0x6b,0x3f, -0x8c,0x1d,0xed,0x27,0x5,0x1e,0x5f,0x5,0xdb,0xfd,0xcb,0x84,0x2e,0xd0,0x87,0x50, -0x34,0xdf,0xd4,0xee,0x9f,0x51,0xa9,0x4e,0xff,0x62,0xa7,0x5b,0x59,0x88,0xf,0x42, -0x8e,0xef,0x53,0x10,0xf6,0xa3,0xd1,0xd1,0x2a,0xfd,0xe1,0x83,0xec,0x7c,0x3f,0xd, -0xf3,0x1,0xf0,0x53,0xaf,0xef,0xf0,0xf0,0xef,0xc2,0x7d,0x58,0xa0,0x2d,0xb1,0xfb, -0x28,0xab,0xfe,0xf9,0xe7,0x9a,0x6f,0xfa,0x3c,0xdf,0xf7,0xe0,0xc1,0xcf,0x4d,0xdf, -0x18,0x19,0xbe,0x99,0xf3,0x33,0x93,0x4c,0x7d,0x59,0xd5,0xaf,0x7c,0xbe,0x4e,0x5e, -0x7d,0xa8,0x20,0xd0,0x3d,0x31,0xab,0xfe,0x39,0x7b,0x5f,0xb6,0xe3,0xdb,0x3f,0x4a, -0xdf,0xca,0x45,0xfb,0x5d,0xf8,0xbe,0x38,0xbe,0x76,0xce,0x7d,0xda,0xe3,0x83,0x39, -0xf6,0x11,0xad,0x4a,0x91,0x57,0xdf,0xda,0x1e,0x7d,0xac,0xad,0x2d,0xc8,0xab,0x4f, -0xbd,0x1,0xbb,0xa1,0x4d,0xd9,0xe5,0xd7,0x47,0x1e,0x6b,0x25,0x1b,0xfe,0xfc,0x8c, -0xf3,0xf9,0x23,0xa3,0x50,0xc5,0xfd,0x32,0x75,0x94,0x97,0x33,0xf6,0x75,0x15,0xfa, -0xa1,0xf6,0x4c,0x13,0x7f,0x7e,0xc6,0xf9,0xfc,0x96,0x51,0xed,0x12,0x78,0x5f,0x76, -0x3e,0xbf,0x95,0xb1,0x6f,0xa8,0xd0,0x9f,0x6a,0x3e,0x7e,0xd5,0xc9,0xf9,0xfc,0x9b, -0x51,0xe7,0x2a,0xf3,0xbe,0xec,0x7c,0xfe,0x2d,0x6b,0x1f,0x56,0x7d,0xe3,0x95,0xec, -0x3e,0x85,0x8c,0x8f,0x2f,0x2a,0xfe,0x54,0x9b,0xa3,0xc9,0xac,0xfd,0x68,0xc6,0xd7, -0x7,0x34,0x8e,0x6f,0x66,0xe7,0x5f,0xd6,0x3e,0x40,0x1f,0x6b,0x73,0x13,0x99,0x5d, -0xbf,0x19,0xfb,0xd6,0x1e,0xd0,0xc7,0x31,0x1e,0xd4,0x5d,0xd4,0x3e,0x6d,0xce,0xf1, -0x6d,0x5a,0xde,0xcc,0xb5,0x8f,0xc4,0xd8,0x58,0x77,0x19,0x3e,0xb6,0xfd,0x41,0x6e, -0x7d,0x6d,0x9a,0x6f,0x1f,0xbd,0xf0,0x5d,0xf8,0x2e,0x7c,0x17,0xbe,0xb,0xdf,0x85, -0xef,0xc2,0x77,0xe1,0xcb,0x81,0x6f,0xaa,0xdf,0xec,0xad,0xe6,0xdd,0x27,0x5f,0xdd, -0xc1,0x74,0x33,0xbf,0x3e,0x3c,0x7a,0x78,0x4a,0x6b,0x79,0xf4,0xe9,0xb7,0x7e,0x47, -0x78,0xf4,0xce,0x71,0x2b,0xdf,0x3e,0xdc,0xcd,0xa9,0x6f,0x5f,0xf7,0x7d,0x80,0xbb, -0xdf,0xcf,0x91,0x4f,0x2e,0x15,0x91,0xe9,0x6b,0xaa,0x3e,0xf9,0xea,0x7,0x78,0xf8, -0x5f,0x32,0xf3,0xd,0x56,0x56,0x84,0x74,0x3e,0x2c,0xa1,0xa1,0xc3,0x87,0x95,0x9f, -0xe1,0x21,0xce,0xcc,0xd7,0x9e,0xb9,0x30,0x69,0xa6,0x6f,0x84,0xf,0x3c,0xbe,0x6e, -0x76,0xbe,0xf4,0x1f,0x3c,0x32,0x9e,0x49,0x56,0x7d,0xef,0xe9,0xbe,0xc7,0xb8,0x5b, -0xcd,0xa7,0xef,0x6f,0xe4,0xb2,0xea,0xdb,0xc1,0xad,0xad,0x1c,0xf9,0xe4,0xab,0xb4, -0x6a,0xfa,0x30,0x2,0x47,0x59,0x8f,0x6f,0xe9,0xdb,0x4f,0x21,0xd6,0xf5,0xb,0x61, -0xd6,0xbe,0x5d,0xf8,0x6e,0xda,0xeb,0x43,0x39,0x5f,0x65,0xfd,0x1f,0x40,0x59,0xfb, -0x76,0x86,0xd,0x90,0x2,0x77,0xa2,0xfa,0x8,0x62,0xed,0x47,0x45,0x9c,0xb5,0x4f, -0x78,0xb5,0x91,0xe6,0x25,0x3e,0x3,0xd5,0x47,0x8b,0xf3,0xf4,0x1d,0xa7,0xf3,0xb9, -0x4b,0xfd,0xe5,0xec,0x7d,0xa3,0xb4,0xed,0xe7,0xcc,0x7,0xd9,0xb7,0xdf,0xdd,0xd7, -0xf2,0xed,0x13,0x6e,0xdb,0x3e,0x61,0x75,0x6d,0x90,0xce,0x97,0xfd,0xf5,0xeb,0xf0, -0x11,0x1,0xd7,0x81,0x90,0xc6,0xb7,0x9f,0x7d,0xff,0xb7,0x3,0xaf,0xb3,0xfe,0x45, -0x11,0x50,0x4d,0xfc,0x9f,0x5b,0x71,0x7d,0x6a,0xbe,0xda,0x60,0xfd,0x73,0xf6,0xe3, -0x87,0xa3,0x7f,0xc6,0x2,0xaa,0x8a,0xef,0x5d,0x8f,0xdd,0xbf,0x48,0xe6,0x3,0x27, -0xaa,0x4f,0x1d,0x7f,0xe7,0x37,0xbe,0x61,0x1,0x56,0xc4,0x46,0x35,0xb6,0x6f,0x84, -0x5,0x47,0xbe,0x9a,0x9f,0xf,0x9,0xf0,0x8f,0x13,0xf9,0x68,0xc1,0x91,0xef,0xe7, -0xe7,0x83,0x2,0x7c,0x2e,0x99,0xaf,0xb6,0x90,0xe3,0x3b,0x28,0x83,0x5a,0x2,0x9f, -0x9a,0xaf,0xf0,0xfc,0xae,0xf,0x57,0x5f,0x3,0xea,0xa0,0x1a,0xbf,0xfd,0x14,0xdb, -0x97,0x7d,0xff,0xe2,0xfc,0xd4,0xc0,0xda,0x0,0x25,0xf0,0xe1,0xda,0xfc,0xf2,0x55, -0xda,0x73,0x42,0xcf,0x57,0xd5,0xf9,0x8d,0x6f,0x19,0xf8,0x68,0x71,0x73,0xde,0xbe, -0x69,0x6e,0xf3,0x95,0xf1,0x31,0x9f,0xc5,0x5f,0x99,0xfd,0x50,0xa8,0xbf,0xfd,0xd8, -0xce,0xb4,0xf3,0x6c,0x3f,0xe3,0x59,0x7c,0x12,0xb8,0x3,0x75,0xe8,0xf1,0x45,0xf3, -0xf7,0x6d,0x9a,0x1,0x86,0xd2,0xb3,0xd8,0x3e,0x84,0x3b,0x73,0xcc,0x57,0x6,0xac, -0x94,0x8d,0x6f,0x63,0x4e,0xfd,0x9f,0xb9,0xaa,0x24,0xb5,0xf,0xcd,0x69,0xfc,0x18, -0xd3,0x8c,0x7c,0x73,0x1a,0x7f,0xd9,0x6a,0x2d,0x41,0x7f,0x2e,0x74,0xc5,0x7a,0x48, -0x34,0xae,0xf,0xce,0x29,0xbf,0xf8,0xda,0xcf,0x88,0xfc,0x8f,0x67,0x6c,0x79,0x64, -0xf8,0xc6,0xab,0x73,0xf7,0xf9,0xce,0x3f,0xc3,0xd7,0x4,0xe5,0x8,0x3e,0x4a,0x6d, -0xdf,0x9c,0x8e,0xaf,0xf9,0x6c,0xac,0xd7,0xd7,0x90,0xc4,0x78,0x3e,0x30,0xaf,0x7c, -0x55,0xf4,0xf4,0xcf,0xa6,0x8f,0xc6,0x3c,0xbe,0x60,0x5e,0xf9,0x6a,0x3f,0x85,0x8f, -0xa2,0x8e,0x7e,0x8,0x34,0xdf,0xbc,0xf2,0x95,0xf7,0xbb,0xc6,0xf2,0x75,0x34,0xdf, -0xb4,0x34,0xcf,0xf1,0x6d,0x9c,0xc6,0xa7,0xbf,0x3a,0x41,0x2e,0x2e,0x32,0x5f,0x99, -0x3e,0x18,0xc5,0x37,0x75,0xbc,0xfc,0xa2,0x3c,0xef,0x7c,0x2a,0x1b,0xef,0x1,0x64, -0xfd,0x4b,0x14,0x1f,0xa6,0xf3,0x6f,0x3f,0xfb,0x1e,0xdd,0xd8,0x15,0x2b,0x7e,0xff, -0x3c,0xdf,0xf3,0x8f,0xef,0x8b,0x5a,0x1f,0xb2,0xae,0x5f,0x3a,0xf7,0xfb,0x23,0x8c, -0x12,0xfa,0xa8,0x30,0x9f,0xfa,0x55,0x7a,0x9f,0xb2,0x65,0xf9,0x9a,0x73,0x9f,0xff, -0x90,0x8b,0xd0,0xf6,0xf1,0x97,0x93,0x17,0xbd,0xd7,0x47,0xc3,0xf2,0x89,0x73,0x19, -0x7f,0x15,0x65,0xcf,0xea,0xff,0xb0,0xb1,0xa7,0x23,0x64,0xc3,0xc9,0xac,0xe5,0xee, -0x5a,0xbe,0x6a,0x5a,0xbe,0x1f,0xcf,0x25,0xbf,0x28,0x4a,0xcb,0xda,0x5e,0x12,0x1b, -0x5d,0xa,0x64,0x71,0x81,0xf3,0x19,0x6,0xfb,0xde,0xe2,0xf9,0x48,0x9b,0xa4,0xf3, -0x11,0xbc,0x66,0x75,0x74,0xd8,0x90,0xc6,0xf2,0x61,0xfb,0xfc,0xe3,0x1d,0x5f,0x2, -0xee,0x27,0xf0,0x4d,0xbf,0x2a,0xd8,0x3e,0x1,0xd8,0xfd,0x4b,0x21,0x8d,0x8f,0x77, -0x7d,0x10,0xf0,0x66,0x3a,0x1f,0xad,0xda,0x3e,0x7b,0x7c,0x23,0xc1,0xbe,0x93,0xa3, -0x20,0x1f,0xaf,0x7f,0x21,0xe0,0x4e,0x86,0x3e,0xb2,0xba,0x3e,0x18,0x7c,0xab,0xa8, -0xd,0xab,0x81,0x3e,0xa9,0xc7,0xb9,0x3f,0x17,0x82,0xea,0x57,0xe9,0x7d,0x8f,0x9c, -0x3e,0x45,0x4,0x15,0x2,0x43,0x7d,0xa4,0xc7,0xa9,0x6f,0x8,0x41,0xe3,0x1b,0x69, -0x4b,0x69,0x7d,0xf6,0xf5,0x61,0xfb,0xce,0xa3,0xfa,0xcc,0x4f,0xb0,0xf,0xf4,0x53, -0xfa,0x80,0xdd,0xbf,0xe8,0x3e,0x38,0xc3,0x77,0xc6,0xf3,0x5,0xe6,0x2b,0x9,0xe8, -0x9b,0xb3,0xa4,0xf1,0xd9,0xfd,0xb3,0xea,0x5b,0x3f,0x1a,0x68,0x5b,0x89,0x4f,0xe8, -0x53,0xb1,0xda,0x2f,0xb0,0x3e,0x24,0x1,0x92,0xb2,0xfd,0x5c,0x47,0x63,0x55,0x9c, -0xea,0xc7,0x77,0xbc,0x76,0x9e,0x8d,0xef,0x24,0x5b,0x9f,0x9a,0x99,0x75,0x1f,0x51, -0xa6,0x2,0x29,0xac,0x6e,0x7e,0xc9,0xac,0x8,0xa2,0xbb,0xe5,0x6b,0x5f,0xde,0x85, -0x5,0xdf,0xf5,0xeb,0xf4,0x65,0x97,0xaf,0x2,0x7d,0x48,0xbb,0x3e,0xf6,0xb5,0x5e, -0x9b,0x8,0x6a,0xcf,0x5d,0x63,0xd7,0xb6,0xd4,0xec,0xc3,0x5e,0xff,0x0,0xfa,0xfa, -0x3f,0x87,0x6f,0x2f,0xbb,0x7c,0x15,0xe8,0xc3,0x9a,0x4f,0x9b,0xf0,0x43,0x5e,0xdf, -0x8,0x99,0x3e,0x6f,0xfe,0xa3,0x73,0xb8,0x3f,0xf,0xf4,0x29,0x6a,0xff,0x7c,0xf3, -0x92,0xe5,0x13,0x98,0xaf,0xdf,0x1c,0xd1,0x9d,0xfe,0x1,0xf0,0xfb,0x88,0xe5,0xe3, -0xe6,0x2b,0x73,0x77,0xa7,0x88,0x3e,0x2b,0x34,0x7d,0x95,0x13,0x9d,0x4,0xb6,0xa, -0x52,0xcf,0x51,0x44,0x3f,0xff,0x56,0x4d,0x5f,0xaf,0xab,0xfa,0x76,0x9b,0x40,0x2f, -0x89,0x97,0x9c,0xbe,0xa9,0xe5,0xdb,0xe4,0xe5,0x97,0x98,0xbe,0xb0,0xf6,0xb3,0x7e, -0x8b,0xb5,0x1f,0x14,0xac,0xec,0xf0,0xe9,0xd7,0x55,0x1f,0xd8,0xe0,0xb4,0xdf,0xd8, -0xf2,0x35,0x17,0xe5,0x63,0xe7,0x1f,0xb2,0xcf,0x3f,0xb5,0xfd,0xd0,0x1a,0x68,0x8a, -0x7e,0xdf,0x91,0xe5,0xc3,0xbc,0xe3,0x6b,0xee,0xce,0x96,0xa9,0x4f,0xfb,0x9e,0xd8, -0xed,0xeb,0x1e,0xf7,0xe1,0x1a,0xa8,0x73,0x7c,0xfb,0xb6,0x8f,0x77,0x7d,0xcc,0xc3, -0xa7,0xc7,0x6a,0xb5,0xff,0xc3,0xf6,0xf9,0x77,0xfc,0x59,0xb9,0x54,0x37,0x7c,0x27, -0xc8,0xe5,0xb3,0xe7,0x3f,0xb8,0xf9,0x6a,0x5f,0xfb,0x99,0x73,0xf0,0x11,0xf7,0xf8, -0xa1,0x45,0x56,0xc5,0xcc,0x57,0x5a,0x13,0xb6,0xb1,0x6c,0xf8,0x8c,0xe2,0xa1,0x7e, -0xff,0xeb,0xca,0x57,0x1b,0x87,0x10,0x18,0xbe,0xe9,0x5c,0x7c,0x9e,0xf1,0x57,0x6b, -0x33,0x6c,0x8e,0x6f,0xda,0x7a,0x49,0xf0,0x86,0xb6,0xed,0xe6,0x80,0x15,0x5f,0xfd, -0xf5,0x83,0x7a,0xdf,0x28,0xdf,0xec,0xab,0x51,0x63,0x2e,0xbe,0xe0,0x7c,0x85,0x74, -0x1f,0x34,0xeb,0x1b,0xe6,0x8d,0xa9,0xcf,0x67,0xee,0x14,0x3e,0xaf,0xe3,0x1b,0x92, -0xaf,0xdc,0xbe,0x80,0xf9,0x41,0xc1,0xd8,0x28,0x3e,0x91,0x4f,0x11,0xd2,0xb7,0xdf, -0xed,0xcf,0xc2,0xdb,0x6f,0x4b,0x1c,0x59,0xbe,0x8d,0xc5,0xfb,0xda,0xd2,0x30,0xfc, -0xfc,0x3b,0x11,0xff,0x9f,0xe5,0xab,0xc7,0xf4,0x91,0x95,0xd8,0x3e,0x35,0x5f,0x95, -0xbe,0xbe,0xb,0xb7,0xb4,0xeb,0x57,0x6f,0xbf,0x76,0xc5,0xf0,0x19,0x93,0x77,0xfe, -0xfa,0x95,0x62,0xee,0xf4,0xaf,0xfa,0xd4,0x4f,0xcc,0xf3,0x4f,0x6d,0xbf,0xd7,0x57, -0x63,0xf9,0xd4,0x7c,0x25,0x8d,0xfa,0x7,0x55,0xd6,0xff,0x1,0x60,0xfa,0xcc,0xc9, -0x4f,0xed,0xfe,0x3,0x39,0xfb,0x3f,0xfd,0xfa,0x38,0xd2,0x7d,0xa,0x5d,0x8b,0x7b, -0x7d,0x98,0x9d,0x85,0xfe,0x29,0xa0,0x48,0xbe,0xd1,0x44,0xe9,0x1f,0x8,0x6c,0xfc, -0x0,0xe2,0x23,0xc1,0x39,0xbe,0x69,0xbe,0xa1,0x73,0xfc,0xd0,0xfb,0x97,0x5d,0x7d, -0xfc,0xc0,0x74,0x27,0xa6,0xef,0x81,0x63,0xe1,0x3d,0xc1,0xc3,0x8,0x3e,0x35,0x5f, -0x91,0x87,0xfd,0x83,0xef,0xda,0xbe,0x77,0x5d,0xf9,0x40,0xf7,0x39,0xc7,0x5f,0xbd, -0x7f,0x5e,0x4f,0xe8,0x5b,0x73,0xd5,0x87,0xe,0x22,0xf8,0xd4,0x7c,0x40,0x6e,0xef, -0x36,0xaf,0x7b,0x96,0x1c,0x68,0x97,0x6,0x42,0xc5,0x3d,0xdd,0x77,0xe0,0xc8,0x2f, -0xce,0xea,0xd7,0x6a,0x4a,0x5f,0x94,0xe3,0xab,0xe6,0x2b,0x22,0x81,0x8d,0x2a,0x27, -0x3f,0xa3,0x9,0x6a,0xf9,0x7c,0xc6,0x27,0x9b,0xf6,0x43,0xd1,0xda,0x6f,0x22,0x81, -0x26,0xcf,0x87,0x47,0x78,0x4d,0xf7,0x35,0x7c,0xf9,0x2a,0xe9,0xf9,0xd7,0xd2,0xde, -0xf5,0x19,0xcb,0xa7,0xe6,0x2b,0x49,0x2,0x75,0xbe,0x4f,0xfd,0x9b,0x9a,0x6f,0xc3, -0x97,0xaf,0xf4,0xeb,0x97,0xc6,0xbf,0x7e,0xd5,0x84,0xce,0xd6,0x5d,0x44,0xf4,0x69, -0xf9,0xea,0x2a,0xa8,0x6f,0x71,0xee,0xdf,0x94,0x9e,0xe9,0x43,0xbe,0x7c,0x85,0x74, -0x5f,0xfc,0xfe,0x4f,0xfb,0xab,0xac,0x83,0x51,0x8e,0xa3,0xf8,0x9c,0xf9,0xaa,0xa7, -0xe7,0xab,0xb1,0xe0,0xf3,0xf9,0xee,0x7f,0xd,0x5f,0xec,0xf1,0xc3,0xe5,0x23,0xa7, -0x51,0x7c,0xce,0x7c,0xa5,0x18,0xf9,0x8a,0xb5,0x1f,0x69,0x99,0x3e,0x7f,0xfd,0xc0, -0xf4,0xc5,0x1d,0x7f,0xc9,0x1f,0x3a,0x7c,0xf4,0x9f,0x45,0xf1,0x39,0xc7,0x5f,0xc5, -0x99,0x5f,0x34,0x9f,0x79,0x7d,0x4,0xfa,0x62,0xe7,0x97,0xbe,0xd3,0x17,0x3b,0x5f, -0x61,0xdd,0x37,0xb0,0xee,0xcf,0xd7,0xd4,0xfe,0x85,0x5f,0xbf,0x4a,0xe1,0xc3,0x28, -0x71,0x7e,0xd1,0x7d,0xb7,0x21,0x3b,0xff,0xa8,0xa0,0xf6,0xcf,0x34,0xeb,0xf6,0x9b, -0x16,0x53,0xe6,0x2b,0x2a,0xcc,0xae,0x5f,0xa5,0xf0,0xd1,0xf8,0xf9,0xea,0xcb,0xbb, -0x70,0x53,0xbb,0x7e,0xa1,0x9e,0xaf,0x4,0x61,0x76,0xfd,0x2a,0xa1,0x4f,0xbb,0x3e, -0x62,0xfa,0xb4,0xfa,0x55,0xbd,0x7f,0xa0,0xdf,0x5f,0xee,0xba,0xf2,0x95,0xed,0xdb, -0xf,0xe8,0xff,0x12,0xdc,0x7f,0x24,0xf0,0x79,0xf3,0xd5,0x3b,0xd4,0x5c,0xdf,0xbe, -0x56,0x64,0xf7,0xbf,0xbe,0xf1,0x23,0x1b,0x9f,0x3c,0x58,0x29,0x94,0x22,0xe4,0xab, -0x6b,0xfd,0x83,0xa2,0x2f,0x5f,0x61,0x69,0x27,0xb8,0xbe,0x81,0x92,0xd6,0x5f,0x62, -0xfb,0xb4,0x7c,0x25,0xed,0xaa,0xf9,0xc0,0x9b,0xaf,0xb0,0xd4,0xb2,0x7c,0xbe,0xfc, -0x12,0xc7,0x37,0x2e,0xa7,0xf1,0x69,0xf5,0x2b,0x35,0x5f,0x21,0x5f,0x3e,0xc0,0xd2, -0xe3,0x92,0xe9,0x1b,0xa6,0xf2,0xe9,0xe5,0x6,0xc3,0x37,0x75,0xff,0x69,0xf9,0x88, -0xee,0x47,0x68,0x3f,0xa4,0xe6,0x2b,0x8e,0x6f,0x64,0xbc,0x86,0x2c,0xe8,0xf8,0x46, -0xae,0x9f,0x2,0x68,0x5f,0xbf,0x34,0xb6,0x2f,0x30,0x5f,0xc9,0x57,0x1,0xc,0xac, -0x5f,0xc5,0xf3,0x95,0xed,0xfb,0x37,0x57,0xa5,0x4a,0xf3,0x5d,0x11,0xdc,0xbf,0x3b, -0x16,0x22,0xe6,0x2b,0x6c,0xce,0xb9,0x73,0xeb,0x57,0x49,0x7d,0xae,0xcf,0x99,0xe6, -0xfb,0xba,0xe8,0xf6,0x91,0x99,0xf9,0x8a,0x98,0x3e,0x3c,0x62,0xbe,0x7d,0x5e,0xff, -0x3c,0x7e,0xae,0xae,0x6d,0x53,0x9f,0xc2,0xf7,0x44,0x3f,0xbe,0x33,0x7c,0xfe,0x7c, -0x35,0x35,0x7d,0xe8,0x9,0x8,0x1b,0xdf,0x50,0xf7,0x79,0xba,0x9d,0xca,0xa7,0xf0, -0x7c,0xca,0xcc,0x7c,0x75,0xce,0x7c,0x93,0x52,0xb8,0xef,0xa5,0xda,0xad,0x28,0xbe, -0x76,0x31,0xd4,0x27,0x44,0xf6,0x9d,0x9d,0xea,0x3e,0xed,0x3d,0x8b,0xb3,0xd6,0xb7, -0x1b,0xbe,0x6,0x88,0x36,0xff,0xe1,0xf0,0x9d,0xa7,0xf0,0x19,0xed,0x77,0x7b,0x42, -0x23,0xe5,0x17,0xd4,0x7d,0x2d,0xa1,0x6f,0x8c,0x1c,0xbe,0x6b,0x9e,0xab,0x1a,0xcf, -0xf0,0xb5,0x25,0x29,0x9a,0x6f,0xfc,0xdc,0x6b,0x1d,0x10,0xfb,0xf8,0x4e,0x2f,0xa9, -0x97,0x64,0xd5,0xe1,0xbb,0xca,0xf1,0x29,0xe3,0xa7,0xad,0xe,0x43,0xcb,0x57,0xdd, -0x5d,0x8,0xd9,0xf5,0xb,0xda,0x2f,0xd3,0x48,0xf9,0xa,0xe1,0x37,0xa2,0xf9,0xa8, -0xb6,0x1c,0x97,0x6d,0x40,0xa8,0x39,0x61,0xc3,0xe1,0xfb,0x5a,0xd9,0xfd,0xa,0x19, -0xcd,0x47,0xe0,0x9b,0xb0,0xe7,0xc8,0x57,0x3f,0xec,0x1f,0x74,0x58,0xff,0x7,0xc0, -0xb7,0xa3,0xe5,0x2b,0xd5,0x17,0xf1,0xf8,0x6a,0x6f,0x48,0x95,0x1d,0x6,0x78,0xe0, -0x1e,0x3f,0xa6,0x25,0xcf,0xf8,0xa1,0xf9,0x14,0x3b,0x5f,0x21,0xd3,0x67,0xe6,0x97, -0x1d,0x96,0xaf,0x4,0x10,0x96,0xaf,0x10,0xbe,0x17,0xcd,0x37,0xd5,0xce,0x3f,0x6b, -0x3,0xcc,0x55,0xd5,0x37,0x74,0xfb,0xe4,0xa2,0x77,0x7c,0xbb,0x65,0xfb,0xb4,0xf9, -0xc1,0x97,0xfb,0x7,0x8f,0x7c,0x3e,0x2c,0x89,0xdb,0x61,0xe3,0x2f,0xc2,0xf5,0x5a, -0x24,0xdf,0x29,0x75,0xbc,0x1c,0x50,0x3b,0xc7,0xd5,0xfb,0x5e,0xb3,0xca,0xa4,0xfa, -0xb8,0xd3,0x85,0x62,0xb5,0x82,0xed,0x7c,0x40,0x5f,0xde,0x6d,0x3e,0xe2,0xe4,0x2b, -0xf1,0x56,0x58,0xbe,0x8a,0x3c,0xbe,0x41,0x67,0xfb,0x11,0xc5,0x11,0x14,0x82,0xdb, -0xef,0x75,0xcb,0xa7,0xd5,0xaf,0xfa,0x60,0xa3,0xc2,0xc9,0x57,0x3b,0xec,0xf8,0x22, -0x9e,0x8f,0xb4,0xf5,0x2d,0x42,0x23,0x5e,0xbf,0xec,0xfc,0xe3,0xf9,0x38,0xe7,0x5f, -0xb5,0x82,0x1c,0xf5,0xab,0xcb,0xa0,0x59,0xe0,0xe4,0xab,0xbe,0xe5,0xe3,0x1d,0x5f, -0x2,0xaa,0xd1,0xda,0x4f,0xef,0xff,0xac,0xd,0x44,0x6b,0xda,0x62,0x35,0xb7,0xcf, -0xf3,0xa,0x28,0xcd,0x57,0x79,0x4,0xed,0x7c,0x5,0xfb,0xa0,0xe,0x39,0xf9,0xaa, -0xc7,0x7c,0x90,0x77,0x7d,0x10,0x50,0x89,0xe1,0x23,0x56,0x79,0xb3,0xac,0xbd,0xb8, -0xd4,0xe5,0xf3,0xde,0xa,0x8,0xa,0xaa,0xfc,0xe8,0x5,0x47,0xbe,0xea,0x19,0xbe, -0x13,0xec,0xce,0x57,0x5f,0x66,0x3e,0xc0,0xeb,0x5f,0x8,0x78,0x25,0x9a,0x6f,0x52, -0xf6,0x8c,0xbf,0x10,0xcd,0xf0,0x5,0xe5,0xab,0x53,0xa3,0x7e,0xc5,0xf2,0xd5,0x67, -0xec,0xfe,0x6d,0x83,0xd7,0x3f,0x13,0xfd,0x46,0x34,0x82,0x4f,0x2,0x69,0x7c,0xce, -0x7c,0x65,0xe4,0x3,0xb3,0xbe,0x81,0x11,0xa,0xcd,0x57,0xa4,0x4d,0xa3,0xf9,0xfa, -0xce,0x7c,0x35,0xfd,0xd7,0x31,0x7d,0xce,0xf1,0xf7,0x38,0x96,0xf,0x24,0xf1,0xe1, -0x56,0x72,0xdf,0x99,0xe1,0xd3,0xeb,0x2f,0xb3,0xf3,0x95,0x4,0x60,0x34,0x1f,0xf0, -0xfa,0x66,0x5e,0x1f,0x41,0xed,0xd7,0xd5,0xf3,0x95,0x1c,0x2d,0xbf,0x48,0x20,0xe2, -0xfa,0x3a,0x9f,0x4f,0x2e,0x25,0xf4,0xed,0xc6,0xa9,0x5f,0x9d,0x80,0x71,0x42,0x9f, -0xb7,0x7f,0xe,0xbf,0x3e,0x1c,0xf3,0x83,0x38,0x4e,0xfd,0x2a,0xfa,0xf8,0x6,0xa8, -0xfb,0xfa,0xe0,0xfb,0x84,0xc0,0xfa,0x95,0x35,0x3f,0x88,0x3,0xea,0x57,0x30,0xd5, -0xfd,0x25,0xaf,0xbe,0xc1,0xf1,0x55,0x3,0xeb,0x57,0x48,0xf5,0x21,0xdf,0xfc,0xa0, -0x9a,0xaf,0xd8,0xfd,0x51,0x27,0xd5,0xfd,0x39,0xaf,0x72,0x40,0x5c,0xf5,0x97,0x30, -0x9f,0x96,0xaf,0x24,0x97,0xcf,0xae,0x5f,0xb1,0xfb,0xdf,0x47,0x99,0xd7,0xaf,0xa2, -0xfb,0xb4,0x7c,0xf5,0x70,0xb7,0xd9,0x9,0xab,0x5f,0xc1,0x54,0xf5,0xa1,0x74,0xbe, -0x90,0xfa,0xd5,0x3c,0x7c,0xf2,0xa5,0xa0,0x72,0x60,0x35,0x7e,0xfd,0x8a,0x9d,0x7f, -0x90,0x77,0x7c,0x93,0xd5,0x4f,0x15,0x2a,0x7f,0x83,0xef,0xb3,0xf6,0x3b,0x8b,0x5c, -0xbf,0xfa,0x14,0x86,0xe5,0xab,0x64,0x3e,0x12,0xe8,0x63,0xd,0x1c,0x32,0x3f,0x78, -0xe8,0xce,0x57,0x4f,0xc3,0xb0,0xfe,0x25,0xd9,0xfa,0x1c,0xea,0xf0,0x89,0x57,0x15, -0xd1,0xf7,0x7,0x91,0x10,0x9c,0xaf,0xa0,0x3b,0x5f,0x59,0xf5,0x2b,0xc8,0x9f,0x5f, -0x98,0xa6,0xf4,0xdd,0xfc,0xfc,0xcc,0xe1,0x33,0x5f,0x78,0xe0,0xf5,0x39,0xf3,0x15, -0x70,0xe7,0x97,0x27,0x30,0x7c,0x7e,0xe6,0x3c,0x9d,0x8f,0xb4,0xa6,0x67,0x7f,0x61, -0x2f,0x36,0x1,0xfc,0xf6,0x73,0x8e,0xbf,0x7b,0x6e,0x5f,0x78,0xfd,0x2a,0xfd,0xf1, -0x6d,0x29,0x6f,0xfc,0x10,0x79,0x7d,0xf2,0x8c,0xf5,0xed,0x91,0xf3,0x55,0x6,0xbe, -0xab,0x6f,0xb4,0xec,0x27,0xb6,0x3a,0xb3,0xdb,0xcf,0xa8,0x5f,0x45,0x9e,0x7f,0x8b, -0xbf,0xfe,0xca,0xed,0x7b,0x3c,0xfa,0x89,0xc3,0x17,0x70,0xfe,0xf9,0xeb,0x57,0x84, -0x46,0xf6,0xd5,0xd3,0xb5,0x9f,0xea,0x3,0xbc,0xf3,0x4f,0xab,0x5f,0x21,0x4e,0xbe, -0x32,0xea,0x57,0x75,0x1a,0x71,0x7e,0x90,0x24,0x5a,0x7f,0xa0,0xfb,0xf4,0xdb,0x61, -0xae,0x4f,0x36,0xeb,0x43,0x43,0x4e,0xbe,0x32,0xea,0x57,0x35,0xbf,0x2f,0xa0,0xff, -0x4b,0xb4,0xfe,0x4a,0xf7,0xe9,0xe5,0x84,0xd6,0xa8,0xd7,0x12,0x5d,0x1d,0x9d,0xa3, -0x7e,0x75,0x10,0x98,0xaf,0x1a,0x7e,0x5f,0xc0,0xf8,0x11,0x7f,0xfd,0xb,0xf3,0xe9, -0xe5,0x98,0x9d,0xab,0xbd,0x96,0xdd,0xbf,0xb4,0xcb,0xae,0xfa,0x15,0xa,0xcc,0x57, -0x3f,0xf2,0x5f,0x1f,0x1,0xe3,0x6f,0x1c,0x9f,0xdd,0x19,0x7c,0x63,0xd6,0x8b,0x71, -0xf4,0xfa,0x95,0xa3,0xfe,0x42,0xfb,0xbb,0x4d,0xe8,0x5f,0x7f,0xe5,0xf0,0xf9,0xf2, -0xcb,0x38,0xee,0xfa,0x2b,0xca,0x69,0xbf,0xa0,0xff,0x14,0xbd,0x7e,0x85,0x1c,0xf9, -0xaa,0xf,0x36,0x42,0x9f,0x5f,0xa0,0xbc,0xf5,0xed,0xf1,0xda,0x8f,0x72,0xce,0xbf, -0x40,0x9f,0xa7,0x7e,0x85,0x76,0x40,0x13,0x2c,0xd6,0x37,0x15,0xc2,0x7d,0x95,0x47, -0xc8,0x51,0xbf,0xe2,0xaf,0x6f,0x9f,0xed,0x8b,0x71,0xfd,0x7a,0x7c,0x9e,0xcf,0xdf, -0x95,0x5c,0xf9,0x4f,0xab,0x5f,0x55,0xed,0x7c,0x75,0xed,0x69,0x50,0x2f,0x84,0x3d, -0x3f,0x13,0xe4,0x8b,0xd1,0xff,0x85,0xfb,0xb4,0x99,0x5c,0x71,0x76,0xfd,0xca,0x98, -0x1f,0x54,0x22,0xfb,0x62,0x8c,0x1f,0xb3,0x7d,0x60,0x76,0xfd,0xca,0xc8,0x57,0x67, -0xd1,0x7d,0x1b,0x19,0xfa,0x22,0xd4,0x37,0x7e,0xa5,0xfb,0x9e,0x78,0x7c,0x1,0xfb, -0xb7,0xc7,0xcb,0xf7,0xe1,0x3e,0x10,0xc9,0x77,0xf6,0xb1,0xee,0x53,0x16,0xef,0x1b, -0x6e,0x47,0x6a,0x3f,0x3d,0x1f,0xdc,0x9e,0xbf,0xcf,0x78,0x43,0xfc,0x9e,0x67,0xa5, -0x98,0x18,0xc9,0xd7,0x96,0x3c,0xbe,0xa0,0x4f,0xa,0x9f,0xf1,0x86,0xf8,0xd6,0xe9, -0x30,0x68,0xfc,0xf0,0xd4,0xaf,0x9a,0xbb,0x10,0x4,0xe6,0x2b,0xfa,0x79,0xb1,0x98, -0xb9,0x4f,0x7b,0x43,0xfc,0xda,0xf1,0x81,0x85,0x10,0x3,0x7d,0xda,0xfc,0xe0,0xf3, -0xfd,0x83,0x6d,0x3b,0x5f,0x79,0x7d,0xa3,0x9,0xca,0xd2,0xa7,0xf5,0x69,0xfa,0x1b, -0xe2,0x5,0xfb,0xf8,0x42,0x10,0xe2,0x1b,0x4d,0x5a,0xfd,0x83,0x5b,0x76,0x7e,0x69, -0x2d,0xc2,0x27,0xb5,0x9d,0x3e,0xed,0xfa,0x5d,0x17,0x2,0xeb,0x57,0xce,0xe7,0x7, -0x39,0x3e,0xc4,0xf5,0xc5,0xab,0xbf,0xf8,0x7c,0xc0,0xeb,0x13,0xc4,0xc0,0xfa,0x95, -0xf5,0xfc,0x20,0x2f,0x5f,0x65,0xec,0x93,0x4b,0x2e,0x9f,0x5c,0x9a,0xe1,0xb,0x7e, -0x7e,0xd0,0xbe,0x3e,0x60,0x86,0x3e,0x4,0x99,0x6f,0x4d,0xf3,0x21,0x38,0xbb,0xfd, -0xc2,0xf3,0x15,0x1d,0x51,0x10,0xf2,0xf3,0xe2,0xfa,0xb4,0xe0,0xae,0xf9,0x7e,0x50, -0x6c,0x69,0x3e,0x23,0xc7,0x43,0xf0,0x83,0x62,0x80,0x4f,0xcb,0x57,0x3b,0xa0,0x1e, -0xec,0x23,0xa3,0xd0,0xed,0x8a,0xe2,0xfb,0xb6,0xa9,0xf6,0x86,0xf8,0x1f,0x14,0xf7, -0xc,0xdf,0xb6,0x5e,0xa2,0xfe,0x41,0xd1,0xb8,0x3e,0xa6,0x77,0x39,0xf5,0xab,0x96, -0xe1,0xd3,0xd7,0x77,0xf2,0x7c,0x42,0xc6,0x3e,0xed,0xf3,0x83,0x22,0xef,0x97,0x14, -0x37,0x42,0xea,0x57,0xd8,0x59,0xbf,0xb2,0x3e,0x57,0x9,0xf7,0x95,0x99,0x91,0xd7, -0x5f,0xc5,0xf2,0xd1,0x46,0x48,0xfd,0xa,0x3b,0xeb,0x43,0x33,0x4f,0xf4,0xa8,0xeb, -0xaf,0xd2,0xf9,0x9c,0xe3,0x2f,0x8a,0xe7,0x8b,0xb8,0xfe,0xca,0xfd,0x19,0x14,0x5c, -0x20,0xcf,0x2f,0x29,0xbd,0x23,0xcc,0x7c,0x7e,0x30,0xb2,0xaf,0x1,0x92,0xec,0xff, -0xe2,0x1,0x79,0x7e,0x79,0x6f,0x56,0xfb,0xdd,0x8e,0xec,0x7b,0x6d,0xe,0x3e,0x42, -0x43,0x7c,0x7a,0x7d,0x57,0x8a,0xe8,0x8b,0xbc,0xfe,0x2a,0xd6,0xf1,0x55,0xf4,0xfa, -0xda,0xe3,0xcb,0x4f,0x15,0x39,0xf5,0x2b,0x63,0x7d,0x7b,0x25,0x62,0xfb,0x45,0x5e, -0x7f,0xe5,0xb9,0x40,0xdc,0x20,0xcf,0x2f,0xe5,0x67,0xb4,0xfe,0xef,0xa5,0x9,0xa1, -0x9c,0xfa,0x95,0xee,0x3,0xd1,0x7d,0x89,0x8e,0xef,0xb6,0x1b,0xe4,0xf9,0xa5,0x31, -0x7e,0xb8,0x7c,0xa3,0x89,0xe9,0x33,0xf3,0xcb,0xa3,0xa8,0xbe,0x7b,0x49,0x7c,0x44, -0x70,0x81,0x3c,0xbf,0xf4,0xfb,0xb4,0xf5,0xed,0x92,0xcb,0xf7,0x6e,0xb4,0xfb,0x8f, -0xc8,0xeb,0xaf,0xdc,0x9f,0x33,0xba,0xae,0x7f,0xc3,0x2f,0x19,0x9b,0x6e,0xb9,0x7f, -0x69,0xd6,0xaf,0xc8,0xe7,0x97,0x9f,0x2a,0xd9,0xf9,0x80,0xbf,0xbe,0xdd,0xe3,0xcb, -0xea,0xfd,0x5b,0xc8,0x75,0xc1,0x42,0x44,0x39,0xed,0x47,0x9e,0xee,0x13,0x47,0xbe, -0xa,0x7a,0x7e,0xd0,0xe5,0xf3,0xbd,0x7f,0x8b,0xb4,0xe5,0x24,0x3e,0xf7,0x5,0xb, -0x7d,0xfd,0xb3,0xee,0x1b,0x49,0xc4,0x91,0xaf,0x82,0x9e,0x1f,0x74,0xd5,0xf,0x7c, -0xef,0xdf,0x22,0xa0,0x2a,0xd0,0xb4,0xfd,0x1f,0xa4,0xbc,0xf6,0x53,0x9e,0xd8,0xbe, -0x90,0xe7,0x7,0xbd,0x3e,0xf7,0xfb,0xb7,0x62,0xac,0xbf,0x8a,0xe1,0x9b,0xbe,0xae, -0xd5,0xef,0x9f,0x4c,0x9e,0x72,0xe6,0x2b,0x73,0x7e,0x30,0xd0,0xc7,0x7d,0xff,0x56, -0x42,0x1f,0x2e,0xb9,0x7c,0xee,0x5f,0xaa,0x5f,0xde,0x9,0xae,0x5f,0xb9,0x7d,0x72, -0x69,0xad,0x64,0xfa,0xb8,0xef,0xdf,0x22,0xe0,0x3f,0x24,0xba,0x3e,0x2a,0xee,0xeb, -0xa3,0xe2,0x39,0xbe,0x3b,0xc1,0xf5,0x2b,0xb7,0xf,0x4b,0x2d,0xe8,0xf0,0xf9,0xde, -0xbf,0x45,0xda,0xc3,0x24,0xe7,0x1f,0xac,0xba,0x7c,0xee,0x5f,0x52,0xed,0x9,0xd7, -0x88,0xfb,0xaf,0x71,0x7c,0xae,0xf7,0x6f,0x91,0xa8,0xeb,0x9b,0xe2,0xf9,0xea,0xd1, -0x7d,0x22,0xf3,0x71,0xdf,0xbf,0x25,0x25,0xf4,0x21,0xb7,0xf,0x25,0xf6,0x8d,0x0, -0x3b,0xff,0xb8,0xef,0xdf,0x9a,0x8f,0x8f,0xe0,0xa8,0xbe,0xd0,0xe7,0x67,0x68,0x8c, -0xf5,0x57,0x7c,0xdf,0x4a,0x11,0x43,0x8e,0x4f,0xd1,0x7d,0x8d,0x4f,0xd7,0xca,0x33, -0xdb,0x2f,0xec,0xf9,0x99,0x14,0xe3,0x9b,0x71,0xb3,0x4f,0xbe,0x64,0xf8,0xcc,0x5f, -0xda,0xf9,0xea,0x39,0xcd,0xf7,0xc7,0xdd,0x16,0x98,0xe9,0xb,0x7b,0x7e,0x26,0xb9, -0xcf,0x28,0x68,0x50,0xa5,0xd6,0xed,0x6a,0x3e,0xb9,0xc4,0xab,0xff,0xbd,0xd8,0xe8, -0xc2,0x99,0xbe,0xb0,0xf5,0x7,0xc9,0x7d,0xec,0x63,0xfa,0xf8,0xf5,0xc9,0x17,0x1b, -0x78,0xf6,0xf5,0x11,0xb6,0xfe,0x20,0x5d,0xfd,0xca,0xf0,0xfd,0xba,0x68,0xf9,0xdc, -0x5b,0x8a,0xa,0xe4,0x78,0xa6,0x6f,0xf6,0xfb,0x21,0x52,0xfb,0x1c,0xed,0x47,0xdc, -0xed,0x47,0x9e,0xae,0xce,0x6e,0x3f,0x67,0x3e,0x10,0x17,0xec,0x1b,0x55,0x67,0x9f, -0x7f,0xb3,0x7c,0x29,0xea,0xa7,0xb3,0x7c,0xca,0x4,0xcf,0xbe,0x7e,0x9d,0x3e,0xde, -0xf5,0x9b,0xda,0xf7,0x16,0xcf,0xa7,0xd7,0xaf,0x94,0xc9,0x94,0xd7,0xff,0x9d,0x4, -0xe6,0xab,0xf4,0xfb,0x5f,0xf9,0x3e,0xf7,0x6f,0xbc,0xc8,0xf3,0xe1,0x90,0xfa,0x8b, -0x44,0xc7,0xf7,0x9f,0xc7,0xbc,0x7c,0xe5,0x1c,0x3f,0x84,0xdb,0xc6,0x7b,0xb9,0xe2, -0xad,0xbf,0xa,0x1a,0x4d,0x7c,0xc7,0x37,0xac,0x3e,0x44,0x61,0xb3,0x87,0x78,0xf9, -0xc5,0xb9,0xfe,0xe0,0xe6,0x6b,0xa8,0x6e,0xf8,0xce,0x17,0xef,0x6b,0x18,0x63,0x6, -0x27,0x5f,0x39,0x7c,0xc6,0xcd,0x69,0xca,0xe3,0x1b,0xe4,0xbb,0x1b,0x32,0x3f,0xa8, -0xe,0x87,0xa,0xe0,0xe4,0x2b,0xd7,0xfb,0xb7,0x5e,0x7a,0x8d,0xa4,0xf7,0xad,0x9b, -0x3b,0x4e,0xfb,0x7d,0xd5,0xb0,0xf6,0x3b,0x41,0x8a,0xe8,0xc8,0x57,0xdc,0xe3,0xfb, -0xd2,0xed,0x9b,0x96,0x6f,0x23,0x73,0x1f,0x9,0x5b,0x7f,0x45,0xc9,0x75,0xe5,0x96, -0x23,0x5f,0x1,0xde,0xf5,0xf1,0x6a,0xe5,0x23,0xcb,0x57,0xcf,0xdc,0x67,0xd4,0xaf, -0xc4,0x6b,0xd8,0xaa,0x29,0xbf,0x2b,0xa3,0x4e,0xa1,0xa0,0xef,0x2f,0xaa,0x9e,0x9d, -0x53,0xe8,0xc8,0x57,0x22,0x2f,0x5f,0xbd,0x5a,0xb1,0xce,0xbf,0x44,0xeb,0xf,0x5c, -0xbe,0x7d,0xaf,0xcf,0xa8,0x5f,0xbd,0x2c,0xd5,0xac,0x5b,0xd9,0x4a,0xb5,0xda,0xa8, -0xd5,0xf4,0xe7,0x7b,0xdc,0xd7,0x87,0xb9,0xa7,0xb5,0x37,0x5f,0xbd,0xaa,0x5d,0x1f, -0xb1,0xf7,0xbf,0xa,0xf0,0x6d,0x70,0xc7,0xf,0xfa,0xd2,0xa4,0x59,0xb7,0x7c,0x95, -0x46,0xd5,0xf0,0x51,0x77,0xff,0x82,0x26,0xdc,0xf1,0xad,0xaa,0xf5,0x2f,0xbb,0xc9, -0xd7,0xbf,0xb8,0x7c,0x97,0x2,0x7c,0xc4,0xf2,0x11,0x8,0x27,0xb8,0x56,0x33,0xe6, -0x67,0x9c,0xfd,0x33,0x46,0xbf,0x2f,0x72,0x7d,0x5a,0xff,0xbc,0x9e,0xdc,0xd7,0xe6, -0x2d,0xb9,0x32,0x2a,0xb2,0x56,0xbe,0x1a,0x7d,0xd4,0xb5,0x7c,0x63,0xf8,0x4,0x17, -0x56,0x9d,0xf3,0x83,0xa1,0xf9,0x2a,0xe1,0xfe,0x57,0xf6,0x7,0x70,0xda,0xcf,0xbe, -0x15,0x37,0xf3,0xd5,0xe4,0xd8,0xf2,0xd1,0xca,0xef,0xb0,0x50,0x3,0xf1,0xf2,0x4b, -0x8a,0xf6,0x3,0x9c,0xf3,0xcf,0xeb,0x1b,0x39,0x7c,0xb0,0xd2,0xa8,0x9,0x35,0x31, -0x9e,0x6f,0x37,0x23,0xdf,0x3e,0xd7,0xa7,0x4c,0xa4,0xd3,0x9a,0xe5,0xab,0x56,0x9b, -0xb3,0x7c,0xbe,0x7c,0x75,0x94,0x7c,0xfd,0x95,0xcb,0x47,0xf9,0x3e,0xe4,0xe8,0xff, -0x5e,0x97,0xd1,0x81,0x50,0x10,0xc3,0xf2,0xd5,0x46,0xfa,0xfd,0xaf,0x62,0xf9,0x5c, -0xbf,0x2b,0x98,0x5f,0xd0,0xfa,0x67,0x38,0xda,0xd5,0x1f,0x4a,0x35,0x9f,0x9f,0x61, -0xfd,0x33,0xa,0x7a,0x3e,0xa0,0xbe,0x0,0x9f,0x68,0x8e,0x32,0xda,0xf8,0x36,0xfc, -0x78,0xc7,0xd8,0x3c,0xd4,0xc8,0x7,0x65,0xe6,0xb,0x7a,0xbe,0x62,0x23,0xa9,0x2f, -0xa0,0x34,0xcd,0xf3,0x39,0xc7,0x5f,0xd5,0x67,0xc,0xba,0xc6,0xf3,0x3d,0xac,0xfd, -0xb8,0xcf,0xa7,0x24,0xcd,0xf7,0xc9,0x7d,0xa,0x3d,0xfe,0x89,0xe8,0xf0,0x89,0x73, -0xf5,0x29,0xa4,0x94,0xc0,0xb7,0x6f,0xfb,0x46,0xc0,0xf2,0xa5,0x7f,0x7e,0x86,0xe3, -0x53,0x60,0x4c,0x1f,0xa6,0xa3,0xd7,0x64,0xcb,0xa7,0xe6,0x2b,0xe6,0x3,0xe9,0x9f, -0x9f,0x49,0xec,0x3b,0xc7,0xaf,0xcb,0xb0,0x50,0xd0,0xea,0xe3,0x48,0xf5,0x11,0xbb, -0xfd,0xec,0x7c,0x5,0xd2,0xef,0x2f,0xc5,0xf1,0xd1,0x48,0xbe,0xc9,0xf7,0xd5,0x80, -0x55,0xab,0x69,0xf3,0xb,0x3,0xd5,0xe7,0xb8,0x3e,0x30,0xb4,0x7c,0xe9,0xf7,0xe7, -0x4a,0xe3,0x53,0x7,0xb8,0x9a,0xb1,0xff,0x95,0x34,0x72,0xf4,0x2f,0xc8,0x7a,0x7f, -0x72,0x6,0xfb,0x9b,0xf1,0x7c,0x20,0x8a,0x4f,0xfa,0xab,0xa,0x6c,0xd6,0x6a,0xdf, -0x35,0x7d,0x76,0xff,0x3c,0xcb,0x97,0xb4,0xfe,0x62,0xfb,0xc4,0x68,0xbe,0xd7,0x61, -0xb3,0xb0,0x7a,0x3d,0x6a,0xbe,0xca,0xd0,0x27,0x44,0xf3,0x9,0x15,0x35,0x1f,0x54, -0xe3,0xe5,0x97,0x2c,0x7c,0x84,0x46,0x3c,0xbe,0xc9,0x7c,0x49,0xeb,0xa7,0xcc,0x37, -0xfd,0x27,0x91,0xc6,0x5f,0xa9,0x5b,0xa9,0xd6,0x66,0xf9,0x52,0x3d,0x9f,0x1c,0x6b, -0x7c,0x23,0xde,0xfd,0xaf,0x26,0x5d,0x35,0x60,0x9,0x7a,0xff,0x87,0xa3,0xd7,0xaf, -0xe6,0xe6,0x9b,0xf2,0xf6,0x97,0x32,0xf3,0xd5,0x29,0x85,0xb0,0xb0,0xb,0x66,0xd4, -0xaf,0xd8,0xdf,0x4a,0xb8,0xfe,0x6a,0x86,0xef,0xdc,0xeb,0xc3,0xd4,0xca,0x57,0xc7, -0x74,0xf8,0x9,0xde,0x1,0xfe,0xfa,0x90,0xc8,0xdd,0xff,0x25,0xd9,0xfa,0xab,0x59, -0xc7,0x57,0x9,0x1b,0x7f,0x87,0x1f,0x2b,0x3c,0xdf,0x8f,0x79,0xf9,0x25,0xee,0xfa, -0xab,0xed,0xc,0x7c,0xc7,0x3f,0x51,0x44,0x8e,0xef,0xad,0x0,0x5f,0x9c,0xf5,0x25, -0x56,0x9a,0x4a,0xe9,0xdb,0xb7,0xf3,0x55,0x8f,0x5b,0xbf,0xb2,0x7d,0xb1,0xd6,0x5f, -0xc9,0x42,0x34,0x1f,0xe,0xcf,0x57,0x8a,0x6c,0xe7,0x2b,0xdb,0xc7,0xbf,0x3e,0x62, -0xad,0xbf,0x1a,0xd3,0x64,0xbe,0x73,0xbc,0xbf,0xf7,0xa8,0x50,0xd8,0x64,0x3e,0x62, -0xe7,0xab,0xa7,0x43,0xf7,0xd7,0x8b,0xb9,0xfe,0x6a,0x8f,0xfd,0x8b,0x35,0x47,0x6b, -0xdd,0x2e,0x6a,0xfb,0xe7,0xc8,0x41,0xbe,0xc9,0xf7,0x9b,0x2d,0x35,0xbf,0x88,0xcc, -0x67,0x5f,0x1f,0x33,0xf6,0xd7,0x8b,0xb9,0xfe,0xca,0x62,0x15,0x7c,0x7d,0xac,0xb6, -0xff,0xd0,0x58,0x8,0xcc,0x57,0xf5,0x96,0x9d,0xaf,0x24,0x47,0xff,0x32,0xe3,0xf9, -0xe4,0x78,0xeb,0xaf,0xac,0xcb,0x83,0x58,0x2b,0xa5,0xda,0xcc,0xa1,0xed,0xdf,0xa4, -0x3d,0xbd,0x1a,0x30,0xfe,0xd6,0x45,0x35,0x5f,0x19,0xfb,0x8b,0x4a,0x8e,0xfe,0x79, -0xe6,0xfe,0x7a,0xb1,0xd6,0x5f,0x91,0x95,0xe8,0x1f,0xaf,0x6f,0x4f,0xcd,0x57,0xae, -0xf5,0x57,0x91,0xf2,0x55,0xbc,0xf1,0x2d,0x4d,0xfb,0x29,0x6a,0x7e,0x41,0xb1,0xf3, -0xb,0x69,0xf,0x4,0x3a,0xff,0xf3,0x4f,0xf5,0xb5,0x92,0xf9,0x80,0x10,0xc7,0xb7, -0x1f,0xed,0xfa,0xe5,0xe4,0xab,0x66,0xab,0x99,0x24,0x5f,0x11,0xb0,0x16,0x27,0xbf, -0x1c,0xfa,0xfa,0x3f,0xec,0x2c,0x1,0x29,0xcc,0x27,0xfb,0xf2,0xd5,0xfe,0x5e,0xc3, -0xc8,0x57,0xa,0xe,0xf0,0xed,0xf1,0xf7,0xbf,0x8a,0xe5,0x93,0x23,0xfa,0x70,0x70, -0xbe,0xd2,0xf7,0x9f,0x54,0xcf,0x2a,0xc1,0x18,0x3f,0xae,0x14,0x8b,0x61,0xf7,0xe7, -0x44,0x7f,0x10,0x28,0xb2,0x6f,0x2a,0x44,0xf3,0xa1,0xe0,0x7c,0x65,0xec,0x8f,0x59, -0xd9,0x11,0xcc,0xf1,0xd7,0x78,0xae,0x27,0x28,0x5f,0x91,0xb6,0x12,0xc7,0xe7,0xcf, -0x7,0x7c,0xdf,0x38,0x78,0xfc,0x7d,0xa2,0xef,0x2f,0x55,0x69,0xf9,0x7c,0x9b,0xdc, -0xfd,0xeb,0x40,0x2c,0x9f,0x3f,0x5f,0x5,0xb4,0x9f,0x30,0xcb,0xd7,0xf4,0xf9,0x9a, -0x3c,0x9f,0x4,0x70,0xba,0x7c,0xcf,0xf7,0x85,0xac,0x1f,0x1f,0xe9,0xfb,0x5f,0xbd, -0x52,0x33,0x7d,0x9f,0x5f,0x66,0x3e,0xee,0xfe,0x89,0x8b,0xf7,0xd,0xf4,0xfd,0xaf, -0x60,0xc3,0xbc,0x3e,0xae,0x5a,0xed,0xc7,0xdd,0xbf,0xf8,0x64,0x3e,0x3e,0x7d,0x7f, -0x6,0x54,0x72,0xac,0x44,0xfb,0xf5,0xdd,0x4a,0xa1,0x0,0x59,0xff,0x2,0xa0,0xb9, -0x3e,0x1b,0x2b,0xf6,0xf1,0x9d,0xcb,0xfd,0x9b,0xcb,0x67,0xf5,0xcf,0xb2,0x3e,0xbf, -0x0,0x1d,0x2b,0xf9,0x1a,0xd,0x35,0xbf,0x74,0x6c,0xdf,0x8f,0xca,0x5e,0xdf,0xfe, -0x5c,0xee,0x7f,0x5d,0x3e,0xd7,0xf8,0x46,0x46,0x13,0xcc,0xf1,0x19,0x7f,0x1d,0x8a, -0xbe,0xf6,0x9b,0x4b,0xfd,0xc0,0xed,0x73,0xe5,0x3,0x32,0x72,0xd6,0x3e,0xaa,0x8, -0xd7,0x6a,0xf6,0xfe,0xa2,0xac,0x7f,0xc6,0xd3,0x62,0x31,0xb3,0xfa,0x8b,0xf8,0xe1, -0x5a,0x78,0xff,0x37,0x70,0xad,0xbf,0x72,0xf9,0xee,0xde,0xad,0x15,0x56,0xbd,0xfb, -0x8b,0x66,0x5c,0xbf,0x12,0x1b,0xd6,0x4e,0x2a,0x11,0xda,0x8f,0xbe,0xe4,0xf4,0x9, -0xa2,0x9a,0xf,0x2a,0xf3,0xad,0x5f,0x81,0x4a,0x17,0x45,0x3f,0xff,0xe8,0x4b,0xce, -0xf3,0xaf,0xda,0x50,0x7d,0x85,0xd8,0xbe,0x58,0xf5,0x53,0x60,0xed,0xb7,0x3a,0xeb, -0xfa,0xd5,0x7d,0x3b,0xce,0xeb,0x57,0xf7,0xc1,0xd8,0xf9,0x2a,0x96,0x4f,0x82,0x38, -0x5a,0xff,0x67,0x3c,0x3f,0x28,0x3a,0xfb,0xbf,0xf,0xef,0x56,0x5,0xa3,0xff,0xb, -0xda,0x9f,0x1,0xa5,0xde,0xff,0x2a,0xb2,0x8f,0xb3,0xfe,0x4a,0xb4,0xf2,0x95,0xfe, -0xfc,0xf9,0xe0,0xae,0x95,0xaf,0x80,0xe9,0x1b,0xf2,0xe7,0x3f,0x62,0xac,0xbf,0x7a, -0x12,0xd5,0xc7,0x59,0xdf,0x4,0xac,0x7c,0xa5,0xef,0x8f,0x54,0x69,0x88,0x66,0x3e, -0x30,0x96,0xfe,0x7a,0xdf,0xbf,0x65,0xfb,0xce,0xe3,0xf8,0x66,0x5c,0x1f,0x21,0x3e, -0x3b,0xbf,0x78,0x7d,0xb7,0x4c,0xdf,0x1,0x7f,0xfe,0x2d,0xc6,0xf1,0xc5,0x68,0x46, -0xff,0xc2,0x7c,0x24,0x64,0xfd,0xd5,0x13,0x23,0x9f,0x8a,0x96,0xf,0x64,0xe7,0x93, -0xd7,0x4a,0xa9,0xdb,0x6f,0xa4,0xb7,0xdf,0x2b,0xf7,0x59,0xbe,0xb2,0xce,0xbf,0x6, -0xff,0xf8,0xc6,0x5d,0x7f,0x75,0xa8,0x9e,0xea,0xeb,0x9a,0x6f,0x5a,0x46,0x74,0x5c, -0xd2,0x7c,0x9b,0x44,0xbb,0x21,0x8e,0xe8,0x1b,0xe8,0xfb,0x5f,0x41,0xb3,0xfd,0xe4, -0xab,0x56,0xfb,0x6d,0xf0,0xaf,0x8f,0xb8,0xeb,0xaf,0xfa,0xb4,0xac,0xa,0x81,0xb6, -0xc1,0xb2,0x36,0xd9,0xa7,0xf9,0x6a,0x53,0xed,0x28,0x84,0x5e,0xbf,0xd5,0x46,0xdf, -0x9c,0x1f,0x54,0x7a,0x46,0x3e,0x30,0x8f,0xaf,0x62,0xf9,0x82,0xfa,0x97,0x98,0xeb, -0xf,0xfa,0xa4,0xf5,0x4d,0xd3,0x77,0xf0,0x97,0x55,0xc3,0x77,0xfe,0xfb,0x3f,0xe1, -0xf4,0x7f,0xce,0xfb,0x96,0xe3,0xf7,0x3e,0x45,0xc6,0xfc,0xa0,0xde,0xff,0x1,0xd8, -0xf0,0xfb,0x2,0xf6,0xe7,0x8a,0xb9,0x7e,0xa3,0x4f,0x1f,0x7f,0x6c,0xfa,0xd0,0x9f, -0x37,0xc,0x1f,0x39,0xfd,0x23,0x4f,0x7e,0xf6,0xf9,0xde,0xff,0xad,0xea,0xb3,0xf7, -0x97,0xe2,0xf8,0x82,0xc6,0xb7,0x98,0xeb,0x5f,0xfa,0xb4,0xd5,0x7b,0x60,0xfa,0x9a, -0xef,0x96,0xd,0x1f,0xba,0x53,0x8,0xf5,0x29,0xc7,0xef,0xf7,0xb1,0xd3,0xc7,0xfa, -0x67,0x35,0x5f,0xcd,0xc1,0xc7,0xda,0xaf,0xc9,0xda,0xf,0xdd,0xd1,0xdb,0x6f,0x1a, -0x54,0xbf,0x52,0x7a,0x1f,0xf4,0x71,0x61,0xb5,0x13,0x2f,0x5f,0x25,0xda,0xff,0x2a, -0xcc,0x17,0x38,0xbf,0xa5,0xec,0x36,0x5e,0xc6,0xb1,0xeb,0x43,0x34,0xeb,0xf6,0xb, -0xf6,0xf5,0x72,0xee,0xdb,0x69,0x3c,0xc4,0xb1,0xeb,0x57,0x34,0xc9,0xfa,0xab,0x43, -0x68,0xfa,0xa6,0xcf,0x33,0xdf,0xe6,0xce,0x2c,0x1f,0xd9,0x69,0xf4,0xcd,0xf9,0xc1, -0xc0,0x7c,0x15,0xb0,0xbe,0x3d,0xc5,0xfa,0x2b,0xdf,0xf8,0x16,0xec,0x73,0xd4,0xaf, -0xbc,0xf9,0x2a,0xf8,0xfd,0x5b,0x34,0xe5,0xfa,0xab,0xe8,0x3e,0xed,0x8b,0x1,0xf9, -0x6a,0x12,0x5c,0xdf,0xa0,0x19,0xac,0xbf,0x8a,0xe8,0xb,0xce,0x57,0xb6,0x2f,0x68, -0x7f,0x2e,0xba,0x58,0x1f,0xf6,0xe4,0x2b,0xe6,0x1b,0xe6,0xc3,0x37,0xd2,0x7d,0xaf, -0x8,0x22,0xcb,0x57,0x33,0x8f,0xef,0x62,0x7d,0x3,0x64,0xe4,0x2b,0x56,0xbf,0x42, -0xa1,0xcf,0xf,0x26,0xf3,0xa9,0xe3,0x98,0xb9,0x66,0x77,0x7d,0xc5,0xdc,0x51,0x4f, -0x1d,0x8b,0xa,0x21,0xbe,0x6a,0xe3,0xd3,0x8a,0x99,0xaf,0xf4,0xfd,0xf,0x20,0x7b, -0x7f,0x8a,0x9d,0xf,0x2,0xde,0x1f,0xbf,0x10,0x9f,0x9a,0xaf,0xba,0xd,0x33,0x5f, -0xe9,0xef,0x1f,0x84,0x2d,0xcb,0x27,0x6,0xd6,0xaf,0x16,0xe9,0x7b,0x5f,0xf3,0x39, -0xf2,0x55,0xd3,0xf2,0x9,0x33,0xc6,0xb7,0xf4,0xcf,0xa7,0xf0,0x8a,0x62,0xbe,0x7c, -0xd5,0x6d,0xba,0xf2,0xd5,0xeb,0x66,0xfd,0x6f,0x7a,0xb9,0x10,0xe6,0x4b,0xf9,0xfc, -0x5b,0x64,0x5f,0xef,0x83,0x6e,0xb3,0xb0,0xa,0xe3,0xe5,0xab,0x5,0xfa,0x76,0x1b, -0x2f,0xce,0xac,0xbf,0x64,0xd7,0x7e,0xb1,0xcf,0x3f,0x35,0x5f,0x69,0x3e,0x10,0xdb, -0x97,0xac,0x7e,0x1a,0xdf,0xb7,0xd3,0x78,0x2b,0xfe,0xfa,0xf6,0xb9,0xf9,0x88,0xec, -0xcf,0x57,0x9f,0x56,0x5,0xfd,0xf9,0x1e,0x5,0xc5,0xc9,0x57,0xd9,0xd6,0x9f,0x99, -0x6f,0xea,0x9d,0x3f,0x72,0xe6,0xab,0xa1,0x9e,0xaf,0xd6,0x68,0xa4,0x7c,0x95,0x7a, -0xfd,0x15,0xd7,0x77,0xee,0x9b,0xdf,0x72,0xe4,0xab,0x3,0x3d,0x1f,0x3c,0xa6,0x91, -0xf2,0x55,0xea,0xf5,0x57,0x5c,0x5f,0xd8,0xf3,0x65,0x4f,0xf4,0xfd,0x9b,0x2a,0x3f, -0xda,0x2e,0x9e,0xf,0x0,0x0,0x12,0x4f,0x49,0x44,0x41,0x54,0xa3,0x91,0xf2,0x55, -0xc2,0xfd,0xaf,0x66,0xf9,0x42,0xf6,0x6f,0x37,0x7d,0x6c,0xfc,0xb5,0xf3,0x15,0xa, -0xf0,0x35,0xc0,0x42,0xdb,0x6f,0xa4,0xfb,0x5e,0x31,0xcf,0x3f,0x35,0x5f,0x6d,0x31, -0x1f,0xff,0xf8,0xc6,0xdf,0xff,0x6a,0xf,0x1f,0x9a,0x3e,0xf9,0x7e,0xd9,0xf4,0x15, -0x37,0xa3,0xfa,0xcc,0x7c,0xc5,0xde,0x4f,0x77,0xd5,0x6a,0x3f,0xc8,0xbf,0x3e,0xe2, -0xef,0x7f,0xd5,0x3a,0xed,0x9b,0x3e,0xd4,0x34,0xa6,0x17,0x55,0x50,0x6d,0x86,0x6f, -0x7c,0x19,0x16,0xa,0x80,0xf5,0x2f,0xce,0x7c,0xc5,0x7c,0x80,0xd7,0xbf,0x24,0xd9, -0xff,0x6a,0xed,0x98,0xf9,0x60,0xd7,0xf4,0x29,0xd8,0xf2,0x1d,0xf1,0xcf,0x3f,0x78, -0x1f,0xd5,0x6a,0xdb,0x1c,0x9f,0x75,0x7d,0x6c,0xf0,0xfa,0xe7,0x24,0xfb,0x5f,0x9, -0xd8,0xf2,0x61,0xe6,0xa3,0x96,0x6f,0x97,0x9f,0x9f,0xe1,0x9b,0xaa,0xcf,0xde,0x5f, -0x94,0xe3,0xe3,0x8e,0x6f,0x49,0xf6,0xbf,0x72,0xfa,0xb6,0x99,0xcf,0x3a,0xff,0xd6, -0xf9,0x3e,0xb0,0x66,0x3d,0x3f,0xa8,0xe7,0x2b,0x76,0x7d,0x84,0xcd,0xf,0xd2,0x64, -0xfb,0x5f,0x39,0x7c,0xd3,0x5b,0xbe,0xf6,0x5b,0xe7,0xd5,0xaf,0x74,0x9f,0xfb,0xf9, -0xc1,0x68,0xf9,0x2a,0xc9,0xf8,0xe6,0xf0,0x51,0xff,0xf1,0xd,0x6e,0xbf,0x24,0xf9, -0x85,0xb4,0xe3,0xef,0xaf,0xb2,0x66,0xfb,0x80,0xff,0xfa,0xd8,0xcd,0xd6,0x17,0xf5, -0xfd,0x74,0xce,0xfe,0x5,0xdb,0xfd,0x8b,0xe8,0xeb,0x5f,0x8e,0x12,0xfb,0x78,0xd7, -0x6f,0x12,0x9f,0xb3,0x7f,0x16,0xb8,0xfd,0x33,0xe7,0xfd,0x24,0x70,0xd,0x9,0x46, -0xff,0x17,0x54,0xbf,0x82,0xbc,0xfe,0x2f,0x89,0x2f,0xc2,0xfd,0xb9,0xbf,0x7f,0x86, -0x81,0xf5,0x2b,0x76,0x7f,0xde,0xe1,0x8d,0x1f,0x4,0xbc,0x4e,0xe7,0xe1,0xf3,0xb5, -0x1f,0xb2,0xf2,0x55,0xcf,0x5d,0x1f,0x42,0x1d,0xd3,0xf7,0x88,0x37,0xfe,0x92,0x36, -0x9c,0x47,0xfb,0xfd,0x3e,0x24,0xbf,0x78,0x7d,0x8f,0xd8,0xf1,0xe5,0xe5,0x97,0x84, -0xfb,0x5f,0xcd,0xf2,0x9d,0xa,0xd1,0x7d,0x95,0x30,0x9f,0x34,0x1f,0x5f,0x58,0xbe, -0xd2,0x7d,0xaf,0x54,0xad,0xfa,0x95,0xe5,0xe3,0x1d,0xdf,0xc5,0xfb,0x6,0xfa,0xf5, -0xc1,0xe6,0x8f,0xe4,0xab,0x13,0x18,0x96,0xaf,0x12,0xee,0x7f,0x15,0xc9,0xb7,0x55, -0x77,0x3c,0xf8,0x3d,0xfe,0x4a,0xc5,0x35,0x3f,0x68,0xcd,0x6f,0x3d,0x81,0x61,0xfd, -0x4b,0xf6,0xf7,0x6f,0x47,0x56,0xff,0x57,0x7d,0xbe,0xe5,0xe8,0x5f,0x6a,0xd,0xfe, -0xfc,0xe0,0xef,0x59,0xfd,0x5,0x66,0xb8,0xff,0x55,0x88,0xcf,0x1a,0xdf,0x8,0x7e, -0x69,0x87,0xe3,0x33,0xf3,0x95,0x3d,0x3f,0x38,0x97,0xfd,0xaf,0x82,0x7d,0x56,0x3e, -0x20,0xd4,0xe9,0x3,0xb5,0xa6,0xd3,0xe7,0x98,0x1f,0x84,0xf3,0xa8,0x5f,0x85,0xf8, -0xac,0xf5,0x57,0x47,0xaf,0xb9,0x7d,0x9e,0xf5,0xed,0x73,0xad,0x5f,0x45,0x69,0x3f, -0xfc,0x86,0xdb,0x17,0xfb,0xf9,0xbc,0xb9,0xf8,0x76,0x33,0xf5,0x65,0x5f,0xbf,0xb7, -0xf3,0x55,0xf5,0x5e,0x2b,0x96,0x2f,0xcb,0xfd,0xaf,0x66,0xd4,0x87,0xf4,0xf5,0x7, -0xae,0xfe,0xf,0xde,0xaf,0x1a,0xf3,0x83,0xc1,0xbe,0x2c,0xf7,0xbf,0xa,0xf7,0x71, -0xd6,0x5f,0x59,0xf9,0x2a,0xd8,0xe7,0xda,0xff,0xea,0xee,0xcd,0xcb,0x86,0x6f,0x3a, -0x8f,0xf9,0x19,0xbf,0xcf,0xca,0x57,0xc1,0x3e,0xd7,0xfe,0x57,0xd5,0xde,0xc4,0xf0, -0x9d,0x2f,0xc6,0x67,0x8d,0xbf,0xc1,0x3e,0xd7,0xfe,0x57,0x95,0xd1,0x64,0x7e,0xc7, -0x97,0xdc,0x49,0xeb,0x7b,0xa9,0x32,0x22,0xf3,0xf3,0xd1,0x9f,0xa6,0xf7,0x49,0x37, -0x99,0x6f,0xe,0xf3,0xbf,0x62,0x5a,0xdf,0xab,0x15,0xf8,0x11,0xf3,0xd5,0x17,0x71, -0xfd,0xc6,0xf7,0xb1,0xf3,0x2f,0xdd,0xfa,0x3,0xd7,0xf3,0x47,0xec,0x67,0x4c,0xef, -0xd2,0xd4,0x3e,0xf5,0xfa,0x48,0xb1,0xff,0x15,0xf0,0xfd,0xc,0xed,0xf9,0xad,0x90, -0xfa,0x41,0x4c,0x5f,0x55,0xeb,0x5f,0xd2,0xee,0x3f,0xa4,0xf,0xe0,0xcc,0x21,0x17, -0x43,0xeb,0x2f,0xb3,0x7c,0x9e,0xfd,0xdb,0xab,0x5a,0xff,0x9c,0xf5,0xfe,0x57,0xc1, -0xcf,0xf,0xc6,0xf5,0xa5,0xde,0xff,0x8a,0xce,0xb9,0xfd,0xd8,0xb7,0x4a,0xb5,0xbf, -0x59,0x86,0xe7,0x1f,0xf7,0xb3,0x9b,0x81,0x8f,0x7b,0xfd,0x66,0xe4,0x4b,0xb1,0xff, -0x55,0xf0,0x67,0xd6,0xfa,0xd,0xfe,0xfb,0x7,0xa9,0xb9,0x8e,0xd7,0xfb,0xad,0x92, -0xae,0xbf,0x4a,0xee,0xd3,0xdf,0x5f,0xe6,0xf7,0x99,0xeb,0xc8,0x39,0xbe,0xe4,0xfb, -0x27,0x26,0xf2,0x11,0x10,0xe0,0xbb,0x15,0xe4,0xdb,0x58,0xac,0xef,0x57,0x1,0xbe, -0xa0,0xe3,0xbb,0x88,0xf5,0x1b,0xe,0x9f,0xf2,0x71,0xce,0x7d,0xbd,0x98,0xd7,0xc7, -0x82,0x7d,0x38,0xe0,0xfa,0xa0,0x4b,0xf4,0xad,0x7f,0x6f,0x2c,0xcb,0xfd,0xe2,0x96, -0xb6,0xfe,0x0,0x71,0x7d,0x64,0xa9,0xbe,0x9a,0x4,0xab,0xd5,0xdb,0xa8,0xaa,0xad, -0x7f,0x19,0x1c,0xe5,0xd0,0x7,0x2a,0x15,0xf1,0xf6,0x4,0x7,0xaf,0xcf,0xa1,0x57, -0x97,0xe8,0x23,0x18,0x54,0x20,0xbd,0x33,0xa1,0x20,0xde,0xf8,0x86,0x16,0xb4,0xbe, -0x49,0xf5,0xbd,0xe,0xc9,0xe4,0x32,0x35,0xe6,0x7,0x4b,0x39,0xf4,0x9,0x15,0x32, -0x21,0x39,0x6e,0xbf,0x4a,0xa5,0x35,0x21,0x58,0xc,0xf5,0x61,0xf9,0x2b,0x45,0x7a, -0xa9,0xfd,0xca,0xda,0x83,0x31,0xad,0x6f,0x6e,0xa6,0x7a,0x7e,0x35,0xa6,0x4f,0xbd, -0x7e,0x6b,0x13,0x5a,0x9d,0xe1,0xc3,0xa,0xa2,0x6b,0x0,0xee,0xec,0xc0,0xb5,0xba, -0xb6,0xb5,0xf0,0xa2,0x7c,0xb4,0x76,0x32,0x96,0xc7,0xb7,0xe9,0x96,0xbe,0xbf,0xe8, -0x61,0x88,0xf,0x6b,0xbe,0xde,0xe,0x68,0xd5,0x16,0xea,0x13,0x8c,0xa,0x96,0x91, -0xaf,0x60,0x4,0x1f,0xae,0xe1,0x5a,0xaa,0xfd,0xaf,0xe2,0xf9,0x44,0xeb,0x96,0x2f, -0x30,0x5f,0xe9,0xe7,0xdf,0xd3,0xaa,0xaf,0x5d,0x71,0xfa,0x92,0xae,0xbf,0x4a,0x91, -0xaf,0xf6,0x42,0xdb,0xef,0x12,0x80,0xdd,0x7,0x0,0x55,0x51,0x2d,0xd1,0xfe,0x57, -0x73,0xcb,0x2f,0xcc,0x57,0x55,0x7d,0x22,0x80,0x55,0x58,0x4b,0xb2,0xff,0x55,0x16, -0x3e,0x25,0xd4,0x57,0xd3,0x7d,0x3f,0xba,0xe,0x6a,0x49,0xf6,0xbf,0xca,0x22,0x5f, -0xf1,0x7c,0x97,0x54,0x18,0xd2,0xfb,0x97,0xba,0x36,0xb5,0x4,0x85,0x8a,0x58,0x4b, -0xb2,0xff,0x55,0x8a,0x7c,0xa5,0xa8,0xf9,0x6a,0x2b,0x28,0x5f,0xad,0x9d,0x92,0x1a, -0x94,0xff,0xa9,0xda,0x3f,0xaf,0xb5,0x5f,0xa9,0x8a,0x63,0x5a,0x59,0xdd,0x4c,0xb2, -0xff,0x55,0x8a,0x7c,0x75,0x4f,0x42,0xd5,0x6a,0x50,0xbe,0x5a,0x3b,0x56,0x6a,0xfd, -0xab,0xdf,0xf4,0x7f,0xab,0xa4,0xef,0x1f,0x8c,0x9f,0xaf,0xde,0x97,0x26,0x58,0x8, -0x1a,0x3f,0xd6,0xd4,0xe3,0xdb,0xfa,0xfc,0x63,0x9e,0xef,0x5e,0xb6,0xbe,0x75,0x73, -0x65,0xaf,0x2f,0x5f,0x29,0x93,0x9,0xfd,0x6e,0x98,0xaf,0x3e,0xea,0x51,0x72,0xc9, -0xe7,0x4b,0xf4,0xfe,0xc1,0xe0,0xf,0xdb,0xc6,0xdd,0x97,0xaf,0x14,0x35,0x5f,0x5d, -0xf,0xca,0x57,0xea,0xf5,0xf1,0x66,0x6b,0xd4,0xe3,0x1f,0x8a,0x6c,0xc7,0x37,0x1a, -0x90,0xaf,0x14,0x35,0x5f,0x5,0xce,0x6f,0x55,0x31,0xbd,0xd7,0xf3,0xfa,0xc6,0xd7, -0x93,0xad,0xbf,0x4a,0xe2,0x33,0xf2,0x55,0xa0,0xaf,0xa6,0x1e,0x5f,0xd5,0xa7,0x25, -0x2c,0x7b,0x78,0x86,0x7,0xc9,0xd7,0xf,0xc5,0xf4,0xa9,0xd7,0x6f,0x5d,0xcd,0x57, -0x81,0xbe,0xba,0xea,0x1b,0xa9,0x3e,0xb5,0x7,0xec,0x58,0xbf,0x9,0x86,0xb,0xf2, -0xe9,0xf9,0x4a,0x91,0xa8,0xde,0xff,0x9d,0xe0,0x80,0xeb,0x63,0x72,0x55,0xf3,0xe1, -0x47,0xec,0xf7,0x4e,0xe7,0xe2,0x2b,0xec,0xb4,0x67,0xe4,0x2b,0x7d,0xff,0x2b,0xf9, -0x7e,0xc9,0xdc,0x5f,0xb4,0x88,0xdc,0x23,0x1c,0xf4,0xf8,0x6e,0x67,0xea,0x23,0xf8, -0x21,0x10,0xc2,0xf3,0x95,0xbe,0xbf,0x40,0x95,0x3d,0x7f,0x24,0xa1,0xa1,0x3b,0x61, -0x79,0x7c,0xed,0x93,0x4c,0x7d,0x8a,0xf2,0x8e,0xb1,0x61,0x77,0x70,0xbe,0x32,0xf6, -0x97,0xea,0x9a,0xbe,0x11,0x3e,0x8,0x6f,0x3f,0x9a,0xad,0x8f,0xce,0xf2,0x29,0x86, -0x4f,0x2e,0x9b,0x3e,0xda,0xf0,0xf8,0x36,0x69,0xd9,0xf0,0xb5,0xb,0xda,0xfa,0xa6, -0xac,0x7d,0x1f,0xcc,0xf2,0xe9,0xfb,0x5f,0x55,0x30,0x70,0xfb,0xb4,0x19,0x85,0x82, -0xee,0x7b,0xc0,0x7c,0xc6,0xfe,0x57,0x52,0xa6,0xfd,0x9f,0x72,0x38,0xcb,0x87,0x8d, -0xfd,0xaf,0x28,0x30,0xd7,0x5f,0x51,0x63,0x93,0x98,0xa9,0xfe,0x7a,0x58,0x6d,0xb9, -0xce,0x9f,0xa,0xe,0xdf,0x9,0x38,0xc9,0xd6,0xa7,0xfc,0x2c,0xc8,0x47,0x8a,0x5b, -0xda,0xfe,0xa2,0xc8,0xd8,0x5f,0xca,0xf4,0x61,0x85,0x18,0xd7,0xef,0x54,0x13,0x69, -0x9,0xb,0x3e,0x2c,0x39,0x8e,0x6f,0xd6,0xe3,0x5b,0x98,0xf,0xe9,0xf7,0xbf,0x3, -0xc3,0xd7,0x65,0xbe,0xf3,0x55,0xdb,0xa7,0xff,0xdb,0xf6,0x26,0x6b,0xbf,0x83,0xec, -0x7d,0x4,0x3f,0xe6,0xf4,0x2f,0xc6,0x97,0x1c,0xf9,0xa,0xa0,0xa6,0x68,0xf8,0x8, -0x42,0x5e,0xdf,0x80,0xf9,0xae,0xcf,0x21,0x1f,0x70,0xfb,0x67,0xd3,0x47,0x8b,0x96, -0x4f,0xbe,0x6f,0x5e,0xbf,0xb4,0xe8,0xf3,0xc9,0xa6,0x6f,0x3a,0x97,0xfa,0xb,0xd, -0xba,0xff,0x20,0x97,0x69,0xd8,0xfa,0x2b,0x6a,0xbf,0x5a,0xc7,0x9c,0x17,0x3c,0x5d, -0xb0,0x8f,0xd0,0xe0,0xfd,0xf,0x78,0xed,0x7,0x17,0xed,0xc3,0xd1,0x7c,0x63,0xc7, -0xf5,0x9b,0x7d,0xfd,0x34,0xd8,0x17,0x92,0xaf,0x5c,0xbe,0x3d,0x47,0xff,0xb7,0x50, -0x9f,0x91,0xaf,0xf8,0xf3,0x83,0x53,0x6b,0xfa,0x77,0xbb,0xe8,0xf2,0x91,0x45,0xf9, -0xcc,0xf1,0x43,0x9f,0x1f,0x6c,0xcb,0xe6,0xf3,0xf1,0x1c,0xdf,0xdb,0x65,0xd3,0x37, -0xb9,0x9e,0xd1,0xfb,0x7,0x63,0xf9,0x88,0xbe,0xff,0x41,0x55,0x2c,0x7,0xd5,0x77, -0xff,0x94,0x8d,0xbf,0xd2,0x41,0x46,0xef,0x1f,0x4c,0xe0,0xab,0xf4,0xc5,0x20,0xdf, -0x6,0xf3,0xf5,0x87,0xcb,0x38,0xbe,0x8a,0xb1,0xff,0x95,0x12,0xe8,0xdb,0x5c,0xb2, -0x4f,0x99,0xe1,0x3,0xce,0x7c,0x9a,0xea,0xfd,0x83,0x89,0x7c,0xd8,0xd8,0xff,0xa, -0x8b,0xb3,0xe6,0x17,0x2c,0x5f,0x7d,0x41,0xfd,0x4b,0x71,0xb,0xb2,0xfa,0x15,0x80, -0x28,0xd8,0x87,0xdd,0xbe,0x8c,0xd7,0x1f,0x4,0xfb,0x50,0xb5,0xc3,0xea,0x57,0x0, -0xfe,0x6d,0x29,0xc8,0x67,0x15,0x30,0xe1,0x41,0xca,0xf7,0xf,0xc6,0xf4,0x4d,0xb0, -0xbd,0xbf,0x28,0x12,0x3,0xdb,0x8f,0x10,0x47,0x7d,0x23,0xf5,0xfa,0x97,0x38,0x3e, -0x6a,0xef,0x2f,0xea,0xed,0x9f,0x9d,0xeb,0x87,0x84,0x7f,0x6f,0xd7,0x87,0x16,0xe9, -0xbb,0x4c,0xbd,0xfb,0x8b,0xf2,0x7d,0xef,0x6d,0xb2,0x6,0xcc,0x60,0xfd,0x55,0xac, -0x7c,0x55,0x89,0xb4,0xfe,0x6a,0x6f,0xd3,0xfe,0xfd,0x45,0xb6,0x1f,0xc1,0x85,0x48, -0xeb,0xff,0xf6,0xa,0xcb,0xf1,0xd1,0x2a,0x8c,0xe4,0x7b,0xb0,0xe1,0xf2,0x2d,0xec, -0xfa,0xa5,0x7a,0xff,0x77,0x12,0xf0,0xfc,0x20,0xb2,0xde,0xaf,0xbb,0x7b,0xe8,0xf2, -0x2d,0xaa,0xff,0x73,0xe7,0x2b,0xf3,0xfe,0x48,0x2e,0x15,0x37,0xd,0xdf,0xd0,0xda, -0xdf,0x7b,0x8a,0x5d,0xbe,0x45,0x8d,0x1f,0xee,0x7c,0xd5,0x4,0xac,0x7e,0x55,0x33, -0x7c,0x7,0x81,0xfb,0x4b,0x6d,0x2c,0x23,0x5f,0xb1,0xfb,0xf3,0x11,0x36,0x7d,0x28, -0xd3,0xfd,0xaf,0x52,0xe4,0x17,0x63,0xff,0x2b,0x6a,0xd5,0x87,0xb0,0xe9,0xd3,0xf6, -0x67,0x90,0xaf,0xee,0x60,0xa,0x37,0x73,0xe0,0x23,0x56,0x7d,0x6d,0x9f,0xf9,0xe4, -0xf2,0x11,0x1e,0x3d,0x3c,0xa5,0x9d,0xda,0x32,0x7d,0x18,0x79,0xea,0x57,0xac,0xfd, -0xb4,0xe7,0x7,0xf1,0xe8,0x9d,0xe3,0xd6,0xa3,0xe5,0xf8,0x88,0x39,0x3f,0x8,0xdd, -0xf5,0x2b,0xcb,0xa7,0xed,0xcf,0xa0,0xfa,0x70,0x17,0xe2,0xe5,0xf8,0xcc,0xf9,0xc1, -0x5d,0x77,0xfd,0xca,0xba,0x3e,0xb4,0xfd,0x19,0xf0,0xe8,0x83,0xe5,0xf9,0x26,0x76, -0xfd,0x0,0x20,0xd6,0xbf,0x10,0xd6,0xbf,0xe8,0xcf,0x6f,0xc9,0x57,0x3f,0xc0,0x43, -0x88,0x96,0xe4,0xb3,0xeb,0x2f,0xce,0xfa,0xd5,0xa6,0xc3,0x87,0x95,0x9f,0xa9,0x3e, -0xc7,0x2b,0x17,0x17,0x5b,0xbf,0x9a,0xb9,0xbf,0xa8,0xe6,0xeb,0x42,0xb0,0x1c,0x5f, -0x58,0xfd,0xca,0x6a,0xbf,0xc7,0xaa,0x4f,0x5c,0x92,0xf,0x47,0xf0,0xed,0xe0,0x16, -0x5c,0xf5,0x7d,0xb7,0xa5,0xd7,0xaf,0xb2,0xdd,0xff,0x2a,0x55,0xfd,0x2a,0x60,0xff, -0x2b,0x9c,0xe9,0xf3,0xd3,0x29,0xf2,0xd5,0x90,0x9f,0xaf,0x4e,0x3b,0x59,0xee,0x7f, -0x95,0x22,0xbf,0x1c,0xf0,0xf3,0xd5,0xf1,0xa3,0x2c,0xf7,0xbf,0x4a,0xe1,0x43,0xfc, -0x7c,0x85,0x61,0x96,0xfb,0x5f,0xa5,0xc8,0x2f,0x88,0x9f,0xaf,0x2,0x7d,0xd,0x90, -0x13,0x5f,0x56,0xfb,0x5f,0x65,0x93,0xaf,0x44,0x96,0xaf,0x10,0xf3,0x65,0xb5,0xff, -0x55,0xca,0x7c,0x65,0xec,0x2f,0xa5,0xbf,0x2e,0x44,0xcf,0x57,0x30,0xac,0x7f,0xc9, -0x7e,0xfd,0xd5,0xcc,0x7c,0x65,0xf8,0xfa,0x94,0xe5,0x2b,0xc0,0x7c,0x59,0xed,0x7f, -0x95,0x49,0xbe,0x62,0xeb,0xf,0x48,0xc8,0xfb,0x93,0xe9,0x1c,0xd6,0x5f,0x45,0xcd, -0x57,0x77,0x4b,0x2c,0x5f,0xad,0x86,0xfb,0x32,0x5e,0x7f,0x15,0x9a,0xaf,0xe0,0x42, -0xf6,0xbf,0x4a,0x9e,0xaf,0xe0,0x82,0xf6,0xef,0x4c,0x9a,0xaf,0x40,0xae,0x7d,0x61, -0xeb,0xdb,0xf3,0x91,0xaf,0xa,0xa1,0xf5,0xab,0x9c,0xe4,0x2b,0x73,0x7e,0x50,0x60, -0xf9,0xa,0xb2,0xfa,0x15,0x6f,0xfc,0x58,0xbc,0x8f,0xe8,0xf3,0x1f,0x55,0xf6,0xfe, -0x41,0x89,0xed,0x7f,0x75,0xd0,0xe4,0x8d,0xbf,0xcb,0xf2,0x55,0x7a,0x2,0xcb,0x57, -0xe6,0xfe,0x57,0xa8,0xc9,0xcb,0x2f,0x8b,0xf7,0x19,0xfb,0x23,0x55,0xd8,0xf8,0x3b, -0x62,0xe3,0x6f,0xfe,0x7d,0xf9,0x38,0xbe,0xd8,0xd8,0xff,0xca,0xf4,0xa9,0xf9,0xca, -0xf2,0x2d,0xf9,0xfa,0x50,0xf3,0x15,0xb0,0xe7,0x7,0x7d,0xf9,0xa,0x35,0x97,0xdc, -0xbf,0xa8,0xf9,0x6a,0xdb,0x9e,0x1f,0x4,0xcc,0x87,0x99,0x6f,0x7f,0xd9,0xfd,0xf3, -0x4,0xdf,0x72,0xcc,0xf,0xa,0x2c,0x5f,0xcd,0x65,0xff,0xab,0x64,0xf9,0xa,0x38, -0xe6,0x7,0x5,0x96,0xaf,0x72,0xe3,0x63,0xcf,0xf,0xe6,0x37,0x5f,0x81,0x8b,0x7c, -0x95,0x2a,0x5f,0x81,0x9c,0xe7,0x2b,0xcd,0x87,0x63,0xbd,0x1f,0x67,0xf1,0xe3,0xc7, -0x69,0xc0,0xfc,0x20,0xcd,0x49,0xbe,0x3a,0xee,0xf1,0xeb,0x57,0x34,0x4f,0xe3,0x2f, -0xa7,0x7e,0x45,0x73,0x92,0x5f,0xf0,0x6f,0xa8,0x7b,0xfd,0x38,0xf3,0xbd,0x97,0x13, -0xdf,0xff,0xd,0xf0,0xfd,0x4d,0x4e,0x8e,0xaf,0xb9,0xfe,0xa,0xb0,0x7c,0xc5,0x7c, -0x78,0xf9,0xf9,0x6a,0xcb,0x3a,0xff,0x98,0xf,0x2b,0x96,0x2f,0x7,0xf9,0xaa,0xca, -0xfa,0x3f,0xce,0xfc,0x20,0xcd,0x41,0xbe,0xaa,0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa, -0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa,0xe6,0x3c,0x5f,0x55,0x73,0x9e,0xaf,0xaa,0x39, -0xcf,0x57,0x5f,0x84,0xf9,0xc1,0x40,0x5f,0x4e,0xf2,0x95,0xdb,0x27,0x5f,0xb1,0xea, -0xcf,0x39,0xc9,0x57,0x6e,0x1f,0x1e,0x21,0x9c,0xaf,0x7c,0xe5,0xf5,0x61,0x94,0xaf, -0x7c,0x15,0xe8,0xdb,0xcf,0xa9,0xf,0xe6,0xf9,0xf8,0xca,0x57,0x6d,0x5f,0x2e,0xaf, -0xf,0xc5,0xf6,0xe5,0xb1,0x7f,0xb1,0xe7,0x7,0x97,0x9e,0xaf,0x2,0x7c,0x21,0xef, -0x77,0xce,0x83,0x2f,0xec,0xfd,0xce,0x4b,0xf7,0xe5,0x2a,0x5f,0x71,0xdb,0x2f,0x47, -0xf9,0xe5,0xb,0xef,0xcb,0xc7,0xf5,0x1b,0x58,0xbf,0xda,0xc8,0x53,0xfd,0x6a,0x70, -0xb7,0xc4,0xf2,0x95,0xb9,0xbe,0x98,0xa2,0x9c,0xd4,0xaf,0x80,0x5e,0xdf,0x10,0x59, -0x7d,0x43,0x9b,0xd7,0xa,0x7e,0x3f,0xdd,0x12,0x8e,0xef,0xaf,0x74,0x9f,0xf6,0x94, -0xba,0x91,0xf,0x4,0xd3,0x7,0x73,0x52,0x1f,0xfa,0x38,0xe7,0x3e,0xa3,0xfe,0xc7, -0xe6,0x8f,0x46,0xf8,0x3b,0xcc,0x97,0xab,0xf9,0x41,0xd3,0xa7,0xe6,0xab,0xe7,0x4c, -0x1f,0x58,0xe6,0xf5,0xf1,0x3d,0x59,0xee,0x5f,0x2e,0x16,0xec,0xfa,0x95,0x3d,0xff, -0xc6,0xea,0x2f,0x60,0x89,0xfd,0xb,0x91,0x50,0xf5,0xf6,0x4,0x41,0xbb,0x7e,0x65, -0xaf,0xbf,0xb2,0x7c,0x4b,0xec,0x9f,0x9,0x70,0xef,0x2f,0xea,0x7c,0x7f,0x63,0x1e, -0xea,0x57,0xa,0xa8,0xd0,0x3b,0x13,0xcc,0x7d,0xff,0xe0,0x66,0x3e,0x7c,0x64,0x72, -0x19,0xe7,0x76,0x7e,0x50,0xf7,0xe5,0x78,0xfe,0x4d,0xf5,0x85,0xef,0x2f,0xba,0x6c, -0x9f,0x84,0x6a,0x13,0x6d,0x29,0x62,0x4e,0xf3,0x15,0x39,0x91,0xc7,0xb7,0x49,0x51, -0xf3,0xe1,0xc3,0x1c,0xd6,0xaf,0xb4,0x47,0x8e,0xcd,0xfd,0xaf,0x4e,0xa1,0x9e,0xaf, -0xd6,0xca,0x2c,0x5f,0x6d,0xe4,0xe1,0xfe,0x5c,0xb0,0xf6,0xbf,0x32,0xf3,0x55,0xcb, -0xca,0x57,0xa2,0xe9,0x13,0x73,0x32,0xfe,0xee,0x51,0xf7,0xfe,0x57,0x2c,0xbf,0xfc, -0x38,0x57,0xf9,0xc5,0xf6,0xb1,0xf7,0xbf,0xbd,0x95,0x13,0x9f,0xf1,0xfc,0xe5,0x6f, -0xcb,0xbe,0xf9,0xd5,0x5c,0xcd,0xf,0xfe,0x6,0xb0,0x7c,0x85,0xf3,0x70,0x7d,0x9c, -0x9f,0xc,0xd4,0x7c,0xe5,0x98,0x1f,0xb4,0xe7,0xdf,0x70,0x1e,0xea,0x57,0x13,0x9, -0xaa,0xf9,0x2a,0xbf,0xf3,0x83,0x13,0x50,0xb9,0xed,0xdc,0xff,0xa,0xb2,0xf9,0x41, -0x5,0x55,0xf3,0x50,0x3f,0x90,0x0,0x54,0xf3,0xd5,0x77,0xed,0x7c,0xc5,0xe6,0x7, -0xf3,0x91,0xaf,0x54,0xdf,0x40,0xcd,0x57,0xd7,0x73,0x3b,0x3f,0xa8,0xb6,0xdf,0x24, -0xcf,0xf3,0x6f,0x12,0xa8,0xe4,0xdb,0x27,0xa9,0xed,0x87,0xf2,0x3b,0x3f,0x38,0x39, -0x81,0x12,0x31,0xfa,0x3f,0x1c,0xe0,0xdb,0x5b,0x66,0xff,0x87,0xec,0x7c,0xa5,0xef, -0x2f,0x3a,0xb8,0x6f,0xd5,0xaf,0x50,0x1e,0xee,0xcf,0xb1,0x9d,0xaf,0x8c,0xfd,0x9b, -0xd8,0xf3,0x3d,0x23,0x63,0x7f,0xd1,0x1c,0xe5,0x2b,0xee,0xfe,0xa2,0xaa,0x6f,0x33, -0x27,0xf9,0xc5,0xf0,0xfd,0xda,0xca,0x2f,0xd,0x36,0xfe,0xe6,0xc4,0x67,0xec,0x2f, -0x6a,0xaf,0x5f,0x63,0x3e,0x9c,0x93,0xe3,0x6b,0xec,0x2f,0xa,0xac,0x7c,0xc5,0xc6, -0xdf,0x65,0xae,0xbf,0xfa,0x70,0xba,0xa6,0xa8,0xf9,0x6a,0x93,0xf5,0x2f,0x80,0xf9, -0xb0,0x72,0x8e,0x72,0x90,0xaf,0xaa,0xb5,0xc7,0xe7,0xd2,0x44,0xbf,0xff,0xc5,0xdc, -0xfd,0x45,0x97,0x9c,0xaf,0x2a,0x8d,0xdf,0x9e,0x4b,0xee,0x7c,0x25,0xb2,0x7c,0x85, -0x96,0x3f,0xbe,0x11,0xd8,0x20,0xe7,0x93,0x9,0x2e,0xf2,0xf2,0x55,0x4e,0x7c,0xe8, -0xce,0x65,0x9c,0xd7,0xf5,0x57,0x9a,0x6f,0x7c,0x27,0xc2,0xfe,0x7,0xcb,0xf3,0xf5, -0x51,0x9e,0x7d,0xa8,0xb6,0x3,0x3f,0xc8,0x71,0xbe,0xba,0x3b,0x5d,0x83,0xef,0x98, -0xf9,0x2a,0x68,0x7e,0x10,0x2d,0xb1,0xff,0x13,0x1c,0xf5,0x2b,0x63,0x7e,0xd0,0xdc, -0xbf,0x4e,0xcd,0x57,0xec,0xfe,0x68,0xb8,0xc4,0xf1,0x43,0xab,0x51,0xb1,0x7c,0x65, -0xd4,0x37,0x44,0x96,0xf,0xac,0xfa,0xfd,0x30,0x47,0xf5,0xd,0x6b,0x7f,0x51,0x47, -0xfd,0xe5,0x20,0x27,0xf9,0xc5,0xc8,0xa7,0x3d,0xcb,0x87,0x73,0xe6,0x53,0x3c,0x3e, -0x36,0x3f,0xdd,0xc8,0x55,0xfd,0xaa,0x2b,0x7a,0xeb,0x57,0x1b,0x4b,0xbc,0x3e,0xbe, -0x27,0x2b,0x5a,0xfd,0xa,0xda,0xf5,0xab,0x3,0xd1,0x5b,0xbf,0x5a,0x62,0xff,0x42, -0x24,0x74,0x4f,0xab,0x5f,0x75,0xec,0xfa,0x95,0xb9,0xbf,0xa8,0xa3,0x7e,0x85,0x96, -0xd7,0x3f,0x13,0x50,0x79,0x5f,0xf5,0x39,0xf6,0x17,0x85,0xa2,0x98,0xa3,0xf9,0x41, -0x5,0x54,0x14,0xad,0x7e,0x65,0xef,0x2f,0xca,0xfa,0xe7,0x7c,0xd4,0xaf,0x34,0xdf, -0x40,0xcd,0x57,0x8f,0x72,0x9a,0xaf,0x8c,0xf6,0x23,0xb8,0x92,0xd3,0xfc,0xa2,0x4d, -0xf,0x6a,0xbe,0x42,0x5e,0x7d,0x12,0xaa,0xab,0x3e,0x4,0x73,0x9a,0xaf,0xc8,0x89, -0xda,0xff,0x49,0xa4,0x8,0x73,0xfa,0xfc,0xa0,0xbe,0x23,0xb1,0x3b,0x5f,0xb1,0xe7, -0x7,0xaf,0xe4,0xe2,0xf9,0x41,0xc1,0x97,0xaf,0x58,0xfd,0xde,0xce,0x57,0x38,0x57, -0xf9,0xca,0xff,0xfc,0x20,0xce,0x49,0x7e,0x31,0xf6,0xef,0x4,0xc0,0x9b,0xaf,0x86, -0xb9,0xf2,0xf5,0xcb,0x5e,0x5f,0x5e,0x8e,0x2f,0xf2,0xd4,0xaf,0x50,0xe,0xea,0x57, -0xa4,0xf1,0xb7,0x57,0xd9,0xfc,0x20,0x74,0xd7,0xaf,0x72,0xb1,0xbe,0x5d,0x79,0xaf, -0x7f,0x26,0x99,0xf3,0x83,0xde,0xfd,0x45,0x41,0xe,0xea,0x57,0xca,0xfb,0xfd,0x27, -0x92,0x73,0xff,0x2b,0xc7,0xfc,0xa0,0xb8,0xfc,0xf1,0x8d,0xe2,0xf7,0xfb,0xca,0xc4, -0xe9,0x73,0xd4,0xaf,0x56,0xf3,0xe0,0xfb,0x40,0xf5,0x5d,0xc6,0x9d,0xbc,0xce,0xf, -0xe2,0xc6,0xcb,0xca,0x24,0xbf,0xf5,0xa1,0x2f,0x80,0xef,0xa1,0x92,0xe7,0xf9,0x41, -0xa5,0xd1,0x57,0xd8,0xfc,0x20,0xcc,0x5f,0xbe,0xa2,0x8a,0x23,0x5f,0x75,0x3c,0xf9, -0x2a,0xf,0xcf,0x47,0x11,0x47,0xbe,0x7a,0xe4,0xc9,0x57,0x9d,0x9c,0x8d,0xbf,0xd0, -0x93,0xaf,0x1e,0xe5,0x2c,0x5f,0x41,0x4f,0xbe,0x62,0xc7,0x17,0xe5,0xdd,0x97,0xa3, -0xe3,0xab,0xe6,0x2b,0xd1,0xfb,0xfc,0x20,0x5c,0x6e,0xbe,0xfa,0x9a,0x27,0x5f,0x9, -0xde,0x7c,0x5,0x96,0x9b,0xaf,0x10,0x5b,0x7f,0x65,0xf8,0xec,0xf5,0xed,0xcc,0xb7, -0xb1,0xdc,0x7c,0xa5,0xfa,0x9c,0xf9,0x8a,0xad,0x3f,0x50,0x72,0xb1,0xff,0x95,0x9a, -0xaf,0xd0,0x1d,0x57,0xbe,0xba,0x5b,0x62,0xf9,0x2a,0x17,0xbe,0xf,0xfa,0xda,0xfc, -0x20,0xcc,0x71,0xbe,0xd2,0xe6,0xdf,0x60,0x8e,0xf3,0x95,0xe6,0x3,0x39,0xce,0x57, -0xaa,0x2f,0xbf,0xeb,0xdb,0xd5,0x7c,0x25,0xab,0xf9,0xaa,0x10,0x56,0xbf,0x82,0x39, -0xc9,0x57,0xe6,0xfc,0xa0,0xe0,0xad,0x5f,0x75,0x72,0x92,0xaf,0x8c,0xf5,0xd9,0x6c, -0x7f,0x51,0xbb,0x7e,0xf5,0x28,0x57,0xfb,0x5f,0xd9,0xfb,0x8b,0x32,0x5f,0x5e,0x9f, -0xcf,0xfb,0xc2,0xf8,0x96,0x79,0x7c,0xdb,0xa5,0x17,0xd4,0xfc,0x2,0x78,0xcf,0xf, -0xd6,0x72,0x90,0xaf,0x68,0x4b,0xea,0x4b,0x13,0xb4,0x1d,0xf6,0xfc,0xe0,0x52,0xdf, -0xf,0xd1,0x92,0xc0,0x6d,0x63,0xff,0x4e,0x7c,0x14,0xe4,0x5b,0xe6,0xfa,0xd8,0xfa, -0x13,0xe0,0x7a,0x3e,0xf,0xb2,0xfd,0x45,0xf3,0xf1,0xfc,0x20,0xad,0x63,0x70,0xe7, -0xb2,0xf3,0xf9,0x41,0xb6,0xbf,0x68,0x4e,0xd6,0xb7,0x6b,0xed,0x47,0xf2,0xfb,0xfc, -0x20,0xad,0x4b,0x20,0xcf,0xf9,0x45,0xf5,0xf5,0x27,0x4,0xe5,0xd7,0xd7,0x2,0x2f, -0xa8,0xf9,0x25,0xbf,0xfb,0x8b,0x8a,0x56,0x7e,0x39,0x9,0xf4,0x2d,0xb3,0xff,0x3, -0x56,0x7e,0x91,0xa8,0xb3,0x7e,0xe5,0xf4,0xe5,0x63,0x7f,0x6,0xdd,0x67,0xd5,0xaf, -0x9c,0xbe,0x7c,0xe4,0x2b,0xd3,0xd7,0x5,0x81,0xef,0xbf,0x5c,0xae,0xef,0xf3,0x9c, -0xfb,0x7e,0x97,0x4b,0xdf,0xb7,0xc1,0xb,0x66,0x7d,0x48,0x9f,0x4b,0x6f,0xc3,0x7c, -0xf9,0x8,0xb8,0xdd,0x37,0xe7,0xdf,0x8c,0xf3,0x2f,0x7f,0x3e,0x2d,0x5f,0x55,0x59, -0xff,0x97,0x37,0x9f,0x2,0xde,0xd0,0xf2,0x55,0xd5,0x37,0x3f,0x98,0x17,0x5f,0x5b, -0xcf,0x57,0x55,0xdf,0xfc,0xa0,0xe5,0x73,0xbc,0x9f,0x78,0x19,0xbe,0x9e,0x9e,0xaf, -0xaa,0x91,0xde,0xef,0xbc,0xc,0x5f,0x5f,0x32,0x7c,0x51,0xde,0xef,0xbc,0x1c,0x5f, -0xdf,0x3f,0xff,0x76,0x12,0xf9,0xbb,0xcd,0xff,0xfa,0xbd,0xf5,0x82,0x39,0xff,0x96, -0xe8,0xb3,0xc0,0xfd,0xf,0x2,0x3e,0x9f,0x17,0x8b,0x4b,0xf4,0x39,0xf6,0x3f,0x8, -0xf8,0x8c,0x26,0x68,0x99,0x3e,0x7b,0xfc,0xfd,0xa2,0xfa,0x50,0xde,0x7d,0x5b,0xb9, -0xf6,0x7d,0x5e,0xcc,0x79,0xfb,0xd1,0x5c,0xfb,0xc8,0x88,0x5c,0xf8,0xd2,0x1c,0xdf, -0xab,0x74,0xc1,0xfd,0x33,0xbf,0x6,0x54,0xc8,0xcd,0xf8,0x96,0x73,0x5f,0xb6,0x9f, -0xb,0xdf,0x85,0x2f,0xe6,0x7,0xad,0x83,0x5f,0x17,0xb,0x8,0x9f,0x4c,0xae,0x95, -0xbe,0xa7,0x28,0x68,0xe7,0x5a,0x9,0xe4,0xc9,0x77,0x8c,0x3a,0x6f,0x11,0x7c,0x7c, -0x2a,0x3d,0x19,0xc1,0xdb,0x67,0x67,0xe8,0xf9,0x11,0xdc,0xce,0x9b,0x4f,0x51,0x8e, -0x8f,0xc1,0x68,0x24,0x81,0x27,0x4f,0xa4,0xd6,0x8,0xde,0xca,0x97,0xef,0xe0,0x45, -0x85,0x1e,0x63,0x0,0xa1,0xa4,0x1a,0xa1,0xa8,0x32,0xf3,0xe4,0xeb,0xa1,0x83,0x7f, -0xf3,0x34,0xed,0xe1,0x5f,0xc2,0x92,0xf4,0x4b,0xcd,0x27,0x5d,0xcb,0x99,0xef,0xb7, -0x5d,0xe5,0xb0,0x87,0x3f,0x1,0xb0,0xf7,0x49,0xaf,0x7,0xc4,0xde,0x28,0x57,0xbe, -0x75,0xcd,0xa7,0xac,0xe3,0x3e,0x80,0xad,0x7e,0xab,0x5,0xc4,0xd6,0x71,0xae,0x7c, -0x3b,0xba,0x6f,0x7,0xf7,0x7b,0xb0,0xde,0x5f,0x5f,0x7,0x62,0xfd,0xb3,0x62,0x9e, -0x7c,0x42,0xb5,0xd7,0x25,0x58,0xa8,0xf5,0x5b,0x12,0xee,0x2b,0x8a,0xb8,0xa3,0x40, -0x90,0x33,0x9f,0xda,0x3f,0xb,0xb5,0xc3,0x9d,0x2b,0x5f,0x3e,0x54,0x7d,0x8f,0x2f, -0xe7,0xab,0x7f,0xbe,0x18,0x7f,0x2f,0x7c,0x17,0xbe,0xb,0xdf,0x85,0xef,0xc2,0x77, -0xe1,0xbb,0xf0,0x5d,0xf8,0x2e,0x7c,0x5f,0x28,0x1f,0x21,0x14,0x62,0xfd,0xc9,0x79, -0xee,0x7,0xd2,0xc3,0xe5,0xfa,0xa6,0xf7,0xe9,0xd6,0x29,0x11,0xa8,0xfe,0x7c,0x99, -0x59,0xe,0x3e,0x33,0xbe,0xd4,0xd1,0xff,0xbf,0xbd,0x64,0xdf,0x33,0xa4,0x78,0x34, -0xd,0xf4,0x6d,0xd1,0xff,0x2a,0x2c,0xd7,0xf7,0xd5,0x69,0x79,0xcf,0xe5,0x1b,0x3a, -0x7d,0x45,0x7a,0x6d,0xc9,0xbe,0x75,0x99,0x6e,0xc8,0x2,0x6d,0xb,0x9d,0xdd,0xe9, -0xb5,0xfa,0x58,0xa0,0x7b,0x54,0x2e,0xe,0x48,0xf1,0x4c,0x2e,0x52,0x48,0x8a,0xf4, -0xc6,0x92,0x7d,0x7f,0x7d,0x42,0xff,0xf9,0xef,0x54,0xdf,0x8d,0xcd,0x75,0xf9,0xf2, -0xf7,0x6,0xcf,0x9e,0x3e,0xa0,0x72,0xa1,0x7d,0xbf,0xf0,0xad,0x71,0x91,0xe,0xdf, -0xfe,0x2e,0x7d,0x66,0xc9,0xbe,0xe9,0xe0,0xe6,0xea,0xa0,0x4c,0x3b,0x57,0x4a,0x6f, -0xb,0x1f,0xbd,0xb0,0xff,0xec,0xa9,0x7a,0x7c,0x8f,0x3e,0x29,0x1f,0xad,0x1e,0x75, -0xe8,0x70,0xbb,0x43,0xbf,0xb5,0x6c,0x5f,0xfb,0x2b,0x97,0xda,0x25,0xda,0x79,0xbb, -0xbc,0x72,0xff,0xa9,0xc2,0x96,0xee,0x3b,0xdd,0xba,0xb9,0x5a,0xdc,0xef,0xd0,0x23, -0xd5,0xf7,0x2f,0x96,0xed,0xeb,0x18,0xfd,0xcb,0xdb,0xc2,0xca,0xdd,0xa7,0x4a,0xdb, -0x86,0x6f,0xfb,0xc6,0x6a,0xa9,0xd3,0xa1,0xa7,0xe5,0xe,0x7d,0x6a,0xe9,0xbe,0x8e, -0xe1,0xa3,0xe5,0x93,0x7f,0x28,0x5a,0x3e,0x95,0xd6,0xa1,0x67,0xe5,0xce,0xf0,0xf2, -0xb2,0x7d,0xfb,0xcc,0x57,0x3a,0xfa,0x87,0xef,0x6c,0x3d,0x73,0x7a,0xa4,0x1d,0xdf, -0x67,0x4e,0xcb,0xea,0xf1,0x95,0x85,0xce,0xde,0xb5,0xa5,0x5f,0x1f,0x45,0xcd,0xd7, -0xbe,0x42,0x37,0xc6,0x4f,0xfd,0xdb,0xf6,0x8d,0xd5,0x13,0x2a,0xaf,0xaa,0xff,0x28, -0xf,0x8a,0x74,0xba,0xb6,0xba,0xb7,0xbe,0x6c,0xdf,0xb8,0xa4,0xfb,0x6e,0xd0,0x7, -0xf2,0x53,0xf7,0xd4,0x8b,0xf9,0x4c,0xef,0x5f,0x56,0xcb,0x6a,0xff,0x32,0xbd,0x7f, -0x69,0x6f,0xc9,0xe3,0x9b,0xe3,0x3,0xb4,0xff,0x31,0x5a,0xb,0x12,0x23,0x3c,0x5c, -0xe4,0xab,0xb,0xdf,0x85,0xef,0xc2,0x77,0xe1,0xcb,0x9b,0xaf,0x9c,0x17,0xdf,0x86, -0x5c,0x56,0x73,0xc0,0x26,0xa5,0x85,0xb1,0x0,0xd4,0x31,0x64,0xcf,0xe9,0x23,0xca, -0xd2,0xef,0x7f,0x57,0x6,0xc5,0xb3,0xc1,0xb5,0x4b,0xf4,0xa1,0x9a,0x52,0xb7,0xa7, -0x25,0xfa,0x60,0xdb,0xe1,0x9b,0xde,0x5b,0xb6,0x6f,0xfa,0xcc,0xde,0xd6,0xd9,0xde, -0x95,0x7f,0x45,0xdf,0xfe,0xde,0xe6,0xb5,0x92,0x5c,0x52,0x33,0xbd,0xf3,0xab,0x7f, -0xb0,0xf4,0xf6,0x9b,0xc2,0xce,0x69,0xe7,0xda,0x19,0x2d,0x9f,0x6d,0x5f,0x29,0x9d, -0xa8,0xb7,0x97,0xeb,0x74,0x7b,0x4f,0x2e,0xad,0x3d,0x27,0xdf,0x24,0x74,0x7a,0x69, -0xe9,0xe7,0xdf,0x94,0x76,0x8e,0x3e,0x29,0x9d,0x91,0xf2,0xd9,0xc3,0x2b,0xdb,0x47, -0x9a,0xef,0x5e,0xf1,0xc1,0xf8,0xf2,0x8d,0x3f,0x18,0x5f,0xbb,0x4f,0xa7,0xbb,0x4b, -0xf7,0xc9,0xa4,0xb8,0xff,0x49,0x69,0x77,0x2a,0x9c,0xbc,0x5d,0xda,0x6e,0xb,0x74, -0xf8,0xf0,0x99,0xb2,0x7c,0xda,0xb9,0xb1,0x7e,0xf4,0x27,0xaa,0xef,0x6c,0xe9,0xbe, -0x93,0x69,0xa9,0xf3,0x8b,0xed,0x8d,0x29,0x3d,0xfa,0xef,0xdb,0xdb,0xeb,0x65,0xf5, -0xfc,0x7b,0x46,0x98,0x1e,0x75,0x6e,0xfc,0xf5,0xfe,0x27,0xcf,0xe6,0xc1,0x77,0x44, -0xb7,0xb6,0xfe,0xd7,0xf6,0x89,0x4c,0xf7,0xff,0x6c,0x7b,0x7b,0x5b,0xbb,0x3e,0x9e, -0xa1,0xed,0x61,0xe7,0xc6,0x2f,0x3a,0x9d,0x5c,0xf8,0xb6,0x68,0xa7,0xb4,0xbb,0x7d, -0x76,0x42,0xb7,0x36,0x54,0xdf,0xb6,0xee,0x5b,0x37,0x7c,0xff,0x2d,0xf,0xbe,0x12, -0xec,0x94,0xf7,0x1e,0x9e,0x9d,0xd2,0xd2,0xa6,0xe9,0x7b,0x96,0x5e,0x31,0x7c,0x1b, -0xaa,0x6f,0xb8,0xec,0xfe,0xe5,0xd2,0xe0,0xb2,0xd0,0xbe,0x76,0x69,0x48,0x56,0xd7, -0xaf,0xac,0xae,0x97,0xe8,0xde,0xfa,0xb3,0x5a,0x9f,0x7d,0xe5,0x17,0xed,0xe2,0xbe, -0xea,0xdb,0x5b,0x76,0xff,0xbc,0xa2,0xfa,0xd4,0xf1,0x63,0x38,0xbd,0xd4,0xfe,0x9a, -0x56,0xe8,0x78,0xb0,0xfe,0x2c,0x5d,0x19,0x5f,0xfe,0xca,0x2f,0x6,0xb9,0xf0,0x51, -0x8a,0x45,0x8a,0x5,0xed,0xf5,0x2e,0x48,0xd0,0xfe,0x4f,0xbb,0x69,0x3,0x5a,0xed, -0xf,0x8b,0x30,0xbf,0xf9,0xa5,0x93,0xef,0x7c,0x45,0x8a,0xf9,0xf6,0xa9,0x39,0xe6, -0x22,0x3f,0xff,0xa3,0xf3,0xfd,0x7f,0x6e,0x69,0x1,0x55,0x8,0x9e,0xa1,0x2b,0x0, -0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//m1284p.png: 12987 bytes diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/clean.bat b/11_m644p_WIZNET_HTTPServer_FLASH_pages/clean.bat deleted file mode 100644 index 9977613..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/clean.bat +++ /dev/null @@ -1,3 +0,0 @@ -del *.b#* -del *.s#* -pause diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/globals.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/globals.h deleted file mode 100644 index 0d3650c..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/globals.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -#define HTTPD_MAX_BUF_SIZE 512 //For Mega644p(4kb RAM)/Mega128(4kb RAM) - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Internet/httpServer_avr/httpServer.h" -#include "webpage.h" - -#define _MAIN_DEBUG_ - -//#include "Application/loopback/loopback.h" -//#include "Application/webserver_simple/webserver_simple.h" - -//#include // itoa etc.. -/* - * (11) Try move all pages saved at from RAM to FLASH address space - * Example of flash data access look at: - * <01_m1284p_bb00_minimum_PSTR_webpage_test> - * <09_m1284p_WIZNET_simple_webserver> - * - * Success initial porting on 10/12/2018 - FREE RAM on webserver: 7936 bytes (From total 16kbytes)! - * NEED further optimization to AVR_RAM->AVR_FLASH point (damn Harvard architecture :( )! - * - * It works on AtMega1284p(16kbytes RAM), but need TODO finish (DONE on v2.3b 12/12/2018)!! - * - * TODO DONE: - * After v2.3 optimization: - * (+4kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 2048 see )) : FREE RAM on webserver: 10372 bytes - much better! (RAM enough for AtMega1284/AtMega2560 ie. AVR with 8-16Kb RAM) - * (+1kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 512 see )) : FREE RAM on webserver: 13444 bytes - awesome! (RAM enough for AtMega644/AtMega128 ie. AVR with 4Kb RAM) - * - * OK 1) Father optimization / (v2.3 12/12/2018) - * OK 2) Father optimization / (v2.3 12/12/2018) - * OK 3) Rename httpServer.*->httpServer_avr.*, httpParser.*->httpParser_avr.*, httpUtil.*->httpUtil_avr.* (v2.3b 12/12/2018) - * Actually made another way: rename parent folder to - * OK 4) Fix not correct showed value on (v2.2 12/12/2018) - * OK 5) Correct indentation in all <*.html> and <*.js> sources and repack it again in . (v2.2 12/12/2018) - * OK 6) Add to webserver (v2.1 12/12/2018) + also added binary files support in webserver via: , bin2hex_v2.py - * 7) Publish sources in my github, wiznetmuseim, avrfreaks etc.. (optional) - * - * (10) Try repeat example HTTPServer_LPC11E36_LPCXpresso on AVR Mega1284p (All pages still in RAM) - * Here used to WEB-server handle cgi-like requests, with AJAX + JSON - * Description here: - * http://wiznetmuseum.com/portfolio-items/w5500-evb-web-server/ - * - * To better undestand AJAX look here (actually here used AJAX + XHTML): - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-automatically-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/AJAX-read-switches-analog/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-XML-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-gauge/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-IO/ - * - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * For prepare binary data (some image data, like favicon.ico) use script. - * Example usage: - * >bin2hex_v2.py favicon.ico - * >out favicon_ico.h - * After that insert into end content from favicon.ico; - * Then use this resource in www server like (look in ): - * reg_httpServer_binContent_avr(PSTR("favicon.ico"),favicon_ico, (uint32_t)sizeof(favicon_ico)); // favicon.ico : webserver icon - * - * - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example (bin2hex_v2.py BETTER SUIT for AVR!!): - * https://tomeko.net/online_tools/file_to_hex.php?lang=en - * - * (9) Simple webserver, based on code from: - * http://www.ermicro.com/blog/?p=1773 - * Article: Integrating Wiznet W5100, WIZ811MJ network module with Atmel AVR Microcontroller - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~10..12.2018 - */ - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega644p v2.3d Static IP HTTP_server FLASH Pages WIZNET_5500 ETHERNET 12/12/2018\r\n"; // Program name - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - if(1) - { - /* Web content registration (web content in webpage.h, Example web pages) */ - - // Index page and netinfo / base64 image demo - reg_httpServer_webContent_avr(PSTR("index.html"), PSTR(index_page)); // index.html : Main page example - - //favicon.ico - reg_httpServer_binContent_avr(PSTR("favicon.ico"),favicon_ico, (uint32_t)sizeof(favicon_ico)); // favicon.ico : webserver icon - - //brd_wiznet.png - reg_httpServer_binContent_avr(PSTR("brd_wiznet.png"),brd_wiznet_png, (uint32_t)sizeof(brd_wiznet_png)); // brd_wiznet.png : webserver image - - /* - //m1284p.png - reg_httpServer_binContent_avr(PSTR("m1284p.png"),m1284p_png, (uint32_t)sizeof(m1284p_png)); // m1284p.png : webserver image - */ - - reg_httpServer_webContent_avr(PSTR("netinfo.html"), PSTR(netinfo_page)); // netinfo.html : Network information example page - reg_httpServer_webContent_avr(PSTR("netinfo.js"), PSTR(wiz550web_netinfo_js)); // netinfo.js : JavaScript for Read Network configuration (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"netinfo.html", (uint8_t *)netinfo_page); // netinfo.html : Network information example page - //reg_httpServer_webContent((uint8_t *)"netinfo.js", (uint8_t *)wiz550web_netinfo_js); // netinfo.js : JavaScript for Read Network configuration (+ ajax.js) - - // AJAX JavaScript functions - reg_httpServer_webContent_avr(PSTR("ajax.js"), PSTR(wiz550web_ajax_js)); // ajax.js : JavaScript for AJAX request transfer - //reg_httpServer_webContent((uint8_t *)"ajax.js", (uint8_t *)wiz550web_ajax_js); // ajax.js : JavaScript for AJAX request transfer - - //Device info page && related ajax script - reg_httpServer_webContent_avr(PSTR("info.html"), PSTR(info_page)); //info.html - reg_httpServer_webContent_avr(PSTR("info.js"), PSTR(wiz550web_info_js)); // info.js : JavaScript for Device information (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"info.html", (uint8_t *)info_page); //info.html - //reg_httpServer_webContent((uint8_t *)"info.js", (uint8_t *)wiz550web_info_js); // info.js : JavaScript for Device information (+ ajax.js) - - reg_httpServer_webContent_avr(PSTR("img.html"), PSTR(img_page)); // img.html : Base64 Image data example page - //reg_httpServer_webContent((uint8_t *)"img.html", (uint8_t *)img_page); // img.html : Base64 Image data example page - - // Example #1 - reg_httpServer_webContent_avr(PSTR("dio.html"), PSTR(dio_page)); // dio.html : Digital I/O control example page - reg_httpServer_webContent_avr(PSTR("dio.js"), PSTR(wiz550web_dio_js)); // dio.js : JavaScript for digital I/O control (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"dio.html", (uint8_t *)dio_page); // dio.html : Digital I/O control example page - //reg_httpServer_webContent((uint8_t *)"dio.js", (uint8_t *)wiz550web_dio_js); // dio.js : JavaScript for digital I/O control (+ ajax.js) - - // Example #2 - reg_httpServer_webContent_avr(PSTR("ain.html"), PSTR(ain_page)); // ain.html : Analog input monitor example page - reg_httpServer_webContent_avr(PSTR("ain.js"), PSTR(wiz550web_ain_js)); // ain.js : JavaScript for Analog input monitor (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"ain.html", (uint8_t *)ain_page); // ain.html : Analog input monitor example page - //reg_httpServer_webContent((uint8_t *)"ain.js", (uint8_t *)wiz550web_ain_js); // ain.js : JavaScript for Analog input monitor (+ ajax.js) - - // Example #3 - reg_httpServer_webContent_avr(PSTR("ain_gauge.html"), PSTR(ain_gauge_page)); // ain_gauge.html : Analog input monitor example page; using Google Gauge chart - reg_httpServer_webContent_avr(PSTR("ain_gauge.js"), PSTR(ain_gauge_js)); // ain_gauge.js : JavaScript for Google Gauge chart (+ ajax.js) - //reg_httpServer_webContent((uint8_t *)"ain_gauge.html", (uint8_t *)ain_gauge_page); // ain_gauge.html : Analog input monitor example page; using Google Gauge chart - //reg_httpServer_webContent((uint8_t *)"ain_gauge.js", (uint8_t *)ain_gauge_js); // ain_gauge.js : JavaScript for Google Gauge chart (+ ajax.js) - -#ifdef _MAIN_DEBUG_ - //display_reg_webContent_list(); - display_reg_webContent_list_avr(); -#endif - } -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - //uint32_t timer_link_1sec = millis(); - uint32_t timer_httpd_1sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } - } - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - } // End of user's code - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - //loopback_tcps(0,ethBuf0,5000); - //loopback_udps(1, ethBuf1, 3000); - - //Use WEBbrowser to connect to webserver: http://192.168.0.199/index.html - //websrv_simple(2, ethBuf2_WEBSRV, 80); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //Not used here, because led1 handle via websrv - /* - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - */ - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/userHandler.c b/11_m644p_WIZNET_HTTPServer_FLASH_pages/userHandler.c deleted file mode 100644 index 6d0e5d1..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/userHandler.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file userHandler.c - * @brief User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -//#include "board.h" -#include "httpUtil.h" -#include "userHandler.h" -//#include "adcHandler.h" -#include "wizchip_conf.h" -#include "globals.h" - -/* Unavailable Pins (W5500-EVB component preempted) */ -// >> UART Rx/Tx : D0 (Rx), D1 (Tx) -// >> W5500 SPI(SPI0) : D11 (MOSI), D12 (MISO), D13 (SCK) - -/* On-board Devices */ -// >> Input : D14 (SW1) / D15 (SW2) -// >> Input : AIN (Potentiometer / TEMP.Sensor) -// >> Output : D8 (LED R) / D9 (LED G) / D10 (LED B) - -/* NXP LPC11Exx GPIO functions */ -// GPIO: Pin state -//Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); - -// GPIO: Pin direction -//Chip_GPIO_GetPinDIR((LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); - -// Pre-defined Get CGI functions -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_netinfo(uint8_t * buf, uint16_t * len); -void make_json_led1(uint8_t * buf, uint16_t * len); -void make_info(uint8_t * buf, uint16_t * len); - -// Pre-defined Set CGI functions -int8_t set_diodir(uint8_t * uri); -int8_t set_diostate(uint8_t * uri); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len) -{ - //return 0; //Just a stub, not used yet.. - //uint8_t ret = 1; // ret = 1 means 'uri_name' matched - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched - uint8_t cgibuf[14] = {0, }; - int8_t cgi_dio = -1; - int8_t cgi_ain = -1; - - uint8_t i; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { -// // to do -// ;//make_json_todo(buf, len); - } - else if(strcmp_P((const char *)uri_name,PSTR("get_netinfo.cgi")) == 0) - { - make_json_netinfo(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_led1.cgi")) == 0) - { - make_json_led1(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_info.cgi")) == 0) - { - make_info(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else - { -// // get_dio0.cgi ~ get_dio15.cgi -// for(i = 0; i < DIOn; i++) -// { -// memset(cgibuf, 0x00, 14); -// sprintf((char *)cgibuf, "get_dio%d.cgi", i); -// if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) -// { -// make_json_dio(buf, len, i); -// cgi_dio = i; -// break; -// } -// } -// -// if(cgi_dio < 0) - //Analog Ins reading get_ain0.cgi ~ get_ain7.cgi - if(1) - { - // get_ain0.cgi ~ get_ain5.cgi (A0 - A5), get_ain6.cgi for on-board potentiometer / Temp.Sensor - LPC11Exx - //for(i = 0; i < AINn; i++) //for LPC11xx - for(i = 0; i < 8; i++) //for AVR Mega1284p, available AIN0..AIN7 - { - memset(cgibuf, 0x00, 14); - sprintf((char *)cgibuf, "get_ain%d.cgi", i); - if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) - { - make_json_ain(buf, len, i); - cgi_ain = i; - ret = 1; - break; - } - } - } - -// if((cgi_dio < 0) && (cgi_ain < 0)) ret = 0; - } - - return ret; -} - - -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len) -{ -// return 0; //Just a stub, not used yet.. - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched -// uint8_t ret = 1; // ret = '1' means 'uri_name' matched - uint8_t val = 0; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { - // to do - ;//val = todo(uri); - //*len = sprintf((char *)buf, "%d", val); - } -// // Digital I/O; dio_s, dio_d -// else if(strcmp_P((const char *)uri_name,PSTR("set_diodir.cgi")) == 0) -// { -// //val = set_diodir(uri); -// //printf_P(PSTR("+++set_diodir.cgi uri_name: %s; uri: %s;\r\n")); -// *len = sprintf_P((char *)buf, PSTR("%d"), val); -// ret = 1; -// } - else if(strcmp((const char *)uri_name, "set_diostate.cgi") == 0) - { - //When uri_name=set_diostate.cgi, and uri HTTP POST request which contains something like: - //pin=8&val=1; or pin=8&val=1; (look && ) - - /* - This is LPC11xx handler - val = set_diostate(uri); - len = sprintf((char *)buf, "%d", val); - len ret = 1; - */ - - - //!!Just for debug - PRINTF("\r\n+++set_diostate.cgi uri_name: %s\r\nuri: %s\r\n", uri_name, uri); - - //Parse URI (Very dirty!!) - if(strstr_P(uri,PSTR("pin=LED1&val=0"))) - { - led1_low(); - *len = sprintf_P((char *)buf, PSTR("LED1: OFF")); - ret = 1; - } - else if(strstr_P(uri,PSTR("pin=LED1&val=1"))) - { - led1_high(); - *len = sprintf_P((char *)buf, PSTR("LED1: ON")); - ret = 1; - } - else - { - //*len = sprintf_P((char *)buf, PSTR("%d"), -1); - *len = sprintf_P((char *)buf, PSTR("???")); - ret = 1; - } - } -// else -// { -// ret = 0; -// } -// - return ret; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Get CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin) -//{ -// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// -// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\ -// \"dio_s\":\"%d\",\ -// \"dio_d\":\"%d\"\ -// });", -// pin, // Digital io pin number -// pin_state, // Digital io status -// pin_dir // Digital io directions -// ); -//} -// -void make_json_led1(uint8_t * buf, uint16_t * len) -{ - if(led1_read()) - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: ON\"});")); //Send back LED1 state via call-back function - } - else - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: OFF\"});")); //Send back LED1 state via call-back function - } - -} - -void make_info(uint8_t * buf, uint16_t * len) -{ - /* - * Send program metrics: - * Program name - * time-date compile - * MCU info - * free ram info - * uptime device - */ - *len = sprintf_P((char *)buf,PSTR(\ - "
%S"\
-			"Compiled at: %S %S\r\n"\
-			"MCU is: %S; CLK is: %luHz\r\n"\
-			"Free RAM: %dbytes\r\n"\
-			"Uptime: %lusec\r\n
"),\ - str_prog_name,\ - compile_time, compile_date,\ - str_mcu, F_CPU,\ - freeRam(),\ - millis()/1000); -} - -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin) -{ - *len = sprintf_P((char *)buf,PSTR( "AinCallback({\"ain_p\":\"%d\",\ - \"ain_v\":\"%d\"\ - });"), - pin, // ADC input pin number - //get_ADC_val(pin) // ADC input value for LPC11xx - adc_read(pin) // ADC input value for AVR - ); -} - -void make_json_netinfo(uint8_t * buf, uint16_t * len) -{ - wiz_NetInfo netinfo; - ctlnetwork(CN_GET_NETINFO, (void*) &netinfo); - - // DHCP: 1 - Static, 2 - DHCP - *len = sprintf_P((char *)buf,PSTR( "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\ - \"ip\":\"%d.%d.%d.%d\",\ - \"gw\":\"%d.%d.%d.%d\",\ - \"sn\":\"%d.%d.%d.%d\",\ - \"dns\":\"%d.%d.%d.%d\",\ - \"dhcp\":\"%d\"\ - });"), - netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5], - netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3], - netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3], - netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3], - netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3], - netinfo.dhcp - ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Set CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//int8_t set_diodir(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // Direction; NotUsed/Input/Output -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > Output) val = Output; -// } -// } -// -// if(val == Input) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input -// else Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -// -// return pin; -//} -// -//int8_t set_diostate(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // State; high(on)/low(off) -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > On) val = On; -// } -// -// if(val == On) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High -// else Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -// } -// -// return pin; -//} diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/userHandler.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/userHandler.h deleted file mode 100644 index 1f9af30..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/userHandler.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file userHandler.h - * @brief Header File for User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __USERHANDLER_H -#define __USERHANDLER_H - -#include -//#define _WEB_DEBUG_ - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Public Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined CGI Interface Functions Handler -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP GET Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP POST Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - - -#endif - diff --git a/11_m644p_WIZNET_HTTPServer_FLASH_pages/webpage.h b/11_m644p_WIZNET_HTTPServer_FLASH_pages/webpage.h deleted file mode 100644 index e82d7af..0000000 --- a/11_m644p_WIZNET_HTTPServer_FLASH_pages/webpage.h +++ /dev/null @@ -1,2408 +0,0 @@ -#ifndef _WEBPAGE_H_ -#define _WEBPAGE_H_ -/* - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example: - * https://tomeko.net/online_tools/file_to_hex.php?lang=en -*/ - -/************************************************************************************* - * JavaScript Functions - *************************************************************************************/ -//main AJAX code -#define wiz550web_ajax_js \ -"function AJAX(a, e)\n"\ -"{\n"\ -" var c = d();\n"\ -" c.onreadystatechange = b;\n"\ -" function d()\n"\ -" {\n"\ -" if(window.XMLHttpRequest)\n"\ -" {\n"\ -" return new XMLHttpRequest()\n"\ -" }\n"\ -" else\n"\ -" {\n"\ -" if(window.ActiveXObject)\n"\ -" {\n"\ -" return new ActiveXObject(\"Microsoft.XMLHTTP\")\n"\ -" }\n"\ -" }\n"\ -" }\n"\ -" function b()\n"\ -" {\n"\ -" if(c.readyState==4)\n"\ -" {\n"\ -" if(c.status==200)\n"\ -" {\n"\ -" if(e)\n"\ -" {\n"\ -" e(c.responseText)\n"\ -" }\n"\ -" }\n"\ -" }\n"\ -" }\n"\ -" this.doGet = function()\n"\ -" {\n"\ -" c.open(\"GET\", a, true); c.send(null)\n"\ -" };\n"\ -" this.doPost = function(f)\n"\ -" {\n"\ -" c.open(\"POST\", a, true);\n"\ -" c.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\n"\ -" c.setRequestHeader(\"ISAJAX\", \"yes\");\n"\ -" c.send(f)\n"\ -" }\n"\ -"}\n"\ -"function $(a)\n"\ -"{\n"\ -" return document.getElementById(a)\n"\ -"}\n"\ -"function $$(a)\n"\ -"{\n"\ -" return document.getElementsByName(a)\n"\ -"}\n"\ -"function $$_ie(a, c)\n"\ -"{\n"\ -" if(!a)\n"\ -" {\n"\ -" a = \"*\"\n"\ -" }\n"\ -" var b = document.getElementsByTagName(a);\n"\ -" var e = []; for(var d = 0; d\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server\n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Web Server Demopage\n"\ -"

\n"\ -" Network Information
\n"\ -" Base64 Image Data
\n"\ -"
\n"\ -" Board Schematic
\n"\ -" Mounting Scheme
\n"\ -"
\n"\ -" Ex1> Digital I/O
\n"\ -" Ex2> Analog Input
\n"\ -" Ex3> Analog Input: Google Gauge Chart
\n"\ -"
\n"\ -" Device Information
\n"\ -"\n"\ -"\n"\ -"" -#define wiz550web_info_js \ -"function getInfo()\n"\ -"{\n"\ -" var oUpdate;\n"\ -" setTimeout(function()\n"\ -" {\n"\ -" oUpdate = new AJAX('get_info.cgi', function(t)\n"\ -" {\n"\ -" try\n"\ -" {\n"\ -" //*eval(t);\n"\ -" document.getElementById('info_txt').innerHTML = t;\n"\ -" }\n"\ -" catch(e)\n"\ -" {\n"\ -" alert(e);\n"\ -" }\n"\ -" }\n"\ -" ); oUpdate.doGet();\n"\ -" }\n"\ -" , 300); setTimeout('getInfo()', 3000);\n"\ -"}\n"\ -"" - - -#define netinfo_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Network Info\n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Web Server Network Information\n"\ -"

\n"\ -"\n"\ -"
    \n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"\n"\ -"
  • \n"\ -"
\n"\ -"\n"\ -"\n"\ -"" - - -#define dio_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Digital I/O v1.1\n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -" \n"\ -"\n"\ -"

LED1: unknown..

\n"\ -"\n"\ -"
\n"\ -" \n"\ -"
\n"\ -"
\n"\ -"\n"\ -"\n"\ -"\n"\ -"" - -#define ain_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Analog Input\n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" \n"\ -" \n"\ -"
\n"\ -"\n"\ -"
\n"\ -" \n"\ -"
\n"\ -"
\n"\ -"\n"\ -"\n"\ -"" - -#define info_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Device Info\n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" W5500-AtMEGA1284p Device Information\n"\ -"

\n"\ -"

..

\n"\ -"\n"\ -"\n"\ -"" - - -//!! No space at RAM in AtMega1284p (16kb only..) -//!! Need replace all pages into FLASH memory (PROGMEM) - Shame AVR-8bit HARVARD Architecture!! - -#define ain_gauge_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Analog Input Gauge\n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
\n"\ -" \n"\ -" \n"\ -"
\n"\ -" \n"\ -"\n"\ -"
\n"\ -"
\n"\ -"\n"\ -"\n"\ -"" - -/* Base64 Image converter: http://base64.wutils.com/encoding-online/ */ -#define img_page \ -"\n"\ -"\n"\ -"\n"\ -"\n"\ -" W5500-AtMEGA1284p Web Server Image\n"\ -" \n"\ -" \n"\ -" \n"\ -"\n"\ -"\n"\ -"\n"\ -"
wizwebserver.png
\n"\ -"\n"\ -"\n"\ -"" - -const char favicon_ico[] PROGMEM = { -0x0,0x0,0x1,0x0,0x1,0x0,0x30,0x30,0x10,0x0,0x1,0x0,0x4,0x0,0x68,0x6, -0x0,0x0,0x16,0x0,0x0,0x0,0x28,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x60,0x0, -0x0,0x0,0x1,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x0, -0x0,0x0,0x48,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x22, -0x24,0x0,0x8c,0x96,0x4,0x0,0xcb,0xd2,0x8d,0x0,0x57,0x5d,0x11,0x0,0xaa,0xb5, -0x4b,0x0,0x41,0x44,0x17,0x0,0xf0,0xf0,0xdc,0x0,0x6f,0x7b,0x9,0x0,0xbf,0xc5, -0x70,0x0,0xdc,0xe2,0xb4,0x0,0xfc,0xfe,0xfc,0x0,0x60,0x6e,0xc,0x0,0x4c,0x53, -0x14,0x0,0x99,0xa7,0x26,0x0,0x31,0x31,0x1c,0x0,0x7c,0x88,0x4,0x0,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa6,0x8d,0x14,0x8a,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11, -0x11,0x11,0x11,0x11,0x11,0x16,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11,0x11,0x11,0x35,0x5,0xb1,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0xe0, -0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa1,0x11,0x11,0x11,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11, -0x11,0x1d,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb1,0x11,0x11,0x4a,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa1,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x11,0x11,0x19,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x91,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x11,0x18,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0xf,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x11,0x11,0x2a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0x51,0x11,0x1a,0xaa,0xaa,0xa8,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x1,0x11,0x14,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x61,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41, -0x11,0xc0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xd1,0x11,0xe0,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x11, -0x11,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x41,0x11,0x50,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0xaa,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0x81, -0x11,0x30,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0, -0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0xaa,0xa0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xa0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xa1,0x11,0x10,0xa,0xaa,0x0,0x0,0x0,0xa, -0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa,0xa0,0x0,0xe,0x11,0x11,0xaa,0xaa,0xa1, -0x11,0x1c,0xa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0xa,0xaa,0x0,0x0,0xaa, -0xaa,0xaa,0x1,0x11,0x12,0xaa,0xaa,0xa6,0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa, -0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x1,0x11,0x1a,0xaa,0xaa,0xaa, -0x11,0x11,0x0,0x0,0xaa,0xaa,0xaa,0xaa,0x0,0x0,0x0,0xa,0xaa,0x0,0x0,0x0, -0xa,0xaa,0xf1,0x11,0x1a,0xaa,0xaa,0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0xaa,0xaa,0xaa,0xaa, -0xa1,0x11,0x13,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xad,0x11,0x11,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc1,0x11,0x1a,0xaa,0xaa,0xaa,0xaa, -0xaa,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xa1,0x11,0x11,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe1,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xa2,0x11,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xb, -0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xd1,0x11,0x11,0xf0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xa4,0x11,0x11,0x11,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf1,0x11, -0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x21,0x11,0x11,0x11,0xf0, -0x0,0x0,0x0,0x0,0xe,0x11,0x11,0x11,0x11,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, -0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xa9,0x11,0x11,0x11, -0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xa2,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1a,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x41, -0x11,0x11,0x11,0x11,0x11,0x2a,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, -0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, -0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 -}; -//favicon.ico: 1662 bytes - -const char brd_wiznet_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x3,0x7f,0x0,0x0,0x3,0x91,0x1,0x3,0x0,0x0,0x0,0x78,0x37,0x89, -0x3e,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54,0x78,0xda,0xed,0x9d,0x4f, -0x88,0x24,0x47,0xbe,0xdf,0x33,0x95,0x62,0x72,0x17,0x86,0x49,0x2d,0xef,0xd2,0x82, -0x66,0x52,0x8b,0x6c,0xf6,0x62,0xcc,0xc,0xc2,0xb8,0x5,0xed,0x4e,0x3d,0x16,0x2c, -0x1e,0x6,0xeb,0x6c,0xf0,0x61,0x16,0xc1,0xd3,0xc1,0x97,0x1a,0xe6,0xe0,0x16,0x2e, -0x3a,0xab,0xdd,0x8b,0xda,0x7,0xa1,0x32,0xf8,0x22,0xc1,0xb0,0x7d,0xf4,0xd5,0xe0, -0xcb,0x33,0x98,0x37,0x59,0x2e,0x31,0xe5,0x83,0x50,0xfb,0xea,0x93,0xb2,0xb6,0x96, -0xad,0x8b,0xb0,0xb2,0xdc,0x87,0x8d,0xf6,0x8b,0xcd,0x78,0xbf,0x5f,0x44,0x64,0x66, -0x44,0x66,0x56,0x66,0x64,0x56,0x56,0xeb,0x8f,0xa7,0x44,0xcd,0x1f,0x4d,0x77,0x7d, -0x3a,0x33,0xe2,0xf7,0xe7,0xfb,0x8b,0x5f,0x44,0x5a,0xec,0x6e,0x5f,0xa9,0xf5,0xa, -0xf8,0xa,0xf8,0xa,0xf8,0xe3,0x6,0xde,0x5e,0xde,0x31,0x70,0x73,0x71,0xc7,0xc0, -0xd5,0xe3,0x3b,0x6,0xae,0xdf,0xfd,0xa9,0x3,0xff,0xf8,0xf1,0x5d,0x3,0x9f,0xde, -0x31,0x30,0xf9,0xf0,0x8e,0x81,0x64,0xfd,0x3d,0x7b,0x1a,0x3a,0xb6,0x1e,0x1c,0x38, -0x71,0xe8,0xaf,0x67,0xcb,0x74,0xe4,0x3d,0xf,0xae,0xbe,0xb6,0xf7,0xa,0x24,0x1c, -0x38,0x39,0xf1,0xd7,0x93,0x88,0x8e,0xdc,0xbf,0xf1,0xfd,0xcf,0xac,0x61,0x5d,0xdb, -0x77,0x25,0x60,0x70,0xfd,0xe0,0x4d,0xf6,0xd9,0x43,0xef,0xf2,0xf9,0x57,0xe3,0x67, -0x8b,0x77,0x0,0x78,0x3a,0xac,0x6b,0x9b,0x97,0x7e,0x80,0xe0,0xfa,0x1f,0xbf,0xc9, -0xfc,0x93,0xf,0xdc,0xe7,0x5f,0x9f,0x3e,0x5b,0xbf,0x93,0xfa,0xf,0xc6,0xc3,0xba, -0xb6,0x55,0xe9,0x7,0x8,0xae,0xff,0xd1,0x17,0x2c,0xa0,0x1f,0x7c,0x44,0xbf,0x1a, -0x3d,0x5b,0x3c,0x3a,0x7e,0xf8,0x60,0xd8,0x2b,0x5c,0x6f,0xf4,0xbf,0xdf,0xf8,0xd7, -0xff,0xe0,0x73,0x37,0xa0,0x8b,0x35,0x89,0xff,0xef,0xc8,0x1d,0x1d,0xfe,0xee,0x5f, -0xe,0x3b,0x86,0xeb,0xdb,0x12,0xf0,0xa,0x81,0xc7,0x87,0xeb,0xf5,0x26,0xfe,0xe3, -0xe8,0xe1,0xb3,0x37,0x9f,0x7f,0xed,0xec,0x15,0x18,0xfb,0xd7,0xff,0xf0,0xb,0x76, -0x7c,0xe0,0xae,0x57,0x5f,0xfd,0xf5,0xb3,0xf4,0xd9,0x17,0xcf,0xbf,0xe,0xf7,0x7a, -0x4b,0x63,0xef,0xfa,0x9f,0x7c,0xc1,0xfc,0x3,0x67,0xbd,0xf8,0xfa,0xbd,0xbf,0x48, -0x9f,0xfd,0x47,0xeb,0xb5,0x61,0x81,0x37,0xa5,0x49,0xb3,0xbe,0xbe,0x7e,0xfc,0x5, -0x9b,0xbe,0x79,0xb3,0x9e,0x7e,0x5,0xc0,0xcd,0x1b,0x43,0x3,0x89,0xab,0xff,0x7d, -0x1,0xc0,0xcf,0x9d,0xc9,0xe3,0x1b,0x30,0xfc,0xb3,0x67,0x94,0x80,0xa7,0x19,0x16, -0x48,0xbd,0x12,0x70,0x81,0xc0,0xf8,0xe9,0x66,0x6d,0xc5,0xe9,0x33,0x4a,0xc3,0x3e, -0x40,0x7a,0xcf,0x83,0xf,0x5e,0xe0,0xc7,0xb1,0xc4,0xa,0xf6,0x9f,0xb5,0x11,0xcb, -0x85,0x5b,0x27,0x80,0xb1,0xe5,0x97,0xfe,0xf5,0xc5,0xf0,0xc0,0xc4,0x72,0x58,0x22, -0x81,0x91,0xe5,0xdd,0x1,0xf0,0xc9,0x9c,0x25,0x73,0x9,0xf4,0x3d,0x96,0xfe,0x66, -0xdf,0xc0,0xcd,0x8a,0x6d,0x96,0x2,0xf8,0xa5,0x37,0x65,0xf4,0xc9,0x5d,0x0,0x13, -0x1c,0x3f,0x97,0xbd,0x74,0xa7,0x8c,0x7c,0x15,0xde,0x1,0x90,0xbc,0xcf,0x81,0xb, -0x67,0xca,0x6e,0xbf,0xbe,0xb,0x20,0x75,0x5,0x70,0xd6,0xa,0x4c,0xc0,0x5b,0xa7, -0x87,0x60,0x3d,0xdf,0xf4,0x6,0x32,0x0,0xa6,0x2e,0x4b,0xc2,0x5,0x5b,0xc4,0x0, -0xfc,0x9d,0x19,0xf0,0x6a,0x30,0xe0,0xf3,0xe6,0x5b,0x1a,0xec,0xc,0xc,0xc1,0x2c, -0x18,0x18,0x7f,0xb0,0x60,0xf3,0x4,0xbc,0xce,0x81,0xe2,0xac,0x6b,0xbe,0x3e,0xf0, -0x7e,0x99,0xfe,0xeb,0xe3,0xe3,0x4f,0xee,0x79,0x3f,0x9f,0xf7,0xf3,0x34,0xc1,0x25, -0x23,0xe1,0x25,0xa3,0xbe,0xf0,0x34,0xe9,0xbb,0xcd,0xc0,0x13,0xd7,0x4a,0xff,0xd5, -0xd1,0xe1,0x6b,0xaf,0xdf,0xb3,0xcf,0x7b,0x1,0x69,0x0,0xb6,0x7,0xc0,0xd4,0xaf, -0xfa,0xd2,0x3a,0xe0,0xf1,0x87,0x7,0xe9,0x5f,0x3d,0xfe,0xf4,0xc3,0xe7,0x2f,0x1f, -0x3f,0xdf,0x1,0x8,0x86,0x6f,0xa,0xbc,0x39,0x4e,0xff,0xea,0x9d,0xaf,0x6e,0xae, -0x3e,0xf9,0xd8,0x1a,0x24,0xf3,0x4e,0xff,0x9d,0x12,0xe1,0xed,0x7a,0xe0,0xbf,0x0, -0xe0,0xf3,0x7b,0x3,0x1,0xe9,0xa8,0x1d,0xf8,0x6f,0x10,0xf8,0xf2,0x63,0xbf,0x1f, -0x30,0x2,0xcb,0x9a,0x40,0x68,0x7,0xc3,0x4f,0x21,0x5a,0x10,0xa2,0xdf,0xd2,0xe9, -0x45,0x75,0xc,0x3f,0x7c,0xfc,0xe9,0xcd,0xe7,0x7d,0xc7,0x90,0x4d,0x1c,0x9,0x73, -0x19,0x5,0xe0,0x2d,0xd,0x75,0x60,0x29,0x11,0x3c,0x86,0x59,0xfa,0xe1,0xa3,0xc3, -0x9b,0xdf,0xf6,0x9d,0xa5,0xc,0xe2,0xa1,0x80,0x81,0x2d,0x22,0x30,0xd5,0x81,0xf, -0xec,0xb2,0x1d,0xbe,0x9d,0x7e,0x78,0x7c,0x7c,0xf3,0xdb,0x5f,0xf5,0xb4,0x43,0xa, -0x1f,0x48,0x1d,0x91,0x30,0x25,0xf0,0x2e,0x1,0xd3,0xc3,0x37,0x6a,0x7c,0x8d,0x48, -0xfc,0x7b,0xa6,0x18,0xbf,0x80,0xf7,0xdb,0x0,0x7b,0x1f,0x26,0x9,0x58,0x87,0x7a, -0x4b,0xf1,0x3,0x8e,0x8f,0xb6,0x0,0x53,0xa7,0xa7,0x6b,0x7b,0x2c,0xa4,0x35,0xc2, -0x66,0xf0,0xa6,0x44,0xab,0x62,0xa4,0xc7,0xa7,0xdb,0xae,0xd0,0xed,0x9,0x7c,0xa, -0x6f,0x48,0x78,0x31,0xe8,0x63,0xa6,0x91,0xda,0x6d,0xc0,0x5d,0xe3,0x61,0xe9,0xa, -0x99,0xb3,0x67,0x60,0x79,0xc,0x4b,0x85,0xa1,0xe1,0x81,0xe5,0x59,0xca,0xd8,0x77, -0x1a,0xf0,0x60,0x34,0x74,0x15,0xa3,0x64,0x87,0x65,0xa0,0xf5,0x64,0x68,0x60,0xc9, -0xd3,0x94,0x80,0xcc,0x5a,0xe,0xd,0x2c,0xf9,0x52,0x15,0x88,0xce,0xfb,0x7c,0xb5, -0xf7,0xc2,0xd0,0x77,0x8d,0xd1,0x62,0xaf,0xc0,0xbd,0xa8,0xa7,0x3b,0x7,0x26,0xd2, -0xd,0xaf,0xb8,0xba,0xa8,0xde,0xd2,0xe9,0xc5,0xd0,0xc0,0x50,0x40,0x71,0x32,0xce, -0x6b,0x80,0x9e,0xbd,0x77,0xa0,0xf2,0x5a,0xee,0x3,0x18,0x8,0x68,0xc,0x7f,0x9e, -0x31,0xdd,0x97,0x32,0xc8,0x1e,0xef,0x5b,0x43,0xbb,0x36,0x30,0x3d,0xea,0x63,0x42, -0x2c,0xe0,0x54,0xfd,0xe,0xd0,0xa7,0x87,0x8f,0x86,0x9e,0xa5,0x60,0xf3,0x69,0x6, -0xc5,0x37,0x55,0x73,0xd6,0x3d,0x38,0x6f,0x7e,0x1f,0x2f,0x24,0xb8,0x94,0x62,0x90, -0x70,0x1f,0xc0,0x58,0x81,0x3a,0x3a,0x70,0xc9,0xf6,0x1,0x54,0x67,0xcc,0x4c,0x7, -0x82,0x59,0xec,0x1,0xa8,0xce,0x18,0x80,0xef,0x1f,0xa8,0xcd,0x98,0x40,0x3,0xe2, -0xbf,0xe,0x1f,0x80,0xd5,0x19,0x3,0x70,0x62,0xe9,0xe5,0xb3,0xe1,0xe3,0x21,0xf7, -0x2f,0x97,0x32,0xed,0xd3,0x81,0xab,0xdb,0xbd,0xc4,0xc3,0xcc,0x6d,0xe3,0x7b,0xaa, -0x7b,0xb6,0xdb,0x3b,0x9,0xc0,0x8a,0xc5,0xdc,0xde,0x41,0x3c,0x54,0x6b,0x6d,0xf1, -0x3e,0x96,0xf3,0x78,0xbd,0xd4,0xf2,0x61,0xec,0x7c,0x7e,0x4b,0xd5,0x5a,0xdb,0x1f, -0xdf,0x64,0x69,0x30,0x38,0xf0,0x75,0x1d,0xa8,0xd6,0xda,0xd6,0x3f,0x67,0xa9,0x3f, -0x34,0x90,0xc8,0x7c,0x34,0xe1,0x19,0x9b,0x5e,0xfa,0x5a,0x9f,0x73,0x2b,0x1d,0xba, -0x5e,0xfa,0x6b,0x10,0x33,0x97,0x2c,0xf6,0xdd,0x2a,0x70,0x29,0xac,0x74,0x58,0x20, -0x48,0xa7,0xcd,0x6a,0xc1,0x7e,0xef,0x9,0xb3,0xd0,0x6a,0x6d,0x1b,0x19,0x94,0x7, -0xaf,0x26,0x2,0x70,0xe5,0x8a,0x12,0xb4,0x5e,0x6b,0x13,0xbe,0x7d,0x3f,0xc0,0xb, -0x1,0x54,0x6b,0x6d,0xa2,0x34,0xb6,0x2f,0xe0,0x4c,0x0,0xd5,0x5a,0x1b,0x66,0x6d, -0xd4,0xdf,0x17,0x10,0xc4,0x61,0x5c,0x72,0x6d,0x3c,0xd5,0x77,0x7,0x9f,0xa5,0x58, -0xd5,0xbf,0x64,0x4b,0x10,0x87,0x49,0x30,0xad,0xd6,0xda,0x2e,0xee,0x10,0x18,0x87, -0xfb,0x0,0xe2,0x42,0x89,0x23,0x6a,0xde,0xc4,0x2f,0x1,0x3d,0x99,0xf3,0xc,0xee, -0x69,0x5c,0xe1,0x69,0x68,0x9,0xc8,0x2b,0x1a,0x89,0x2e,0x5f,0xad,0x86,0x97,0x6d, -0xbe,0xd8,0x25,0x7c,0x69,0x5a,0x2,0xf2,0xfc,0x9f,0xe8,0x9,0x40,0xe3,0x6b,0xe7, -0xc6,0x81,0xaa,0xae,0xd8,0x2f,0x90,0x54,0x3d,0x77,0xa3,0x55,0x92,0x9d,0x23,0x7e, -0xb8,0x7,0x20,0x75,0x57,0x7c,0xc1,0x92,0x1c,0xf8,0x2c,0x39,0xc8,0xa,0x77,0x3e, -0x8b,0x20,0xf4,0x62,0x3a,0xa3,0xd7,0xfa,0x6,0x0,0x12,0x67,0xc5,0x17,0x2c,0x71, -0x96,0xe6,0xb,0x96,0x0,0x9c,0x9c,0x5,0xfc,0xa,0x7,0x7,0x26,0xf6,0xa,0xec, -0x50,0xac,0xae,0xe5,0xb,0x96,0x0,0xb4,0x4e,0x2,0x1c,0xc3,0xd4,0xb2,0x86,0x6, -0x3e,0x1,0x20,0x38,0xee,0xe5,0x85,0xcb,0xe6,0x4e,0x1,0xbc,0xff,0x20,0xc0,0x59, -0xba,0x7,0x60,0xf2,0x21,0xdb,0x80,0xe3,0x5e,0x2d,0x16,0x6c,0xb1,0x98,0xe6,0xc0, -0x87,0xf7,0x2,0xb4,0xc3,0x3d,0x0,0xc9,0xdb,0x6c,0x93,0xbc,0xaf,0x1,0x27,0x30, -0x96,0xfe,0x6b,0x1,0xf7,0x34,0xaf,0x6b,0x63,0x18,0x5b,0x2c,0xdc,0x15,0x48,0x1d, -0xb6,0x21,0x6e,0x15,0x38,0x81,0x49,0x3,0xa1,0x69,0x52,0x2,0x36,0x5,0x64,0x33, -0x60,0xea,0xf0,0x5,0xcb,0xa,0x30,0x12,0xb3,0x34,0x2a,0x1,0xa3,0x9d,0xaf,0x30, -0x84,0x68,0x1,0xca,0x69,0x9,0x91,0x76,0xce,0xc4,0xa4,0x59,0xc2,0x18,0x7a,0xa0, -0x17,0xd7,0x15,0xe3,0x5f,0x95,0xc5,0x55,0xf,0x60,0x70,0x1,0x50,0x8,0x4f,0x0, -0x9d,0xc9,0x2c,0x34,0x39,0xf3,0x99,0x2b,0xef,0x5d,0x52,0x2,0xfe,0x97,0x5d,0x81, -0x24,0x98,0xf3,0xf5,0xc3,0x4,0x60,0x4b,0x99,0x67,0x13,0x0,0x5e,0xd2,0x20,0x2b, -0x2c,0x68,0xc0,0x78,0x67,0xd7,0x16,0xac,0xf8,0x72,0x1e,0x1,0xd8,0x46,0x2a,0x9, -0xa,0xc0,0x45,0xf6,0xe7,0x12,0xf0,0xcb,0x7d,0x3a,0xef,0x1a,0x2d,0x49,0x3e,0xbd, -0x13,0x20,0xe8,0x80,0x8,0x26,0xee,0x1c,0x80,0x6f,0xde,0xd,0xf0,0x81,0x1d,0xf9, -0xa9,0x7f,0x1,0xc0,0x7f,0xb6,0xb3,0xa7,0x29,0xd5,0x4b,0x33,0xe1,0xd,0xd3,0x7, -0x47,0x51,0x8c,0xe4,0xfa,0xd3,0x8f,0x29,0x8,0xa9,0x77,0x1,0x18,0xee,0xc,0x2c, -0x95,0x2f,0xb3,0x12,0x83,0x27,0xa,0x2a,0x62,0xde,0xae,0xbf,0xa2,0x0,0xfc,0x0, -0x22,0x24,0x61,0x77,0x3,0xfc,0x14,0x80,0xf4,0x3,0xf0,0x47,0xc9,0xee,0xc0,0xa0, -0x52,0xfd,0x2a,0x55,0x6e,0x70,0xc,0xef,0x23,0x70,0x61,0x83,0x20,0xd8,0x3d,0xc5, -0xf0,0x2a,0xd5,0xaf,0x1c,0x7e,0x9e,0x25,0xde,0xf1,0x31,0x2,0xd7,0x30,0x86,0xd1, -0xee,0x49,0x94,0x5b,0xa9,0x7e,0xe5,0xd0,0x28,0xab,0x12,0xaf,0x29,0x0,0x89,0xb, -0xc0,0xff,0xb0,0x3b,0xb0,0xe6,0x1e,0x66,0x57,0x9c,0xc1,0x1,0x48,0x0,0xe8,0x0, -0xf0,0x60,0x77,0x60,0xa9,0x5e,0x9a,0x5f,0xb1,0x2,0x6,0x20,0x98,0xc5,0xed,0xcd, -0xbb,0xec,0xf7,0x47,0xbb,0x3,0x5b,0x66,0xc,0x17,0xa4,0xeb,0xd4,0xa6,0x6c,0x73, -0x73,0xc1,0xe2,0xd3,0xdd,0x81,0x6d,0x33,0xc6,0xe5,0x42,0xd1,0xa5,0xec,0x66,0x3, -0xb9,0xdd,0xee,0x76,0xd8,0x3a,0x63,0x34,0x7d,0xb8,0x1c,0x0,0x58,0x3b,0x63,0x4a, -0xf0,0x5c,0x2c,0xae,0x86,0x0,0xea,0xf5,0x52,0xee,0x5b,0x10,0x8a,0x1,0x98,0x84, -0x85,0x3e,0xe4,0xc0,0xf9,0x10,0xc0,0x3a,0xb7,0x2d,0x5d,0x37,0x46,0x5f,0xd,0x71, -0x31,0x4,0xb0,0xcb,0xcb,0xb9,0x63,0x60,0xfa,0xf6,0x1d,0x3,0xe9,0x87,0xbb,0x3, -0xcb,0xd,0xad,0x9,0x26,0x9e,0x52,0x1f,0x4e,0x66,0xa5,0x24,0x8a,0xc,0x30,0x4b, -0xcb,0xd,0xad,0x31,0x36,0x62,0x49,0x7d,0x88,0x42,0x46,0x3,0x6e,0x86,0x8,0xc0, -0xbc,0x4e,0x53,0x34,0xb4,0x46,0x96,0x9f,0xe9,0x43,0x50,0x4e,0xa1,0xae,0x9e,0x56, -0xb1,0x35,0x80,0x3e,0x9c,0x73,0x7d,0x98,0x35,0xb4,0x46,0x27,0x7e,0xa6,0xf,0xd3, -0xfb,0x7,0x39,0x50,0xd4,0x67,0xdc,0x21,0x80,0x58,0xdc,0x8b,0x5,0xf0,0xa5,0x37, -0x65,0x2f,0x7d,0x3f,0xd3,0x87,0xe9,0xc9,0x71,0xe,0xbc,0xe2,0xbf,0x7e,0x37,0x14, -0x30,0x91,0xfd,0xa5,0xee,0x94,0x2d,0x3c,0x3f,0xd3,0x87,0x8,0xcc,0xf4,0xe1,0xd5, -0x70,0x82,0x94,0x37,0xb4,0xca,0xfe,0xd2,0x39,0x0,0x2f,0xfd,0x4c,0x1f,0x72,0xe0, -0x64,0x2f,0xc0,0xac,0xa1,0x75,0x9,0xc0,0xb9,0x9f,0xe9,0x43,0xe,0x8c,0x6,0x7, -0x62,0xbb,0x27,0x44,0xa,0x12,0x8a,0x76,0xcf,0x79,0xec,0x67,0xfa,0x30,0xf5,0xc0, -0x79,0xc7,0x3f,0x7e,0xa0,0x14,0xa4,0xd8,0x5f,0x9a,0xd9,0xa1,0x14,0xa4,0xa9,0xb, -0xf1,0x30,0x19,0x1a,0x98,0x35,0xb4,0xa6,0x7e,0xe1,0x69,0x32,0x41,0xea,0x26,0xb9, -0x20,0x1d,0xe,0x58,0xee,0x2f,0x45,0x5f,0x9a,0x9,0xd2,0xcb,0x4d,0xee,0xda,0x86, -0x3,0x1a,0xbe,0x5e,0x1,0x3b,0x0,0x4b,0x4d,0x58,0xc9,0x23,0x30,0x85,0x27,0xf0, -0xbf,0x21,0x4d,0xc4,0x78,0x78,0x7e,0x31,0x34,0xb0,0xd4,0x66,0x96,0xbc,0x5,0xc0, -0xf7,0x0,0x38,0x81,0x7f,0x82,0x64,0xf8,0xdc,0x19,0x1a,0x58,0x6a,0xa4,0x43,0xb3, -0x88,0x60,0xa6,0x4e,0xe0,0x8d,0x91,0xc2,0xb2,0x87,0x36,0x8b,0x52,0xab,0xe0,0xfc, -0x35,0x9f,0x7d,0xf2,0x3a,0xc4,0xc3,0xd7,0x21,0x1e,0xfe,0x2c,0x4c,0xf,0xde,0x18, -0xda,0xf0,0x4b,0xcd,0x90,0x18,0x2d,0xa6,0xf,0x20,0x1e,0x42,0x0,0x3e,0x39,0xc, -0xb3,0x86,0xd6,0x1,0x5d,0x5b,0xa9,0xdd,0x73,0x31,0x5,0xe0,0x43,0x0,0x9e,0x88, -0x0,0x2c,0x9b,0x3f,0x6,0x4,0x96,0x1a,0x5a,0xf7,0xf,0xbc,0xeb,0x2b,0xac,0x8c, -0xe1,0xbe,0x81,0xe5,0x59,0xba,0x77,0x60,0xd9,0xe,0x31,0x1e,0x62,0x8a,0x61,0x59, -0x5a,0x5e,0xba,0x3f,0x4f,0xb3,0x7f,0x60,0xc9,0x97,0xee,0x1f,0xf8,0x2a,0x1e,0xb2, -0x3d,0x9b,0x5,0x64,0x8a,0xc,0x32,0x45,0x16,0x81,0x6a,0x9b,0x4,0x6c,0xf8,0xcc, -0xfb,0xce,0x81,0x4,0xbe,0x82,0xd8,0x62,0x8f,0x58,0x8c,0x6f,0x80,0x46,0x0,0x9d, -0xc0,0x1b,0xa5,0xa2,0xdc,0x28,0x34,0xa0,0x2f,0x95,0xa9,0x21,0xa,0xb1,0x8,0xdf, -0xb6,0x34,0x4d,0xe1,0xf,0x52,0xb9,0x86,0x39,0x20,0x70,0xc,0x40,0xc8,0x76,0x97, -0x90,0xf4,0xce,0xf1,0xbd,0x64,0xec,0x72,0xce,0x98,0x77,0xc1,0x52,0xf,0xf3,0xe3, -0xc1,0x81,0x90,0xf0,0x6e,0x20,0xdb,0x45,0xf5,0xbe,0xc0,0x37,0x24,0xbf,0x53,0x8, -0x57,0xfe,0x9c,0xa5,0xc1,0x2,0xde,0xd3,0x57,0xc0,0x9f,0x8,0xf0,0x7a,0x40,0xb3, -0x70,0xe0,0xed,0xe6,0xeb,0xf8,0x5b,0xa2,0xc5,0x2b,0xe0,0xe0,0xd1,0xe2,0x15,0xf0, -0x15,0xf0,0xa7,0xe,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0x21,0x6,0x77,0x2c,0xf0,0xee, -0x7e,0x85,0x44,0xf6,0xb3,0xf1,0x6d,0xe6,0x4d,0x40,0x5e,0x52,0x76,0x76,0x7,0x26, -0x1c,0x18,0xb6,0x3,0xb3,0x5e,0xc2,0x5d,0x81,0x71,0x76,0x3f,0x5b,0x80,0x69,0xd6, -0xda,0xb7,0x2b,0x90,0xf,0xd,0x66,0x77,0x2d,0x40,0x6a,0x65,0xb7,0x62,0x47,0xa0, -0xa8,0xf6,0x7b,0x3f,0x3c,0x20,0x29,0xe6,0xf2,0x6e,0x40,0xf1,0x39,0x6e,0x2b,0x50, -0x4c,0x2e,0xcb,0xdf,0x15,0x28,0xe7,0x82,0xd3,0xa,0x14,0x93,0xcb,0xf2,0x76,0x5, -0xd2,0xbc,0x75,0xb6,0x5,0x18,0xe5,0xb7,0x62,0x37,0x20,0xc9,0x3b,0x59,0x5b,0x80, -0x93,0xfc,0x56,0xec,0x6,0x94,0x43,0x3,0xb3,0xaf,0xa,0x4c,0x8b,0x11,0xb,0x59, -0xd1,0x63,0xbb,0x1b,0x30,0xce,0x3d,0x69,0x33,0x30,0xb5,0xac,0x8e,0x76,0xb1,0x5, -0x28,0x87,0x6,0x3e,0xba,0xf9,0x96,0x52,0xd5,0xc7,0x77,0x2,0x2a,0xf1,0xc1,0x67, -0x45,0x17,0xb6,0xd7,0x2,0x24,0xea,0x37,0xf5,0x5,0x7a,0xb9,0x55,0xe0,0xec,0xab, -0x1,0x16,0xc7,0x3c,0x86,0x89,0xf2,0x4d,0xdd,0x80,0x13,0xd,0x98,0xdf,0x29,0xa7, -0x6e,0xc,0x8b,0x29,0x19,0xc6,0xc5,0x4f,0xd6,0x11,0xa8,0xbc,0xa6,0x85,0x55,0x80, -0x21,0xd6,0x0,0xdf,0x29,0x80,0x51,0xf1,0x93,0xed,0x4,0x4c,0x8a,0x96,0xf2,0x1a, -0xe0,0xb3,0x2,0x38,0x51,0xba,0xeb,0x77,0x1,0xc6,0x45,0x86,0xd1,0xc,0x54,0x9b, -0xdd,0x77,0x1,0x46,0xc5,0x94,0x6d,0x4,0x9e,0x15,0xc0,0x70,0x27,0x60,0x31,0x85, -0xbc,0x46,0xe0,0xa9,0x9e,0x6c,0xf5,0x7,0x16,0x9f,0xe3,0x36,0x7a,0x9a,0x91,0x6e, -0xbd,0xbd,0x81,0x69,0xf1,0x39,0x4e,0x23,0xf0,0x89,0x66,0x4c,0xfd,0x81,0x54,0xd9, -0xdb,0xd1,0xe8,0x69,0xde,0x53,0x6e,0xc5,0x2e,0x40,0xa2,0xf8,0x9d,0x17,0x86,0x99, -0xb7,0xb3,0xb,0x30,0x69,0xce,0xbc,0x3f,0xf,0x6b,0x80,0xf6,0x2e,0xc0,0xb8,0x19, -0x78,0x10,0x68,0x40,0x3f,0x19,0x6,0xe8,0xa4,0x5b,0x80,0xe9,0x3b,0xbe,0x6,0x14, -0xbf,0xed,0xe,0xf4,0x85,0xf9,0xd7,0x0,0x9f,0x5d,0x7d,0xaf,0x40,0x47,0x75,0x4c, -0x6d,0x7b,0x7d,0x9a,0x80,0x32,0xe7,0xac,0x1,0x7e,0xa4,0x1,0x5d,0xa6,0x8d,0x79, -0xd3,0x2b,0x6c,0x2,0xda,0x32,0x48,0xd5,0x1,0xb5,0x31,0xf4,0xc5,0x17,0x1a,0xdc, -0xd2,0xb4,0x11,0xe8,0xca,0xb8,0x5f,0x33,0x4b,0xef,0x69,0xb3,0x34,0x10,0xf1,0x7a, -0x67,0xa0,0x57,0x7c,0x5e,0x19,0xf8,0x99,0x66,0x87,0xa1,0xf8,0xc9,0x76,0x6,0xfa, -0x32,0x77,0xb,0xda,0x3c,0x4d,0xe,0x94,0xe5,0x7b,0x74,0xb5,0x14,0xbe,0x8d,0x5a, -0x21,0xaf,0xf4,0x27,0xf8,0xb6,0xb1,0xd2,0xdf,0x1f,0xf8,0x77,0x2a,0x50,0xfe,0x6e, -0x67,0x8b,0x5c,0xb8,0xb2,0x46,0xf8,0x6,0xe4,0xac,0xca,0x1f,0xca,0x2a,0x7f,0x33, -0x30,0x90,0xe9,0x70,0x1b,0xd0,0x96,0x29,0x98,0x4d,0xc1,0x40,0xc4,0xda,0xa1,0xcb, -0x37,0x5b,0x25,0xbc,0xc5,0x5,0x8d,0x2b,0xe0,0x6b,0xf9,0x13,0xab,0x19,0x18,0xca, -0x84,0xdf,0x18,0x48,0xe0,0x8f,0x84,0x97,0x30,0x1d,0x5e,0xc2,0x8c,0x79,0x9,0xd3, -0xcb,0x4a,0x98,0xf0,0x3e,0x1b,0x4,0xe8,0xca,0x44,0xdd,0x86,0x2f,0x86,0x6f,0xb0, -0xe1,0x9b,0x6d,0xf8,0xbb,0x3,0x6f,0x17,0x60,0x2e,0x7c,0x8d,0x7,0x63,0xec,0xc3, -0xfb,0xa4,0x11,0x98,0x69,0x28,0x63,0x20,0x7c,0x13,0xa6,0xa9,0x98,0x39,0x2,0x8, -0x86,0x14,0xa0,0xc2,0x23,0xbb,0x60,0x36,0x1e,0xbc,0x1f,0xe,0xb,0x8c,0xbc,0x49, -0x10,0xf9,0x56,0x30,0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0x9d,0x5a,0xc4,0xa6, -0x36,0x71,0x88,0x9d,0xb8,0xc4,0x89,0xef,0xd,0x2,0xf4,0xa4,0xd8,0xb2,0x23,0x3f, -0xa,0xa2,0x60,0x12,0x4c,0x42,0x0,0x32,0x0,0xa6,0x76,0xa,0x38,0xea,0x50,0x7, -0x90,0x2e,0x71,0x93,0x46,0xa0,0x9d,0xe9,0x60,0x73,0x60,0x10,0x7,0x51,0x8,0x48, -0x16,0x85,0x60,0x94,0xa9,0xcd,0xec,0xd4,0x1,0xa4,0x9b,0x2,0x8e,0xba,0xc4,0x23, -0x43,0x3,0xc3,0x24,0x88,0x58,0x1c,0x9c,0xb3,0x38,0x84,0x29,0x3,0xa,0xe4,0x3c, -0x75,0x99,0x4d,0x3d,0xe6,0x10,0x2f,0x75,0x89,0x4f,0xfb,0x3,0xd9,0x4e,0xc0,0x54, -0x8b,0x20,0x9e,0x1,0x30,0xda,0xd,0x48,0x35,0xa0,0x6b,0x0,0xb4,0x82,0xdd,0x80, -0xda,0x4d,0x5a,0xb7,0x3,0xd3,0xe0,0xae,0x81,0xe1,0xd5,0x4e,0xb3,0x74,0x30,0xa0, -0xa9,0x1d,0xee,0x8,0xec,0xee,0x69,0xea,0x81,0xd,0x9e,0x66,0xb,0xd0,0xd8,0x97, -0xfe,0x8,0x80,0x96,0xbf,0x53,0x78,0xda,0x11,0xd8,0x3d,0x0,0x6f,0x1,0x36,0x5, -0x60,0xb6,0x53,0x8a,0xb1,0x23,0xb0,0x7b,0x12,0xb5,0x5,0xd8,0x90,0x44,0x7d,0x1e, -0xee,0x94,0x26,0x6e,0x1,0x36,0xa4,0x89,0xba,0x3e,0xec,0x9c,0x8,0x53,0x55,0x8b, -0x84,0x6,0xc0,0x92,0x3e,0xec,0x9c,0xea,0x53,0xf5,0x6c,0xbc,0x2,0xb8,0x3d,0xd5, -0x2f,0xc9,0x35,0x9f,0x69,0x35,0x81,0x76,0xf5,0x44,0xd9,0xff,0x29,0x82,0x53,0x18, -0xb7,0x8b,0x99,0x12,0xb0,0xb3,0x5c,0xa3,0xec,0xdb,0xa2,0x14,0x11,0xc6,0xa1,0x81, -0x5c,0xab,0x13,0xa4,0xe6,0xa,0x18,0x80,0xf9,0xdf,0x6e,0x42,0x1a,0x1a,0x8,0xd2, -0xdd,0x34,0xfe,0x36,0xe0,0x56,0xc9,0x5d,0xd2,0x87,0x9d,0xab,0x18,0xdb,0x80,0x5b, -0xab,0x18,0x25,0x7d,0xd8,0xb9,0x4e,0xb3,0xd,0x68,0xb2,0x24,0xdb,0xab,0x12,0x55, -0x3,0xac,0xaf,0x44,0x25,0x76,0xe2,0xe0,0xb6,0x7d,0x30,0xa7,0xf4,0x71,0x7a,0x2, -0xbe,0x8c,0x58,0x7d,0x6a,0x6d,0x35,0xc0,0xfa,0x5a,0x5b,0x62,0x25,0x36,0x7,0x82, -0xcf,0x7c,0x44,0x8f,0x21,0xa6,0x9f,0x5a,0x7d,0xaa,0x89,0x35,0xc0,0xfa,0x6a,0x62, -0x62,0x8d,0x0,0x11,0xfe,0x19,0x92,0x24,0xfa,0x68,0x74,0x64,0x3d,0xb2,0x8e,0xac, -0x3e,0xf5,0xd2,0x1a,0x60,0x7d,0xbd,0x74,0x43,0x9e,0x92,0x53,0xc6,0x6e,0x19,0xf5, -0xc9,0xe8,0xad,0xa3,0xf1,0xa3,0xf1,0xc9,0x51,0x9f,0x8a,0x70,0xd,0xb0,0xbe,0x22, -0xbc,0xa1,0x4f,0xe9,0x29,0xdf,0xab,0xfd,0x4d,0x92,0x58,0x47,0xe9,0xa3,0xf4,0xe4, -0xa4,0x4f,0xcd,0xbb,0xe,0x58,0x5b,0xf3,0xe6,0xc0,0x73,0xb6,0x84,0x49,0xb3,0xe1, -0x40,0x48,0x89,0xfb,0x54,0xf5,0xeb,0x80,0xb5,0x55,0x7d,0x0,0x92,0x53,0x8b,0xcd, -0x0,0xb8,0xdc,0xbc,0x6,0xc0,0x30,0xd,0xfa,0xac,0x5b,0xd4,0x1,0x6b,0xd7,0x2d, -0x36,0x94,0x4f,0x9a,0xb,0x0,0xae,0x36,0x9f,0x1,0xd0,0x4a,0x83,0x3e,0x2b,0x33, -0x75,0xc0,0xda,0x95,0x19,0x0,0xda,0xe4,0x28,0xbc,0x4,0xe0,0x7a,0x93,0x1e,0xa5, -0x90,0xec,0x6,0x13,0x93,0x20,0xe1,0x37,0x1,0x93,0x70,0xeb,0xda,0x53,0xe,0xb4, -0xfc,0x3b,0x2,0x92,0x91,0x45,0x68,0xe8,0x66,0xc0,0xc0,0x3a,0xb,0x8c,0xc2,0xa0, -0xd7,0x4,0xe4,0xf1,0xb0,0x7e,0x39,0x2f,0xb1,0x36,0x49,0x48,0xcf,0x7c,0xb8,0xa5, -0xdf,0x71,0x20,0x3d,0x9,0x8c,0x16,0x2c,0xe7,0x5b,0x80,0xde,0x1a,0x80,0x3c,0xc5, -0xa8,0x5f,0xb0,0x4c,0xec,0xd,0x9,0xe9,0x38,0xc0,0xd4,0x84,0x3,0xd3,0x93,0xc0, -0x68,0x49,0x76,0x53,0xf,0x4c,0x9d,0x2,0x58,0xbb,0x24,0xb,0x40,0x7a,0x4a,0xc7, -0x61,0x6,0x4,0xc3,0xf,0x8c,0x16,0x9d,0xb5,0x13,0x29,0xa,0x20,0x79,0xaa,0x0, -0xeb,0x16,0x9d,0x37,0x30,0x8a,0xa7,0xa7,0xa7,0x19,0x10,0x5d,0x5b,0x60,0xb4,0xac, -0xae,0x1d,0x99,0x28,0x80,0x98,0xa6,0x13,0xaa,0x0,0xeb,0x96,0xd5,0x37,0x30,0x8a, -0xa7,0x96,0x38,0x14,0x14,0x80,0xe8,0xbc,0x5d,0xb3,0xc6,0x1,0xaf,0x1e,0x98,0x7e, -0x54,0x0,0xeb,0x1a,0x7,0x0,0x8,0x2,0x62,0xc3,0xb3,0xb6,0x4d,0xca,0xc3,0x93, -0x6b,0xd6,0x1a,0xb1,0xa8,0xde,0x52,0xb8,0x68,0xd,0x58,0xd7,0x1a,0x1,0x40,0xd0, -0xec,0x19,0x90,0x7,0x60,0xd7,0xac,0xf9,0x63,0x59,0xf,0x64,0xbf,0x2a,0x80,0x4d, -0xcd,0x1f,0x4a,0x5e,0x6a,0xd8,0xde,0x42,0xaa,0xc0,0x2b,0xc6,0x37,0x2b,0xe6,0xc0, -0xa6,0xf6,0x16,0xd,0x68,0xd4,0xc0,0x43,0x83,0xa,0xf0,0x1b,0xc6,0x1b,0x79,0x73, -0x60,0x53,0x3,0x8f,0x6,0x34,0x6b,0x51,0xf2,0x6a,0xd,0x3f,0x50,0x66,0x69,0x53, -0x8b,0x92,0x6,0x34,0xeb,0xfa,0xba,0xd8,0xee,0xda,0x32,0x60,0x43,0xd7,0x97,0x6, -0x34,0xeb,0x6b,0xdb,0xb4,0x3,0x1b,0xfa,0xda,0xb4,0x7e,0x1a,0xb3,0xce,0x3d,0xc5, -0xd7,0x6c,0x3,0x36,0x74,0xee,0xe9,0x40,0xa3,0xde,0x44,0xc5,0xd7,0x6c,0x3,0x1a, -0xf7,0x26,0xc6,0x46,0x49,0xa9,0xa7,0x2,0xc3,0x12,0xf0,0x32,0xab,0x7a,0xf1,0xa1, -0x69,0x3,0x9a,0xbd,0x16,0xa,0x30,0x2d,0x3,0xf5,0x53,0xbf,0xda,0x6e,0xa9,0xd9, -0x6b,0xd9,0x4,0xd4,0xcf,0x1c,0x1c,0x6,0x48,0x9a,0x80,0xec,0xbc,0x19,0xa8,0x1c, -0x98,0x6b,0xc,0x2c,0x7c,0x4d,0x1d,0x30,0x9,0x9a,0x81,0xc5,0x24,0x37,0x6,0x16, -0x3f,0xa3,0x0,0x62,0x15,0x10,0xf7,0xa,0x9,0xa0,0xf6,0x94,0x92,0x17,0x9a,0x5c, -0xe3,0x3b,0xb2,0x13,0x94,0x6b,0x47,0x2e,0xd6,0x63,0xcb,0x1f,0x1c,0x1b,0x64,0x54, -0x39,0x10,0x86,0x46,0x0,0xb5,0x69,0xa3,0xcb,0x35,0xbe,0xab,0x7e,0x8e,0x72,0xed, -0xc8,0x9d,0xf8,0x13,0x9f,0x31,0x56,0x5a,0x16,0x30,0x7,0x62,0x9d,0x4c,0x2,0xd5, -0x47,0xdd,0xd5,0x0,0x2f,0xb7,0x3,0x7d,0x83,0xcc,0xad,0x6,0xc8,0x26,0xf5,0xc0, -0x91,0x15,0x4e,0xc2,0x3f,0xc3,0x78,0xa0,0x3e,0xbc,0x67,0xb9,0xc2,0xe0,0x53,0x93, -0x91,0x4c,0xaa,0x40,0x2c,0x3b,0x66,0xc0,0xc4,0xaf,0x1,0xa2,0x3e,0xc,0xcf,0xd9, -0x2d,0x98,0x5,0xe8,0xc3,0x93,0x13,0xff,0xd2,0x33,0x7,0x2a,0xde,0x34,0x3,0x62, -0x61,0x35,0x3,0x2a,0x8f,0x19,0xd0,0xe5,0x5a,0x88,0xc7,0xdb,0x59,0x3e,0xe8,0xc3, -0x93,0x93,0x60,0xe1,0x9b,0x3,0x95,0xb3,0xa7,0x33,0xa0,0x28,0x1d,0xcb,0xd9,0x1f, -0x7,0xf5,0xc0,0x33,0x9f,0x3b,0x8d,0xd,0x7,0xb2,0xe,0x40,0xe5,0x50,0x5f,0xe, -0xf4,0x27,0x61,0xe4,0x5b,0x5,0x90,0xba,0xb5,0x40,0x32,0xe,0xf8,0x81,0x48,0xa0, -0xf,0xe1,0x96,0x76,0x2,0xce,0x75,0x60,0xb6,0xa6,0x92,0xc7,0xee,0xa8,0xe,0x8, -0xfa,0xd0,0x66,0x17,0x69,0x70,0x5,0xfa,0x10,0xe4,0x76,0xd0,0x5,0x18,0xeb,0x40, -0x10,0x31,0x80,0x54,0x80,0xc4,0xaf,0x3,0xda,0xc4,0x66,0x97,0xa9,0x7f,0x5,0xea, -0xe9,0x24,0x98,0xf8,0xbe,0x67,0x2e,0xd7,0x28,0x36,0xbf,0xf2,0x8d,0xf2,0xf5,0xc0, -0xfc,0x98,0xda,0x92,0x5c,0xb3,0x98,0x9b,0x7a,0x2,0x18,0x79,0xbe,0x67,0x2e,0xd7, -0x52,0x5c,0x48,0xe0,0xfb,0x83,0x68,0x3d,0x30,0x9b,0x36,0xba,0x5c,0x3b,0x25,0x20, -0xd7,0xdc,0xab,0xef,0x10,0xc8,0x5c,0xc3,0x5b,0x2a,0x82,0xe1,0x14,0xae,0xd1,0xa7, -0x21,0xa8,0x3c,0x56,0xb,0x4c,0xdd,0xaa,0x2f,0x5,0x31,0x83,0x72,0xed,0x37,0x3c, -0xf3,0xe,0xd8,0xa5,0x21,0x50,0x1c,0xa8,0x8f,0x47,0x51,0x4d,0xe1,0xed,0x6f,0x1, -0x66,0xe,0xb5,0x46,0xae,0x8d,0x38,0xd0,0xdc,0xe,0x45,0xce,0xb6,0x81,0xdf,0xae, -0xc1,0xa6,0xae,0x38,0xb0,0x32,0x4b,0xf3,0x38,0x5c,0x23,0xd7,0x4e,0x7d,0xe,0x34, -0xf0,0x34,0xc4,0x2a,0xa2,0x2f,0xf9,0x30,0x72,0xd6,0xf3,0xc8,0xbd,0xe6,0x40,0x69, -0x87,0xf3,0x50,0x39,0x7b,0xef,0x9c,0xaf,0x37,0x54,0xe5,0x5a,0x7a,0x86,0x40,0x23, -0x5f,0xca,0x8f,0x6e,0x92,0x39,0x5b,0xea,0x4e,0xec,0x9b,0xcb,0x89,0xb3,0xc2,0x74, -0x29,0xf3,0x34,0x1a,0x10,0xe2,0x70,0x6c,0xd5,0xc8,0x35,0x6c,0x99,0x6,0x60,0x11, -0x2d,0xb6,0x3,0xe5,0xf1,0xbe,0xc2,0xc4,0x60,0x4a,0x6f,0x7c,0xcb,0x5e,0x22,0xf0, -0x89,0xf4,0xa5,0x1a,0x30,0xc5,0x15,0xb2,0xa0,0x2a,0xd7,0xa4,0x20,0xcd,0x3,0x70, -0x3,0x50,0x1e,0xef,0x2b,0x76,0x1e,0xde,0xb3,0xac,0xd3,0x13,0xcb,0x4a,0x28,0x7c, -0xcb,0x13,0x19,0x2d,0x34,0x20,0x4c,0x9b,0x49,0x5d,0x43,0x6b,0x39,0x4d,0x6c,0x0, -0x4e,0x44,0x8a,0xcc,0xed,0x22,0x7d,0xcb,0xb2,0x8e,0xc7,0x96,0x35,0xce,0x80,0x18, -0xf,0x75,0x20,0xf5,0xea,0x1b,0x5a,0x4b,0x59,0x5b,0x3,0x50,0x8a,0x0,0x6e,0x17, -0xe9,0xa9,0x65,0x1d,0x42,0x7e,0x7d,0x9c,0x1,0x31,0xc5,0xd0,0x81,0xa8,0x1b,0xdc, -0x5d,0x80,0xa9,0x94,0x39,0x7c,0x18,0xd2,0x91,0x13,0xdf,0x8f,0xdd,0xe8,0x30,0x7, -0x42,0x12,0x55,0x2,0x26,0xf5,0xd,0xad,0x21,0xeb,0x8,0x24,0x2,0xe8,0x26,0xf7, -0x63,0x2f,0xe6,0xc0,0xec,0x5b,0x4a,0x40,0xa,0x79,0x5a,0xd,0xd0,0x35,0x7,0x8e, -0x6c,0xe9,0xb8,0xf9,0x15,0x92,0xfb,0xb1,0x9f,0x34,0x2,0xad,0xd3,0xda,0x96,0x5d, -0x73,0x20,0xb1,0x73,0x2d,0x93,0x8e,0x7e,0x49,0xef,0xc7,0x1,0x69,0x4,0xbe,0x7e, -0x5c,0x3,0xe4,0x9b,0xde,0xcd,0x80,0x36,0x15,0xc0,0x4b,0xe,0x3c,0x1a,0xb7,0x2, -0x5d,0xea,0xe0,0x36,0xfa,0xe6,0x54,0xdf,0x0,0x38,0xe7,0xc0,0x13,0x23,0xa0,0x15, -0x54,0x80,0x49,0x67,0xe0,0x86,0x3,0x3,0x6a,0x2,0x7c,0x51,0x5,0x4e,0xd8,0xdd, -0x2,0xbb,0xcc,0x52,0x39,0x69,0xc8,0x6e,0xc0,0xa0,0xab,0x59,0x70,0xbb,0x48,0x47, -0x7e,0xbb,0x59,0x38,0x64,0xc7,0x2b,0x94,0x5,0x15,0x7e,0xae,0xaf,0xa9,0xe1,0xef, -0x32,0x86,0x79,0x5,0xc7,0x2f,0xb9,0xb6,0x10,0x23,0x5b,0xd5,0xb5,0x51,0x74,0x6d, -0x41,0x79,0x39,0xf,0x66,0x29,0x56,0xf4,0xed,0x24,0xd,0xc,0x9d,0xb7,0x28,0x6b, -0xab,0xce,0x3b,0xb4,0x44,0x97,0x41,0x9,0x88,0xad,0x29,0xa,0x50,0x2e,0xe7,0x61, -0xc6,0x77,0x6c,0x8d,0x21,0xb0,0x5,0x86,0xe1,0x89,0xc7,0x8b,0x74,0x8c,0x30,0x19, -0x9e,0xce,0x64,0x1f,0x45,0x9,0x88,0xad,0x29,0x2a,0x50,0x2e,0xe7,0xc5,0x3e,0xc5, -0xa5,0xbc,0x47,0xa4,0x15,0x98,0x9f,0xaf,0xf,0x76,0x1,0x77,0xc5,0x1a,0x9f,0x59, -0x16,0xa5,0x1c,0xee,0x30,0x19,0x80,0x43,0xfd,0x27,0xf4,0xb,0x20,0x97,0x6b,0x24, -0x4,0xb9,0x16,0x92,0x11,0x3d,0x1a,0x3f,0x4a,0xc2,0x36,0x60,0xfe,0x4,0x1,0xb4, -0xb,0xdf,0xb2,0x48,0x60,0xd9,0x3c,0xe2,0x9f,0xc2,0xe0,0x8a,0x14,0x43,0x3f,0x13, -0x1a,0x53,0x8c,0x40,0x93,0x6b,0x24,0x5c,0xe2,0x73,0x9b,0x79,0x55,0x3f,0x6e,0xd, -0xc0,0x49,0x56,0xd7,0x44,0xbb,0x98,0x4e,0xec,0x8d,0x3f,0x71,0x96,0x8,0x1c,0x41, -0x7a,0x28,0x92,0x28,0x1d,0x88,0x49,0x94,0xe,0x4c,0xc4,0x72,0xde,0x6,0xfe,0x5f, -0x32,0x6b,0x5,0x12,0x4b,0xb1,0xdd,0x45,0xe4,0xac,0x2e,0x23,0x77,0xce,0x3,0x70, -0x9e,0x26,0xea,0x40,0x4c,0x13,0x55,0x20,0x5c,0x9f,0x90,0x6b,0x9,0x2,0x2f,0x5a, -0x81,0xc5,0xcb,0xe7,0xe3,0xb8,0x58,0x62,0xca,0x7f,0x1b,0xa5,0x4f,0x8a,0x44,0xb8, -0xfc,0xdd,0x2a,0x10,0x34,0xfe,0x9c,0x17,0x5b,0x57,0x89,0x45,0xf0,0x88,0x16,0x73, -0xe0,0x94,0x7f,0x8a,0x48,0xf5,0x37,0x93,0x93,0x27,0x45,0xaa,0xdf,0x8,0x4,0xb1, -0xc6,0x63,0xdb,0x9a,0x22,0xd0,0x53,0x36,0x5a,0xb5,0xc9,0xb5,0x5,0xb7,0x6a,0x1f, -0xde,0x1,0x5d,0xf9,0x86,0x40,0x90,0x6b,0x10,0xbb,0xf9,0xf9,0xc3,0xa9,0x75,0xca, -0xaf,0xd0,0x58,0xae,0xdd,0x70,0xab,0x16,0x72,0x6d,0x1d,0xfc,0xce,0x8,0x88,0x72, -0xd,0xc4,0x1a,0xfe,0xbc,0xdf,0x31,0x7a,0x84,0x7,0xd1,0x98,0xdd,0xd2,0x85,0xbe, -0x92,0x60,0xe,0x4,0xb9,0x36,0xe,0x64,0x99,0x2e,0x5,0xe0,0x5f,0x1a,0x2,0x4b, -0xf,0xc,0xe9,0x2,0xa4,0xa7,0xa1,0xf8,0x4e,0x43,0x3b,0x2c,0xe4,0x9a,0x12,0xd3, -0xe8,0xfa,0xc5,0xef,0xcc,0x66,0x29,0xca,0x35,0x69,0x37,0x49,0xe1,0x69,0xd2,0x86, -0x65,0x12,0xe1,0x4b,0x6f,0xb,0x41,0xc3,0x81,0x9b,0xab,0x93,0x27,0x45,0xd9,0x24, -0xa4,0xca,0xf7,0x73,0x3b,0x8c,0x1c,0x45,0xae,0xc9,0x1a,0x56,0x52,0xf8,0xd2,0xb4, -0x61,0x99,0x44,0x0,0x69,0x96,0xb8,0x49,0x20,0xb1,0xce,0x32,0x4f,0x13,0x71,0x51, -0xe3,0xeb,0x9e,0x26,0xb2,0xb,0xb9,0x46,0xa4,0x9c,0xa5,0x4a,0xb4,0x68,0x5,0xf2, -0x7b,0x5e,0xd4,0x69,0x68,0x6a,0xe5,0xbe,0x14,0x97,0xd5,0x13,0xa5,0x46,0xcf,0x7d, -0x69,0x64,0x15,0x72,0x2d,0x3,0xa6,0x4a,0x3c,0x6c,0x58,0x97,0x91,0xc0,0x40,0xab, -0x7a,0xab,0xd1,0x2,0x57,0xb9,0x63,0x65,0x15,0x42,0x44,0xb,0x6c,0xf9,0x68,0x90, -0x6b,0x93,0x36,0x20,0x1f,0x3f,0xa2,0x1,0xb3,0x78,0x88,0xab,0xdc,0x91,0xb2,0xce, -0x22,0xe2,0x21,0x3e,0xee,0xab,0x9,0x68,0xb7,0x1,0xa7,0xda,0x34,0x55,0x23,0x3e, -0x56,0x13,0x27,0xc5,0x4a,0x92,0x8c,0xf8,0x69,0x33,0x30,0xba,0x73,0xa0,0x63,0xa4, -0x80,0x7d,0xd,0x28,0x93,0x28,0x4,0x2a,0x8b,0x73,0x32,0x89,0x6a,0xb9,0xa5,0x71, -0x2b,0x70,0x55,0x8,0xfd,0xc,0xa8,0x2c,0x23,0xa8,0x40,0x91,0x26,0x92,0xa3,0x66, -0xa0,0xdb,0x6,0xdc,0x68,0xab,0x41,0x15,0xe0,0x91,0x55,0x4a,0x84,0x93,0xd3,0xbe, -0xc0,0x2b,0x71,0x5d,0xb7,0x45,0x1,0xac,0xe,0x38,0xb6,0xf4,0x54,0x3f,0xb3,0xc3, -0x2d,0xc0,0xa6,0xf5,0x4a,0x9,0xa4,0xe2,0x32,0x65,0xf9,0xb2,0x2,0x64,0x1a,0x70, -0x92,0x7b,0x9a,0x7a,0x60,0xda,0xb4,0x22,0x2b,0x81,0xfc,0xf3,0x49,0x1e,0xf,0x9b, -0x81,0x56,0xee,0x4b,0xb7,0x0,0x43,0xe2,0xd1,0x36,0x20,0x9a,0x4,0x1d,0xe7,0xe5, -0xcb,0x46,0x60,0x8d,0xb6,0x28,0x3,0xfd,0x36,0xa0,0xd0,0xf8,0x47,0x79,0xf9,0xb2, -0x65,0xc,0xdb,0x80,0xb4,0x1d,0x78,0x29,0x8b,0x85,0xb2,0x7c,0xd9,0x36,0x4b,0x5b, -0x80,0x91,0xdb,0xa,0xe4,0xa1,0x62,0x9e,0x97,0x2f,0x5b,0xec,0x70,0x31,0x39,0x6d, -0x4,0x4e,0x9c,0x56,0x20,0x37,0xc4,0x79,0x56,0xbe,0x6c,0xf3,0x34,0xb,0xeb,0x54, -0xa6,0x18,0xd8,0xb6,0x18,0xaa,0xdd,0x31,0x1c,0x8,0xfa,0xa4,0x4d,0x3d,0xf1,0x50, -0x71,0x9e,0x95,0x2f,0xdb,0x7c,0xe9,0x4b,0xeb,0x48,0x66,0x6d,0x90,0x22,0xc6,0x15, -0x20,0x8,0xa2,0x71,0x1b,0x90,0xff,0x44,0x7,0x4a,0xf9,0xb2,0x8,0x4f,0x6b,0x56, -0x9,0x4f,0x5f,0x3e,0x3c,0x90,0xc0,0x33,0x87,0x4d,0x42,0x7a,0x2,0x60,0x7c,0xa2, -0x70,0xb0,0xe4,0x40,0x94,0x7d,0x6d,0x40,0x1c,0x33,0xd0,0x94,0xb2,0x7c,0x9,0xf7, -0xb0,0x8,0xc0,0x6b,0x56,0x9,0xc0,0x5f,0x6,0x7,0x32,0x11,0x1e,0xdb,0x30,0xd5, -0xc8,0x99,0x35,0xb6,0x1,0x48,0x21,0xe9,0xa,0xa5,0xb0,0x6d,0x15,0xa4,0x81,0xaa, -0x80,0x1,0x58,0xa4,0x18,0x6b,0x56,0x49,0x31,0xbe,0xc,0x25,0x90,0x9e,0xbe,0x5, -0x16,0x15,0xa7,0x30,0x8f,0x11,0xe8,0x3f,0xf,0x79,0x71,0xc2,0x8d,0xee,0xb7,0x2, -0x75,0x8d,0xff,0x2d,0xd6,0x29,0x79,0x12,0x85,0xc0,0x4a,0x12,0x55,0x0,0x47,0x23, -0x5c,0x5d,0x4b,0x4f,0x1e,0x11,0xf8,0x4,0xea,0xfb,0xfc,0xa,0x47,0x5e,0xdc,0xe, -0x9c,0x72,0x60,0x56,0xc5,0x28,0xaa,0xfa,0x8,0xac,0xa4,0x89,0xf9,0x2d,0xa5,0x23, -0xbe,0xba,0x96,0x9e,0x3c,0xa6,0xa1,0xcf,0xc8,0x95,0x2d,0x80,0x7e,0xd2,0xe,0x5c, -0xe0,0x17,0xda,0x59,0x9d,0xa6,0x58,0xb7,0xc8,0x17,0x2c,0xd5,0x44,0xf8,0x65,0x1, -0x14,0xab,0x6b,0x2,0x78,0x3b,0xb5,0x4,0x30,0x20,0xed,0xc0,0x15,0xaf,0x26,0x66, -0x95,0xa8,0x62,0x65,0xa6,0x16,0xb8,0x78,0xa8,0x1,0x2f,0x53,0xeb,0x1d,0x1,0x3c, -0x34,0x7,0x62,0x51,0x61,0x74,0x3c,0x36,0x3,0x46,0xf7,0x8f,0x72,0xb9,0x76,0x8a, -0xab,0x6b,0xd6,0x33,0x4,0x6e,0xae,0xf,0xc3,0x36,0xa0,0xda,0x1a,0xa1,0x94,0x2f, -0x5b,0x81,0xa7,0x99,0x5c,0xa3,0x7c,0x75,0xd,0x7e,0x7,0x60,0xe2,0x76,0x0,0x82, -0x4,0x52,0x8a,0x7b,0xa6,0x40,0xb1,0xd8,0x15,0xa4,0x1,0x7,0xc6,0x5d,0x80,0x69, -0x17,0x60,0x69,0x75,0xd,0x80,0x9,0x9a,0x45,0xec,0xdc,0x11,0x10,0x9c,0x29,0xb1, -0x0,0xb8,0x5a,0x7d,0xda,0x6a,0x16,0xc5,0x2b,0x50,0xcb,0x97,0x2d,0x66,0xa1,0xe8, -0x43,0xca,0x97,0xf3,0x2,0x6a,0x3,0x70,0xb1,0x9a,0xb4,0x1a,0xbe,0x1a,0xa8,0x94, -0xf2,0x65,0x8b,0xe1,0x6b,0x40,0x5c,0xce,0xb,0x20,0x6a,0x0,0x70,0x33,0x63,0x6d, -0xae,0x4d,0x2d,0x9b,0x98,0xbb,0x36,0x9e,0x89,0x48,0xe0,0xd8,0xda,0x94,0x3,0x70, -0x93,0xf3,0x56,0xb,0xb,0x4a,0xf9,0xf2,0x5b,0x46,0x9a,0x9c,0xb7,0xa,0x3c,0xb3, -0x2b,0xc0,0xa6,0xf0,0xa4,0x16,0x16,0x94,0xf2,0xa5,0xec,0x2f,0xdd,0x16,0x9e,0x32, -0x60,0xa9,0xd8,0x1b,0x18,0x4,0x60,0xb5,0xb0,0xa0,0x94,0x2f,0xbf,0xcd,0xcf,0xdd, -0xad,0xd,0xc0,0x2d,0xc0,0xa6,0x14,0x43,0x73,0x35,0x45,0xf9,0xf2,0x5b,0xf8,0xe4, -0x86,0x14,0x23,0xb1,0x7a,0x27,0x51,0x9a,0xab,0x29,0xca,0x97,0x0,0x6c,0x4a,0xa2, -0xda,0x80,0xd,0x69,0xa2,0x66,0xf9,0x45,0xf9,0x52,0xef,0xfa,0xaa,0xa4,0x89,0x6d, -0x40,0xc6,0xc,0x80,0x60,0xf9,0x79,0xf9,0xb2,0xc,0xac,0x24,0xc2,0x53,0x32,0x0, -0xf0,0x8a,0xa9,0x9d,0xa,0xac,0x31,0xd5,0x1f,0x4,0x78,0x59,0x94,0x2f,0xcb,0xc0, -0xb2,0x5c,0x1b,0x6,0x38,0x2f,0xca,0x97,0xcd,0x40,0x6b,0x20,0xa0,0x5a,0x18,0x6a, -0x4,0xe,0x75,0x4b,0xc9,0x76,0x60,0x57,0xb9,0x66,0x6,0x2c,0xa,0xa6,0xed,0xb3, -0xb4,0xbf,0x5c,0x53,0xd,0x31,0xd8,0xa,0xac,0x94,0x4d,0x5a,0x80,0x46,0x9e,0x86, -0x67,0xfb,0xed,0xc0,0xd2,0xea,0x1a,0x44,0x35,0x74,0xc2,0x36,0x81,0xe9,0x16,0x2c, -0xe0,0x7f,0x9b,0xfb,0xd2,0xe2,0x98,0xeb,0xa,0xb0,0x5a,0xfa,0xca,0x8b,0xec,0xc, -0x1f,0xbe,0xb,0x2a,0x88,0x3,0x2f,0x58,0xd2,0x21,0x5a,0x28,0xc7,0x45,0x94,0x81, -0xd5,0x68,0x91,0x3,0x41,0xae,0xcd,0x18,0x3d,0x82,0xec,0x34,0xa0,0x81,0xcd,0xe2, -0xe,0xf1,0x90,0xef,0x30,0xae,0x7,0x56,0xe3,0x61,0xbe,0x6e,0x21,0xe4,0x1a,0xa4, -0x35,0x34,0x48,0xce,0x2c,0x16,0x75,0x88,0xf8,0x5a,0x25,0x4a,0x7,0x56,0x23,0x7e, -0xbe,0x32,0x3,0x72,0xd,0xae,0x8b,0xd0,0x90,0x4,0x31,0x7d,0x23,0x9c,0x74,0xc8, -0x69,0x94,0xf6,0xf9,0x32,0xb0,0x9a,0xd3,0x7c,0x7f,0x40,0xd0,0x87,0x36,0x4c,0x1b, -0x1a,0x26,0xe1,0x92,0x1c,0x5,0x3f,0xeb,0x90,0x26,0x2a,0xae,0xa6,0xc,0xdc,0x9e, -0x26,0xa2,0x3e,0xfc,0x5,0x4c,0x1b,0x12,0xc6,0x6c,0x46,0xc6,0xc7,0x7,0x1d,0x12, -0x61,0xc5,0xd5,0x54,0x7a,0xf5,0x9b,0x96,0xf3,0x70,0x77,0x1e,0x4b,0xc2,0x19,0xbb, -0x20,0xd6,0x23,0x2b,0x30,0x4e,0xf5,0x55,0x57,0xd3,0x15,0x78,0x9,0xe6,0x70,0x1, -0xe,0xbd,0x2b,0x10,0x93,0x28,0x59,0xbe,0xd4,0xf6,0xae,0xb1,0xc6,0xe5,0x3c,0x0, -0xba,0x70,0x53,0x5d,0xe6,0x75,0x7,0xfe,0xae,0x36,0x1e,0xc6,0x8d,0xcb,0x79,0x34, -0xdc,0xa4,0x3e,0x88,0x6e,0x2f,0xf5,0x9,0x68,0x1a,0xd6,0x9,0xf8,0x95,0xd2,0x7d, -0x59,0x0,0x69,0xf3,0xea,0x5a,0xb8,0xc1,0x87,0x9a,0x51,0x9f,0x6,0xdd,0x81,0x71, -0x6d,0x4e,0xd3,0xe,0xc,0x53,0x8f,0x4,0x60,0x8a,0x39,0xb0,0x76,0x96,0xa6,0x9e, -0x13,0x27,0x67,0x9e,0x1b,0x27,0xa7,0x81,0x7b,0x91,0xc5,0xfc,0xbc,0xfb,0xd2,0x8, -0x88,0xda,0x22,0xc4,0x1d,0x81,0x3e,0xf6,0xf,0x14,0xc0,0x5a,0x3b,0xac,0x3,0x2a, -0xdd,0x97,0xc2,0x53,0xfb,0x1c,0xd8,0x28,0xd7,0xc2,0x4d,0x2,0x9e,0x1,0x17,0xf5, -0xa,0x60,0xad,0xa7,0xa9,0x1,0x46,0x79,0xf9,0x52,0xee,0x3f,0xe4,0xda,0x82,0x86, -0xdb,0x3d,0xd,0x7,0x6e,0x38,0x70,0x53,0x0,0xeb,0x9d,0x77,0xd,0xf0,0xd3,0xbc, -0x7c,0x29,0xf7,0x1f,0x72,0xf5,0x54,0xb3,0x9c,0xd7,0x2,0xac,0xf,0x4f,0x35,0xc0, -0x87,0x79,0xf9,0xf2,0x5b,0xb9,0xe8,0x29,0xd6,0xf,0xb7,0x86,0xa7,0x2d,0x29,0x46, -0x7d,0x0,0xae,0x2,0x8b,0xf2,0xa5,0x4,0xa,0x5,0x4c,0xc3,0xad,0x1,0x78,0x5b, -0x4e,0x53,0x9b,0x62,0xd4,0x0,0x55,0x5,0x2c,0x6e,0x9f,0xc5,0x81,0x5b,0x53,0x8c, -0x4e,0x49,0x54,0xd,0x50,0xd5,0xf8,0xe2,0xf6,0x59,0x21,0x2,0xb7,0x26,0x51,0x9d, -0xd2,0xc4,0x5a,0x60,0x51,0xc5,0xd8,0x6,0x34,0x4a,0x13,0x6b,0x13,0xe1,0x3a,0xa0, -0x52,0xbe,0xe4,0xc0,0x7,0x12,0xd8,0x35,0x11,0x36,0x6,0x2a,0xe5,0x4b,0xe,0xf4, -0x25,0x70,0x90,0x54,0xbf,0xe,0x58,0x94,0x2f,0x95,0xa3,0x46,0x92,0xb0,0x2a,0xd7, -0x86,0x2,0x9e,0xd4,0x1,0xe3,0xb0,0x2a,0xd7,0x86,0x2,0xe6,0xc5,0x3d,0x71,0x5c, -0xc,0x9e,0x61,0xc5,0x6a,0xe4,0x1a,0xdb,0x1b,0x10,0xc6,0x90,0xd5,0xc8,0x35,0x36, -0x8c,0x5c,0x53,0xab,0x89,0xfa,0x9,0x3c,0xe5,0x59,0xca,0x86,0x91,0x6b,0x5a,0x33, -0x64,0x6e,0x87,0xa8,0x0,0xca,0x76,0xf8,0xc3,0x3,0x1a,0xea,0x43,0xb5,0xfb,0x72, -0x2b,0x50,0x6b,0x2c,0x47,0x7d,0x48,0xac,0x10,0x77,0x71,0xa7,0xa8,0xf,0x13,0x91, -0xb5,0x99,0xea,0x43,0xb5,0xfb,0x32,0x77,0xde,0x8,0x2c,0x3b,0x6f,0xa6,0xea,0x43, -0x4,0x1e,0xc3,0x1f,0x51,0x1f,0x4a,0xa0,0xa9,0x3e,0x54,0xbb,0x2f,0xf3,0xf0,0x84, -0xc0,0x72,0x78,0x62,0xaa,0x3e,0x4,0x20,0xe8,0xc3,0x30,0x42,0x7d,0x28,0x81,0xa6, -0xfa,0x50,0xed,0xbe,0xcc,0x3,0x30,0x2,0xcb,0x1,0x98,0xa9,0xfa,0x10,0xfe,0x84, -0xfa,0x70,0xc2,0x40,0x1f,0x26,0xac,0x93,0x3e,0x54,0xbb,0x2f,0xf3,0x14,0x3,0x81, -0xe5,0x14,0x83,0xa9,0x72,0xd,0xfe,0x84,0x72,0xcd,0x65,0x20,0xd7,0x46,0xac,0x93, -0x5c,0x53,0xbb,0x2f,0xf3,0x24,0xa,0x81,0xe5,0x24,0x8a,0xa9,0x72,0xd,0xf,0x53, -0x61,0xf4,0xcc,0x63,0x20,0xd7,0x1e,0x45,0xdb,0xd2,0xc4,0xb4,0xdc,0x2c,0x91,0xe2, -0xdd,0x53,0xba,0x2f,0xf3,0x34,0x11,0x81,0xe5,0x34,0x51,0x5,0xf2,0xc3,0x54,0x18, -0x19,0xfb,0x28,0xd7,0x1e,0x59,0xe1,0x96,0x44,0xb8,0x1e,0x58,0x94,0x2f,0x6b,0xa5, -0x7f,0x9e,0x8,0xb3,0xaa,0x5c,0xc3,0x45,0xbd,0x26,0x31,0x53,0xf,0x2c,0xca,0x97, -0x5d,0x80,0x47,0x28,0xd7,0x88,0xc5,0xe5,0xda,0x61,0x37,0x60,0x5e,0xbe,0x2c,0x1f, -0x45,0xb9,0x15,0x88,0x72,0xd,0x27,0xcc,0xc,0x8c,0x3,0xe5,0x5a,0xda,0xd,0x98, -0x97,0x2f,0x9b,0x8e,0x3e,0x29,0x6d,0x96,0xa3,0x78,0xb6,0x9,0xdc,0x4e,0x72,0x82, -0x72,0x2d,0xed,0xa6,0xf,0xb7,0xad,0x69,0xda,0x5b,0x81,0xa8,0x9e,0xe8,0x18,0xe4, -0x1a,0xa1,0xc7,0xc1,0x40,0x40,0xea,0xe9,0x1b,0xab,0x6b,0x37,0xcb,0x79,0x24,0x3d, -0x6,0xf5,0x94,0xdd,0x52,0xc3,0xa2,0x42,0xfd,0x2b,0x9,0x21,0x56,0x6f,0x1b,0x43, -0xb9,0xba,0x6,0x72,0x6d,0x7c,0x84,0xc0,0x71,0xd0,0xa5,0x6c,0xb2,0xbd,0x50,0x7c, -0xd9,0x4,0xb4,0x46,0x28,0x66,0xac,0x47,0x20,0x66,0x32,0xb3,0xa8,0x7a,0x9a,0xfa, -0x49,0xb3,0xa5,0xf6,0x3e,0x61,0x71,0x3,0x10,0x57,0xd7,0x88,0xc5,0x7f,0x5,0x67, -0x1c,0x6e,0xf1,0xa5,0x1d,0x80,0x60,0x28,0x81,0xde,0xea,0xad,0x3,0x71,0x75,0x8d, -0x58,0xfc,0xd7,0x34,0xb0,0xb6,0xc9,0xb5,0x16,0x60,0xe4,0x2b,0xc5,0x1b,0xf0,0xa4, -0x34,0xa8,0x7,0x9a,0xcb,0xb5,0x66,0x60,0xaa,0x74,0x89,0x9,0x39,0x7a,0xd5,0x9, -0x58,0x13,0xf1,0x9b,0x81,0x89,0x5f,0x6c,0x9c,0xba,0xe5,0xd1,0xf0,0xba,0x1b,0xd0, -0x30,0xa7,0x29,0x4c,0x3d,0x3f,0x61,0x0,0x93,0xc,0x8c,0xf7,0xeb,0x6e,0x40,0xc3, -0xac,0x2d,0x7f,0x81,0xf7,0x9c,0x69,0xc0,0xeb,0x9b,0x6e,0x40,0xc3,0x44,0x58,0x2d, -0xf2,0x91,0x2,0x38,0x39,0xb4,0xaf,0x37,0x54,0x19,0x83,0x1f,0x3a,0xb0,0xfd,0x6c, -0x3a,0x2c,0x3d,0xc9,0xf2,0x13,0x7,0x9e,0xd8,0xce,0xed,0x5e,0x81,0x31,0x8b,0x7d, -0xb9,0xdd,0x8e,0x3,0x71,0x96,0xef,0x2,0xc,0x22,0xbf,0xd9,0x2c,0xe6,0xd4,0x8f, -0x65,0x7f,0x9d,0x0,0xda,0xd7,0xe0,0xc0,0x8a,0x9e,0xd1,0xc1,0x81,0x53,0x98,0x93, -0xc1,0x42,0x3,0xa2,0xb7,0xca,0xf,0xe,0x1a,0x1c,0xe8,0x83,0x3a,0xfc,0x66,0xa5, -0x8e,0xe1,0x35,0x24,0xf3,0x76,0xde,0xf3,0x3f,0x38,0x30,0xf8,0x86,0xb1,0xef,0x6e, -0x90,0xe6,0xc8,0x59,0xca,0xd8,0xb1,0xf8,0x6,0xbf,0x8b,0xe1,0x4f,0x3c,0x33,0x60, -0x1a,0xc2,0x75,0xdc,0xdc,0x72,0x20,0xdc,0x4b,0xa1,0x2c,0x24,0x70,0xda,0xc5,0xb5, -0xc9,0xf4,0x8b,0x3,0x1b,0xad,0xe2,0xc,0x7e,0xf9,0x33,0x11,0x40,0x42,0x5,0xf0, -0xb9,0x0,0x5e,0x37,0x1,0x23,0x7b,0xbe,0x51,0x9c,0x77,0x76,0xd,0xed,0xc0,0x3f, -0xe3,0x65,0xd2,0x1c,0xc8,0xa5,0x4c,0x27,0xa0,0x8,0x4f,0x54,0xc6,0x9c,0x56,0x20, -0x41,0x20,0x1b,0x87,0x19,0x90,0x4b,0x99,0x76,0x20,0xd,0x73,0xa0,0x8,0xc0,0x44, -0x4e,0xea,0x56,0xe0,0x2d,0xf7,0xd4,0x67,0x2,0xb8,0xa1,0x42,0xca,0x7c,0x65,0x0, -0x5c,0x30,0x9,0x14,0x29,0x46,0x22,0x27,0x75,0xeb,0xa4,0xb9,0xf9,0x4e,0x56,0xd2, -0x25,0x90,0x4b,0x99,0x4e,0x40,0x91,0x44,0xc5,0xd2,0xa5,0xb5,0x2,0x57,0x1c,0xf8, -0x4d,0xe,0xe4,0xfb,0x35,0x4d,0x80,0x2f,0xbd,0xc,0xc8,0xd3,0x44,0x63,0xe0,0xfa, -0x1b,0xfc,0xf5,0xbb,0xab,0x1c,0xc8,0xc,0x81,0x20,0xf4,0x36,0xca,0xba,0x45,0xec, -0x76,0x5,0x5e,0xb3,0x75,0x7,0x60,0x64,0xe7,0x93,0x46,0xa4,0xfa,0xb1,0x37,0xd9, -0x37,0x70,0xa9,0x3,0x7d,0x31,0x3b,0x5b,0xc3,0xd3,0xfa,0x45,0x4f,0xe0,0x62,0xd3, -0xf,0xb8,0x50,0x81,0xeb,0xe,0x63,0xc8,0xb6,0x0,0xdb,0xec,0xf0,0x9a,0x3,0xff, -0xd4,0xf5,0xa,0x11,0x38,0x5b,0xea,0x63,0xf8,0xd0,0xe8,0xd8,0xd4,0xde,0xc0,0xc5, -0x26,0x9a,0xe9,0xb3,0xd4,0x10,0x18,0xf6,0x4,0xce,0x97,0xb1,0xab,0xdb,0x61,0x1, -0x6c,0x9a,0xa5,0xbd,0x81,0x91,0x8d,0x5b,0x3a,0x55,0x4f,0x63,0x6,0x9c,0x66,0xc0, -0xcc,0xf0,0xd1,0x7,0x7f,0x25,0xfc,0xe2,0xf,0x9,0x8,0xde,0xda,0xa5,0xbe,0xee, -0xbc,0x4f,0x0,0x98,0x72,0xb3,0x68,0x2,0x5e,0x95,0x80,0xd2,0x79,0xe3,0xe1,0xb2, -0x7e,0x23,0x90,0x78,0x90,0x42,0x6b,0xe1,0xe9,0xac,0x17,0x50,0x86,0x27,0x3c,0x2, -0xd9,0xbd,0xee,0xa0,0xf,0x21,0x0,0x53,0xe,0xc,0xa3,0x56,0x20,0xfc,0x45,0x2, -0x8b,0x0,0x7c,0x8c,0x8b,0x18,0x66,0xc0,0x3c,0xc5,0x80,0x5f,0x6f,0x4,0xb0,0xe9, -0x75,0x85,0xf,0xda,0xc,0xa,0xa0,0x4c,0x31,0xf0,0x54,0x69,0xdb,0x10,0x98,0x25, -0x51,0xa6,0x40,0x18,0x6e,0xbf,0x0,0xca,0x24,0xea,0x91,0xe5,0x4f,0x2c,0x43,0x60, -0x96,0x26,0x9a,0x2,0x61,0x42,0x7b,0x12,0x8,0x69,0x22,0xaf,0x44,0x1d,0x63,0xa5, -0x30,0x32,0x5,0x66,0x89,0xb0,0x29,0x30,0x72,0x2d,0x57,0x0,0x95,0x44,0xf8,0x2d, -0x3c,0x73,0xe8,0x83,0xbe,0xc0,0xe6,0x49,0x13,0x79,0x13,0x15,0x88,0x8b,0x4,0x8, -0x84,0xe9,0xb3,0xf,0x20,0x8c,0x5f,0xe4,0x47,0x8,0x2c,0xc4,0xc,0x9a,0xd6,0x3e, -0x81,0x93,0xa,0x90,0x8e,0xef,0xf8,0xa,0x41,0x90,0xee,0x15,0x28,0xc6,0xb0,0x90, -0x6b,0xec,0x76,0x57,0x60,0xc3,0xb,0x81,0x62,0x96,0x16,0x45,0x5,0xb6,0xa1,0x9d, -0x66,0x69,0x56,0xa7,0x31,0x5,0x4a,0x3b,0xcc,0x80,0x70,0x37,0x56,0xb4,0x93,0x1d, -0x66,0x95,0x28,0x53,0xa0,0xf4,0x34,0x6a,0x25,0x8a,0x1a,0x78,0x9a,0x92,0x5c,0xeb, -0x0,0x94,0xbe,0x54,0xad,0xb5,0x51,0x3,0x5f,0x5a,0x92,0x6b,0x39,0xd0,0x7a,0xaf, -0x6d,0xd2,0xc8,0xf0,0x24,0xbf,0x7,0xa3,0x85,0x4f,0x5b,0xa3,0x45,0x45,0xae,0x15, -0xc0,0xe6,0x78,0x78,0x75,0x15,0xa8,0x40,0x59,0x2f,0xa5,0xad,0xf1,0xb0,0x22,0xd7, -0x4c,0xcd,0xa2,0x4,0x94,0x15,0x61,0xda,0x1a,0xf1,0x2b,0x72,0x4d,0x2,0x5b,0x73, -0x9a,0x32,0xf0,0x12,0x72,0x9a,0x38,0x5b,0xef,0xea,0x22,0xd7,0xfa,0x2,0x45,0x55, -0x9f,0x76,0x97,0x6b,0x1a,0xb0,0x29,0x3a,0x95,0x80,0x62,0xdd,0x82,0x76,0x97,0x6b, -0x7d,0x81,0x62,0x65,0xe6,0x87,0x9,0x5c,0xe,0x2,0x14,0x29,0x6,0xed,0xae,0xf, -0x7b,0x3,0x13,0xf1,0xe0,0xf1,0xce,0xfa,0xd0,0x14,0x58,0xf2,0x34,0x79,0x87,0x42, -0x67,0x7d,0x68,0x6a,0x16,0xfd,0x81,0x25,0x7d,0xb8,0x7f,0x60,0x49,0x1f,0xf6,0x1, -0x16,0xd5,0x0,0xda,0x5d,0x1f,0xf6,0x0,0xa6,0xc5,0xea,0x2f,0xed,0x2e,0xd7,0x7a, -0x0,0x49,0xb1,0xc2,0x4d,0xbb,0xcb,0x35,0x36,0xc1,0xe5,0x72,0xbb,0xcb,0x2c,0x4d, -0x8a,0xec,0x98,0x76,0x97,0x6b,0x8c,0xaf,0xd1,0x77,0x2,0xc6,0xc5,0x97,0xd3,0x3e, -0x72,0xcd,0x4b,0x3b,0x2,0x23,0xb5,0x53,0x48,0xa4,0x18,0x69,0xed,0xd9,0x97,0xb5, -0x49,0x14,0xb5,0x5c,0x23,0x60,0xa1,0x80,0x65,0x8b,0x92,0x4,0x8a,0x24,0xca,0xc, -0x88,0x69,0xe2,0x9f,0x88,0xe5,0xfc,0x3f,0xa3,0xa2,0xc2,0x56,0x20,0xa6,0x89,0x66, -0x40,0x9c,0x9f,0x2b,0xc8,0xfd,0x12,0x4,0x62,0xb3,0x85,0x29,0xf0,0x81,0x2,0x14, -0x89,0xb0,0x39,0x70,0x1e,0xfb,0x78,0xcc,0x6b,0x37,0xa0,0xaf,0x1,0x31,0xd5,0x37, -0x7,0x5e,0xc4,0xc1,0x64,0x14,0xf2,0x6f,0x35,0x7,0x62,0x6f,0x62,0x5f,0xa0,0x1b, -0x87,0xd1,0x69,0x70,0x97,0xc0,0x28,0x8c,0x8e,0xfd,0xc,0x68,0x38,0x4b,0x2b,0xc0, -0xd2,0x13,0xad,0x1a,0x80,0xa9,0x37,0x9,0xa3,0x87,0x5e,0x47,0x60,0x65,0xc,0xcd, -0x81,0x14,0xbe,0x37,0xf2,0xdc,0x8e,0xc0,0xca,0x2c,0x45,0x3b,0x59,0x1b,0xd9,0x21, -0x3d,0x7e,0x2b,0x8c,0x3e,0xb8,0xec,0x8,0xac,0xd8,0xa1,0x21,0x10,0x3c,0xd,0x39, -0x7a,0x12,0x4c,0xde,0xbf,0xd8,0x9,0xe8,0x4f,0x9a,0x80,0x89,0x7,0x11,0xdf,0xcd, -0x7d,0x29,0x19,0x81,0x1d,0x7e,0x38,0xe7,0x81,0x12,0xb7,0xde,0x1b,0xcd,0xd2,0x8a, -0x2f,0xfd,0x41,0x1,0x63,0x7,0x80,0x4e,0x1e,0x9e,0xc8,0x33,0x98,0x62,0x37,0x1d, -0x81,0x95,0xf0,0xd4,0x4,0xc4,0xbc,0x3b,0xb2,0xf3,0x0,0x9c,0x7c,0x4,0xce,0xfb, -0x76,0x66,0xe,0x8c,0xe5,0xf6,0x78,0x2d,0x0,0x37,0x1,0xe7,0xb3,0xd9,0x66,0xbe, -0xcc,0x53,0x8c,0x4,0x54,0xba,0x7b,0xbb,0xec,0x6,0xac,0xa4,0x18,0x6f,0x34,0x0, -0x17,0xcb,0xd9,0x46,0xd1,0x87,0x31,0x4,0x16,0x8f,0xc6,0xdd,0x80,0x95,0x24,0xea, -0xe6,0x9a,0x6c,0x7,0xb2,0x68,0xa3,0xe8,0xc3,0xe5,0x14,0x53,0x8c,0x51,0x6,0x6c, -0x37,0xb,0x3e,0x7e,0xe5,0x34,0xb1,0x5,0xf8,0x54,0xd1,0x87,0xcb,0x2b,0xf0,0x8c, -0x69,0x57,0x60,0x39,0x11,0x6e,0x2,0x7e,0x69,0x7f,0xf9,0x58,0xd1,0x16,0x4b,0xcc, -0x6b,0xf7,0xc,0x7c,0xb9,0x5,0x68,0xe6,0x69,0xfa,0x0,0x7f,0xb1,0x1d,0x68,0x36, -0x69,0x3a,0x1,0x17,0xcb,0x85,0x7d,0xd7,0xc0,0x73,0x5,0x38,0xeb,0xa,0x5c,0x5f, -0xdd,0x74,0x6,0xce,0xf4,0x59,0x3a,0x0,0x30,0x69,0xf4,0x34,0x0,0x5c,0x16,0x76, -0xb8,0x77,0x20,0x68,0xfc,0xa5,0xf4,0xa5,0xe8,0x69,0x3a,0xcf,0xd2,0xa,0x30,0x68, -0x1,0x2a,0xd1,0x2,0x7d,0xa9,0x0,0x3e,0xd9,0x5,0xd8,0xe2,0x4b,0x95,0x78,0x88, -0xd1,0x2,0x5c,0x1b,0xc8,0xb5,0xdf,0xec,0x0,0x6c,0x8b,0x16,0x25,0xb9,0xb6,0xbc, -0x46,0x5f,0xba,0x64,0x6,0x2f,0xb1,0xba,0x56,0x1,0x1e,0x9b,0x3,0x31,0xe2,0x2f, -0xd7,0xe0,0xfa,0x6f,0xd,0x81,0x58,0x11,0xae,0x0,0x8f,0x3a,0x0,0x21,0x89,0x8a, -0x79,0x3c,0x9c,0x99,0x1,0x13,0x5e,0x68,0x2f,0x19,0xbe,0x4c,0xa2,0x4c,0xe5,0x5a, -0xf2,0xc,0x22,0xfe,0xcd,0xdc,0xc,0x88,0x55,0xfd,0x1a,0xa0,0x7c,0xa6,0xa9,0x59, -0x22,0x9c,0x8c,0xe0,0xc7,0x5e,0x5d,0x98,0x1,0x71,0xdd,0xa2,0x2,0xec,0x28,0xd7, -0x20,0x2f,0xf5,0xad,0xf7,0xd5,0xb6,0xfb,0x9a,0x2d,0x9d,0xea,0xea,0x5a,0xd,0xb0, -0x93,0x98,0xa1,0x87,0x6f,0x5,0x93,0xf,0x4c,0x81,0x7e,0xb4,0x33,0x30,0xf5,0x2c, -0x29,0x66,0xc,0x80,0x93,0x1f,0x27,0x10,0xe4,0xda,0xa1,0x7f,0x77,0xb7,0x54,0x28, -0x60,0xff,0xee,0x26,0xd,0x68,0xfc,0x30,0x1a,0x5,0x86,0xc0,0x5d,0xcd,0x2,0xeb, -0x34,0x11,0x0,0xdf,0xb,0xcd,0x80,0xc5,0x72,0x5e,0xd9,0xf0,0x3b,0x2c,0xe7,0xc5, -0xa0,0xf,0xb5,0xaf,0x68,0x0,0x16,0xcb,0x79,0x65,0xd7,0xd6,0x0,0x2c,0xc9,0x35, -0x96,0xbc,0xe5,0xeb,0x1b,0xe,0x1a,0x80,0xea,0x72,0x5e,0xa9,0xd6,0xb6,0x1d,0x58, -0x92,0x6b,0x8c,0xbc,0x51,0xda,0xdf,0xd3,0x0,0xac,0x2d,0x41,0xb7,0x55,0x13,0x4b, -0x72,0x8d,0xd1,0x3,0xcb,0xf1,0x76,0x1,0xb6,0xd5,0x4b,0x4b,0x72,0x8d,0xb1,0xc3, -0xd2,0x6,0xa6,0xae,0xc0,0xb6,0x8a,0x70,0x49,0xae,0x69,0x5,0xec,0x7e,0xc0,0x96, -0x9a,0x77,0x49,0xae,0x69,0x25,0xfa,0x66,0xe0,0x34,0xec,0xb5,0x8c,0x50,0x92,0x6b, -0xbc,0xe6,0x6d,0x6,0xbc,0xee,0x7,0x2c,0xc9,0x35,0x66,0x1f,0xb8,0x77,0x17,0x0, -0x0,0x15,0x2f,0x49,0x44,0x41,0x54,0xfe,0x52,0x80,0xc5,0x73,0x1d,0x4d,0x80,0x2f, -0xfb,0x2,0x5f,0xf4,0x5a,0x28,0x29,0xc9,0xb5,0x5e,0x40,0x4d,0xe3,0xb7,0x8e,0xa1, -0x2e,0xd7,0x3a,0x0,0xf3,0xfe,0x52,0xbd,0x8a,0xa1,0x3,0x37,0x6d,0x72,0xad,0x17, -0x30,0xf1,0x9d,0x6d,0xc0,0x55,0x9b,0x5c,0xeb,0x2,0xfc,0x26,0x3,0xc6,0xe1,0x6c, -0x1b,0x70,0xd1,0x26,0xd7,0xfa,0x1,0x8b,0x23,0xd5,0x4,0x70,0x95,0x3,0xaf,0xdb, -0xe4,0x5a,0x7,0x60,0xde,0xe7,0xcd,0xa2,0x62,0x97,0x9c,0x0,0x4e,0x72,0xe0,0x55, -0x9b,0x5c,0xeb,0x0,0xcc,0x3b,0xd9,0xd9,0xac,0x78,0x56,0x68,0x19,0x18,0xb4,0xc9, -0xb5,0xe,0x40,0xd1,0xab,0xff,0xb7,0x61,0xd,0xf0,0x7e,0xd6,0x31,0xc4,0xf,0x56, -0xee,0x78,0xb6,0xc9,0xd6,0x57,0xbe,0x1b,0x41,0x2,0xff,0xae,0x0,0x1e,0x66,0x40, -0x7a,0xd7,0x40,0xfe,0x3c,0xaa,0x8e,0x87,0xa9,0x6c,0x7d,0xe5,0x1b,0x3c,0x10,0xb8, -0xe6,0xcd,0x18,0x15,0xe0,0x2d,0x6b,0x5f,0xce,0x4b,0xda,0xa4,0x76,0xe,0xcc,0xb6, -0xb0,0x20,0x30,0x96,0x4f,0x1c,0x2b,0x4d,0x9a,0x1b,0xd6,0xde,0xf5,0x65,0xc,0xcc, -0x37,0xe9,0xa0,0x59,0x44,0x1,0x5b,0xb9,0x55,0xe0,0x9a,0xb5,0xf7,0xb5,0x19,0x3, -0xf3,0x6d,0x48,0x68,0xf8,0x91,0xc7,0xd6,0xb3,0xc2,0xf0,0xb3,0x5d,0x41,0xd7,0x83, -0x2,0xf3,0x8d,0x56,0xe0,0xda,0x26,0xe,0x5b,0xe0,0x2,0x14,0xd5,0xf7,0x3d,0x4d, -0x7,0x5,0xe6,0x5b,0xc9,0xc0,0x79,0x43,0xf2,0x7c,0x8d,0xdb,0x26,0xa8,0xf2,0xd0, -0xfb,0x17,0x2,0x3c,0x1c,0x70,0x4e,0x43,0xca,0xaf,0x1,0xc2,0x13,0x7c,0xd3,0xd4, -0xba,0xcc,0x81,0x4c,0x2,0x83,0x41,0x81,0x31,0xbb,0xbc,0x48,0xc5,0x35,0xe0,0x13, -0x24,0xaf,0xec,0x65,0x7e,0x4b,0x25,0x90,0xd7,0x94,0x87,0x3,0xe2,0x53,0xb1,0xc4, -0x86,0x47,0xec,0x7d,0x77,0x9e,0xdb,0x24,0x2c,0x1,0x29,0x1b,0x14,0x58,0x6c,0xe9, -0xc4,0x87,0x72,0x5a,0xc7,0xe,0x3e,0x23,0x5a,0x3,0xde,0x32,0x3,0x3b,0x5c,0x2b, -0x67,0x4d,0xb6,0xbc,0x8a,0x5d,0xb2,0xd8,0xe1,0x7f,0xe4,0x54,0x36,0x8f,0x6f,0x98, -0x81,0xa7,0xe9,0x0,0xcc,0xf7,0x1,0x47,0x28,0xa4,0x4e,0xdd,0xca,0xe6,0xf1,0x95, -0x2,0x8c,0x1d,0xea,0x24,0x16,0xa3,0x63,0x9b,0x4f,0xb4,0xc2,0x97,0x76,0x0,0x26, -0xd9,0xb6,0x1a,0xf8,0xcd,0xb2,0x46,0x2e,0x23,0x81,0xe,0x5c,0xab,0x40,0x9b,0xd8, -0x8,0x3c,0xb5,0xf8,0x33,0x2b,0x8a,0x68,0xd1,0x1,0x98,0xed,0xe5,0xc6,0x34,0x31, -0xb2,0x12,0x4f,0x3c,0xfe,0x42,0x1,0x5e,0xab,0x40,0x2b,0xb6,0x46,0x16,0x23,0x23, -0xeb,0x2c,0x3,0x8a,0x0,0xdc,0x1,0x98,0x7,0x2a,0x48,0x13,0x13,0x2b,0xf6,0xb4, -0xc7,0x92,0x23,0xf0,0x4a,0x1,0x2e,0x93,0x25,0x79,0xa,0x77,0x25,0x49,0xc6,0x19, -0x50,0xa4,0x18,0x3d,0x80,0x98,0x26,0x52,0x1b,0x81,0x49,0xa8,0x1,0x7d,0x15,0x48, -0x56,0xf4,0x29,0x3e,0x26,0x9b,0x9e,0x66,0x40,0x91,0x44,0xf5,0x0,0xf2,0x34,0xd1, -0xc6,0x86,0x5b,0xaa,0x2a,0xaf,0x17,0xf2,0x69,0xbe,0x39,0x90,0x6d,0x1c,0x98,0x47, -0x74,0x94,0x3,0x79,0x9a,0xd8,0x7,0x88,0x69,0xe2,0x3c,0xf2,0x53,0x8f,0xb9,0x1a, -0x30,0x2c,0x1,0x13,0x1b,0x6e,0x7a,0x32,0xca,0x66,0xa9,0x48,0x84,0x7b,0x0,0x79, -0x9a,0x78,0x33,0x9,0x0,0xa8,0x96,0x76,0x5f,0x50,0x56,0x6,0x5a,0x60,0xaa,0xf1, -0xd3,0x1c,0xc8,0x53,0xfd,0x1e,0x40,0x9e,0xd3,0xac,0x1,0x18,0x6a,0x83,0xf8,0xe2, -0xb6,0x2,0x1c,0x81,0xd,0x46,0x6c,0x20,0x20,0x7f,0xd0,0x8d,0x3a,0x88,0x2f,0x6e, -0x34,0x60,0x2,0x63,0x48,0xc0,0x70,0xce,0xb,0xe0,0x3f,0xdd,0x5,0x78,0x6d,0x8d, -0xc7,0xec,0x4f,0x4c,0x5,0xae,0x98,0x66,0xf8,0x2b,0x7c,0x8,0x8f,0xcf,0x9c,0x2, -0xe8,0xee,0x2,0xfc,0xda,0xa2,0x6f,0x26,0xae,0x7a,0x8c,0xc3,0x8b,0x45,0x1b,0xd0, -0x1b,0x18,0x78,0xad,0x1,0x1d,0x4,0x52,0x9c,0x59,0xc3,0x8c,0xe1,0x67,0x16,0x7f, -0x26,0x85,0xa,0xbc,0x2a,0x1,0xe9,0x53,0x2,0x49,0x82,0xcf,0xda,0xcd,0x22,0x6d, -0xde,0xfc,0xc8,0xcd,0xe2,0xb9,0xc5,0x62,0x77,0xad,0x7e,0xef,0x8b,0x40,0x9b,0x34, -0x30,0x4f,0x47,0x9,0x9,0xc1,0xc1,0x4f,0x5b,0xd,0xbf,0x5,0xc8,0xd,0xff,0xd0, -0x61,0x49,0x70,0xad,0x7e,0xef,0xdf,0x86,0x3a,0x10,0x9d,0x77,0xcc,0x1f,0x11,0x1a, -0xa,0xe0,0x93,0xad,0xae,0xad,0xd,0x88,0xae,0xd,0xe2,0x6f,0xe2,0x5d,0xab,0x2b, -0xe3,0xff,0xbd,0x4,0x24,0x10,0xa0,0x96,0x2a,0xf0,0x67,0x5b,0x9d,0x77,0xb,0x90, -0x6b,0xfc,0x3,0x97,0xfd,0xe1,0xd7,0x57,0x2a,0xf0,0x6f,0x98,0xe,0xa4,0x10,0x82, -0x35,0xe0,0xe1,0xd6,0xf0,0xd4,0x2,0xe4,0x55,0xc,0x78,0xff,0x71,0xa4,0x1d,0xac, -0xf4,0xdf,0x34,0x60,0x35,0xc5,0xa0,0xdb,0x3,0x70,0xb,0x90,0xd7,0x69,0x20,0xd9, -0xbf,0x3e,0xd6,0x80,0xff,0xb5,0x5,0x98,0x6c,0x4f,0x31,0x5a,0x80,0xbc,0x12,0x5, -0x1,0xff,0xda,0x77,0x94,0x7,0x4e,0xb2,0xff,0xdc,0x2,0xfc,0xfd,0xf6,0x24,0xaa, -0xd,0x88,0xb5,0x36,0xf0,0x21,0xd7,0x57,0x6f,0xa9,0x59,0xcd,0xb4,0x5,0xf8,0xc9, -0xf6,0x34,0x31,0x6d,0x3d,0x94,0x83,0xf1,0x3,0x86,0xbe,0x3a,0x25,0x9e,0x39,0xf0, -0xe1,0xf6,0x44,0x18,0xe6,0x5e,0xbb,0xf7,0x1,0xe3,0xff,0x32,0x4c,0x94,0x2,0xbd, -0xdf,0xc,0xa4,0x27,0x3b,0x2,0xe1,0x6e,0xc6,0xc5,0x43,0x6e,0x59,0x7e,0xa3,0xb6, -0x1,0x49,0xda,0x1f,0x28,0x6e,0x38,0xa4,0x6e,0xc5,0x63,0x7c,0x8b,0x23,0xa3,0xb7, -0x1,0x97,0x3b,0x3,0x67,0x1c,0x58,0x14,0x16,0x5f,0x34,0x3,0x17,0x3b,0x3,0x31, -0xbd,0x88,0xa,0x31,0x73,0xdb,0x2,0xf4,0x77,0x6,0x62,0x7a,0xa1,0x3c,0xff,0x74, -0xd3,0xc,0x4c,0x83,0x9d,0x81,0x98,0x23,0xe2,0xa2,0x85,0x3c,0x5a,0x69,0xd5,0xc, -0x24,0x4d,0x65,0x13,0x43,0xe0,0xc,0xa3,0xa2,0xe5,0x4d,0x70,0x18,0x13,0x7b,0xdd, -0xc,0xdc,0x34,0x15,0x86,0x4c,0x5c,0x1b,0x1a,0x46,0xc8,0xae,0x0,0xc8,0x17,0xcb, -0x62,0xeb,0x5a,0x7,0xa2,0x5c,0xc3,0xbc,0x7b,0x6c,0x53,0xfc,0xf7,0x70,0xd1,0x54, -0xfa,0x32,0x4,0x82,0x77,0xb,0x22,0x90,0xdf,0x38,0x6f,0x22,0x71,0x50,0xa3,0x2e, -0xd7,0x20,0xef,0x6,0xb9,0xc6,0x9f,0xb,0x1f,0x4e,0x9b,0x8a,0x7b,0x86,0x40,0xf0, -0x6e,0x41,0x62,0x1d,0x7a,0x11,0xcb,0x4f,0x86,0xd4,0xe5,0x5a,0x78,0x81,0x72,0x8d, -0xc7,0xc3,0xb3,0xa0,0xa9,0x5e,0x6a,0xa,0x8c,0xd3,0x90,0x5a,0x7,0x1,0xda,0x87, -0x3c,0xfb,0x52,0x97,0x6b,0xa1,0x83,0x72,0x6d,0x84,0x87,0x9e,0x9d,0x86,0x4d,0x15, -0x61,0x53,0x20,0x1,0x7f,0x3c,0x39,0xc2,0x7,0xff,0x66,0x6b,0xc0,0x5b,0x81,0x4f, -0xd9,0xde,0x81,0xa0,0xf,0xcf,0x1c,0xd4,0x87,0x4f,0xf1,0xe,0xfc,0xba,0xb1,0xc8, -0x6e,0xa,0x64,0xaf,0xc3,0x6d,0x7d,0x84,0x99,0x60,0x76,0x60,0xaa,0x2e,0x66,0xc4, -0x3c,0x7d,0x8a,0xe7,0xd3,0x7b,0x8d,0xcb,0x8,0xc6,0x40,0x98,0x2e,0x64,0xc4,0x68, -0x90,0x1f,0x9,0xab,0x3,0xc9,0xdb,0xa8,0xf,0x9f,0x42,0xbc,0xc6,0xa,0x56,0xc3, -0x42,0x89,0x31,0x30,0xe1,0x2d,0x63,0x8,0x74,0xe2,0x1a,0xa0,0xd4,0x87,0x93,0x50, -0x14,0xc3,0x47,0xef,0x92,0x5d,0x81,0x2,0x8a,0x40,0xf7,0xf,0xf5,0x40,0xd0,0x87, -0x9b,0xd7,0x85,0x8e,0xe4,0x87,0x58,0xb3,0x5e,0xaf,0x3a,0x20,0x75,0x26,0x61,0x59, -0x1f,0x26,0x58,0xa3,0x39,0x4f,0xee,0x87,0x6c,0x55,0xc8,0xb5,0xe1,0x80,0x56,0x50, -0x91,0x6b,0x2b,0x94,0x6b,0xc9,0x61,0xc8,0xd7,0x73,0x77,0x38,0x8a,0x52,0x7,0xf2, -0x59,0x2a,0x8f,0xd7,0x2e,0xc9,0xb5,0x15,0xca,0xb5,0xe4,0x18,0x82,0x21,0x5f,0xd0, -0x18,0x6,0x88,0xf,0x7,0xa8,0x7,0xd2,0x70,0x85,0x72,0x2d,0x19,0x87,0x14,0xf, -0x6a,0x24,0x56,0xef,0xb3,0x2f,0x75,0x20,0xba,0xb6,0xec,0xc4,0x72,0x5d,0xae,0x85, -0x2b,0x94,0x6b,0xa8,0xd9,0x30,0x4d,0x8c,0xfa,0x9f,0x7d,0xa9,0x1,0x29,0x3a,0xef, -0xec,0x4c,0x76,0x5d,0xae,0x85,0x2b,0x29,0xd7,0x56,0x98,0x26,0xde,0xeb,0xb8,0x9c, -0xa7,0x68,0x19,0xed,0xac,0xd4,0x54,0x6c,0xed,0xb4,0x2a,0x40,0x8,0x4b,0x2b,0x54, -0x4f,0xa7,0x36,0x5b,0x0,0x30,0x3e,0xe9,0xb8,0x9c,0xa7,0x56,0x31,0xb5,0x76,0xa, -0x79,0x88,0xab,0x5b,0x6,0xa2,0x63,0x43,0xe0,0xd8,0x61,0xb8,0x3b,0xcf,0xe9,0xba, -0x9c,0x97,0xbf,0xb0,0x1c,0xa3,0x9e,0xd0,0xc8,0x53,0xc,0xf9,0xe4,0x80,0xfa,0x14, -0x3,0xec,0x26,0x24,0x7e,0xd7,0xd5,0xb5,0xad,0x40,0x9e,0x44,0xc9,0x67,0x23,0xd4, -0x3,0x41,0x63,0x85,0x93,0xce,0xab,0x6b,0x5b,0x81,0xc2,0x8d,0x8b,0xa7,0x3f,0xd4, -0x3,0x97,0x8c,0x8d,0xdd,0x1e,0x67,0x5f,0x2a,0xc0,0xb8,0x74,0xe0,0x6e,0xf6,0x7c, -0x8b,0x7a,0xe0,0x82,0xb1,0x27,0x61,0x8f,0xb3,0x2f,0x95,0x49,0x53,0x7e,0x5,0xf2, -0x9,0x1e,0xf5,0x40,0x8f,0x57,0xe7,0x1b,0x8e,0xa2,0x24,0x56,0xd8,0x2,0xb4,0xab, -0x4b,0x1a,0xdb,0x81,0xf0,0xaf,0xb8,0xd8,0xd8,0x0,0x4c,0x1a,0xd7,0x4e,0x3a,0x3, -0xc1,0xf5,0x9d,0x87,0x8d,0xcf,0xe5,0x8e,0x9b,0xab,0x26,0x5d,0x81,0x33,0xf0,0x46, -0xcd,0xc0,0xa8,0x7c,0xea,0xf2,0x4e,0xc0,0xd8,0x61,0x51,0x18,0x36,0x2f,0xc1,0x58, -0xee,0x70,0xc0,0xd8,0xa,0x52,0x87,0x35,0x3,0x2d,0xcb,0x19,0xc,0x88,0xc3,0x93, -0x4,0xcd,0xc0,0x96,0x4d,0xac,0x37,0x4c,0x7d,0xa0,0x5e,0xb,0x90,0x4f,0x7,0x9b, -0xdd,0x19,0x90,0xf3,0xb0,0xb6,0x32,0x38,0xb0,0xde,0xf0,0x13,0x3e,0xdd,0x23,0xd6, -0xa,0x3c,0xed,0xc,0xac,0x75,0x6d,0x82,0x97,0xba,0xed,0x40,0xda,0x19,0x58,0xe7, -0xbc,0xe5,0xb9,0xfb,0x71,0xd0,0xa,0xb4,0xd3,0xce,0xc0,0x9a,0xf0,0xf4,0xbf,0xa4, -0x35,0xdb,0x6c,0x67,0xe0,0x4d,0x15,0x58,0x13,0x80,0xe5,0xc1,0xa8,0xc4,0xdf,0x7, -0xf0,0xa4,0x92,0x62,0xe4,0xc5,0xbe,0x9,0x63,0x3b,0x8f,0x61,0x15,0x78,0x5c,0x49, -0xa2,0x32,0x20,0x75,0x4d,0x80,0xa7,0x9d,0x81,0x95,0x34,0x31,0x3,0xca,0x87,0x97, -0xed,0x66,0x87,0x35,0xc0,0x4a,0x22,0x2c,0x81,0x7f,0x76,0xd8,0x7e,0x80,0x95,0x54, -0x5f,0x2,0x89,0x6f,0x0,0x6c,0x71,0xde,0x37,0xc4,0x72,0xeb,0x80,0x93,0x5a,0x60, -0x51,0x11,0x8e,0x6b,0x9e,0x36,0x60,0x14,0x9e,0x6e,0x12,0xcb,0xa9,0x3,0x5a,0x2d, -0xc0,0xa8,0xf6,0x89,0xa,0x6,0x1,0xf8,0x86,0x6d,0x3a,0xdc,0xd2,0x2,0xc8,0xb7, -0xd6,0x38,0x3d,0x52,0x8c,0x1b,0xb5,0x39,0xb1,0x3,0x90,0xa7,0x77,0x76,0x8f,0x24, -0xa,0x80,0xa1,0xf1,0x2c,0x2d,0x80,0xa9,0xd2,0xeb,0xd3,0x2d,0x4d,0xbc,0x61,0xff, -0x23,0xac,0xb7,0x43,0x5e,0x72,0xdf,0x6,0xa4,0xca,0xc1,0xd8,0x5d,0x33,0xef,0x8b, -0xa0,0xde,0xd3,0xc4,0x78,0x67,0xb6,0x1,0x89,0xd2,0x3e,0xd5,0x15,0xf8,0x9f,0xfc, -0x7a,0x5f,0x1a,0xe1,0xd8,0x6f,0x3,0xca,0x84,0xdd,0xef,0x3,0xfc,0x8b,0xab,0xfa, -0x68,0x31,0x4f,0x1b,0x80,0x71,0xed,0x63,0x3f,0xcc,0x80,0xef,0x5c,0xc7,0x38,0x18, -0xa9,0x9c,0x76,0xb8,0x2d,0x82,0xc7,0xc3,0x5,0x6b,0x0,0x46,0x5b,0x1e,0x6d,0x62, -0x0,0x4c,0x9f,0x2d,0x62,0x64,0x88,0x8d,0x79,0x20,0xef,0x2d,0x4b,0x44,0xfc,0x46, -0xe0,0x44,0x3e,0xec,0xab,0x7,0x90,0x3c,0x5b,0xf3,0xe,0x33,0x2f,0xb7,0x21,0x99, -0xd3,0x34,0x2,0x73,0x65,0xd7,0x3,0xc8,0x5d,0x5b,0xd6,0xed,0x8d,0x5e,0x42,0x66, -0x6d,0x3f,0x28,0x60,0x9a,0x3f,0xec,0xab,0x3b,0x50,0x38,0xef,0xec,0x18,0x0,0x74, -0xbc,0x32,0x11,0x6e,0x2,0xe6,0xf,0xa9,0xe9,0x6e,0x88,0x37,0xb7,0x3c,0x1e,0x66, -0x3b,0xa0,0x30,0xb4,0x48,0x60,0x93,0x1d,0x92,0xc,0xe8,0xf7,0x30,0x8b,0x3e,0xc0, -0x64,0xcb,0xf3,0x77,0xcc,0x81,0xd9,0xd9,0x11,0x38,0xd3,0xd,0x80,0xf1,0xd6,0x67, -0xc,0xed,0x0,0xd4,0xa2,0xc5,0x37,0x53,0x21,0xed,0xc4,0x43,0x67,0xc3,0x28,0x7f, -0xea,0xde,0xbe,0x80,0x53,0x57,0x94,0x57,0x82,0x88,0x3,0x27,0x19,0xd0,0xde,0x17, -0xf0,0x33,0x57,0x5e,0x21,0xf7,0xbb,0xa1,0x52,0xd3,0xe9,0x53,0x18,0x5a,0xf2,0x8c, -0x41,0xa6,0x78,0x4e,0x66,0x87,0xda,0x18,0x7e,0xf6,0xc,0x7e,0xb9,0x25,0x94,0x9d, -0xe3,0xdf,0xce,0x94,0xa7,0xee,0xd,0x2,0xe4,0xae,0x4d,0x7,0xfe,0x5b,0xcc,0xbb, -0xc9,0x6d,0xfa,0x17,0xf8,0xb7,0x53,0xa5,0x88,0x34,0x8,0x90,0x3b,0x6f,0x1d,0xf8, -0x2b,0x4,0x9e,0x6e,0x8,0x6e,0x4d,0x67,0xa3,0x2,0xe8,0xf,0x2,0x14,0x72,0x2d, -0x9,0x4b,0x93,0x26,0x3d,0xbd,0xd9,0xf0,0x49,0xf3,0x64,0xeb,0x83,0xb0,0xcc,0x6a, -0x6d,0x76,0x19,0x28,0xe4,0x5a,0xac,0xce,0x52,0xfe,0xeb,0xd1,0x5a,0x64,0x78,0xef, -0x35,0x3c,0xec,0xcb,0x14,0xe8,0x4b,0x20,0x71,0x72,0xb9,0x76,0x51,0x1,0x1e,0xac, -0xc5,0xa4,0x51,0xa,0x81,0x3d,0x22,0xa2,0xe5,0x6f,0x0,0x18,0xf2,0x7b,0x95,0x3a, -0xa9,0x93,0xcb,0x35,0xb7,0x2,0xfc,0xfc,0x5a,0x4c,0x1a,0x5,0x68,0xf7,0x5,0x8a, -0x16,0xe1,0xd4,0x85,0xeb,0x92,0x69,0x22,0xf5,0xa,0xa0,0x7c,0xbe,0xd6,0xff,0xbc, -0x12,0xf,0x85,0x12,0xd3,0x25,0x19,0xe,0xc8,0x13,0x61,0xde,0x5d,0xa3,0x3,0xa3, -0xab,0xd,0xcb,0x81,0xe2,0xb7,0xbe,0xc0,0xb,0xb1,0x73,0x6,0x3e,0x78,0x9e,0xa5, -0xfa,0xbc,0x17,0x53,0x7,0xc6,0x1,0xcb,0x81,0x8e,0x10,0x34,0x83,0x1,0x27,0x9a, -0x1d,0x4a,0x60,0xa2,0x0,0x5d,0x21,0xd9,0x6,0x3,0x5a,0x35,0xc0,0x24,0xf3,0x64, -0xd2,0xe2,0xc9,0xb0,0xb7,0xb4,0xa,0x8c,0x33,0x4f,0x26,0x7d,0x1a,0x1d,0x16,0xa8, -0x46,0x8b,0x9a,0x2b,0x94,0x55,0xe1,0x1,0x67,0x69,0x15,0x98,0x47,0xfc,0xc1,0x81, -0x95,0xb2,0xc9,0xf,0x1,0x28,0x7f,0xb7,0x87,0x73,0x6d,0x9b,0x49,0xd8,0x0,0xb4, -0x45,0x8e,0xd7,0x1f,0x58,0x75,0xde,0xcb,0x49,0xb0,0x4f,0x60,0x35,0x3c,0xcd,0x26, -0x7e,0xd9,0x79,0x2b,0x40,0x57,0xe4,0xe9,0x3,0x1,0x79,0x0,0x9e,0x7f,0x76,0x77, -0x40,0xa1,0xf,0xa7,0x77,0x7,0x14,0xfa,0xb0,0x11,0x98,0xb9,0x9e,0x61,0x80,0x42, -0xae,0x69,0x40,0x77,0x60,0x60,0x4d,0x22,0xac,0xc9,0x35,0x9e,0xb5,0xed,0x19,0xa8, -0x55,0x31,0x78,0x22,0x5c,0x7,0xec,0xf8,0x72,0x1b,0x80,0x7a,0x5e,0xea,0xe,0x3, -0xb4,0x1b,0x80,0x5a,0x25,0x6a,0xa8,0x31,0xdc,0x64,0xc0,0x1a,0x41,0xaa,0xd5,0xda, -0xbe,0x99,0xe,0x7,0xe4,0xbf,0xd6,0x0,0x1b,0xaa,0x89,0x3,0x0,0x6b,0x8a,0xa, -0xa6,0x40,0x5c,0x42,0xe1,0x67,0xdc,0xfb,0xfc,0x14,0x8,0x6a,0x61,0xe9,0xf,0x3f, -0x91,0x3f,0xc8,0x18,0x97,0x54,0x59,0xe4,0x88,0x16,0x88,0x89,0x97,0x3,0x6b,0xca, -0x26,0xcd,0xc0,0xc2,0xd3,0xe0,0x3d,0xb1,0x3c,0x5e,0x5a,0xc2,0x87,0xc7,0x10,0x80, -0xe2,0x68,0xc4,0x16,0x16,0xc8,0x70,0xbf,0x39,0x80,0x6c,0xd1,0xe4,0x61,0xb9,0x8, -0x8c,0xc2,0x4d,0x6d,0x25,0xca,0x10,0x48,0xe1,0x93,0x28,0xfc,0x55,0xec,0x10,0xf3, -0xf8,0x22,0x1c,0xfe,0xd8,0xe0,0x1e,0x61,0x80,0xb0,0x48,0x86,0x5f,0xcf,0xdb,0x58, -0x52,0xcb,0xc9,0x27,0x4d,0x76,0xdc,0x4,0xae,0xe2,0xd4,0xae,0xae,0x6d,0x5,0x12, -0x7e,0xf6,0xa2,0xc3,0x7,0x5,0x9b,0x8c,0x63,0xbe,0x17,0xce,0xc3,0x7e,0xe,0x86, -0xa9,0x16,0xe4,0x6,0xf2,0xf1,0xc3,0xb8,0xbf,0x91,0x1f,0x62,0xc0,0x6f,0xac,0xec, -0xf2,0xc2,0xf6,0xd1,0xda,0xd5,0xb5,0xe9,0xb6,0x78,0x8,0x99,0x15,0xc0,0x6c,0x3e, -0xed,0xf0,0x91,0xe,0x11,0x40,0x71,0xea,0x59,0xfc,0xc,0x65,0x3f,0x15,0xf,0x57, -0xe,0xf0,0x11,0x74,0xf0,0xa5,0x62,0xf4,0x4,0x50,0x6c,0x76,0x76,0xd8,0x6d,0xed, -0xea,0xda,0x56,0x20,0xd6,0x3e,0xf1,0x9d,0x3d,0xb4,0x2,0x2d,0x19,0xde,0xd8,0x93, -0x3,0x20,0x8f,0x8a,0xe7,0x3e,0xa0,0x10,0x81,0x91,0xb2,0x9e,0xf2,0xfd,0x16,0x2, -0x18,0x7b,0x19,0x70,0xeb,0xea,0x5a,0x5d,0x4e,0x13,0x79,0x90,0xa4,0xfb,0x56,0x30, -0x39,0xb1,0x42,0xeb,0xc4,0x4a,0xad,0xb1,0xd,0x79,0x83,0x4d,0x6d,0xe2,0x10,0x3b, -0x71,0x89,0x13,0xbb,0x89,0x1b,0x79,0xb1,0x17,0xe1,0x43,0x43,0x1e,0xf3,0x1d,0x25, -0x2,0xb8,0x58,0x8,0xe0,0x72,0xfb,0xea,0x5a,0x5d,0xd6,0x6,0x9f,0x13,0x44,0x1, -0x1e,0x9d,0xb,0x40,0x6,0x40,0x5c,0x3f,0xa4,0x36,0x6e,0x8,0x1,0xa4,0x4b,0x0, -0x97,0x0,0x2e,0xf6,0xf1,0x79,0x62,0xd1,0x63,0xbe,0x67,0x46,0x0,0xaf,0xd7,0x2, -0x38,0xdb,0xbe,0xba,0x56,0xb,0xc,0xe2,0x20,0xa,0x1,0x9,0xd3,0x1d,0x8c,0x32, -0xb5,0x99,0xd,0xa9,0x98,0x4d,0xdd,0x14,0x70,0xd4,0x25,0x1e,0x20,0x7d,0xe2,0xc5, -0x41,0x2,0x3f,0x59,0xfc,0x98,0xef,0xa,0x92,0x93,0x46,0x2,0xbf,0x68,0x5f,0xb7, -0xf8,0x5e,0x80,0x99,0xb6,0x88,0xc2,0x24,0x80,0xcf,0x8,0xce,0x61,0x70,0x60,0x8e, -0x42,0x9a,0x79,0xe,0xd9,0xad,0xd,0x72,0xd6,0x21,0x5e,0xea,0x12,0x9f,0xba,0x9, -0x88,0xdb,0x38,0x24,0x3e,0x7c,0xe9,0x63,0xde,0xa4,0xaf,0x3,0x6f,0xdb,0x97,0x82, -0x54,0xf5,0xb4,0x3,0xf0,0x5a,0x5,0x4e,0xda,0x80,0x99,0x3e,0x1c,0xa,0x68,0xb5, -0x1,0x33,0x5,0xbc,0x3,0xf0,0x4a,0xbb,0xa5,0xac,0x5,0x98,0x69,0xfc,0xfe,0x40, -0xfe,0x10,0xe9,0xe,0x40,0x59,0xc5,0xe8,0x3f,0x4b,0x79,0x45,0x44,0x0,0x71,0x96, -0xb6,0x2,0x65,0x92,0xd2,0xdf,0xf0,0x6f,0x58,0xe,0xac,0x74,0x41,0x37,0x1,0x7b, -0xbb,0xb6,0x75,0x1,0xac,0xf4,0x79,0x97,0x80,0x4a,0xad,0xad,0xb7,0xf3,0xc6,0xc7, -0x23,0x89,0xd5,0x4d,0xe9,0xbc,0x9b,0x80,0x4a,0x35,0xf1,0xe7,0x7d,0xc3,0x93,0xa, -0xc,0x2a,0x9b,0x3,0x4a,0x40,0xa5,0x5e,0xfa,0x66,0xcf,0x0,0xac,0xa7,0x18,0x95, -0xed,0xf,0x25,0xa0,0x52,0x11,0x7e,0xb7,0x67,0x8a,0xa1,0x3,0x31,0xc5,0x68,0x2, -0x2a,0x35,0xef,0x8f,0x7b,0x26,0x51,0x7a,0xd6,0x86,0x49,0x54,0x13,0x50,0xa9,0xea, -0xdf,0xf6,0x4e,0x13,0xdf,0x17,0xc0,0xd7,0xb2,0x34,0xb1,0x11,0x58,0xac,0x5b,0xdc, -0xf6,0x4c,0x84,0x75,0x20,0x63,0x2d,0xc0,0x62,0x65,0xa6,0x2f,0x50,0x1f,0xc3,0x2a, -0x50,0xec,0xa3,0xcb,0x2a,0xdc,0xca,0xda,0x13,0xe9,0xae,0x9e,0x4,0xf0,0x44,0x2, -0xa9,0x11,0xb0,0x58,0x5d,0xeb,0xb,0x64,0xf,0xc4,0x2,0x4,0x19,0x85,0x26,0xc0, -0x1d,0xd6,0xf,0xb,0xd1,0x96,0xf7,0x51,0xd4,0x1,0x37,0xfc,0x58,0x12,0x7f,0xb1, -0xfb,0xa,0x69,0x6,0x8c,0xd4,0xcc,0xbb,0x15,0xb8,0xc3,0x1a,0x70,0x6,0x94,0xa7, -0xd,0xd0,0xa9,0x11,0x70,0x87,0x55,0xee,0xc,0x28,0x77,0x39,0x53,0x66,0x6,0xec, -0xdf,0x38,0xf0,0x63,0x1,0x1a,0xf6,0x62,0xd0,0x70,0x28,0xa0,0x61,0xb7,0xc9,0x70, -0x40,0xc3,0x7e,0x9a,0xe1,0x80,0x86,0x1d,0x43,0xd,0x40,0xad,0x81,0xa7,0x1d,0x68, -0xd8,0x13,0x35,0x1c,0x30,0x35,0x31,0xc3,0x74,0xdb,0x4f,0x54,0xde,0x91,0x60,0x0, -0x64,0x26,0x8b,0x87,0x83,0x2,0x27,0x6,0x66,0x38,0x28,0x30,0x32,0x31,0x43,0x87, -0xe,0x4,0xb4,0xf6,0xf0,0xa,0x9a,0x80,0xa6,0xaf,0x88,0x76,0x8e,0x26,0xbb,0x1, -0x93,0xbb,0x6,0x92,0xbb,0x6,0xf6,0x78,0xfd,0x90,0x81,0xdc,0x48,0xa6,0xba,0xcb, -0xc2,0xef,0x22,0x4a,0x42,0x3b,0x24,0x30,0xad,0x1,0x7a,0x64,0xf,0x40,0x4c,0xa1, -0xe9,0x7d,0x9f,0x2b,0x28,0x4,0xf2,0xe3,0x2,0x21,0x6c,0x45,0x11,0x4b,0xdd,0xbd, -0x1,0x7f,0x6,0xaa,0xc9,0x65,0x3a,0x70,0x2,0x9e,0x26,0x61,0xc3,0x3,0x9,0xd7, -0x86,0xa0,0xb,0xdf,0x97,0x40,0xf4,0x19,0x3e,0xe3,0xda,0xf0,0x7c,0xb9,0x7,0x60, -0xf2,0x74,0xce,0x92,0xe8,0x92,0xc5,0xb,0x1,0x7c,0xf9,0xd0,0xe7,0xea,0xf7,0xfe, -0xeb,0x1,0x8b,0xe6,0xfc,0x94,0x36,0xda,0x21,0x9d,0xac,0x4f,0xf5,0x35,0xe0,0x66, -0xc5,0x36,0xcb,0x5,0x5b,0x66,0xc0,0x40,0x0,0x1f,0x3e,0x0,0x61,0xea,0xee,0xb, -0xb8,0x5a,0x14,0x57,0x98,0x1,0x4f,0x2,0xdc,0x41,0xb4,0x3f,0x60,0x36,0x86,0x8, -0x9c,0xc1,0x18,0x22,0x10,0xf,0xdb,0x70,0x9,0x9a,0x47,0x67,0xa0,0x2e,0x48,0x7f, -0x10,0xc0,0xcc,0x2c,0x5e,0xfa,0x3e,0xdf,0x88,0x8a,0x40,0x5c,0x8d,0xbf,0x20,0x1c, -0x3a,0x3c,0x10,0xd,0x1f,0xeb,0x33,0xb,0x0,0xe2,0x8a,0x84,0x9f,0x6,0x3c,0xc5, -0x98,0x11,0x1,0x1d,0xe,0xf8,0x1b,0x30,0x8b,0xd9,0x25,0x77,0x6d,0x1c,0x8,0x66, -0x41,0x0,0xe8,0x51,0x1,0x5c,0xc2,0x37,0xcd,0x7,0x5,0xda,0x17,0x30,0xa5,0xc4, -0xd1,0x4f,0x8,0x8c,0xd0,0xcd,0xf1,0xb1,0x13,0xc0,0xd,0x7c,0xd3,0x6a,0x48,0x20, -0x71,0x2e,0xb9,0xa7,0xc9,0xd3,0x8a,0xfb,0x1,0x3f,0x74,0xe1,0x92,0x34,0x7,0xdf, -0xdb,0xe4,0xc3,0x15,0x63,0xe7,0xab,0x97,0x4e,0x47,0x20,0x75,0xa7,0xdc,0x79,0x17, -0x40,0xe1,0x4b,0x17,0x2d,0x57,0x75,0x1b,0xbf,0xbd,0x86,0x8f,0x5f,0xbd,0xb4,0x3a, -0x2,0x7b,0xbe,0xd6,0xcb,0xf5,0x3b,0x0,0x3c,0xfa,0xcd,0xcb,0x71,0xd8,0xf,0x88, -0x75,0xb6,0x4d,0xaa,0xab,0x9b,0xcb,0xd,0x3e,0xf2,0x1b,0xcf,0x4a,0x15,0xe1,0x52, -0xb9,0xf3,0xeb,0xd9,0xfa,0x31,0x4c,0xed,0x71,0xdc,0x1b,0x88,0x95,0xc4,0x65,0xaa, -0xeb,0x37,0x37,0x81,0xe1,0xc4,0x63,0x1a,0xf0,0x11,0xdc,0x8e,0x8c,0xd1,0x12,0xf8, -0xbf,0xd9,0xe3,0x6b,0x10,0x6b,0x7f,0x78,0x79,0xd6,0x19,0x88,0xc7,0x1,0x2e,0x78, -0xad,0x74,0xc6,0xfb,0x6e,0x7c,0x26,0x8e,0xea,0x8,0x52,0x37,0x9,0x53,0x2f,0x82, -0x49,0x3b,0x41,0x7d,0xc7,0xeb,0xb8,0x79,0x42,0x72,0x9b,0xbe,0xcb,0x81,0xff,0xbc, -0x2f,0x70,0xc9,0x5c,0x36,0x67,0x3a,0x10,0x53,0x8c,0x8b,0xb,0xb8,0x52,0x7,0x26, -0x73,0x2,0xc1,0x63,0xa9,0x0,0xe9,0xc7,0x30,0xdb,0x92,0xbf,0xee,0xd,0x5c,0xc1, -0x7b,0xc1,0xbf,0xac,0x0,0x62,0x12,0x35,0x83,0xdb,0xf8,0xef,0x21,0x46,0x9f,0x13, -0x96,0xcc,0xb,0x61,0xb8,0xbe,0x25,0xe4,0xa,0x80,0x1f,0xdd,0x1b,0x1a,0x88,0x6e, -0x2e,0x86,0x48,0x15,0x1,0x70,0xa9,0x2,0x37,0x14,0x80,0xe3,0xe1,0x81,0xd8,0xc4, -0x99,0xc0,0x6f,0xf1,0x29,0x4b,0x12,0x15,0xb8,0x2,0x7f,0x94,0x1e,0x7f,0xf4,0x49, -0xd7,0x59,0x9a,0xf0,0x2,0xbb,0x9b,0x3,0xb1,0x67,0x44,0x16,0xd8,0x39,0x10,0x23, -0x47,0x4,0x57,0x98,0x1c,0xb1,0x4,0xf,0x5d,0x2d,0xc,0xff,0x18,0x1f,0x2b,0xb6, -0xfe,0xa4,0xab,0xe1,0xb7,0x1,0xb3,0x31,0xa4,0x6f,0xb0,0x64,0xfc,0x4b,0x5,0x18, -0x41,0xfc,0x62,0xe7,0xeb,0xce,0xae,0x4d,0x5,0xe2,0x2c,0x55,0x81,0xea,0x2c,0x3d, -0x3,0xb3,0x38,0xb1,0x7,0x70,0xde,0xd4,0x5f,0x81,0x65,0x2f,0xe4,0x9a,0x5,0xc4, -0x42,0x18,0x43,0x74,0x0,0xf3,0x34,0xe0,0xcb,0x7,0x1e,0x18,0xbd,0x1f,0xf1,0x43, -0x91,0xa9,0x41,0xa9,0xcc,0x60,0xd2,0xb8,0x2b,0xf8,0x54,0x1,0xc4,0x2,0x36,0x81, -0x14,0x23,0x39,0x83,0xa8,0xf,0xc0,0x89,0x9d,0x7b,0x9a,0xb4,0xe4,0x69,0x76,0x0, -0x5e,0xc2,0x2c,0x55,0x80,0x14,0x80,0x4,0x80,0x89,0x4,0x6e,0xf1,0xa5,0x3b,0x0, -0x17,0x0,0x9c,0x2e,0x14,0xc9,0x4,0x1,0x18,0x80,0x24,0xed,0x55,0x2d,0xde,0x5b, -0x78,0xda,0x1d,0x48,0x20,0x91,0xd9,0xe8,0xc7,0x3b,0xa3,0x59,0xf0,0xeb,0xb4,0x8, -0xc3,0xff,0x92,0x72,0xcd,0xeb,0x47,0x6,0x4,0xa7,0xb9,0x49,0x82,0xb2,0x20,0x15, -0xc0,0x53,0x46,0x42,0x88,0x16,0xe1,0x72,0x0,0x60,0x92,0x55,0xe9,0x63,0x8,0xc0, -0xe0,0xc7,0x16,0xf2,0x8b,0xd1,0x9b,0xba,0x31,0x7,0xa6,0xd6,0x5b,0x90,0x39,0x46, -0xe0,0xc7,0xcf,0x87,0x0,0x86,0x2,0xba,0x4,0x1f,0x36,0x9f,0x79,0xfc,0x8,0x6b, -0x3c,0x8b,0x1c,0x2d,0xe0,0x7c,0xc6,0x4b,0x93,0xf4,0x18,0xcc,0xc3,0xbb,0x80,0xf7, -0x10,0x76,0x98,0x88,0x68,0xc0,0x56,0x73,0xf0,0xa5,0xf3,0x29,0x3f,0x6e,0x19,0x37, -0x4e,0xe0,0x67,0x47,0x17,0x2,0x78,0xe6,0x8,0x21,0x34,0x88,0x1d,0xe2,0xa6,0x5, -0x4c,0x7c,0x57,0xb,0x0,0x2e,0xa6,0x1c,0x8e,0xd,0xce,0x8,0xce,0xe4,0x5a,0x8, -0xb0,0x48,0x44,0x8d,0x21,0x5c,0x9b,0x68,0x21,0xce,0x80,0x32,0xfe,0x71,0x28,0x46, -0x3c,0xe,0x14,0x41,0x38,0xdb,0xec,0xbe,0x23,0x50,0xde,0xc3,0xc,0x98,0xca,0x2b, -0xe6,0x60,0xaf,0x0,0x76,0xbb,0x42,0xc2,0xab,0xbf,0x51,0x6d,0x19,0x5f,0xde,0xbf, -0xc,0x98,0x5d,0x31,0xde,0xea,0x6c,0xc,0x11,0xd8,0x6d,0xc,0x13,0x5e,0xdf,0x9e, -0xd4,0x2e,0x54,0xc8,0xfb,0xb7,0xbc,0x84,0x59,0xea,0x7a,0xf9,0x8c,0xc1,0xf3,0x2c, -0xb2,0x59,0xa,0xc0,0x8e,0xb3,0xb4,0xe9,0xa,0xe5,0xfd,0x8b,0xef,0x81,0x7a,0xba, -0xe7,0x15,0x33,0xe6,0x9c,0xf1,0xbc,0x34,0xe0,0x9d,0x45,0xdd,0xed,0xb0,0xe1,0x4b, -0xc4,0xa0,0x25,0xf,0x3c,0x16,0xe3,0xb2,0x67,0x36,0x63,0xa2,0xdc,0xd3,0x70,0x60, -0x57,0x4f,0xd3,0xf0,0x12,0xf7,0x90,0x80,0x10,0x4d,0x1e,0x6,0xf2,0x8a,0xf9,0x55, -0x67,0xbe,0x94,0x3,0x3b,0xfa,0xd2,0x48,0x34,0x5d,0xd5,0xa6,0x8,0x99,0x6f,0xc9, -0xbe,0xc5,0x17,0x50,0xba,0x53,0x3c,0x9c,0x88,0xa6,0x2b,0x7b,0x7b,0x5e,0x5a,0xbc, -0xf2,0xbc,0x74,0x17,0x60,0xd3,0x15,0xee,0x27,0x0,0xb7,0xbe,0xca,0xd7,0x29,0xd7, -0x94,0x84,0x59,0x48,0x9f,0x61,0x6f,0x6,0x4,0x2e,0x59,0xe9,0x61,0x7,0x62,0xfe, -0xa6,0x72,0x34,0xc5,0x63,0x79,0xcc,0x67,0x29,0x3f,0x96,0xa6,0xd6,0x17,0x52,0xb0, -0x3d,0x8a,0x59,0x5b,0x28,0xe,0xcb,0x41,0x13,0x9c,0x82,0x59,0x3c,0xb4,0xc4,0x89, -0x59,0xae,0x70,0x3a,0x84,0xbb,0xf,0xf3,0x44,0x98,0x9f,0x93,0x5a,0xeb,0xb,0x79, -0xbd,0xd4,0x5d,0x8,0xdf,0x19,0x8,0xe8,0x34,0xa,0xd9,0x21,0xd6,0x4b,0x8b,0x50, -0xc5,0x81,0x63,0x67,0x80,0x2b,0xe4,0xa9,0xbe,0xb3,0x10,0x97,0xe1,0x89,0x86,0x80, -0x4b,0x98,0xd3,0x7,0x30,0xcd,0x22,0x79,0xd5,0xe7,0x12,0x98,0xba,0x3,0x8c,0x61, -0xf2,0x4,0x2b,0x51,0x8b,0xdc,0x7f,0xe2,0x5d,0x58,0xdc,0x7,0xe0,0x38,0x50,0x43, -0x15,0x97,0xdc,0xa9,0x37,0x4,0x10,0x6b,0x6d,0x58,0x2c,0x9d,0x89,0x1,0x7c,0x89, -0x35,0x1a,0xf0,0x3a,0x7,0x69,0xa0,0x86,0x2a,0x1,0xf4,0x87,0x2,0x62,0xed,0x52, -0x46,0xd8,0x5,0x3e,0x9a,0x43,0x2,0x59,0x36,0x6b,0x5c,0x9,0xc,0x7e,0xb4,0x40, -0x2c,0x96,0xa,0x87,0xcd,0x16,0xe0,0x56,0x97,0x19,0x30,0xcb,0xa8,0x1c,0x39,0x69, -0x6,0x3,0x52,0x71,0x19,0x38,0x55,0x17,0x60,0xfd,0x31,0x2,0xcf,0x64,0x12,0xc3, -0x8f,0xed,0xed,0x6c,0x87,0xd,0xc0,0x70,0x2e,0xe7,0xbb,0xcb,0xb3,0xd1,0x5,0x4e, -0xc9,0x43,0x9f,0x1d,0x8e,0x3,0x7e,0x9a,0x1c,0x4f,0x5a,0xe3,0x21,0x81,0xc1,0x5, -0x40,0x5d,0xe9,0x49,0xa7,0x6c,0x91,0xe0,0xb2,0x10,0x48,0xee,0x23,0xc5,0x8b,0x92, -0x1,0x81,0x24,0xb8,0x84,0xb,0x29,0xe2,0xe1,0x82,0x60,0x6e,0x18,0x2,0x30,0xdc, -0x4f,0xb4,0xa0,0xc1,0x14,0x2e,0xa4,0x88,0x13,0xb,0x34,0x3c,0x6c,0xf,0x3c,0xda, -0x73,0x78,0xba,0xf3,0x78,0x18,0xf3,0xdb,0xa9,0xcf,0xfb,0x89,0x1c,0x43,0x4b,0x9a, -0xc5,0xb0,0x40,0xf8,0xec,0x45,0x52,0x2,0x8e,0xb,0x60,0x58,0x7a,0x54,0xcf,0x8e, -0x63,0xe8,0x73,0x47,0x33,0x7,0x7d,0x28,0x3a,0x2f,0x19,0xef,0xbc,0xb4,0x4,0x10, -0x5b,0x3d,0xd1,0x2d,0x24,0xfe,0xa0,0x40,0x54,0x50,0x33,0x4f,0x5,0xa6,0xf7,0x8f, -0x39,0x90,0x3a,0xb1,0x88,0xfe,0x1e,0x1b,0xcc,0x2c,0x3c,0xf6,0x7b,0x54,0x50,0xa0, -0xf,0x71,0x7f,0x56,0xc4,0x1b,0x59,0xc3,0xf4,0xe4,0x50,0x0,0xff,0x92,0x88,0x83, -0xde,0x1c,0x36,0x94,0xa7,0x81,0xbc,0x14,0x1f,0x86,0xb7,0x4,0x31,0x83,0x5b,0xde, -0x2e,0xc1,0x34,0x70,0x65,0x26,0xb8,0x1f,0x72,0xf5,0xf4,0x84,0x14,0xe9,0xc7,0xee, -0x40,0xc8,0xd7,0x36,0x58,0x2f,0x5,0x27,0x9d,0x0,0x10,0x37,0xf5,0x4d,0x1,0x8a, -0x6b,0x4f,0xc1,0x6f,0x5,0x70,0x74,0xda,0x5d,0x1f,0xb6,0x3,0xe1,0xc7,0x4f,0xdc, -0x12,0x30,0x12,0xc0,0xd3,0xa3,0x42,0x33,0xe,0x7,0x44,0xa7,0x5d,0x6,0xc2,0x25, -0xb9,0x30,0x86,0xe3,0x83,0x22,0x7d,0x1b,0xe,0x98,0xe0,0x99,0xce,0x9e,0x6,0xf4, -0xc0,0xf2,0x2e,0x0,0x78,0x62,0x29,0x95,0x86,0xc1,0x80,0x44,0x74,0x43,0xab,0x40, -0x6c,0x1c,0x98,0x11,0xb9,0x6,0x2c,0xd3,0xb7,0xe1,0x66,0x29,0x6,0x60,0xcb,0x57, -0x81,0xc,0x81,0x4b,0x61,0xf8,0xb2,0x98,0x33,0x84,0x1d,0xca,0xc6,0x81,0x95,0xcc, -0x11,0x95,0x12,0x34,0x98,0x87,0x58,0x3f,0xe4,0x22,0x88,0x30,0xc6,0x86,0xd0,0x16, -0xbc,0x35,0x42,0x91,0xe2,0x2a,0x70,0x3f,0xf1,0xf0,0xae,0x81,0xdf,0x5b,0x3c,0xfc, -0x1e,0x80,0x59,0xe1,0x52,0xbd,0xdf,0x79,0x12,0xc5,0x8b,0xec,0xf7,0xbc,0xbb,0x3, -0xd2,0xae,0xcb,0x8,0xdb,0x27,0x8d,0x9d,0xa9,0x47,0x1,0xc4,0xe7,0xc,0xc6,0x59, -0x5d,0x4d,0x49,0x13,0x4b,0xb,0x96,0xbb,0xd8,0x21,0x63,0xfc,0x29,0x1b,0x12,0x18, -0xbb,0xfc,0xe1,0x4a,0xe2,0xfc,0x51,0x5,0x38,0x4a,0x40,0xd9,0xd,0x61,0xf8,0x89, -0xdc,0xd0,0x91,0x1,0xf9,0x86,0xe,0x47,0x1a,0xbb,0x2,0x4c,0x8,0xa8,0x82,0x21, -0xc,0x3f,0x81,0x94,0x3e,0x21,0x21,0x5f,0x99,0xc1,0x4e,0x85,0x39,0x5c,0xc5,0x25, -0xe8,0xb,0x2c,0xe6,0x89,0xfd,0x32,0xa2,0x12,0x35,0x1c,0x10,0x7c,0x26,0x36,0x30, -0x65,0xc0,0x5,0x7c,0xe8,0x74,0xc5,0x98,0x3f,0xff,0xa9,0x1,0x9,0xa4,0xfb,0x9, -0x8a,0x99,0x2,0xc8,0x2e,0xe0,0xff,0x5f,0xc2,0x18,0x7a,0x30,0x86,0x4f,0x6,0x9b, -0x34,0x12,0x48,0xfd,0x5,0x24,0x9f,0x3a,0x10,0xfb,0x4b,0x65,0x3f,0xd,0xb1,0xa2, -0xa1,0xe4,0x9a,0x4,0xa6,0x0,0xa4,0x25,0x20,0xf6,0x97,0xca,0x7e,0x1a,0x6a,0xcf, -0x7,0x32,0xfc,0x6c,0x49,0x16,0x9b,0xde,0x52,0x5f,0x5b,0x3,0xe6,0xfd,0xa5,0xb2, -0x9f,0x26,0x75,0x16,0x3,0xb9,0xb6,0x1c,0x78,0x57,0xe1,0xe9,0xce,0x81,0x3f,0xe4, -0x7a,0xe9,0xb0,0xfa,0xb0,0xad,0x5e,0x3a,0x98,0x3e,0x54,0x15,0x70,0x49,0xac,0xa4, -0x2e,0x2b,0xca,0x6d,0x83,0xe9,0xc3,0x42,0xb6,0x15,0x7,0x57,0x65,0x2f,0xa5,0x5e, -0x3a,0x9c,0x3e,0xcc,0x3,0xb1,0x5f,0x9c,0xa4,0x9c,0xcf,0x58,0x56,0x54,0xbf,0x6, -0xd3,0x87,0xf9,0xcb,0xcd,0xca,0xb8,0xa5,0xab,0xe,0xb3,0x85,0x9a,0x81,0xf4,0x61, -0xfe,0xba,0xa8,0x5e,0x42,0xbe,0xac,0x17,0xe,0xa8,0xf,0xf3,0xd7,0xac,0x66,0xd6, -0x28,0x6b,0x89,0x83,0xe9,0xc3,0xef,0xf,0x98,0xad,0x3e,0x97,0x6f,0xb3,0x1c,0xdb, -0xc1,0x4,0x69,0x31,0x43,0x6a,0x2e,0x61,0xa6,0x8c,0xed,0x50,0x82,0xb4,0x62,0xe6, -0xba,0x78,0x2c,0xa6,0xe8,0x50,0x82,0x54,0xb3,0xb,0x56,0x2,0x16,0x5,0xda,0xe1, -0x4,0xa9,0x61,0xaa,0x3f,0x9c,0x20,0xfd,0xff,0x49,0xae,0x7d,0xf,0xfa,0xb0,0x7c, -0x38,0x3a,0x46,0xdf,0x73,0x30,0x7,0x47,0x8e,0xa1,0x35,0xb4,0x3e,0x2c,0x1f,0xff, -0x8e,0x40,0xdc,0x16,0x6f,0x2b,0xa2,0x74,0x50,0x60,0xe9,0x80,0xfb,0x22,0xd5,0x17, -0xc0,0x61,0x12,0x61,0xd,0xe8,0x57,0x81,0x7,0x8f,0x18,0x7d,0x74,0x2a,0x80,0xce, -0xd0,0x76,0xf8,0xd2,0x9b,0x56,0x80,0xc7,0xa7,0xa2,0x9a,0x88,0xc0,0xd9,0x90,0x76, -0x88,0xea,0x69,0xe1,0xea,0x86,0xff,0x5a,0xc0,0x38,0x70,0x7c,0x20,0x24,0x77,0x3c, -0x38,0x70,0xae,0x3,0x27,0x12,0x78,0x66,0x9,0x60,0xf2,0x74,0x68,0xe0,0x52,0x7, -0x46,0x12,0x18,0x4a,0x20,0x79,0x3c,0x64,0xd6,0x6,0xfa,0x70,0x9e,0x78,0xe5,0x10, -0x29,0xba,0x2f,0x27,0xf0,0x3b,0x8c,0xe1,0x78,0xc8,0x59,0x8a,0xfa,0xb0,0xfc,0xdc, -0x7,0x12,0xe4,0xfd,0xa5,0x68,0xfc,0xc3,0x9a,0x5,0xea,0xc3,0xb2,0xe1,0x63,0xca, -0xed,0x2d,0xe1,0x9f,0x62,0x2e,0x4a,0x7,0x36,0x7c,0xbf,0xde,0xb5,0x71,0x71,0x2a, -0x37,0x79,0xc,0xec,0xda,0x5e,0x85,0xa7,0x81,0x81,0x24,0xad,0xee,0xb7,0x98,0x14, -0x65,0xb0,0xce,0x3d,0xc2,0x3f,0x42,0xa0,0x33,0xb0,0x59,0x60,0x2b,0x49,0x79,0x47, -0x9,0x3f,0xdb,0xc9,0xe6,0xeb,0x16,0x9d,0x1b,0xcb,0xd,0x24,0x77,0xb6,0xc1,0x43, -0x91,0x16,0x24,0xcc,0x1a,0xcb,0x49,0x18,0x83,0xa7,0x9b,0xd,0x8,0x2c,0xb6,0x3f, -0x28,0x76,0x8f,0x8d,0x74,0xa2,0xb1,0x1c,0xdb,0xe8,0x86,0xea,0xdc,0x33,0x4,0x76, -0xec,0x82,0x7e,0x5,0xbc,0x7b,0x60,0xdd,0x2c,0xdd,0x2b,0x10,0x77,0x76,0x95,0xe2, -0xa1,0x56,0x82,0x1e,0x6c,0xdd,0x22,0xf7,0x34,0xb8,0x9b,0x44,0x8f,0x87,0x3f,0x31, -0xe0,0xab,0x0,0x3c,0x7c,0x0,0x76,0xb1,0x53,0x81,0x95,0x33,0x6f,0x7e,0x4e,0xa9, -0x25,0x3f,0xc8,0x1e,0x12,0x98,0x38,0xe2,0x20,0x31,0x2d,0x3c,0x81,0x95,0xe0,0xd1, -0x5a,0x56,0xc8,0xcf,0x1c,0x33,0xf9,0xb0,0x2e,0xa9,0xbe,0x68,0xda,0xd1,0xbe,0x39, -0x3b,0x59,0xcd,0xaf,0x9b,0xc4,0xbb,0x7a,0x9a,0x4,0x72,0xcf,0xa4,0x54,0x6a,0xbb, -0x84,0x24,0x18,0x80,0x27,0x72,0x2b,0xd4,0x78,0x48,0x20,0x6e,0x2e,0x2e,0x6d,0xc5, -0x4d,0x83,0x5,0xbc,0x45,0x43,0x11,0x61,0xfe,0x40,0xbd,0x89,0xaf,0x80,0xaf,0x80, -0x3b,0x49,0xee,0xad,0x75,0x9a,0x7d,0x44,0x8b,0x9f,0x3e,0xf0,0x55,0x3c,0x7c,0x5, -0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x7c,0x5,0x2c,0x80, -0x7f,0xf,0x8f,0x5b,0x9c,0x1e,0xf,0x3e,0xf1,0xfb,0x0,0x0,0x0,0x0,0x49,0x45, -0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//brd_wiznet.png: 13702 bytes - -/* -const char m1284p_png[] PROGMEM = { -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52, -0x0,0x0,0x4,0xf8,0x0,0x0,0x3,0x3b,0x1,0x3,0x0,0x0,0x0,0xed,0x52,0xbc, -0x4d,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0xa5, -0xd9,0x9f,0xdd,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0x12,0x74,0x0, -0x0,0x12,0x74,0x1,0xde,0x66,0x1f,0x78,0x0,0x0,0x20,0x0,0x49,0x44,0x41,0x54, -0x78,0xda,0xed,0xdd,0x5f,0x8c,0x23,0xc7,0x9d,0x1f,0xf0,0x59,0x4f,0x20,0x26,0xb0, -0xb5,0xf4,0x21,0x2f,0x6,0xbc,0xbb,0xf4,0xc5,0x4f,0x79,0x73,0x5e,0x6e,0x25,0x68, -0xb5,0xb4,0x90,0x7,0x3f,0xfa,0xf1,0x2,0x8,0xd2,0x2a,0x2f,0xf9,0x3,0x45,0x4b, -0x19,0x86,0x96,0xbb,0xe2,0x72,0x7a,0xd6,0x3,0x64,0x1e,0x12,0xdc,0xdc,0x21,0x2f, -0x39,0x48,0xde,0x31,0x70,0x7,0xf8,0xe1,0x60,0xad,0x2,0x45,0xa2,0x6c,0x2e,0xa7, -0x39,0x98,0xb3,0x6,0xc1,0x59,0xe2,0x19,0x4e,0x30,0xb6,0x29,0xb2,0x38,0x37,0x97, -0xa3,0x90,0x11,0xbb,0x38,0x1e,0x2f,0xab,0x67,0x8a,0x5d,0x95,0xfe,0x57,0xfd,0xb7, -0xba,0xd9,0xff,0x48,0xb6,0x70,0x43,0xdc,0x59,0xda,0x9d,0xdd,0x99,0x8f,0xaa,0xbb, -0xab,0xbe,0xfd,0xab,0xea,0xea,0x15,0x9a,0xef,0xcf,0xca,0x85,0xef,0xc2,0xe7,0xfe, -0xf4,0x4b,0xc5,0x5c,0xfb,0x7a,0x12,0xca,0xb5,0xaf,0x3b,0xc9,0xb9,0x8f,0x5e,0xf8, -0xd2,0xf9,0x60,0xce,0x7d,0x60,0x91,0xbe,0xc1,0x5a,0x71,0x73,0x73,0x73,0x5a,0xda, -0x23,0xd7,0xae,0x14,0x89,0x2c,0xcc,0xf6,0x21,0x71,0x91,0x3e,0xd8,0x42,0xb5,0x5a, -0x4d,0xa1,0x2d,0x65,0x34,0x42,0xd3,0x8,0x3f,0xbb,0x7,0x85,0x85,0xfa,0xba,0x58, -0xf5,0x61,0xc3,0x77,0x1e,0xc1,0xd7,0xbf,0x56,0x58,0xac,0x8f,0xaa,0x40,0xb9,0xdc, -0x52,0xe0,0x8,0x11,0xba,0xc0,0x63,0x17,0xd9,0xb7,0xaf,0xb6,0x1f,0xc8,0xaf,0x6f, -0x4f,0x6d,0x3f,0xaa,0xf9,0x3e,0x2d,0x12,0x2a,0xe4,0xcf,0x87,0x71,0xed,0xcd,0x12, -0x68,0x3d,0xd,0x5b,0xd3,0x9b,0x84,0xe6,0xd0,0x57,0x33,0x8f,0x6f,0x9d,0x12,0x25, -0x7f,0x3e,0xbd,0x7f,0xc1,0x62,0x4b,0x91,0x14,0x4a,0xf0,0xec,0xbf,0xd2,0x3e,0x3c, -0x1c,0xb4,0x6f,0x81,0x45,0xf9,0xcc,0xfe,0xf9,0xf9,0x3d,0x72,0xe5,0x69,0x4a,0xc6, -0xe5,0x99,0x7f,0x85,0xf4,0xfb,0x10,0x83,0x85,0xf9,0x62,0x7f,0x94,0x7e,0x1f,0x60, -0x28,0xe6,0xd9,0xb7,0x9b,0x67,0x1f,0x3e,0xec,0xf7,0x31,0xa,0xe8,0x87,0xc6,0xfe, -0x13,0x93,0x90,0xc3,0x8,0xa3,0x7a,0x86,0xbe,0x7e,0x9f,0x4,0xfa,0x10,0xe0,0xf8, -0xfa,0xc9,0x13,0x45,0x52,0xdf,0x79,0xc0,0xb1,0x87,0x9c,0x3,0x5f,0x17,0x2b,0x60, -0x81,0x3e,0xd4,0x57,0x8f,0x6f,0x90,0x6f,0xc0,0xf5,0x41,0xba,0x58,0x5f,0xf,0x2b, -0x41,0xed,0x57,0xf5,0x1f,0xf8,0xe6,0x7c,0x7c,0x2d,0x24,0x15,0x8a,0x9c,0x5b,0x5d, -0x74,0x78,0x78,0x18,0xe4,0x1b,0x94,0x17,0xe7,0xbb,0x81,0x3a,0x93,0xb8,0xb7,0x92, -0xa,0x7d,0xd3,0xff,0x9b,0x7,0x73,0xf1,0x91,0x56,0xf5,0x91,0x14,0xdb,0x7,0xb9, -0xbe,0xb9,0x5c,0x1f,0xad,0x6a,0x5,0xc6,0xf6,0x49,0x9c,0x3,0xf,0xe7,0xd3,0xbf, -0xb4,0x1a,0x15,0x80,0x38,0xe7,0xdf,0x8a,0xfd,0xf1,0x7,0xfd,0x31,0xcf,0x37,0x9f, -0xfe,0xb9,0xf5,0x1,0x4,0xbc,0x52,0x4b,0xa8,0x6f,0x81,0xe3,0x5b,0xeb,0xff,0x40, -0xd0,0x9f,0xa3,0x4f,0xbe,0x1e,0xe1,0xb0,0x7,0xf9,0x56,0xd5,0x1b,0xba,0xff,0x5d, -0x10,0x77,0x38,0xbe,0x92,0xfd,0xaf,0xfb,0x69,0x7c,0xe8,0x0,0x95,0x13,0xfb,0xea, -0xa7,0xb4,0x35,0x84,0xe2,0xda,0x3c,0x7d,0x5d,0x29,0x79,0xfb,0xad,0x1d,0xab,0xfd, -0x33,0xdc,0x29,0xf8,0xaf,0xf,0xe8,0xf0,0x7d,0x54,0x4e,0xe3,0x8b,0x12,0xd2,0x2, -0x7d,0x81,0x41,0xbf,0xe3,0xf0,0xfd,0x3c,0x4d,0x8a,0x96,0x15,0x30,0xf,0xdf,0x23, -0xe7,0xf1,0x4d,0x95,0xf2,0xaf,0xc6,0xf6,0xb5,0x3d,0xbe,0x31,0xe7,0x6f,0xc0,0xcc, -0x7c,0x7d,0x31,0xae,0x6f,0xdd,0x38,0x9f,0x8a,0x44,0x30,0x7c,0x3,0x61,0x2b,0xdc, -0x17,0xe9,0xfc,0x1b,0x6,0xe5,0xa0,0xb8,0x3e,0xb2,0x62,0xfc,0xec,0x55,0xe6,0x1b, -0x92,0x62,0x6,0xed,0x77,0x18,0x14,0xb5,0x85,0x38,0xbe,0x35,0xf5,0x6,0xb3,0x6c, -0x70,0xbe,0x41,0x84,0xba,0xe1,0x93,0xb3,0xf0,0xc9,0x1,0xbf,0x5d,0x8e,0xe5,0x6b, -0xb5,0x94,0xcf,0x69,0xc7,0x48,0x56,0x37,0x85,0x55,0xc3,0x77,0xd8,0xe1,0xf8,0x88, -0x1e,0x9e,0xb1,0x54,0x8e,0x78,0xfd,0x4e,0x53,0xf4,0x42,0x2e,0xdf,0x67,0x6a,0x87, -0xab,0x75,0xb9,0xe5,0xcb,0xe6,0x78,0x3e,0xdc,0x34,0x7d,0x53,0xc1,0xea,0x90,0x2d, -0xdf,0x8,0x58,0xfd,0xdf,0x54,0xf0,0xf7,0xde,0x47,0xf6,0xf,0x29,0x66,0xe1,0xeb, -0x2a,0x54,0xf3,0x6d,0x68,0xbe,0xb6,0xf9,0xf3,0xfe,0xbe,0xd4,0x61,0xc7,0xc2,0xf8, -0xe7,0x86,0x2e,0xb8,0xa3,0x47,0xa9,0x2e,0xb4,0xc6,0xf,0xd9,0x6a,0x21,0xfb,0x84, -0xdd,0xcd,0x64,0x98,0xb1,0x7d,0x43,0x45,0x3d,0x91,0x8f,0xe8,0x25,0xcd,0x37,0x36, -0x7d,0x3,0xc1,0xf4,0x8d,0xcd,0x66,0xb9,0xc4,0xf7,0x8d,0xad,0x56,0x9b,0x5a,0x91, -0x61,0x7d,0xd6,0x5,0xd2,0xd6,0x23,0x46,0x39,0xb2,0xf,0xd3,0x5f,0xd2,0xc1,0xca, -0xec,0x8f,0xc3,0xd7,0x5e,0x89,0xf4,0xb9,0x94,0x85,0xaf,0x8b,0x8a,0xff,0x23,0x62, -0xfb,0xbd,0xa3,0x1f,0xc9,0x66,0x82,0xf6,0x1b,0x8,0x89,0x7d,0x2d,0x48,0xef,0xa9, -0x5d,0xa9,0x7e,0xfe,0xb1,0x6f,0xf3,0xf7,0x65,0xee,0xf9,0xe7,0xf3,0x45,0x3e,0xff, -0x9c,0x23,0x9a,0xfe,0xbb,0x24,0xba,0xf,0x10,0x99,0x5d,0xbf,0xff,0x99,0x5d,0xbf, -0x45,0xff,0xf5,0xab,0xfa,0xfa,0x46,0x4,0x3,0xd6,0xf,0x9e,0x71,0xfd,0xda,0x83, -0x90,0x8,0x12,0xfb,0xd6,0x1e,0x4c,0xbf,0xa2,0xf6,0x7f,0xda,0xad,0xe0,0xcd,0x6b, -0x2,0xac,0xe3,0xbd,0x3d,0x3c,0xdc,0x33,0x7d,0xac,0xec,0xb,0x1d,0xbe,0xb5,0xb2, -0xe5,0x73,0x54,0x85,0xad,0x6,0xb2,0x93,0x23,0xb1,0x7b,0x74,0xb1,0x6f,0xfd,0x97, -0x94,0x4c,0x5f,0x31,0xfa,0xf8,0x36,0x55,0x87,0x5b,0x4d,0xf0,0xcc,0x9a,0xd0,0x79, -0xfe,0xb4,0xd5,0x3a,0x1d,0x8e,0xb9,0x3e,0xdf,0x81,0xb,0xf7,0x39,0x5a,0xd7,0xf6, -0x11,0x68,0xfa,0x4,0xed,0xa4,0xbd,0xb4,0xdb,0x7e,0xa5,0x3c,0x7b,0xfc,0xbd,0x59, -0xd2,0x5,0x7f,0x48,0x84,0x47,0x2f,0x1d,0xb7,0x5a,0xc7,0xc3,0x69,0x31,0x3,0x9f, -0x63,0x7c,0x73,0xf8,0xcc,0xe3,0x7b,0x53,0xeb,0xa,0xb0,0xb0,0x3,0x94,0x68,0xf9, -0x45,0x13,0x14,0x88,0x0,0x5f,0xea,0xb6,0x5a,0x5d,0x2b,0x1f,0xa4,0xf2,0x1d,0x72, -0x7d,0xdb,0xfb,0xac,0x49,0xa2,0xfb,0xda,0x86,0x40,0xcd,0x57,0xf0,0x35,0xdd,0xc7, -0x4e,0xed,0x54,0x3e,0x47,0xbe,0x5a,0xbf,0x66,0xf9,0x2a,0xa6,0xf,0xea,0x3e,0x31, -0x92,0xcf,0x14,0xa8,0x3f,0x3,0xbe,0xd6,0x6c,0xb5,0x9a,0x94,0x4d,0xf5,0xa6,0xf2, -0xb9,0x4e,0x21,0xdf,0xf9,0xa7,0xfb,0x2e,0xed,0xb7,0xeb,0xd1,0x7d,0xda,0x3f,0xde, -0xa8,0xb5,0x5a,0x35,0xfb,0xdb,0xce,0xd5,0x37,0x2d,0x8,0x72,0x9c,0xf6,0xd3,0x7d, -0x97,0x5a,0xad,0x4b,0x72,0x29,0xe3,0xf6,0x73,0x1c,0x5f,0xe8,0x38,0xbe,0x40,0x20, -0x71,0x7d,0xf7,0x70,0xab,0x85,0x31,0xec,0x64,0xdc,0x7e,0x3b,0xbe,0xfe,0x4f,0xbb, -0x3e,0x60,0xc4,0xeb,0xc3,0xe1,0xd3,0xfb,0x67,0x8c,0x1e,0x65,0xeb,0x23,0x6b,0x76, -0x5f,0xb8,0xdf,0x2e,0xd3,0x75,0x7d,0xfc,0x50,0x50,0x6c,0x9f,0xf1,0xc1,0xa8,0x92, -0xad,0xef,0x8c,0x38,0x7c,0xeb,0x45,0xba,0x72,0x53,0xf7,0x61,0xb5,0x7f,0xae,0xe7, -0xc1,0x37,0x24,0xce,0xdc,0x55,0x24,0xee,0xdc,0x16,0xdf,0x37,0xc9,0xf8,0xfa,0x0, -0xdc,0xf6,0x8b,0x53,0x3f,0x70,0xfb,0x9e,0x4,0xf8,0x64,0xf4,0xeb,0x72,0xba,0xeb, -0x37,0x76,0x7e,0xe1,0xfa,0x7e,0x5f,0xe0,0xfb,0xd0,0xf7,0xbb,0x20,0x5d,0xff,0x97, -0x8d,0xf,0x6,0xb4,0x1f,0x7c,0xbf,0xb,0x53,0xfa,0x80,0xdd,0xbf,0x24,0xf6,0x5, -0xf6,0xcf,0xf0,0x49,0x32,0xdf,0xe7,0x6a,0xff,0x22,0xdc,0xbd,0x79,0x59,0xfd,0xd7, -0x6d,0xbb,0x7f,0x26,0xc5,0x4d,0x51,0x48,0xe2,0xb,0x1c,0xdf,0xa4,0x3f,0x4a,0xe6, -0xeb,0xa9,0xfd,0xf3,0xcd,0x6a,0x6f,0x62,0xfb,0xf4,0xf1,0x17,0xd5,0x76,0x68,0xa6, -0x3e,0xd8,0x78,0x31,0x91,0xaf,0xa5,0xe6,0xab,0x9b,0x95,0x91,0xe6,0xbb,0xe5,0xf0, -0x4d,0x94,0x56,0x7e,0x7c,0x2f,0x55,0x46,0xc4,0xe1,0xdb,0x56,0x7d,0x84,0x36,0xb3, -0xf5,0xa1,0xea,0x5b,0x89,0xae,0x5f,0x51,0xf7,0x49,0x6a,0x68,0x26,0xc0,0x6e,0x3f, -0x35,0x44,0x37,0xb2,0xf5,0x25,0xed,0xff,0x34,0xdf,0xab,0x15,0xf8,0x91,0x76,0x4d, -0xd8,0x3e,0xfa,0x11,0xfd,0xab,0x6c,0x7d,0x49,0xc7,0xf,0xd3,0x37,0xb1,0xfb,0x17, -0xed,0xfa,0xa5,0x13,0xfa,0xc3,0x7c,0xf8,0xb4,0xfb,0xf3,0x57,0x8d,0xeb,0xc3,0xd1, -0xff,0x65,0x7f,0x7d,0x24,0xf5,0x69,0x85,0x89,0xaa,0xd1,0xbf,0xb8,0xf2,0x55,0x84, -0xfe,0x45,0xae,0x45,0xf4,0x71,0xe6,0xb7,0xa2,0x8f,0x1f,0xea,0xa7,0x6a,0xf4,0xcf, -0x8e,0x7c,0x10,0xa9,0x7f,0x46,0x8d,0x85,0xf8,0x12,0xe7,0x2b,0x33,0x2a,0x43,0x3a, -0xbe,0x59,0x9a,0x6b,0xfb,0x25,0xcc,0x57,0x68,0xdb,0x14,0xa0,0x1e,0xc,0xf5,0xe9, -0x1f,0x85,0xfb,0x65,0xb7,0xef,0x50,0x19,0x87,0xfa,0xe2,0xe5,0x17,0x73,0xb2,0x53, -0xf5,0x8d,0x78,0xbe,0x43,0xdd,0x0,0x49,0x49,0x6f,0xb3,0x93,0x91,0xf7,0xcb,0xac, -0x88,0x21,0xca,0x77,0x4b,0xa6,0xaf,0x7f,0x16,0xba,0x92,0x36,0xb1,0xf,0xf2,0x7c, -0xfd,0xa9,0xfe,0x55,0xc5,0xf8,0x91,0xd2,0x6b,0xde,0x2f,0xb3,0x5,0x45,0x22,0x32, -0x6b,0x68,0x88,0x8a,0x6f,0x84,0xf9,0xd8,0xfd,0x9b,0x18,0xdf,0xc7,0x3b,0xff,0x44, -0x7d,0xe1,0x3,0xc4,0x13,0xe3,0x4f,0xfd,0xc4,0xfb,0xe5,0xa,0x6b,0x3f,0x68,0xd6, -0x20,0x55,0x9f,0x12,0xb2,0x5a,0xd4,0xba,0x3f,0x57,0x1b,0x50,0x51,0x3e,0xbc,0x59, -0x9c,0xe5,0x1b,0xaf,0x86,0xb6,0x9f,0x38,0x31,0x7c,0x46,0xc5,0x8,0x7e,0xec,0xfd, -0x32,0xb4,0x7c,0x34,0x92,0x8f,0xb2,0xfb,0x73,0xf5,0x4f,0x4f,0xcf,0x1a,0x3d,0x14, -0xb9,0x7f,0x9e,0xe1,0xd3,0xbf,0x11,0xf2,0x9e,0x7f,0xe2,0x67,0xb6,0x4f,0xb0,0x7c, -0xbc,0xd5,0xac,0xc8,0xed,0x2b,0x1b,0xbe,0x2e,0x9e,0xe5,0x3b,0xa5,0xa1,0xd7,0x87, -0x28,0x19,0x3e,0xf3,0xfb,0x7b,0xaf,0x5f,0x71,0x28,0x78,0x7d,0x50,0x54,0x94,0xa0, -0xcb,0xc2,0x31,0xbe,0xa9,0x3e,0xe5,0x8d,0x6,0x9e,0xe9,0x33,0xab,0x9c,0x41,0xfd, -0x8b,0xd8,0xf,0xf7,0x41,0x8e,0xaf,0xce,0xfb,0xa1,0x9b,0x3c,0xdf,0x87,0xb3,0x7d, -0x66,0xa9,0x2f,0xa8,0x7f,0x16,0xbf,0x2d,0x18,0xd7,0x47,0x80,0xaf,0x62,0xf9,0xfa, -0xe6,0x71,0xdc,0xe8,0x2b,0x9c,0x93,0xca,0x2a,0x46,0x8b,0xe,0xdf,0x4f,0xc4,0xaf, -0xcf,0xf6,0x19,0x7,0x18,0x6e,0xf3,0xc7,0xb7,0xbe,0xd1,0xff,0x29,0x12,0xe4,0xfa, -0xfa,0x56,0xfb,0x21,0x73,0xa8,0x47,0xf0,0x50,0x19,0xf8,0xaf,0xf,0x6b,0xa9,0x8e, -0xe0,0xf2,0x75,0x23,0xb7,0x5f,0x80,0xcf,0xea,0x9f,0x8b,0x5c,0xdf,0xe1,0xd8,0xea, -0x9f,0xd7,0x98,0x8f,0xfb,0x3,0xd9,0x9f,0xb3,0xf2,0xa9,0xee,0x8b,0x70,0x7d,0x98, -0xff,0x61,0x41,0xbe,0x4,0xe3,0x1b,0xf7,0xb3,0xc7,0xab,0x5f,0xf5,0x22,0xf4,0x2f, -0xc6,0x1f,0x18,0xf0,0x63,0x44,0x7c,0xdf,0x20,0x60,0x71,0x51,0x91,0x57,0xbf,0xea, -0x45,0xe8,0x9f,0x8d,0xf6,0x6b,0x67,0xe5,0x6b,0xaf,0xac,0x66,0x9b,0xaf,0x8c,0xf3, -0xaf,0xb3,0x4f,0xb3,0xf1,0x75,0x58,0x87,0x1a,0xa1,0xfd,0xa2,0xd5,0x37,0xf4,0xef, -0xd7,0xd9,0x98,0xb3,0x6f,0x3f,0x71,0x7d,0x68,0xcb,0xf4,0xc9,0xcf,0xe1,0xfd,0x4b, -0x68,0xf7,0x50,0x99,0x8b,0xef,0x30,0xa9,0xcf,0x18,0x3f,0x3a,0xdf,0xa4,0xe8,0x37, -0xa7,0x4d,0x38,0x4,0x7d,0xc7,0x12,0xe2,0x81,0x7a,0xae,0x68,0xdf,0x4c,0x3d,0x4b, -0x78,0x3e,0xf3,0xcb,0xda,0x49,0xbc,0xc2,0x4e,0xbb,0xa0,0xf3,0x4f,0x4e,0xea,0x33, -0xff,0x73,0xff,0xa5,0xe6,0x13,0xe0,0x81,0x28,0xbe,0x39,0x17,0x9f,0xbd,0x98,0x23, -0x51,0xfd,0x8f,0xfc,0x47,0x8a,0xce,0x8f,0x5,0x88,0x36,0xc4,0x74,0xed,0x17,0x9c, -0x4b,0x13,0xfa,0x8c,0xfe,0x85,0xfc,0x27,0x2a,0x9f,0x1f,0x7f,0x7,0xa2,0x96,0x88, -0xc2,0xc2,0x79,0xf2,0xe7,0x6c,0x36,0x53,0xe5,0xfb,0xe9,0xe7,0x94,0x7e,0xfd,0xc5, -0xe7,0x20,0x52,0xe6,0xe5,0x1b,0xa6,0xf3,0x49,0x2,0xed,0xbe,0x58,0xd3,0x7c,0x83, -0xf2,0x5c,0x7c,0xe9,0xee,0x8f,0xce,0x24,0x1,0xe9,0xbe,0x96,0x58,0x11,0xd3,0x5d, -0x1f,0x97,0xe6,0xe1,0x3b,0x81,0x65,0xd4,0x6d,0xaa,0xbe,0x66,0xdf,0xf1,0x24,0x47, -0x7e,0x7c,0xa7,0xb0,0x2c,0x3f,0xd7,0xdc,0x84,0x68,0xef,0x30,0x67,0x3e,0xe3,0xfe, -0xed,0x8,0x66,0x96,0xf,0x32,0xf6,0xd1,0x6c,0xf3,0xd5,0x6c,0x5f,0xcc,0xf5,0x43, -0xec,0x2f,0xcd,0xd5,0x7,0x3e,0xb5,0xd7,0xbb,0x24,0xf2,0xc1,0xd9,0xf5,0xb5,0x54, -0xbe,0xae,0xbd,0x62,0x3e,0x91,0x8f,0x66,0xe5,0xa3,0xa7,0x87,0x87,0xb4,0xed,0xed, -0xe2,0x61,0x63,0x84,0x63,0x75,0x92,0x91,0x7d,0x68,0x4f,0x5b,0x91,0x6,0xa7,0x65, -0xa4,0xaf,0x56,0xf3,0xfa,0xf6,0xf6,0xcc,0x5,0x6b,0xe2,0x98,0x2,0xdd,0x75,0xda, -0xef,0xfb,0x1f,0xa4,0x87,0x8d,0x98,0x1d,0x7b,0x64,0xdf,0xb0,0xa5,0x2f,0x3b,0xc1, -0x60,0xa8,0xdf,0xa9,0x78,0x7d,0xad,0x96,0xd9,0x72,0xea,0x8d,0xfa,0xb6,0xee,0x3a, -0xea,0xf7,0xfb,0x3e,0x1f,0xaa,0xce,0xcb,0x77,0xd0,0x6a,0x19,0xbe,0x83,0xbf,0xac, -0x72,0x7d,0x2d,0xcb,0xf7,0xf2,0x9f,0x69,0xae,0xd3,0x59,0x3e,0x54,0x58,0xa5,0x47, -0xf,0xba,0x30,0xa3,0xe3,0xcb,0x7c,0xe8,0xcf,0x1b,0x1c,0x9f,0xa2,0xd8,0xbe,0xfe, -0xbf,0x63,0xbe,0xb6,0xf7,0xfb,0x9c,0x23,0xfb,0x2f,0x4e,0x70,0x9d,0xf6,0x76,0x7e, -0x93,0x9d,0xef,0x81,0xe1,0x6b,0xbe,0x5b,0xe6,0xfa,0x1e,0x58,0x3e,0xa9,0x1d,0xd4, -0x7e,0xe7,0xc8,0xbe,0x3e,0x34,0x9f,0xb8,0xf3,0xdb,0xcc,0xdb,0xaf,0xc9,0x6b,0x3f, -0x8c,0x1d,0xed,0x27,0x5,0x1e,0x5f,0x5,0xdb,0xfd,0xcb,0x84,0x2e,0xd0,0x87,0x50, -0x34,0xdf,0xd4,0xee,0x9f,0x51,0xa9,0x4e,0xff,0x62,0xa7,0x5b,0x59,0x88,0xf,0x42, -0x8e,0xef,0x53,0x10,0xf6,0xa3,0xd1,0xd1,0x2a,0xfd,0xe1,0x83,0xec,0x7c,0x3f,0xd, -0xf3,0x1,0xf0,0x53,0xaf,0xef,0xf0,0xf0,0xef,0xc2,0x7d,0x58,0xa0,0x2d,0xb1,0xfb, -0x28,0xab,0xfe,0xf9,0xe7,0x9a,0x6f,0xfa,0x3c,0xdf,0xf7,0xe0,0xc1,0xcf,0x4d,0xdf, -0x18,0x19,0xbe,0x99,0xf3,0x33,0x93,0x4c,0x7d,0x59,0xd5,0xaf,0x7c,0xbe,0x4e,0x5e, -0x7d,0xa8,0x20,0xd0,0x3d,0x31,0xab,0xfe,0x39,0x7b,0x5f,0xb6,0xe3,0xdb,0x3f,0x4a, -0xdf,0xca,0x45,0xfb,0x5d,0xf8,0xbe,0x38,0xbe,0x76,0xce,0x7d,0xda,0xe3,0x83,0x39, -0xf6,0x11,0xad,0x4a,0x91,0x57,0xdf,0xda,0x1e,0x7d,0xac,0xad,0x2d,0xc8,0xab,0x4f, -0xbd,0x1,0xbb,0xa1,0x4d,0xd9,0xe5,0xd7,0x47,0x1e,0x6b,0x25,0x1b,0xfe,0xfc,0x8c, -0xf3,0xf9,0x23,0xa3,0x50,0xc5,0xfd,0x32,0x75,0x94,0x97,0x33,0xf6,0x75,0x15,0xfa, -0xa1,0xf6,0x4c,0x13,0x7f,0x7e,0xc6,0xf9,0xfc,0x96,0x51,0xed,0x12,0x78,0x5f,0x76, -0x3e,0xbf,0x95,0xb1,0x6f,0xa8,0xd0,0x9f,0x6a,0x3e,0x7e,0xd5,0xc9,0xf9,0xfc,0x9b, -0x51,0xe7,0x2a,0xf3,0xbe,0xec,0x7c,0xfe,0x2d,0x6b,0x1f,0x56,0x7d,0xe3,0x95,0xec, -0x3e,0x85,0x8c,0x8f,0x2f,0x2a,0xfe,0x54,0x9b,0xa3,0xc9,0xac,0xfd,0x68,0xc6,0xd7, -0x7,0x34,0x8e,0x6f,0x66,0xe7,0x5f,0xd6,0x3e,0x40,0x1f,0x6b,0x73,0x13,0x99,0x5d, -0xbf,0x19,0xfb,0xd6,0x1e,0xd0,0xc7,0x31,0x1e,0xd4,0x5d,0xd4,0x3e,0x6d,0xce,0xf1, -0x6d,0x5a,0xde,0xcc,0xb5,0x8f,0xc4,0xd8,0x58,0x77,0x19,0x3e,0xb6,0xfd,0x41,0x6e, -0x7d,0x6d,0x9a,0x6f,0x1f,0xbd,0xf0,0x5d,0xf8,0x2e,0x7c,0x17,0xbe,0xb,0xdf,0x85, -0xef,0xc2,0x77,0xe1,0xcb,0x81,0x6f,0xaa,0xdf,0xec,0xad,0xe6,0xdd,0x27,0x5f,0xdd, -0xc1,0x74,0x33,0xbf,0x3e,0x3c,0x7a,0x78,0x4a,0x6b,0x79,0xf4,0xe9,0xb7,0x7e,0x47, -0x78,0xf4,0xce,0x71,0x2b,0xdf,0x3e,0xdc,0xcd,0xa9,0x6f,0x5f,0xf7,0x7d,0x80,0xbb, -0xdf,0xcf,0x91,0x4f,0x2e,0x15,0x91,0xe9,0x6b,0xaa,0x3e,0xf9,0xea,0x7,0x78,0xf8, -0x5f,0x32,0xf3,0xd,0x56,0x56,0x84,0x74,0x3e,0x2c,0xa1,0xa1,0xc3,0x87,0x95,0x9f, -0xe1,0x21,0xce,0xcc,0xd7,0x9e,0xb9,0x30,0x69,0xa6,0x6f,0x84,0xf,0x3c,0xbe,0x6e, -0x76,0xbe,0xf4,0x1f,0x3c,0x32,0x9e,0x49,0x56,0x7d,0xef,0xe9,0xbe,0xc7,0xb8,0x5b, -0xcd,0xa7,0xef,0x6f,0xe4,0xb2,0xea,0xdb,0xc1,0xad,0xad,0x1c,0xf9,0xe4,0xab,0xb4, -0x6a,0xfa,0x30,0x2,0x47,0x59,0x8f,0x6f,0xe9,0xdb,0x4f,0x21,0xd6,0xf5,0xb,0x61, -0xd6,0xbe,0x5d,0xf8,0x6e,0xda,0xeb,0x43,0x39,0x5f,0x65,0xfd,0x1f,0x40,0x59,0xfb, -0x76,0x86,0xd,0x90,0x2,0x77,0xa2,0xfa,0x8,0x62,0xed,0x47,0x45,0x9c,0xb5,0x4f, -0x78,0xb5,0x91,0xe6,0x25,0x3e,0x3,0xd5,0x47,0x8b,0xf3,0xf4,0x1d,0xa7,0xf3,0xb9, -0x4b,0xfd,0xe5,0xec,0x7d,0xa3,0xb4,0xed,0xe7,0xcc,0x7,0xd9,0xb7,0xdf,0xdd,0xd7, -0xf2,0xed,0x13,0x6e,0xdb,0x3e,0x61,0x75,0x6d,0x90,0xce,0x97,0xfd,0xf5,0xeb,0xf0, -0x11,0x1,0xd7,0x81,0x90,0xc6,0xb7,0x9f,0x7d,0xff,0xb7,0x3,0xaf,0xb3,0xfe,0x45, -0x11,0x50,0x4d,0xfc,0x9f,0x5b,0x71,0x7d,0x6a,0xbe,0xda,0x60,0xfd,0x73,0xf6,0xe3, -0x87,0xa3,0x7f,0xc6,0x2,0xaa,0x8a,0xef,0x5d,0x8f,0xdd,0xbf,0x48,0xe6,0x3,0x27, -0xaa,0x4f,0x1d,0x7f,0xe7,0x37,0xbe,0x61,0x1,0x56,0xc4,0x46,0x35,0xb6,0x6f,0x84, -0x5,0x47,0xbe,0x9a,0x9f,0xf,0x9,0xf0,0x8f,0x13,0xf9,0x68,0xc1,0x91,0xef,0xe7, -0xe7,0x83,0x2,0x7c,0x2e,0x99,0xaf,0xb6,0x90,0xe3,0x3b,0x28,0x83,0x5a,0x2,0x9f, -0x9a,0xaf,0xf0,0xfc,0xae,0xf,0x57,0x5f,0x3,0xea,0xa0,0x1a,0xbf,0xfd,0x14,0xdb, -0x97,0x7d,0xff,0xe2,0xfc,0xd4,0xc0,0xda,0x0,0x25,0xf0,0xe1,0xda,0xfc,0xf2,0x55, -0xda,0x73,0x42,0xcf,0x57,0xd5,0xf9,0x8d,0x6f,0x19,0xf8,0x68,0x71,0x73,0xde,0xbe, -0x69,0x6e,0xf3,0x95,0xf1,0x31,0x9f,0xc5,0x5f,0x99,0xfd,0x50,0xa8,0xbf,0xfd,0xd8, -0xce,0xb4,0xf3,0x6c,0x3f,0xe3,0x59,0x7c,0x12,0xb8,0x3,0x75,0xe8,0xf1,0x45,0xf3, -0xf7,0x6d,0x9a,0x1,0x86,0xd2,0xb3,0xd8,0x3e,0x84,0x3b,0x73,0xcc,0x57,0x6,0xac, -0x94,0x8d,0x6f,0x63,0x4e,0xfd,0x9f,0xb9,0xaa,0x24,0xb5,0xf,0xcd,0x69,0xfc,0x18, -0xd3,0x8c,0x7c,0x73,0x1a,0x7f,0xd9,0x6a,0x2d,0x41,0x7f,0x2e,0x74,0xc5,0x7a,0x48, -0x34,0xae,0xf,0xce,0x29,0xbf,0xf8,0xda,0xcf,0x88,0xfc,0x8f,0x67,0x6c,0x79,0x64, -0xf8,0xc6,0xab,0x73,0xf7,0xf9,0xce,0x3f,0xc3,0xd7,0x4,0xe5,0x8,0x3e,0x4a,0x6d, -0xdf,0x9c,0x8e,0xaf,0xf9,0x6c,0xac,0xd7,0xd7,0x90,0xc4,0x78,0x3e,0x30,0xaf,0x7c, -0x55,0xf4,0xf4,0xcf,0xa6,0x8f,0xc6,0x3c,0xbe,0x60,0x5e,0xf9,0x6a,0x3f,0x85,0x8f, -0xa2,0x8e,0x7e,0x8,0x34,0xdf,0xbc,0xf2,0x95,0xf7,0xbb,0xc6,0xf2,0x75,0x34,0xdf, -0xb4,0x34,0xcf,0xf1,0x6d,0x9c,0xc6,0xa7,0xbf,0x3a,0x41,0x2e,0x2e,0x32,0x5f,0x99, -0x3e,0x18,0xc5,0x37,0x75,0xbc,0xfc,0xa2,0x3c,0xef,0x7c,0x2a,0x1b,0xef,0x1,0x64, -0xfd,0x4b,0x14,0x1f,0xa6,0xf3,0x6f,0x3f,0xfb,0x1e,0xdd,0xd8,0x15,0x2b,0x7e,0xff, -0x3c,0xdf,0xf3,0x8f,0xef,0x8b,0x5a,0x1f,0xb2,0xae,0x5f,0x3a,0xf7,0xfb,0x23,0x8c, -0x12,0xfa,0xa8,0x30,0x9f,0xfa,0x55,0x7a,0x9f,0xb2,0x65,0xf9,0x9a,0x73,0x9f,0xff, -0x90,0x8b,0xd0,0xf6,0xf1,0x97,0x93,0x17,0xbd,0xd7,0x47,0xc3,0xf2,0x89,0x73,0x19, -0x7f,0x15,0x65,0xcf,0xea,0xff,0xb0,0xb1,0xa7,0x23,0x64,0xc3,0xc9,0xac,0xe5,0xee, -0x5a,0xbe,0x6a,0x5a,0xbe,0x1f,0xcf,0x25,0xbf,0x28,0x4a,0xcb,0xda,0x5e,0x12,0x1b, -0x5d,0xa,0x64,0x71,0x81,0xf3,0x19,0x6,0xfb,0xde,0xe2,0xf9,0x48,0x9b,0xa4,0xf3, -0x11,0xbc,0x66,0x75,0x74,0xd8,0x90,0xc6,0xf2,0x61,0xfb,0xfc,0xe3,0x1d,0x5f,0x2, -0xee,0x27,0xf0,0x4d,0xbf,0x2a,0xd8,0x3e,0x1,0xd8,0xfd,0x4b,0x21,0x8d,0x8f,0x77, -0x7d,0x10,0xf0,0x66,0x3a,0x1f,0xad,0xda,0x3e,0x7b,0x7c,0x23,0xc1,0xbe,0x93,0xa3, -0x20,0x1f,0xaf,0x7f,0x21,0xe0,0x4e,0x86,0x3e,0xb2,0xba,0x3e,0x18,0x7c,0xab,0xa8, -0xd,0xab,0x81,0x3e,0xa9,0xc7,0xb9,0x3f,0x17,0x82,0xea,0x57,0xe9,0x7d,0x8f,0x9c, -0x3e,0x45,0x4,0x15,0x2,0x43,0x7d,0xa4,0xc7,0xa9,0x6f,0x8,0x41,0xe3,0x1b,0x69, -0x4b,0x69,0x7d,0xf6,0xf5,0x61,0xfb,0xce,0xa3,0xfa,0xcc,0x4f,0xb0,0xf,0xf4,0x53, -0xfa,0x80,0xdd,0xbf,0xe8,0x3e,0x38,0xc3,0x77,0xc6,0xf3,0x5,0xe6,0x2b,0x9,0xe8, -0x9b,0xb3,0xa4,0xf1,0xd9,0xfd,0xb3,0xea,0x5b,0x3f,0x1a,0x68,0x5b,0x89,0x4f,0xe8, -0x53,0xb1,0xda,0x2f,0xb0,0x3e,0x24,0x1,0x92,0xb2,0xfd,0x5c,0x47,0x63,0x55,0x9c, -0xea,0xc7,0x77,0xbc,0x76,0x9e,0x8d,0xef,0x24,0x5b,0x9f,0x9a,0x99,0x75,0x1f,0x51, -0xa6,0x2,0x29,0xac,0x6e,0x7e,0xc9,0xac,0x8,0xa2,0xbb,0xe5,0x6b,0x5f,0xde,0x85, -0x5,0xdf,0xf5,0xeb,0xf4,0x65,0x97,0xaf,0x2,0x7d,0x48,0xbb,0x3e,0xf6,0xb5,0x5e, -0x9b,0x8,0x6a,0xcf,0x5d,0x63,0xd7,0xb6,0xd4,0xec,0xc3,0x5e,0xff,0x0,0xfa,0xfa, -0x3f,0x87,0x6f,0x2f,0xbb,0x7c,0x15,0xe8,0xc3,0x9a,0x4f,0x9b,0xf0,0x43,0x5e,0xdf, -0x8,0x99,0x3e,0x6f,0xfe,0xa3,0x73,0xb8,0x3f,0xf,0xf4,0x29,0x6a,0xff,0x7c,0xf3, -0x92,0xe5,0x13,0x98,0xaf,0xdf,0x1c,0xd1,0x9d,0xfe,0x1,0xf0,0xfb,0x88,0xe5,0xe3, -0xe6,0x2b,0x73,0x77,0xa7,0x88,0x3e,0x2b,0x34,0x7d,0x95,0x13,0x9d,0x4,0xb6,0xa, -0x52,0xcf,0x51,0x44,0x3f,0xff,0x56,0x4d,0x5f,0xaf,0xab,0xfa,0x76,0x9b,0x40,0x2f, -0x89,0x97,0x9c,0xbe,0xa9,0xe5,0xdb,0xe4,0xe5,0x97,0x98,0xbe,0xb0,0xf6,0xb3,0x7e, -0x8b,0xb5,0x1f,0x14,0xac,0xec,0xf0,0xe9,0xd7,0x55,0x1f,0xd8,0xe0,0xb4,0xdf,0xd8, -0xf2,0x35,0x17,0xe5,0x63,0xe7,0x1f,0xb2,0xcf,0x3f,0xb5,0xfd,0xd0,0x1a,0x68,0x8a, -0x7e,0xdf,0x91,0xe5,0xc3,0xbc,0xe3,0x6b,0xee,0xce,0x96,0xa9,0x4f,0xfb,0x9e,0xd8, -0xed,0xeb,0x1e,0xf7,0xe1,0x1a,0xa8,0x73,0x7c,0xfb,0xb6,0x8f,0x77,0x7d,0xcc,0xc3, -0xa7,0xc7,0x6a,0xb5,0xff,0xc3,0xf6,0xf9,0x77,0xfc,0x59,0xb9,0x54,0x37,0x7c,0x27, -0xc8,0xe5,0xb3,0xe7,0x3f,0xb8,0xf9,0x6a,0x5f,0xfb,0x99,0x73,0xf0,0x11,0xf7,0xf8, -0xa1,0x45,0x56,0xc5,0xcc,0x57,0x5a,0x13,0xb6,0xb1,0x6c,0xf8,0x8c,0xe2,0xa1,0x7e, -0xff,0xeb,0xca,0x57,0x1b,0x87,0x10,0x18,0xbe,0xe9,0x5c,0x7c,0x9e,0xf1,0x57,0x6b, -0x33,0x6c,0x8e,0x6f,0xda,0x7a,0x49,0xf0,0x86,0xb6,0xed,0xe6,0x80,0x15,0x5f,0xfd, -0xf5,0x83,0x7a,0xdf,0x28,0xdf,0xec,0xab,0x51,0x63,0x2e,0xbe,0xe0,0x7c,0x85,0x74, -0x1f,0x34,0xeb,0x1b,0xe6,0x8d,0xa9,0xcf,0x67,0xee,0x14,0x3e,0xaf,0xe3,0x1b,0x92, -0xaf,0xdc,0xbe,0x80,0xf9,0x41,0xc1,0xd8,0x28,0x3e,0x91,0x4f,0x11,0xd2,0xb7,0xdf, -0xed,0xcf,0xc2,0xdb,0x6f,0x4b,0x1c,0x59,0xbe,0x8d,0xc5,0xfb,0xda,0xd2,0x30,0xfc, -0xfc,0x3b,0x11,0xff,0x9f,0xe5,0xab,0xc7,0xf4,0x91,0x95,0xd8,0x3e,0x35,0x5f,0x95, -0xbe,0xbe,0xb,0xb7,0xb4,0xeb,0x57,0x6f,0xbf,0x76,0xc5,0xf0,0x19,0x93,0x77,0xfe, -0xfa,0x95,0x62,0xee,0xf4,0xaf,0xfa,0xd4,0x4f,0xcc,0xf3,0x4f,0x6d,0xbf,0xd7,0x57, -0x63,0xf9,0xd4,0x7c,0x25,0x8d,0xfa,0x7,0x55,0xd6,0xff,0x1,0x60,0xfa,0xcc,0xc9, -0x4f,0xed,0xfe,0x3,0x39,0xfb,0x3f,0xfd,0xfa,0x38,0xd2,0x7d,0xa,0x5d,0x8b,0x7b, -0x7d,0x98,0x9d,0x85,0xfe,0x29,0xa0,0x48,0xbe,0xd1,0x44,0xe9,0x1f,0x8,0x6c,0xfc, -0x0,0xe2,0x23,0xc1,0x39,0xbe,0x69,0xbe,0xa1,0x73,0xfc,0xd0,0xfb,0x97,0x5d,0x7d, -0xfc,0xc0,0x74,0x27,0xa6,0xef,0x81,0x63,0xe1,0x3d,0xc1,0xc3,0x8,0x3e,0x35,0x5f, -0x91,0x87,0xfd,0x83,0xef,0xda,0xbe,0x77,0x5d,0xf9,0x40,0xf7,0x39,0xc7,0x5f,0xbd, -0x7f,0x5e,0x4f,0xe8,0x5b,0x73,0xd5,0x87,0xe,0x22,0xf8,0xd4,0x7c,0x40,0x6e,0xef, -0x36,0xaf,0x7b,0x96,0x1c,0x68,0x97,0x6,0x42,0xc5,0x3d,0xdd,0x77,0xe0,0xc8,0x2f, -0xce,0xea,0xd7,0x6a,0x4a,0x5f,0x94,0xe3,0xab,0xe6,0x2b,0x22,0x81,0x8d,0x2a,0x27, -0x3f,0xa3,0x9,0x6a,0xf9,0x7c,0xc6,0x27,0x9b,0xf6,0x43,0xd1,0xda,0x6f,0x22,0x81, -0x26,0xcf,0x87,0x47,0x78,0x4d,0xf7,0x35,0x7c,0xf9,0x2a,0xe9,0xf9,0xd7,0xd2,0xde, -0xf5,0x19,0xcb,0xa7,0xe6,0x2b,0x49,0x2,0x75,0xbe,0x4f,0xfd,0x9b,0x9a,0x6f,0xc3, -0x97,0xaf,0xf4,0xeb,0x97,0xc6,0xbf,0x7e,0xd5,0x84,0xce,0xd6,0x5d,0x44,0xf4,0x69, -0xf9,0xea,0x2a,0xa8,0x6f,0x71,0xee,0xdf,0x94,0x9e,0xe9,0x43,0xbe,0x7c,0x85,0x74, -0x5f,0xfc,0xfe,0x4f,0xfb,0xab,0xac,0x83,0x51,0x8e,0xa3,0xf8,0x9c,0xf9,0xaa,0xa7, -0xe7,0xab,0xb1,0xe0,0xf3,0xf9,0xee,0x7f,0xd,0x5f,0xec,0xf1,0xc3,0xe5,0x23,0xa7, -0x51,0x7c,0xce,0x7c,0xa5,0x18,0xf9,0x8a,0xb5,0x1f,0x69,0x99,0x3e,0x7f,0xfd,0xc0, -0xf4,0xc5,0x1d,0x7f,0xc9,0x1f,0x3a,0x7c,0xf4,0x9f,0x45,0xf1,0x39,0xc7,0x5f,0xc5, -0x99,0x5f,0x34,0x9f,0x79,0x7d,0x4,0xfa,0x62,0xe7,0x97,0xbe,0xd3,0x17,0x3b,0x5f, -0x61,0xdd,0x37,0xb0,0xee,0xcf,0xd7,0xd4,0xfe,0x85,0x5f,0xbf,0x4a,0xe1,0xc3,0x28, -0x71,0x7e,0xd1,0x7d,0xb7,0x21,0x3b,0xff,0xa8,0xa0,0xf6,0xcf,0x34,0xeb,0xf6,0x9b, -0x16,0x53,0xe6,0x2b,0x2a,0xcc,0xae,0x5f,0xa5,0xf0,0xd1,0xf8,0xf9,0xea,0xcb,0xbb, -0x70,0x53,0xbb,0x7e,0xa1,0x9e,0xaf,0x4,0x61,0x76,0xfd,0x2a,0xa1,0x4f,0xbb,0x3e, -0x62,0xfa,0xb4,0xfa,0x55,0xbd,0x7f,0xa0,0xdf,0x5f,0xee,0xba,0xf2,0x95,0xed,0xdb, -0xf,0xe8,0xff,0x12,0xdc,0x7f,0x24,0xf0,0x79,0xf3,0xd5,0x3b,0xd4,0x5c,0xdf,0xbe, -0x56,0x64,0xf7,0xbf,0xbe,0xf1,0x23,0x1b,0x9f,0x3c,0x58,0x29,0x94,0x22,0xe4,0xab, -0x6b,0xfd,0x83,0xa2,0x2f,0x5f,0x61,0x69,0x27,0xb8,0xbe,0x81,0x92,0xd6,0x5f,0x62, -0xfb,0xb4,0x7c,0x25,0xed,0xaa,0xf9,0xc0,0x9b,0xaf,0xb0,0xd4,0xb2,0x7c,0xbe,0xfc, -0x12,0xc7,0x37,0x2e,0xa7,0xf1,0x69,0xf5,0x2b,0x35,0x5f,0x21,0x5f,0x3e,0xc0,0xd2, -0xe3,0x92,0xe9,0x1b,0xa6,0xf2,0xe9,0xe5,0x6,0xc3,0x37,0x75,0xff,0x69,0xf9,0x88, -0xee,0x47,0x68,0x3f,0xa4,0xe6,0x2b,0x8e,0x6f,0x64,0xbc,0x86,0x2c,0xe8,0xf8,0x46, -0xae,0x9f,0x2,0x68,0x5f,0xbf,0x34,0xb6,0x2f,0x30,0x5f,0xc9,0x57,0x1,0xc,0xac, -0x5f,0xc5,0xf3,0x95,0xed,0xfb,0x37,0x57,0xa5,0x4a,0xf3,0x5d,0x11,0xdc,0xbf,0x3b, -0x16,0x22,0xe6,0x2b,0x6c,0xce,0xb9,0x73,0xeb,0x57,0x49,0x7d,0xae,0xcf,0x99,0xe6, -0xfb,0xba,0xe8,0xf6,0x91,0x99,0xf9,0x8a,0x98,0x3e,0x3c,0x62,0xbe,0x7d,0x5e,0xff, -0x3c,0x7e,0xae,0xae,0x6d,0x53,0x9f,0xc2,0xf7,0x44,0x3f,0xbe,0x33,0x7c,0xfe,0x7c, -0x35,0x35,0x7d,0xe8,0x9,0x8,0x1b,0xdf,0x50,0xf7,0x79,0xba,0x9d,0xca,0xa7,0xf0, -0x7c,0xca,0xcc,0x7c,0x75,0xce,0x7c,0x93,0x52,0xb8,0xef,0xa5,0xda,0xad,0x28,0xbe, -0x76,0x31,0xd4,0x27,0x44,0xf6,0x9d,0x9d,0xea,0x3e,0xed,0x3d,0x8b,0xb3,0xd6,0xb7, -0x1b,0xbe,0x6,0x88,0x36,0xff,0xe1,0xf0,0x9d,0xa7,0xf0,0x19,0xed,0x77,0x7b,0x42, -0x23,0xe5,0x17,0xd4,0x7d,0x2d,0xa1,0x6f,0x8c,0x1c,0xbe,0x6b,0x9e,0xab,0x1a,0xcf, -0xf0,0xb5,0x25,0x29,0x9a,0x6f,0xfc,0xdc,0x6b,0x1d,0x10,0xfb,0xf8,0x4e,0x2f,0xa9, -0x97,0x64,0xd5,0xe1,0xbb,0xca,0xf1,0x29,0xe3,0xa7,0xad,0xe,0x43,0xcb,0x57,0xdd, -0x5d,0x8,0xd9,0xf5,0xb,0xda,0x2f,0xd3,0x48,0xf9,0xa,0xe1,0x37,0xa2,0xf9,0xa8, -0xb6,0x1c,0x97,0x6d,0x40,0xa8,0x39,0x61,0xc3,0xe1,0xfb,0x5a,0xd9,0xfd,0xa,0x19, -0xcd,0x47,0xe0,0x9b,0xb0,0xe7,0xc8,0x57,0x3f,0xec,0x1f,0x74,0x58,0xff,0x7,0xc0, -0xb7,0xa3,0xe5,0x2b,0xd5,0x17,0xf1,0xf8,0x6a,0x6f,0x48,0x95,0x1d,0x6,0x78,0xe0, -0x1e,0x3f,0xa6,0x25,0xcf,0xf8,0xa1,0xf9,0x14,0x3b,0x5f,0x21,0xd3,0x67,0xe6,0x97, -0x1d,0x96,0xaf,0x4,0x10,0x96,0xaf,0x10,0xbe,0x17,0xcd,0x37,0xd5,0xce,0x3f,0x6b, -0x3,0xcc,0x55,0xd5,0x37,0x74,0xfb,0xe4,0xa2,0x77,0x7c,0xbb,0x65,0xfb,0xb4,0xf9, -0xc1,0x97,0xfb,0x7,0x8f,0x7c,0x3e,0x2c,0x89,0xdb,0x61,0xe3,0x2f,0xc2,0xf5,0x5a, -0x24,0xdf,0x29,0x75,0xbc,0x1c,0x50,0x3b,0xc7,0xd5,0xfb,0x5e,0xb3,0xca,0xa4,0xfa, -0xb8,0xd3,0x85,0x62,0xb5,0x82,0xed,0x7c,0x40,0x5f,0xde,0x6d,0x3e,0xe2,0xe4,0x2b, -0xf1,0x56,0x58,0xbe,0x8a,0x3c,0xbe,0x41,0x67,0xfb,0x11,0xc5,0x11,0x14,0x82,0xdb, -0xef,0x75,0xcb,0xa7,0xd5,0xaf,0xfa,0x60,0xa3,0xc2,0xc9,0x57,0x3b,0xec,0xf8,0x22, -0x9e,0x8f,0xb4,0xf5,0x2d,0x42,0x23,0x5e,0xbf,0xec,0xfc,0xe3,0xf9,0x38,0xe7,0x5f, -0xb5,0x82,0x1c,0xf5,0xab,0xcb,0xa0,0x59,0xe0,0xe4,0xab,0xbe,0xe5,0xe3,0x1d,0x5f, -0x2,0xaa,0xd1,0xda,0x4f,0xef,0xff,0xac,0xd,0x44,0x6b,0xda,0x62,0x35,0xb7,0xcf, -0xf3,0xa,0x28,0xcd,0x57,0x79,0x4,0xed,0x7c,0x5,0xfb,0xa0,0xe,0x39,0xf9,0xaa, -0xc7,0x7c,0x90,0x77,0x7d,0x10,0x50,0x89,0xe1,0x23,0x56,0x79,0xb3,0xac,0xbd,0xb8, -0xd4,0xe5,0xf3,0xde,0xa,0x8,0xa,0xaa,0xfc,0xe8,0x5,0x47,0xbe,0xea,0x19,0xbe, -0x13,0xec,0xce,0x57,0x5f,0x66,0x3e,0xc0,0xeb,0x5f,0x8,0x78,0x25,0x9a,0x6f,0x52, -0xf6,0x8c,0xbf,0x10,0xcd,0xf0,0x5,0xe5,0xab,0x53,0xa3,0x7e,0xc5,0xf2,0xd5,0x67, -0xec,0xfe,0x6d,0x83,0xd7,0x3f,0x13,0xfd,0x46,0x34,0x82,0x4f,0x2,0x69,0x7c,0xce, -0x7c,0x65,0xe4,0x3,0xb3,0xbe,0x81,0x11,0xa,0xcd,0x57,0xa4,0x4d,0xa3,0xf9,0xfa, -0xce,0x7c,0x35,0xfd,0xd7,0x31,0x7d,0xce,0xf1,0xf7,0x38,0x96,0xf,0x24,0xf1,0xe1, -0x56,0x72,0xdf,0x99,0xe1,0xd3,0xeb,0x2f,0xb3,0xf3,0x95,0x4,0x60,0x34,0x1f,0xf0, -0xfa,0x66,0x5e,0x1f,0x41,0xed,0xd7,0xd5,0xf3,0x95,0x1c,0x2d,0xbf,0x48,0x20,0xe2, -0xfa,0x3a,0x9f,0x4f,0x2e,0x25,0xf4,0xed,0xc6,0xa9,0x5f,0x9d,0x80,0x71,0x42,0x9f, -0xb7,0x7f,0xe,0xbf,0x3e,0x1c,0xf3,0x83,0x38,0x4e,0xfd,0x2a,0xfa,0xf8,0x6,0xa8, -0xfb,0xfa,0xe0,0xfb,0x84,0xc0,0xfa,0x95,0x35,0x3f,0x88,0x3,0xea,0x57,0x30,0xd5, -0xfd,0x25,0xaf,0xbe,0xc1,0xf1,0x55,0x3,0xeb,0x57,0x48,0xf5,0x21,0xdf,0xfc,0xa0, -0x9a,0xaf,0xd8,0xfd,0x51,0x27,0xd5,0xfd,0x39,0xaf,0x72,0x40,0x5c,0xf5,0x97,0x30, -0x9f,0x96,0xaf,0x24,0x97,0xcf,0xae,0x5f,0xb1,0xfb,0xdf,0x47,0x99,0xd7,0xaf,0xa2, -0xfb,0xb4,0x7c,0xf5,0x70,0xb7,0xd9,0x9,0xab,0x5f,0xc1,0x54,0xf5,0xa1,0x74,0xbe, -0x90,0xfa,0xd5,0x3c,0x7c,0xf2,0xa5,0xa0,0x72,0x60,0x35,0x7e,0xfd,0x8a,0x9d,0x7f, -0x90,0x77,0x7c,0x93,0xd5,0x4f,0x15,0x2a,0x7f,0x83,0xef,0xb3,0xf6,0x3b,0x8b,0x5c, -0xbf,0xfa,0x14,0x86,0xe5,0xab,0x64,0x3e,0x12,0xe8,0x63,0xd,0x1c,0x32,0x3f,0x78, -0xe8,0xce,0x57,0x4f,0xc3,0xb0,0xfe,0x25,0xd9,0xfa,0x1c,0xea,0xf0,0x89,0x57,0x15, -0xd1,0xf7,0x7,0x91,0x10,0x9c,0xaf,0xa0,0x3b,0x5f,0x59,0xf5,0x2b,0xc8,0x9f,0x5f, -0x98,0xa6,0xf4,0xdd,0xfc,0xfc,0xcc,0xe1,0x33,0x5f,0x78,0xe0,0xf5,0x39,0xf3,0x15, -0x70,0xe7,0x97,0x27,0x30,0x7c,0x7e,0xe6,0x3c,0x9d,0x8f,0xb4,0xa6,0x67,0x7f,0x61, -0x2f,0x36,0x1,0xfc,0xf6,0x73,0x8e,0xbf,0x7b,0x6e,0x5f,0x78,0xfd,0x2a,0xfd,0xf1, -0x6d,0x29,0x6f,0xfc,0x10,0x79,0x7d,0xf2,0x8c,0xf5,0xed,0x91,0xf3,0x55,0x6,0xbe, -0xab,0x6f,0xb4,0xec,0x27,0xb6,0x3a,0xb3,0xdb,0xcf,0xa8,0x5f,0x45,0x9e,0x7f,0x8b, -0xbf,0xfe,0xca,0xed,0x7b,0x3c,0xfa,0x89,0xc3,0x17,0x70,0xfe,0xf9,0xeb,0x57,0x84, -0x46,0xf6,0xd5,0xd3,0xb5,0x9f,0xea,0x3,0xbc,0xf3,0x4f,0xab,0x5f,0x21,0x4e,0xbe, -0x32,0xea,0x57,0x75,0x1a,0x71,0x7e,0x90,0x24,0x5a,0x7f,0xa0,0xfb,0xf4,0xdb,0x61, -0xae,0x4f,0x36,0xeb,0x43,0x43,0x4e,0xbe,0x32,0xea,0x57,0x35,0xbf,0x2f,0xa0,0xff, -0x4b,0xb4,0xfe,0x4a,0xf7,0xe9,0xe5,0x84,0xd6,0xa8,0xd7,0x12,0x5d,0x1d,0x9d,0xa3, -0x7e,0x75,0x10,0x98,0xaf,0x1a,0x7e,0x5f,0xc0,0xf8,0x11,0x7f,0xfd,0xb,0xf3,0xe9, -0xe5,0x98,0x9d,0xab,0xbd,0x96,0xdd,0xbf,0xb4,0xcb,0xae,0xfa,0x15,0xa,0xcc,0x57, -0x3f,0xf2,0x5f,0x1f,0x1,0xe3,0x6f,0x1c,0x9f,0xdd,0x19,0x7c,0x63,0xd6,0x8b,0x71, -0xf4,0xfa,0x95,0xa3,0xfe,0x42,0xfb,0xbb,0x4d,0xe8,0x5f,0x7f,0xe5,0xf0,0xf9,0xf2, -0xcb,0x38,0xee,0xfa,0x2b,0xca,0x69,0xbf,0xa0,0xff,0x14,0xbd,0x7e,0x85,0x1c,0xf9, -0xaa,0xf,0x36,0x42,0x9f,0x5f,0xa0,0xbc,0xf5,0xed,0xf1,0xda,0x8f,0x72,0xce,0xbf, -0x40,0x9f,0xa7,0x7e,0x85,0x76,0x40,0x13,0x2c,0xd6,0x37,0x15,0xc2,0x7d,0x95,0x47, -0xc8,0x51,0xbf,0xe2,0xaf,0x6f,0x9f,0xed,0x8b,0x71,0xfd,0x7a,0x7c,0x9e,0xcf,0xdf, -0x95,0x5c,0xf9,0x4f,0xab,0x5f,0x55,0xed,0x7c,0x75,0xed,0x69,0x50,0x2f,0x84,0x3d, -0x3f,0x13,0xe4,0x8b,0xd1,0xff,0x85,0xfb,0xb4,0x99,0x5c,0x71,0x76,0xfd,0xca,0x98, -0x1f,0x54,0x22,0xfb,0x62,0x8c,0x1f,0xb3,0x7d,0x60,0x76,0xfd,0xca,0xc8,0x57,0x67, -0xd1,0x7d,0x1b,0x19,0xfa,0x22,0xd4,0x37,0x7e,0xa5,0xfb,0x9e,0x78,0x7c,0x1,0xfb, -0xb7,0xc7,0xcb,0xf7,0xe1,0x3e,0x10,0xc9,0x77,0xf6,0xb1,0xee,0x53,0x16,0xef,0x1b, -0x6e,0x47,0x6a,0x3f,0x3d,0x1f,0xdc,0x9e,0xbf,0xcf,0x78,0x43,0xfc,0x9e,0x67,0xa5, -0x98,0x18,0xc9,0xd7,0x96,0x3c,0xbe,0xa0,0x4f,0xa,0x9f,0xf1,0x86,0xf8,0xd6,0xe9, -0x30,0x68,0xfc,0xf0,0xd4,0xaf,0x9a,0xbb,0x10,0x4,0xe6,0x2b,0xfa,0x79,0xb1,0x98, -0xb9,0x4f,0x7b,0x43,0xfc,0xda,0xf1,0x81,0x85,0x10,0x3,0x7d,0xda,0xfc,0xe0,0xf3, -0xfd,0x83,0x6d,0x3b,0x5f,0x79,0x7d,0xa3,0x9,0xca,0xd2,0xa7,0xf5,0x69,0xfa,0x1b, -0xe2,0x5,0xfb,0xf8,0x42,0x10,0xe2,0x1b,0x4d,0x5a,0xfd,0x83,0x5b,0x76,0x7e,0x69, -0x2d,0xc2,0x27,0xb5,0x9d,0x3e,0xed,0xfa,0x5d,0x17,0x2,0xeb,0x57,0xce,0xe7,0x7, -0x39,0x3e,0xc4,0xf5,0xc5,0xab,0xbf,0xf8,0x7c,0xc0,0xeb,0x13,0xc4,0xc0,0xfa,0x95, -0xf5,0xfc,0x20,0x2f,0x5f,0x65,0xec,0x93,0x4b,0x2e,0x9f,0x5c,0x9a,0xe1,0xb,0x7e, -0x7e,0xd0,0xbe,0x3e,0x60,0x86,0x3e,0x4,0x99,0x6f,0x4d,0xf3,0x21,0x38,0xbb,0xfd, -0xc2,0xf3,0x15,0x1d,0x51,0x10,0xf2,0xf3,0xe2,0xfa,0xb4,0xe0,0xae,0xf9,0x7e,0x50, -0x6c,0x69,0x3e,0x23,0xc7,0x43,0xf0,0x83,0x62,0x80,0x4f,0xcb,0x57,0x3b,0xa0,0x1e, -0xec,0x23,0xa3,0xd0,0xed,0x8a,0xe2,0xfb,0xb6,0xa9,0xf6,0x86,0xf8,0x1f,0x14,0xf7, -0xc,0xdf,0xb6,0x5e,0xa2,0xfe,0x41,0xd1,0xb8,0x3e,0xa6,0x77,0x39,0xf5,0xab,0x96, -0xe1,0xd3,0xd7,0x77,0xf2,0x7c,0x42,0xc6,0x3e,0xed,0xf3,0x83,0x22,0xef,0x97,0x14, -0x37,0x42,0xea,0x57,0xd8,0x59,0xbf,0xb2,0x3e,0x57,0x9,0xf7,0x95,0x99,0x91,0xd7, -0x5f,0xc5,0xf2,0xd1,0x46,0x48,0xfd,0xa,0x3b,0xeb,0x43,0x33,0x4f,0xf4,0xa8,0xeb, -0xaf,0xd2,0xf9,0x9c,0xe3,0x2f,0x8a,0xe7,0x8b,0xb8,0xfe,0xca,0xfd,0x19,0x14,0x5c, -0x20,0xcf,0x2f,0x29,0xbd,0x23,0xcc,0x7c,0x7e,0x30,0xb2,0xaf,0x1,0x92,0xec,0xff, -0xe2,0x1,0x79,0x7e,0x79,0x6f,0x56,0xfb,0xdd,0x8e,0xec,0x7b,0x6d,0xe,0x3e,0x42, -0x43,0x7c,0x7a,0x7d,0x57,0x8a,0xe8,0x8b,0xbc,0xfe,0x2a,0xd6,0xf1,0x55,0xf4,0xfa, -0xda,0xe3,0xcb,0x4f,0x15,0x39,0xf5,0x2b,0x63,0x7d,0x7b,0x25,0x62,0xfb,0x45,0x5e, -0x7f,0xe5,0xb9,0x40,0xdc,0x20,0xcf,0x2f,0xe5,0x67,0xb4,0xfe,0xef,0xa5,0x9,0xa1, -0x9c,0xfa,0x95,0xee,0x3,0xd1,0x7d,0x89,0x8e,0xef,0xb6,0x1b,0xe4,0xf9,0xa5,0x31, -0x7e,0xb8,0x7c,0xa3,0x89,0xe9,0x33,0xf3,0xcb,0xa3,0xa8,0xbe,0x7b,0x49,0x7c,0x44, -0x70,0x81,0x3c,0xbf,0xf4,0xfb,0xb4,0xf5,0xed,0x92,0xcb,0xf7,0x6e,0xb4,0xfb,0x8f, -0xc8,0xeb,0xaf,0xdc,0x9f,0x33,0xba,0xae,0x7f,0xc3,0x2f,0x19,0x9b,0x6e,0xb9,0x7f, -0x69,0xd6,0xaf,0xc8,0xe7,0x97,0x9f,0x2a,0xd9,0xf9,0x80,0xbf,0xbe,0xdd,0xe3,0xcb, -0xea,0xfd,0x5b,0xc8,0x75,0xc1,0x42,0x44,0x39,0xed,0x47,0x9e,0xee,0x13,0x47,0xbe, -0xa,0x7a,0x7e,0xd0,0xe5,0xf3,0xbd,0x7f,0x8b,0xb4,0xe5,0x24,0x3e,0xf7,0x5,0xb, -0x7d,0xfd,0xb3,0xee,0x1b,0x49,0xc4,0x91,0xaf,0x82,0x9e,0x1f,0x74,0xd5,0xf,0x7c, -0xef,0xdf,0x22,0xa0,0x2a,0xd0,0xb4,0xfd,0x1f,0xa4,0xbc,0xf6,0x53,0x9e,0xd8,0xbe, -0x90,0xe7,0x7,0xbd,0x3e,0xf7,0xfb,0xb7,0x62,0xac,0xbf,0x8a,0xe1,0x9b,0xbe,0xae, -0xd5,0xef,0x9f,0x4c,0x9e,0x72,0xe6,0x2b,0x73,0x7e,0x30,0xd0,0xc7,0x7d,0xff,0x56, -0x42,0x1f,0x2e,0xb9,0x7c,0xee,0x5f,0xaa,0x5f,0xde,0x9,0xae,0x5f,0xb9,0x7d,0x72, -0x69,0xad,0x64,0xfa,0xb8,0xef,0xdf,0x22,0xe0,0x3f,0x24,0xba,0x3e,0x2a,0xee,0xeb, -0xa3,0xe2,0x39,0xbe,0x3b,0xc1,0xf5,0x2b,0xb7,0xf,0x4b,0x2d,0xe8,0xf0,0xf9,0xde, -0xbf,0x45,0xda,0xc3,0x24,0xe7,0x1f,0xac,0xba,0x7c,0xee,0x5f,0x52,0xed,0x9,0xd7, -0x88,0xfb,0xaf,0x71,0x7c,0xae,0xf7,0x6f,0x91,0xa8,0xeb,0x9b,0xe2,0xf9,0xea,0xd1, -0x7d,0x22,0xf3,0x71,0xdf,0xbf,0x25,0x25,0xf4,0x21,0xb7,0xf,0x25,0xf6,0x8d,0x0, -0x3b,0xff,0xb8,0xef,0xdf,0x9a,0x8f,0x8f,0xe0,0xa8,0xbe,0xd0,0xe7,0x67,0x68,0x8c, -0xf5,0x57,0x7c,0xdf,0x4a,0x11,0x43,0x8e,0x4f,0xd1,0x7d,0x8d,0x4f,0xd7,0xca,0x33, -0xdb,0x2f,0xec,0xf9,0x99,0x14,0xe3,0x9b,0x71,0xb3,0x4f,0xbe,0x64,0xf8,0xcc,0x5f, -0xda,0xf9,0xea,0x39,0xcd,0xf7,0xc7,0xdd,0x16,0x98,0xe9,0xb,0x7b,0x7e,0x26,0xb9, -0xcf,0x28,0x68,0x50,0xa5,0xd6,0xed,0x6a,0x3e,0xb9,0xc4,0xab,0xff,0xbd,0xd8,0xe8, -0xc2,0x99,0xbe,0xb0,0xf5,0x7,0xc9,0x7d,0xec,0x63,0xfa,0xf8,0xf5,0xc9,0x17,0x1b, -0x78,0xf6,0xf5,0x11,0xb6,0xfe,0x20,0x5d,0xfd,0xca,0xf0,0xfd,0xba,0x68,0xf9,0xdc, -0x5b,0x8a,0xa,0xe4,0x78,0xa6,0x6f,0xf6,0xfb,0x21,0x52,0xfb,0x1c,0xed,0x47,0xdc, -0xed,0x47,0x9e,0xae,0xce,0x6e,0x3f,0x67,0x3e,0x10,0x17,0xec,0x1b,0x55,0x67,0x9f, -0x7f,0xb3,0x7c,0x29,0xea,0xa7,0xb3,0x7c,0xca,0x4,0xcf,0xbe,0x7e,0x9d,0x3e,0xde, -0xf5,0x9b,0xda,0xf7,0x16,0xcf,0xa7,0xd7,0xaf,0x94,0xc9,0x94,0xd7,0xff,0x9d,0x4, -0xe6,0xab,0xf4,0xfb,0x5f,0xf9,0x3e,0xf7,0x6f,0xbc,0xc8,0xf3,0xe1,0x90,0xfa,0x8b, -0x44,0xc7,0xf7,0x9f,0xc7,0xbc,0x7c,0xe5,0x1c,0x3f,0x84,0xdb,0xc6,0x7b,0xb9,0xe2, -0xad,0xbf,0xa,0x1a,0x4d,0x7c,0xc7,0x37,0xac,0x3e,0x44,0x61,0xb3,0x87,0x78,0xf9, -0xc5,0xb9,0xfe,0xe0,0xe6,0x6b,0xa8,0x6e,0xf8,0xce,0x17,0xef,0x6b,0x18,0x63,0x6, -0x27,0x5f,0x39,0x7c,0xc6,0xcd,0x69,0xca,0xe3,0x1b,0xe4,0xbb,0x1b,0x32,0x3f,0xa8, -0xe,0x87,0xa,0xe0,0xe4,0x2b,0xd7,0xfb,0xb7,0x5e,0x7a,0x8d,0xa4,0xf7,0xad,0x9b, -0x3b,0x4e,0xfb,0x7d,0xd5,0xb0,0xf6,0x3b,0x41,0x8a,0xe8,0xc8,0x57,0xdc,0xe3,0xfb, -0xd2,0xed,0x9b,0x96,0x6f,0x23,0x73,0x1f,0x9,0x5b,0x7f,0x45,0xc9,0x75,0xe5,0x96, -0x23,0x5f,0x1,0xde,0xf5,0xf1,0x6a,0xe5,0x23,0xcb,0x57,0xcf,0xdc,0x67,0xd4,0xaf, -0xc4,0x6b,0xd8,0xaa,0x29,0xbf,0x2b,0xa3,0x4e,0xa1,0xa0,0xef,0x2f,0xaa,0x9e,0x9d, -0x53,0xe8,0xc8,0x57,0x22,0x2f,0x5f,0xbd,0x5a,0xb1,0xce,0xbf,0x44,0xeb,0xf,0x5c, -0xbe,0x7d,0xaf,0xcf,0xa8,0x5f,0xbd,0x2c,0xd5,0xac,0x5b,0xd9,0x4a,0xb5,0xda,0xa8, -0xd5,0xf4,0xe7,0x7b,0xdc,0xd7,0x87,0xb9,0xa7,0xb5,0x37,0x5f,0xbd,0xaa,0x5d,0x1f, -0xb1,0xf7,0xbf,0xa,0xf0,0x6d,0x70,0xc7,0xf,0xfa,0xd2,0xa4,0x59,0xb7,0x7c,0x95, -0x46,0xd5,0xf0,0x51,0x77,0xff,0x82,0x26,0xdc,0xf1,0xad,0xaa,0xf5,0x2f,0xbb,0xc9, -0xd7,0xbf,0xb8,0x7c,0x97,0x2,0x7c,0xc4,0xf2,0x11,0x8,0x27,0xb8,0x56,0x33,0xe6, -0x67,0x9c,0xfd,0x33,0x46,0xbf,0x2f,0x72,0x7d,0x5a,0xff,0xbc,0x9e,0xdc,0xd7,0xe6, -0x2d,0xb9,0x32,0x2a,0xb2,0x56,0xbe,0x1a,0x7d,0xd4,0xb5,0x7c,0x63,0xf8,0x4,0x17, -0x56,0x9d,0xf3,0x83,0xa1,0xf9,0x2a,0xe1,0xfe,0x57,0xf6,0x7,0x70,0xda,0xcf,0xbe, -0x15,0x37,0xf3,0xd5,0xe4,0xd8,0xf2,0xd1,0xca,0xef,0xb0,0x50,0x3,0xf1,0xf2,0x4b, -0x8a,0xf6,0x3,0x9c,0xf3,0xcf,0xeb,0x1b,0x39,0x7c,0xb0,0xd2,0xa8,0x9,0x35,0x31, -0x9e,0x6f,0x37,0x23,0xdf,0x3e,0xd7,0xa7,0x4c,0xa4,0xd3,0x9a,0xe5,0xab,0x56,0x9b, -0xb3,0x7c,0xbe,0x7c,0x75,0x94,0x7c,0xfd,0x95,0xcb,0x47,0xf9,0x3e,0xe4,0xe8,0xff, -0x5e,0x97,0xd1,0x81,0x50,0x10,0xc3,0xf2,0xd5,0x46,0xfa,0xfd,0xaf,0x62,0xf9,0x5c, -0xbf,0x2b,0x98,0x5f,0xd0,0xfa,0x67,0x38,0xda,0xd5,0x1f,0x4a,0x35,0x9f,0x9f,0x61, -0xfd,0x33,0xa,0x7a,0x3e,0xa0,0xbe,0x0,0x9f,0x68,0x8e,0x32,0xda,0xf8,0x36,0xfc, -0x78,0xc7,0xd8,0x3c,0xd4,0xc8,0x7,0x65,0xe6,0xb,0x7a,0xbe,0x62,0x23,0xa9,0x2f, -0xa0,0x34,0xcd,0xf3,0x39,0xc7,0x5f,0xd5,0x67,0xc,0xba,0xc6,0xf3,0x3d,0xac,0xfd, -0xb8,0xcf,0xa7,0x24,0xcd,0xf7,0xc9,0x7d,0xa,0x3d,0xfe,0x89,0xe8,0xf0,0x89,0x73, -0xf5,0x29,0xa4,0x94,0xc0,0xb7,0x6f,0xfb,0x46,0xc0,0xf2,0xa5,0x7f,0x7e,0x86,0xe3, -0x53,0x60,0x4c,0x1f,0xa6,0xa3,0xd7,0x64,0xcb,0xa7,0xe6,0x2b,0xe6,0x3,0xe9,0x9f, -0x9f,0x49,0xec,0x3b,0xc7,0xaf,0xcb,0xb0,0x50,0xd0,0xea,0xe3,0x48,0xf5,0x11,0xbb, -0xfd,0xec,0x7c,0x5,0xd2,0xef,0x2f,0xc5,0xf1,0xd1,0x48,0xbe,0xc9,0xf7,0xd5,0x80, -0x55,0xab,0x69,0xf3,0xb,0x3,0xd5,0xe7,0xb8,0x3e,0x30,0xb4,0x7c,0xe9,0xf7,0xe7, -0x4a,0xe3,0x53,0x7,0xb8,0x9a,0xb1,0xff,0x95,0x34,0x72,0xf4,0x2f,0xc8,0x7a,0x7f, -0x72,0x6,0xfb,0x9b,0xf1,0x7c,0x20,0x8a,0x4f,0xfa,0xab,0xa,0x6c,0xd6,0x6a,0xdf, -0x35,0x7d,0x76,0xff,0x3c,0xcb,0x97,0xb4,0xfe,0x62,0xfb,0xc4,0x68,0xbe,0xd7,0x61, -0xb3,0xb0,0x7a,0x3d,0x6a,0xbe,0xca,0xd0,0x27,0x44,0xf3,0x9,0x15,0x35,0x1f,0x54, -0xe3,0xe5,0x97,0x2c,0x7c,0x84,0x46,0x3c,0xbe,0xc9,0x7c,0x49,0xeb,0xa7,0xcc,0x37, -0xfd,0x27,0x91,0xc6,0x5f,0xa9,0x5b,0xa9,0xd6,0x66,0xf9,0x52,0x3d,0x9f,0x1c,0x6b, -0x7c,0x23,0xde,0xfd,0xaf,0x26,0x5d,0x35,0x60,0x9,0x7a,0xff,0x87,0xa3,0xd7,0xaf, -0xe6,0xe6,0x9b,0xf2,0xf6,0x97,0x32,0xf3,0xd5,0x29,0x85,0xb0,0xb0,0xb,0x66,0xd4, -0xaf,0xd8,0xdf,0x4a,0xb8,0xfe,0x6a,0x86,0xef,0xdc,0xeb,0xc3,0xd4,0xca,0x57,0xc7, -0x74,0xf8,0x9,0xde,0x1,0xfe,0xfa,0x90,0xc8,0xdd,0xff,0x25,0xd9,0xfa,0xab,0x59, -0xc7,0x57,0x9,0x1b,0x7f,0x87,0x1f,0x2b,0x3c,0xdf,0x8f,0x79,0xf9,0x25,0xee,0xfa, -0xab,0xed,0xc,0x7c,0xc7,0x3f,0x51,0x44,0x8e,0xef,0xad,0x0,0x5f,0x9c,0xf5,0x25, -0x56,0x9a,0x4a,0xe9,0xdb,0xb7,0xf3,0x55,0x8f,0x5b,0xbf,0xb2,0x7d,0xb1,0xd6,0x5f, -0xc9,0x42,0x34,0x1f,0xe,0xcf,0x57,0x8a,0x6c,0xe7,0x2b,0xdb,0xc7,0xbf,0x3e,0x62, -0xad,0xbf,0x1a,0xd3,0x64,0xbe,0x73,0xbc,0xbf,0xf7,0xa8,0x50,0xd8,0x64,0x3e,0x62, -0xe7,0xab,0xa7,0x43,0xf7,0xd7,0x8b,0xb9,0xfe,0x6a,0x8f,0xfd,0x8b,0x35,0x47,0x6b, -0xdd,0x2e,0x6a,0xfb,0xe7,0xc8,0x41,0xbe,0xc9,0xf7,0x9b,0x2d,0x35,0xbf,0x88,0xcc, -0x67,0x5f,0x1f,0x33,0xf6,0xd7,0x8b,0xb9,0xfe,0xca,0x62,0x15,0x7c,0x7d,0xac,0xb6, -0xff,0xd0,0x58,0x8,0xcc,0x57,0xf5,0x96,0x9d,0xaf,0x24,0x47,0xff,0x32,0xe3,0xf9, -0xe4,0x78,0xeb,0xaf,0xac,0xcb,0x83,0x58,0x2b,0xa5,0xda,0xcc,0xa1,0xed,0xdf,0xa4, -0x3d,0xbd,0x1a,0x30,0xfe,0xd6,0x45,0x35,0x5f,0x19,0xfb,0x8b,0x4a,0x8e,0xfe,0x79, -0xe6,0xfe,0x7a,0xb1,0xd6,0x5f,0x91,0x95,0xe8,0x1f,0xaf,0x6f,0x4f,0xcd,0x57,0xae, -0xf5,0x57,0x91,0xf2,0x55,0xbc,0xf1,0x2d,0x4d,0xfb,0x29,0x6a,0x7e,0x41,0xb1,0xf3, -0xb,0x69,0xf,0x4,0x3a,0xff,0xf3,0x4f,0xf5,0xb5,0x92,0xf9,0x80,0x10,0xc7,0xb7, -0x1f,0xed,0xfa,0xe5,0xe4,0xab,0x66,0xab,0x99,0x24,0x5f,0x11,0xb0,0x16,0x27,0xbf, -0x1c,0xfa,0xfa,0x3f,0xec,0x2c,0x1,0x29,0xcc,0x27,0xfb,0xf2,0xd5,0xfe,0x5e,0xc3, -0xc8,0x57,0xa,0xe,0xf0,0xed,0xf1,0xf7,0xbf,0x8a,0xe5,0x93,0x23,0xfa,0x70,0x70, -0xbe,0xd2,0xf7,0x9f,0x54,0xcf,0x2a,0xc1,0x18,0x3f,0xae,0x14,0x8b,0x61,0xf7,0xe7, -0x44,0x7f,0x10,0x28,0xb2,0x6f,0x2a,0x44,0xf3,0xa1,0xe0,0x7c,0x65,0xec,0x8f,0x59, -0xd9,0x11,0xcc,0xf1,0xd7,0x78,0xae,0x27,0x28,0x5f,0x91,0xb6,0x12,0xc7,0xe7,0xcf, -0x7,0x7c,0xdf,0x38,0x78,0xfc,0x7d,0xa2,0xef,0x2f,0x55,0x69,0xf9,0x7c,0x9b,0xdc, -0xfd,0xeb,0x40,0x2c,0x9f,0x3f,0x5f,0x5,0xb4,0x9f,0x30,0xcb,0xd7,0xf4,0xf9,0x9a, -0x3c,0x9f,0x4,0x70,0xba,0x7c,0xcf,0xf7,0x85,0xac,0x1f,0x1f,0xe9,0xfb,0x5f,0xbd, -0x52,0x33,0x7d,0x9f,0x5f,0x66,0x3e,0xee,0xfe,0x89,0x8b,0xf7,0xd,0xf4,0xfd,0xaf, -0x60,0xc3,0xbc,0x3e,0xae,0x5a,0xed,0xc7,0xdd,0xbf,0xf8,0x64,0x3e,0x3e,0x7d,0x7f, -0x6,0x54,0x72,0xac,0x44,0xfb,0xf5,0xdd,0x4a,0xa1,0x0,0x59,0xff,0x2,0xa0,0xb9, -0x3e,0x1b,0x2b,0xf6,0xf1,0x9d,0xcb,0xfd,0x9b,0xcb,0x67,0xf5,0xcf,0xb2,0x3e,0xbf, -0x0,0x1d,0x2b,0xf9,0x1a,0xd,0x35,0xbf,0x74,0x6c,0xdf,0x8f,0xca,0x5e,0xdf,0xfe, -0x5c,0xee,0x7f,0x5d,0x3e,0xd7,0xf8,0x46,0x46,0x13,0xcc,0xf1,0x19,0x7f,0x1d,0x8a, -0xbe,0xf6,0x9b,0x4b,0xfd,0xc0,0xed,0x73,0xe5,0x3,0x32,0x72,0xd6,0x3e,0xaa,0x8, -0xd7,0x6a,0xf6,0xfe,0xa2,0xac,0x7f,0xc6,0xd3,0x62,0x31,0xb3,0xfa,0x8b,0xf8,0xe1, -0x5a,0x78,0xff,0x37,0x70,0xad,0xbf,0x72,0xf9,0xee,0xde,0xad,0x15,0x56,0xbd,0xfb, -0x8b,0x66,0x5c,0xbf,0x12,0x1b,0xd6,0x4e,0x2a,0x11,0xda,0x8f,0xbe,0xe4,0xf4,0x9, -0xa2,0x9a,0xf,0x2a,0xf3,0xad,0x5f,0x81,0x4a,0x17,0x45,0x3f,0xff,0xe8,0x4b,0xce, -0xf3,0xaf,0xda,0x50,0x7d,0x85,0xd8,0xbe,0x58,0xf5,0x53,0x60,0xed,0xb7,0x3a,0xeb, -0xfa,0xd5,0x7d,0x3b,0xce,0xeb,0x57,0xf7,0xc1,0xd8,0xf9,0x2a,0x96,0x4f,0x82,0x38, -0x5a,0xff,0x67,0x3c,0x3f,0x28,0x3a,0xfb,0xbf,0xf,0xef,0x56,0x5,0xa3,0xff,0xb, -0xda,0x9f,0x1,0xa5,0xde,0xff,0x2a,0xb2,0x8f,0xb3,0xfe,0x4a,0xb4,0xf2,0x95,0xfe, -0xfc,0xf9,0xe0,0xae,0x95,0xaf,0x80,0xe9,0x1b,0xf2,0xe7,0x3f,0x62,0xac,0xbf,0x7a, -0x12,0xd5,0xc7,0x59,0xdf,0x4,0xac,0x7c,0xa5,0xef,0x8f,0x54,0x69,0x88,0x66,0x3e, -0x30,0x96,0xfe,0x7a,0xdf,0xbf,0x65,0xfb,0xce,0xe3,0xf8,0x66,0x5c,0x1f,0x21,0x3e, -0x3b,0xbf,0x78,0x7d,0xb7,0x4c,0xdf,0x1,0x7f,0xfe,0x2d,0xc6,0xf1,0xc5,0x68,0x46, -0xff,0xc2,0x7c,0x24,0x64,0xfd,0xd5,0x13,0x23,0x9f,0x8a,0x96,0xf,0x64,0xe7,0x93, -0xd7,0x4a,0xa9,0xdb,0x6f,0xa4,0xb7,0xdf,0x2b,0xf7,0x59,0xbe,0xb2,0xce,0xbf,0x6, -0xff,0xf8,0xc6,0x5d,0x7f,0x75,0xa8,0x9e,0xea,0xeb,0x9a,0x6f,0x5a,0x46,0x74,0x5c, -0xd2,0x7c,0x9b,0x44,0xbb,0x21,0x8e,0xe8,0x1b,0xe8,0xfb,0x5f,0x41,0xb3,0xfd,0xe4, -0xab,0x56,0xfb,0x6d,0xf0,0xaf,0x8f,0xb8,0xeb,0xaf,0xfa,0xb4,0xac,0xa,0x81,0xb6, -0xc1,0xb2,0x36,0xd9,0xa7,0xf9,0x6a,0x53,0xed,0x28,0x84,0x5e,0xbf,0xd5,0x46,0xdf, -0x9c,0x1f,0x54,0x7a,0x46,0x3e,0x30,0x8f,0xaf,0x62,0xf9,0x82,0xfa,0x97,0x98,0xeb, -0xf,0xfa,0xa4,0xf5,0x4d,0xd3,0x77,0xf0,0x97,0x55,0xc3,0x77,0xfe,0xfb,0x3f,0xe1, -0xf4,0x7f,0xce,0xfb,0x96,0xe3,0xf7,0x3e,0x45,0xc6,0xfc,0xa0,0xde,0xff,0x1,0xd8, -0xf0,0xfb,0x2,0xf6,0xe7,0x8a,0xb9,0x7e,0xa3,0x4f,0x1f,0x7f,0x6c,0xfa,0xd0,0x9f, -0x37,0xc,0x1f,0x39,0xfd,0x23,0x4f,0x7e,0xf6,0xf9,0xde,0xff,0xad,0xea,0xb3,0xf7, -0x97,0xe2,0xf8,0x82,0xc6,0xb7,0x98,0xeb,0x5f,0xfa,0xb4,0xd5,0x7b,0x60,0xfa,0x9a, -0xef,0x96,0xd,0x1f,0xba,0x53,0x8,0xf5,0x29,0xc7,0xef,0xf7,0xb1,0xd3,0xc7,0xfa, -0x67,0x35,0x5f,0xcd,0xc1,0xc7,0xda,0xaf,0xc9,0xda,0xf,0xdd,0xd1,0xdb,0x6f,0x1a, -0x54,0xbf,0x52,0x7a,0x1f,0xf4,0x71,0x61,0xb5,0x13,0x2f,0x5f,0x25,0xda,0xff,0x2a, -0xcc,0x17,0x38,0xbf,0xa5,0xec,0x36,0x5e,0xc6,0xb1,0xeb,0x43,0x34,0xeb,0xf6,0xb, -0xf6,0xf5,0x72,0xee,0xdb,0x69,0x3c,0xc4,0xb1,0xeb,0x57,0x34,0xc9,0xfa,0xab,0x43, -0x68,0xfa,0xa6,0xcf,0x33,0xdf,0xe6,0xce,0x2c,0x1f,0xd9,0x69,0xf4,0xcd,0xf9,0xc1, -0xc0,0x7c,0x15,0xb0,0xbe,0x3d,0xc5,0xfa,0x2b,0xdf,0xf8,0x16,0xec,0x73,0xd4,0xaf, -0xbc,0xf9,0x2a,0xf8,0xfd,0x5b,0x34,0xe5,0xfa,0xab,0xe8,0x3e,0xed,0x8b,0x1,0xf9, -0x6a,0x12,0x5c,0xdf,0xa0,0x19,0xac,0xbf,0x8a,0xe8,0xb,0xce,0x57,0xb6,0x2f,0x68, -0x7f,0x2e,0xba,0x58,0x1f,0xf6,0xe4,0x2b,0xe6,0x1b,0xe6,0xc3,0x37,0xd2,0x7d,0xaf, -0x8,0x22,0xcb,0x57,0x33,0x8f,0xef,0x62,0x7d,0x3,0x64,0xe4,0x2b,0x56,0xbf,0x42, -0xa1,0xcf,0xf,0x26,0xf3,0xa9,0xe3,0x98,0xb9,0x66,0x77,0x7d,0xc5,0xdc,0x51,0x4f, -0x1d,0x8b,0xa,0x21,0xbe,0x6a,0xe3,0xd3,0x8a,0x99,0xaf,0xf4,0xfd,0xf,0x20,0x7b, -0x7f,0x8a,0x9d,0xf,0x2,0xde,0x1f,0xbf,0x10,0x9f,0x9a,0xaf,0xba,0xd,0x33,0x5f, -0xe9,0xef,0x1f,0x84,0x2d,0xcb,0x27,0x6,0xd6,0xaf,0x16,0xe9,0x7b,0x5f,0xf3,0x39, -0xf2,0x55,0xd3,0xf2,0x9,0x33,0xc6,0xb7,0xf4,0xcf,0xa7,0xf0,0x8a,0x62,0xbe,0x7c, -0xd5,0x6d,0xba,0xf2,0xd5,0xeb,0x66,0xfd,0x6f,0x7a,0xb9,0x10,0xe6,0x4b,0xf9,0xfc, -0x5b,0x64,0x5f,0xef,0x83,0x6e,0xb3,0xb0,0xa,0xe3,0xe5,0xab,0x5,0xfa,0x76,0x1b, -0x2f,0xce,0xac,0xbf,0x64,0xd7,0x7e,0xb1,0xcf,0x3f,0x35,0x5f,0x69,0x3e,0x10,0xdb, -0x97,0xac,0x7e,0x1a,0xdf,0xb7,0xd3,0x78,0x2b,0xfe,0xfa,0xf6,0xb9,0xf9,0x88,0xec, -0xcf,0x57,0x9f,0x56,0x5,0xfd,0xf9,0x1e,0x5,0xc5,0xc9,0x57,0xd9,0xd6,0x9f,0x99, -0x6f,0xea,0x9d,0x3f,0x72,0xe6,0xab,0xa1,0x9e,0xaf,0xd6,0x68,0xa4,0x7c,0x95,0x7a, -0xfd,0x15,0xd7,0x77,0xee,0x9b,0xdf,0x72,0xe4,0xab,0x3,0x3d,0x1f,0x3c,0xa6,0x91, -0xf2,0x55,0xea,0xf5,0x57,0x5c,0x5f,0xd8,0xf3,0x65,0x4f,0xf4,0xfd,0x9b,0x2a,0x3f, -0xda,0x2e,0x9e,0xf,0x0,0x0,0x12,0x4f,0x49,0x44,0x41,0x54,0xa3,0x91,0xf2,0x55, -0xc2,0xfd,0xaf,0x66,0xf9,0x42,0xf6,0x6f,0x37,0x7d,0x6c,0xfc,0xb5,0xf3,0x15,0xa, -0xf0,0x35,0xc0,0x42,0xdb,0x6f,0xa4,0xfb,0x5e,0x31,0xcf,0x3f,0x35,0x5f,0x6d,0x31, -0x1f,0xff,0xf8,0xc6,0xdf,0xff,0x6a,0xf,0x1f,0x9a,0x3e,0xf9,0x7e,0xd9,0xf4,0x15, -0x37,0xa3,0xfa,0xcc,0x7c,0xc5,0xde,0x4f,0x77,0xd5,0x6a,0x3f,0xc8,0xbf,0x3e,0xe2, -0xef,0x7f,0xd5,0x3a,0xed,0x9b,0x3e,0xd4,0x34,0xa6,0x17,0x55,0x50,0x6d,0x86,0x6f, -0x7c,0x19,0x16,0xa,0x80,0xf5,0x2f,0xce,0x7c,0xc5,0x7c,0x80,0xd7,0xbf,0x24,0xd9, -0xff,0x6a,0xed,0x98,0xf9,0x60,0xd7,0xf4,0x29,0xd8,0xf2,0x1d,0xf1,0xcf,0x3f,0x78, -0x1f,0xd5,0x6a,0xdb,0x1c,0x9f,0x75,0x7d,0x6c,0xf0,0xfa,0xe7,0x24,0xfb,0x5f,0x9, -0xd8,0xf2,0x61,0xe6,0xa3,0x96,0x6f,0x97,0x9f,0x9f,0xe1,0x9b,0xaa,0xcf,0xde,0x5f, -0x94,0xe3,0xe3,0x8e,0x6f,0x49,0xf6,0xbf,0x72,0xfa,0xb6,0x99,0xcf,0x3a,0xff,0xd6, -0xf9,0x3e,0xb0,0x66,0x3d,0x3f,0xa8,0xe7,0x2b,0x76,0x7d,0x84,0xcd,0xf,0xd2,0x64, -0xfb,0x5f,0x39,0x7c,0xd3,0x5b,0xbe,0xf6,0x5b,0xe7,0xd5,0xaf,0x74,0x9f,0xfb,0xf9, -0xc1,0x68,0xf9,0x2a,0xc9,0xf8,0xe6,0xf0,0x51,0xff,0xf1,0xd,0x6e,0xbf,0x24,0xf9, -0x85,0xb4,0xe3,0xef,0xaf,0xb2,0x66,0xfb,0x80,0xff,0xfa,0xd8,0xcd,0xd6,0x17,0xf5, -0xfd,0x74,0xce,0xfe,0x5,0xdb,0xfd,0x8b,0xe8,0xeb,0x5f,0x8e,0x12,0xfb,0x78,0xd7, -0x6f,0x12,0x9f,0xb3,0x7f,0x16,0xb8,0xfd,0x33,0xe7,0xfd,0x24,0x70,0xd,0x9,0x46, -0xff,0x17,0x54,0xbf,0x82,0xbc,0xfe,0x2f,0x89,0x2f,0xc2,0xfd,0xb9,0xbf,0x7f,0x86, -0x81,0xf5,0x2b,0x76,0x7f,0xde,0xe1,0x8d,0x1f,0x4,0xbc,0x4e,0xe7,0xe1,0xf3,0xb5, -0x1f,0xb2,0xf2,0x55,0xcf,0x5d,0x1f,0x42,0x1d,0xd3,0xf7,0x88,0x37,0xfe,0x92,0x36, -0x9c,0x47,0xfb,0xfd,0x3e,0x24,0xbf,0x78,0x7d,0x8f,0xd8,0xf1,0xe5,0xe5,0x97,0x84, -0xfb,0x5f,0xcd,0xf2,0x9d,0xa,0xd1,0x7d,0x95,0x30,0x9f,0x34,0x1f,0x5f,0x58,0xbe, -0xd2,0x7d,0xaf,0x54,0xad,0xfa,0x95,0xe5,0xe3,0x1d,0xdf,0xc5,0xfb,0x6,0xfa,0xf5, -0xc1,0xe6,0x8f,0xe4,0xab,0x13,0x18,0x96,0xaf,0x12,0xee,0x7f,0x15,0xc9,0xb7,0x55, -0x77,0x3c,0xf8,0x3d,0xfe,0x4a,0xc5,0x35,0x3f,0x68,0xcd,0x6f,0x3d,0x81,0x61,0xfd, -0x4b,0xf6,0xf7,0x6f,0x47,0x56,0xff,0x57,0x7d,0xbe,0xe5,0xe8,0x5f,0x6a,0xd,0xfe, -0xfc,0xe0,0xef,0x59,0xfd,0x5,0x66,0xb8,0xff,0x55,0x88,0xcf,0x1a,0xdf,0x8,0x7e, -0x69,0x87,0xe3,0x33,0xf3,0x95,0x3d,0x3f,0x38,0x97,0xfd,0xaf,0x82,0x7d,0x56,0x3e, -0x20,0xd4,0xe9,0x3,0xb5,0xa6,0xd3,0xe7,0x98,0x1f,0x84,0xf3,0xa8,0x5f,0x85,0xf8, -0xac,0xf5,0x57,0x47,0xaf,0xb9,0x7d,0x9e,0xf5,0xed,0x73,0xad,0x5f,0x45,0x69,0x3f, -0xfc,0x86,0xdb,0x17,0xfb,0xf9,0xbc,0xb9,0xf8,0x76,0x33,0xf5,0x65,0x5f,0xbf,0xb7, -0xf3,0x55,0xf5,0x5e,0x2b,0x96,0x2f,0xcb,0xfd,0xaf,0x66,0xd4,0x87,0xf4,0xf5,0x7, -0xae,0xfe,0xf,0xde,0xaf,0x1a,0xf3,0x83,0xc1,0xbe,0x2c,0xf7,0xbf,0xa,0xf7,0x71, -0xd6,0x5f,0x59,0xf9,0x2a,0xd8,0xe7,0xda,0xff,0xea,0xee,0xcd,0xcb,0x86,0x6f,0x3a, -0x8f,0xf9,0x19,0xbf,0xcf,0xca,0x57,0xc1,0x3e,0xd7,0xfe,0x57,0xd5,0xde,0xc4,0xf0, -0x9d,0x2f,0xc6,0x67,0x8d,0xbf,0xc1,0x3e,0xd7,0xfe,0x57,0x95,0xd1,0x64,0x7e,0xc7, -0x97,0xdc,0x49,0xeb,0x7b,0xa9,0x32,0x22,0xf3,0xf3,0xd1,0x9f,0xa6,0xf7,0x49,0x37, -0x99,0x6f,0xe,0xf3,0xbf,0x62,0x5a,0xdf,0xab,0x15,0xf8,0x11,0xf3,0xd5,0x17,0x71, -0xfd,0xc6,0xf7,0xb1,0xf3,0x2f,0xdd,0xfa,0x3,0xd7,0xf3,0x47,0xec,0x67,0x4c,0xef, -0xd2,0xd4,0x3e,0xf5,0xfa,0x48,0xb1,0xff,0x15,0xf0,0xfd,0xc,0xed,0xf9,0xad,0x90, -0xfa,0x41,0x4c,0x5f,0x55,0xeb,0x5f,0xd2,0xee,0x3f,0xa4,0xf,0xe0,0xcc,0x21,0x17, -0x43,0xeb,0x2f,0xb3,0x7c,0x9e,0xfd,0xdb,0xab,0x5a,0xff,0x9c,0xf5,0xfe,0x57,0xc1, -0xcf,0xf,0xc6,0xf5,0xa5,0xde,0xff,0x8a,0xce,0xb9,0xfd,0xd8,0xb7,0x4a,0xb5,0xbf, -0x59,0x86,0xe7,0x1f,0xf7,0xb3,0x9b,0x81,0x8f,0x7b,0xfd,0x66,0xe4,0x4b,0xb1,0xff, -0x55,0xf0,0x67,0xd6,0xfa,0xd,0xfe,0xfb,0x7,0xa9,0xb9,0x8e,0xd7,0xfb,0xad,0x92, -0xae,0xbf,0x4a,0xee,0xd3,0xdf,0x5f,0xe6,0xf7,0x99,0xeb,0xc8,0x39,0xbe,0xe4,0xfb, -0x27,0x26,0xf2,0x11,0x10,0xe0,0xbb,0x15,0xe4,0xdb,0x58,0xac,0xef,0x57,0x1,0xbe, -0xa0,0xe3,0xbb,0x88,0xf5,0x1b,0xe,0x9f,0xf2,0x71,0xce,0x7d,0xbd,0x98,0xd7,0xc7, -0x82,0x7d,0x38,0xe0,0xfa,0xa0,0x4b,0xf4,0xad,0x7f,0x6f,0x2c,0xcb,0xfd,0xe2,0x96, -0xb6,0xfe,0x0,0x71,0x7d,0x64,0xa9,0xbe,0x9a,0x4,0xab,0xd5,0xdb,0xa8,0xaa,0xad, -0x7f,0x19,0x1c,0xe5,0xd0,0x7,0x2a,0x15,0xf1,0xf6,0x4,0x7,0xaf,0xcf,0xa1,0x57, -0x97,0xe8,0x23,0x18,0x54,0x20,0xbd,0x33,0xa1,0x20,0xde,0xf8,0x86,0x16,0xb4,0xbe, -0x49,0xf5,0xbd,0xe,0xc9,0xe4,0x32,0x35,0xe6,0x7,0x4b,0x39,0xf4,0x9,0x15,0x32, -0x21,0x39,0x6e,0xbf,0x4a,0xa5,0x35,0x21,0x58,0xc,0xf5,0x61,0xf9,0x2b,0x45,0x7a, -0xa9,0xfd,0xca,0xda,0x83,0x31,0xad,0x6f,0x6e,0xa6,0x7a,0x7e,0x35,0xa6,0x4f,0xbd, -0x7e,0x6b,0x13,0x5a,0x9d,0xe1,0xc3,0xa,0xa2,0x6b,0x0,0xee,0xec,0xc0,0xb5,0xba, -0xb6,0xb5,0xf0,0xa2,0x7c,0xb4,0x76,0x32,0x96,0xc7,0xb7,0xe9,0x96,0xbe,0xbf,0xe8, -0x61,0x88,0xf,0x6b,0xbe,0xde,0xe,0x68,0xd5,0x16,0xea,0x13,0x8c,0xa,0x96,0x91, -0xaf,0x60,0x4,0x1f,0xae,0xe1,0x5a,0xaa,0xfd,0xaf,0xe2,0xf9,0x44,0xeb,0x96,0x2f, -0x30,0x5f,0xe9,0xe7,0xdf,0xd3,0xaa,0xaf,0x5d,0x71,0xfa,0x92,0xae,0xbf,0x4a,0x91, -0xaf,0xf6,0x42,0xdb,0xef,0x12,0x80,0xdd,0x7,0x0,0x55,0x51,0x2d,0xd1,0xfe,0x57, -0x73,0xcb,0x2f,0xcc,0x57,0x55,0x7d,0x22,0x80,0x55,0x58,0x4b,0xb2,0xff,0x55,0x16, -0x3e,0x25,0xd4,0x57,0xd3,0x7d,0x3f,0xba,0xe,0x6a,0x49,0xf6,0xbf,0xca,0x22,0x5f, -0xf1,0x7c,0x97,0x54,0x18,0xd2,0xfb,0x97,0xba,0x36,0xb5,0x4,0x85,0x8a,0x58,0x4b, -0xb2,0xff,0x55,0x8a,0x7c,0xa5,0xa8,0xf9,0x6a,0x2b,0x28,0x5f,0xad,0x9d,0x92,0x1a, -0x94,0xff,0xa9,0xda,0x3f,0xaf,0xb5,0x5f,0xa9,0x8a,0x63,0x5a,0x59,0xdd,0x4c,0xb2, -0xff,0x55,0x8a,0x7c,0x75,0x4f,0x42,0xd5,0x6a,0x50,0xbe,0x5a,0x3b,0x56,0x6a,0xfd, -0xab,0xdf,0xf4,0x7f,0xab,0xa4,0xef,0x1f,0x8c,0x9f,0xaf,0xde,0x97,0x26,0x58,0x8, -0x1a,0x3f,0xd6,0xd4,0xe3,0xdb,0xfa,0xfc,0x63,0x9e,0xef,0x5e,0xb6,0xbe,0x75,0x73, -0x65,0xaf,0x2f,0x5f,0x29,0x93,0x9,0xfd,0x6e,0x98,0xaf,0x3e,0xea,0x51,0x72,0xc9, -0xe7,0x4b,0xf4,0xfe,0xc1,0xe0,0xf,0xdb,0xc6,0xdd,0x97,0xaf,0x14,0x35,0x5f,0x5d, -0xf,0xca,0x57,0xea,0xf5,0xf1,0x66,0x6b,0xd4,0xe3,0x1f,0x8a,0x6c,0xc7,0x37,0x1a, -0x90,0xaf,0x14,0x35,0x5f,0x5,0xce,0x6f,0x55,0x31,0xbd,0xd7,0xf3,0xfa,0xc6,0xd7, -0x93,0xad,0xbf,0x4a,0xe2,0x33,0xf2,0x55,0xa0,0xaf,0xa6,0x1e,0x5f,0xd5,0xa7,0x25, -0x2c,0x7b,0x78,0x86,0x7,0xc9,0xd7,0xf,0xc5,0xf4,0xa9,0xd7,0x6f,0x5d,0xcd,0x57, -0x81,0xbe,0xba,0xea,0x1b,0xa9,0x3e,0xb5,0x7,0xec,0x58,0xbf,0x9,0x86,0xb,0xf2, -0xe9,0xf9,0x4a,0x91,0xa8,0xde,0xff,0x9d,0xe0,0x80,0xeb,0x63,0x72,0x55,0xf3,0xe1, -0x47,0xec,0xf7,0x4e,0xe7,0xe2,0x2b,0xec,0xb4,0x67,0xe4,0x2b,0x7d,0xff,0x2b,0xf9, -0x7e,0xc9,0xdc,0x5f,0xb4,0x88,0xdc,0x23,0x1c,0xf4,0xf8,0x6e,0x67,0xea,0x23,0xf8, -0x21,0x10,0xc2,0xf3,0x95,0xbe,0xbf,0x40,0x95,0x3d,0x7f,0x24,0xa1,0xa1,0x3b,0x61, -0x79,0x7c,0xed,0x93,0x4c,0x7d,0x8a,0xf2,0x8e,0xb1,0x61,0x77,0x70,0xbe,0x32,0xf6, -0x97,0xea,0x9a,0xbe,0x11,0x3e,0x8,0x6f,0x3f,0x9a,0xad,0x8f,0xce,0xf2,0x29,0x86, -0x4f,0x2e,0x9b,0x3e,0xda,0xf0,0xf8,0x36,0x69,0xd9,0xf0,0xb5,0xb,0xda,0xfa,0xa6, -0xac,0x7d,0x1f,0xcc,0xf2,0xe9,0xfb,0x5f,0x55,0x30,0x70,0xfb,0xb4,0x19,0x85,0x82, -0xee,0x7b,0xc0,0x7c,0xc6,0xfe,0x57,0x52,0xa6,0xfd,0x9f,0x72,0x38,0xcb,0x87,0x8d, -0xfd,0xaf,0x28,0x30,0xd7,0x5f,0x51,0x63,0x93,0x98,0xa9,0xfe,0x7a,0x58,0x6d,0xb9, -0xce,0x9f,0xa,0xe,0xdf,0x9,0x38,0xc9,0xd6,0xa7,0xfc,0x2c,0xc8,0x47,0x8a,0x5b, -0xda,0xfe,0xa2,0xc8,0xd8,0x5f,0xca,0xf4,0x61,0x85,0x18,0xd7,0xef,0x54,0x13,0x69, -0x9,0xb,0x3e,0x2c,0x39,0x8e,0x6f,0xd6,0xe3,0x5b,0x98,0xf,0xe9,0xf7,0xbf,0x3, -0xc3,0xd7,0x65,0xbe,0xf3,0x55,0xdb,0xa7,0xff,0xdb,0xf6,0x26,0x6b,0xbf,0x83,0xec, -0x7d,0x4,0x3f,0xe6,0xf4,0x2f,0xc6,0x97,0x1c,0xf9,0xa,0xa0,0xa6,0x68,0xf8,0x8, -0x42,0x5e,0xdf,0x80,0xf9,0xae,0xcf,0x21,0x1f,0x70,0xfb,0x67,0xd3,0x47,0x8b,0x96, -0x4f,0xbe,0x6f,0x5e,0xbf,0xb4,0xe8,0xf3,0xc9,0xa6,0x6f,0x3a,0x97,0xfa,0xb,0xd, -0xba,0xff,0x20,0x97,0x69,0xd8,0xfa,0x2b,0x6a,0xbf,0x5a,0xc7,0x9c,0x17,0x3c,0x5d, -0xb0,0x8f,0xd0,0xe0,0xfd,0xf,0x78,0xed,0x7,0x17,0xed,0xc3,0xd1,0x7c,0x63,0xc7, -0xf5,0x9b,0x7d,0xfd,0x34,0xd8,0x17,0x92,0xaf,0x5c,0xbe,0x3d,0x47,0xff,0xb7,0x50, -0x9f,0x91,0xaf,0xf8,0xf3,0x83,0x53,0x6b,0xfa,0x77,0xbb,0xe8,0xf2,0x91,0x45,0xf9, -0xcc,0xf1,0x43,0x9f,0x1f,0x6c,0xcb,0xe6,0xf3,0xf1,0x1c,0xdf,0xdb,0x65,0xd3,0x37, -0xb9,0x9e,0xd1,0xfb,0x7,0x63,0xf9,0x88,0xbe,0xff,0x41,0x55,0x2c,0x7,0xd5,0x77, -0xff,0x94,0x8d,0xbf,0xd2,0x41,0x46,0xef,0x1f,0x4c,0xe0,0xab,0xf4,0xc5,0x20,0xdf, -0x6,0xf3,0xf5,0x87,0xcb,0x38,0xbe,0x8a,0xb1,0xff,0x95,0x12,0xe8,0xdb,0x5c,0xb2, -0x4f,0x99,0xe1,0x3,0xce,0x7c,0x9a,0xea,0xfd,0x83,0x89,0x7c,0xd8,0xd8,0xff,0xa, -0x8b,0xb3,0xe6,0x17,0x2c,0x5f,0x7d,0x41,0xfd,0x4b,0x71,0xb,0xb2,0xfa,0x15,0x80, -0x28,0xd8,0x87,0xdd,0xbe,0x8c,0xd7,0x1f,0x4,0xfb,0x50,0xb5,0xc3,0xea,0x57,0x0, -0xfe,0x6d,0x29,0xc8,0x67,0x15,0x30,0xe1,0x41,0xca,0xf7,0xf,0xc6,0xf4,0x4d,0xb0, -0xbd,0xbf,0x28,0x12,0x3,0xdb,0x8f,0x10,0x47,0x7d,0x23,0xf5,0xfa,0x97,0x38,0x3e, -0x6a,0xef,0x2f,0xea,0xed,0x9f,0x9d,0xeb,0x87,0x84,0x7f,0x6f,0xd7,0x87,0x16,0xe9, -0xbb,0x4c,0xbd,0xfb,0x8b,0xf2,0x7d,0xef,0x6d,0xb2,0x6,0xcc,0x60,0xfd,0x55,0xac, -0x7c,0x55,0x89,0xb4,0xfe,0x6a,0x6f,0xd3,0xfe,0xfd,0x45,0xb6,0x1f,0xc1,0x85,0x48, -0xeb,0xff,0xf6,0xa,0xcb,0xf1,0xd1,0x2a,0x8c,0xe4,0x7b,0xb0,0xe1,0xf2,0x2d,0xec, -0xfa,0xa5,0x7a,0xff,0x77,0x12,0xf0,0xfc,0x20,0xb2,0xde,0xaf,0xbb,0x7b,0xe8,0xf2, -0x2d,0xaa,0xff,0x73,0xe7,0x2b,0xf3,0xfe,0x48,0x2e,0x15,0x37,0xd,0xdf,0xd0,0xda, -0xdf,0x7b,0x8a,0x5d,0xbe,0x45,0x8d,0x1f,0xee,0x7c,0xd5,0x4,0xac,0x7e,0x55,0x33, -0x7c,0x7,0x81,0xfb,0x4b,0x6d,0x2c,0x23,0x5f,0xb1,0xfb,0xf3,0x11,0x36,0x7d,0x28, -0xd3,0xfd,0xaf,0x52,0xe4,0x17,0x63,0xff,0x2b,0x6a,0xd5,0x87,0xb0,0xe9,0xd3,0xf6, -0x67,0x90,0xaf,0xee,0x60,0xa,0x37,0x73,0xe0,0x23,0x56,0x7d,0x6d,0x9f,0xf9,0xe4, -0xf2,0x11,0x1e,0x3d,0x3c,0xa5,0x9d,0xda,0x32,0x7d,0x18,0x79,0xea,0x57,0xac,0xfd, -0xb4,0xe7,0x7,0xf1,0xe8,0x9d,0xe3,0xd6,0xa3,0xe5,0xf8,0x88,0x39,0x3f,0x8,0xdd, -0xf5,0x2b,0xcb,0xa7,0xed,0xcf,0xa0,0xfa,0x70,0x17,0xe2,0xe5,0xf8,0xcc,0xf9,0xc1, -0x5d,0x77,0xfd,0xca,0xba,0x3e,0xb4,0xfd,0x19,0xf0,0xe8,0x83,0xe5,0xf9,0x26,0x76, -0xfd,0x0,0x20,0xd6,0xbf,0x10,0xd6,0xbf,0xe8,0xcf,0x6f,0xc9,0x57,0x3f,0xc0,0x43, -0x88,0x96,0xe4,0xb3,0xeb,0x2f,0xce,0xfa,0xd5,0xa6,0xc3,0x87,0x95,0x9f,0xa9,0x3e, -0xc7,0x2b,0x17,0x17,0x5b,0xbf,0x9a,0xb9,0xbf,0xa8,0xe6,0xeb,0x42,0xb0,0x1c,0x5f, -0x58,0xfd,0xca,0x6a,0xbf,0xc7,0xaa,0x4f,0x5c,0x92,0xf,0x47,0xf0,0xed,0xe0,0x16, -0x5c,0xf5,0x7d,0xb7,0xa5,0xd7,0xaf,0xb2,0xdd,0xff,0x2a,0x55,0xfd,0x2a,0x60,0xff, -0x2b,0x9c,0xe9,0xf3,0xd3,0x29,0xf2,0xd5,0x90,0x9f,0xaf,0x4e,0x3b,0x59,0xee,0x7f, -0x95,0x22,0xbf,0x1c,0xf0,0xf3,0xd5,0xf1,0xa3,0x2c,0xf7,0xbf,0x4a,0xe1,0x43,0xfc, -0x7c,0x85,0x61,0x96,0xfb,0x5f,0xa5,0xc8,0x2f,0x88,0x9f,0xaf,0x2,0x7d,0xd,0x90, -0x13,0x5f,0x56,0xfb,0x5f,0x65,0x93,0xaf,0x44,0x96,0xaf,0x10,0xf3,0x65,0xb5,0xff, -0x55,0xca,0x7c,0x65,0xec,0x2f,0xa5,0xbf,0x2e,0x44,0xcf,0x57,0x30,0xac,0x7f,0xc9, -0x7e,0xfd,0xd5,0xcc,0x7c,0x65,0xf8,0xfa,0x94,0xe5,0x2b,0xc0,0x7c,0x59,0xed,0x7f, -0x95,0x49,0xbe,0x62,0xeb,0xf,0x48,0xc8,0xfb,0x93,0xe9,0x1c,0xd6,0x5f,0x45,0xcd, -0x57,0x77,0x4b,0x2c,0x5f,0xad,0x86,0xfb,0x32,0x5e,0x7f,0x15,0x9a,0xaf,0xe0,0x42, -0xf6,0xbf,0x4a,0x9e,0xaf,0xe0,0x82,0xf6,0xef,0x4c,0x9a,0xaf,0x40,0xae,0x7d,0x61, -0xeb,0xdb,0xf3,0x91,0xaf,0xa,0xa1,0xf5,0xab,0x9c,0xe4,0x2b,0x73,0x7e,0x50,0x60, -0xf9,0xa,0xb2,0xfa,0x15,0x6f,0xfc,0x58,0xbc,0x8f,0xe8,0xf3,0x1f,0x55,0xf6,0xfe, -0x41,0x89,0xed,0x7f,0x75,0xd0,0xe4,0x8d,0xbf,0xcb,0xf2,0x55,0x7a,0x2,0xcb,0x57, -0xe6,0xfe,0x57,0xa8,0xc9,0xcb,0x2f,0x8b,0xf7,0x19,0xfb,0x23,0x55,0xd8,0xf8,0x3b, -0x62,0xe3,0x6f,0xfe,0x7d,0xf9,0x38,0xbe,0xd8,0xd8,0xff,0xca,0xf4,0xa9,0xf9,0xca, -0xf2,0x2d,0xf9,0xfa,0x50,0xf3,0x15,0xb0,0xe7,0x7,0x7d,0xf9,0xa,0x35,0x97,0xdc, -0xbf,0xa8,0xf9,0x6a,0xdb,0x9e,0x1f,0x4,0xcc,0x87,0x99,0x6f,0x7f,0xd9,0xfd,0xf3, -0x4,0xdf,0x72,0xcc,0xf,0xa,0x2c,0x5f,0xcd,0x65,0xff,0xab,0x64,0xf9,0xa,0x38, -0xe6,0x7,0x5,0x96,0xaf,0x72,0xe3,0x63,0xcf,0xf,0xe6,0x37,0x5f,0x81,0x8b,0x7c, -0x95,0x2a,0x5f,0x81,0x9c,0xe7,0x2b,0xcd,0x87,0x63,0xbd,0x1f,0x67,0xf1,0xe3,0xc7, -0x69,0xc0,0xfc,0x20,0xcd,0x49,0xbe,0x3a,0xee,0xf1,0xeb,0x57,0x34,0x4f,0xe3,0x2f, -0xa7,0x7e,0x45,0x73,0x92,0x5f,0xf0,0x6f,0xa8,0x7b,0xfd,0x38,0xf3,0xbd,0x97,0x13, -0xdf,0xff,0xd,0xf0,0xfd,0x4d,0x4e,0x8e,0xaf,0xb9,0xfe,0xa,0xb0,0x7c,0xc5,0x7c, -0x78,0xf9,0xf9,0x6a,0xcb,0x3a,0xff,0x98,0xf,0x2b,0x96,0x2f,0x7,0xf9,0xaa,0xca, -0xfa,0x3f,0xce,0xfc,0x20,0xcd,0x41,0xbe,0xaa,0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa, -0xce,0x9a,0x1f,0x5c,0x72,0xbe,0xaa,0xe6,0x3c,0x5f,0x55,0x73,0x9e,0xaf,0xaa,0x39, -0xcf,0x57,0x5f,0x84,0xf9,0xc1,0x40,0x5f,0x4e,0xf2,0x95,0xdb,0x27,0x5f,0xb1,0xea, -0xcf,0x39,0xc9,0x57,0x6e,0x1f,0x1e,0x21,0x9c,0xaf,0x7c,0xe5,0xf5,0x61,0x94,0xaf, -0x7c,0x15,0xe8,0xdb,0xcf,0xa9,0xf,0xe6,0xf9,0xf8,0xca,0x57,0x6d,0x5f,0x2e,0xaf, -0xf,0xc5,0xf6,0xe5,0xb1,0x7f,0xb1,0xe7,0x7,0x97,0x9e,0xaf,0x2,0x7c,0x21,0xef, -0x77,0xce,0x83,0x2f,0xec,0xfd,0xce,0x4b,0xf7,0xe5,0x2a,0x5f,0x71,0xdb,0x2f,0x47, -0xf9,0xe5,0xb,0xef,0xcb,0xc7,0xf5,0x1b,0x58,0xbf,0xda,0xc8,0x53,0xfd,0x6a,0x70, -0xb7,0xc4,0xf2,0x95,0xb9,0xbe,0x98,0xa2,0x9c,0xd4,0xaf,0x80,0x5e,0xdf,0x10,0x59, -0x7d,0x43,0x9b,0xd7,0xa,0x7e,0x3f,0xdd,0x12,0x8e,0xef,0xaf,0x74,0x9f,0xf6,0x94, -0xba,0x91,0xf,0x4,0xd3,0x7,0x73,0x52,0x1f,0xfa,0x38,0xe7,0x3e,0xa3,0xfe,0xc7, -0xe6,0x8f,0x46,0xf8,0x3b,0xcc,0x97,0xab,0xf9,0x41,0xd3,0xa7,0xe6,0xab,0xe7,0x4c, -0x1f,0x58,0xe6,0xf5,0xf1,0x3d,0x59,0xee,0x5f,0x2e,0x16,0xec,0xfa,0x95,0x3d,0xff, -0xc6,0xea,0x2f,0x60,0x89,0xfd,0xb,0x91,0x50,0xf5,0xf6,0x4,0x41,0xbb,0x7e,0x65, -0xaf,0xbf,0xb2,0x7c,0x4b,0xec,0x9f,0x9,0x70,0xef,0x2f,0xea,0x7c,0x7f,0x63,0x1e, -0xea,0x57,0xa,0xa8,0xd0,0x3b,0x13,0xcc,0x7d,0xff,0xe0,0x66,0x3e,0x7c,0x64,0x72, -0x19,0xe7,0x76,0x7e,0x50,0xf7,0xe5,0x78,0xfe,0x4d,0xf5,0x85,0xef,0x2f,0xba,0x6c, -0x9f,0x84,0x6a,0x13,0x6d,0x29,0x62,0x4e,0xf3,0x15,0x39,0x91,0xc7,0xb7,0x49,0x51, -0xf3,0xe1,0xc3,0x1c,0xd6,0xaf,0xb4,0x47,0x8e,0xcd,0xfd,0xaf,0x4e,0xa1,0x9e,0xaf, -0xd6,0xca,0x2c,0x5f,0x6d,0xe4,0xe1,0xfe,0x5c,0xb0,0xf6,0xbf,0x32,0xf3,0x55,0xcb, -0xca,0x57,0xa2,0xe9,0x13,0x73,0x32,0xfe,0xee,0x51,0xf7,0xfe,0x57,0x2c,0xbf,0xfc, -0x38,0x57,0xf9,0xc5,0xf6,0xb1,0xf7,0xbf,0xbd,0x95,0x13,0x9f,0xf1,0xfc,0xe5,0x6f, -0xcb,0xbe,0xf9,0xd5,0x5c,0xcd,0xf,0xfe,0x6,0xb0,0x7c,0x85,0xf3,0x70,0x7d,0x9c, -0x9f,0xc,0xd4,0x7c,0xe5,0x98,0x1f,0xb4,0xe7,0xdf,0x70,0x1e,0xea,0x57,0x13,0x9, -0xaa,0xf9,0x2a,0xbf,0xf3,0x83,0x13,0x50,0xb9,0xed,0xdc,0xff,0xa,0xb2,0xf9,0x41, -0x5,0x55,0xf3,0x50,0x3f,0x90,0x0,0x54,0xf3,0xd5,0x77,0xed,0x7c,0xc5,0xe6,0x7, -0xf3,0x91,0xaf,0x54,0xdf,0x40,0xcd,0x57,0xd7,0x73,0x3b,0x3f,0xa8,0xb6,0xdf,0x24, -0xcf,0xf3,0x6f,0x12,0xa8,0xe4,0xdb,0x27,0xa9,0xed,0x87,0xf2,0x3b,0x3f,0x38,0x39, -0x81,0x12,0x31,0xfa,0x3f,0x1c,0xe0,0xdb,0x5b,0x66,0xff,0x87,0xec,0x7c,0xa5,0xef, -0x2f,0x3a,0xb8,0x6f,0xd5,0xaf,0x50,0x1e,0xee,0xcf,0xb1,0x9d,0xaf,0x8c,0xfd,0x9b, -0xd8,0xf3,0x3d,0x23,0x63,0x7f,0xd1,0x1c,0xe5,0x2b,0xee,0xfe,0xa2,0xaa,0x6f,0x33, -0x27,0xf9,0xc5,0xf0,0xfd,0xda,0xca,0x2f,0xd,0x36,0xfe,0xe6,0xc4,0x67,0xec,0x2f, -0x6a,0xaf,0x5f,0x63,0x3e,0x9c,0x93,0xe3,0x6b,0xec,0x2f,0xa,0xac,0x7c,0xc5,0xc6, -0xdf,0x65,0xae,0xbf,0xfa,0x70,0xba,0xa6,0xa8,0xf9,0x6a,0x93,0xf5,0x2f,0x80,0xf9, -0xb0,0x72,0x8e,0x72,0x90,0xaf,0xaa,0xb5,0xc7,0xe7,0xd2,0x44,0xbf,0xff,0xc5,0xdc, -0xfd,0x45,0x97,0x9c,0xaf,0x2a,0x8d,0xdf,0x9e,0x4b,0xee,0x7c,0x25,0xb2,0x7c,0x85, -0x96,0x3f,0xbe,0x11,0xd8,0x20,0xe7,0x93,0x9,0x2e,0xf2,0xf2,0x55,0x4e,0x7c,0xe8, -0xce,0x65,0x9c,0xd7,0xf5,0x57,0x9a,0x6f,0x7c,0x27,0xc2,0xfe,0x7,0xcb,0xf3,0xf5, -0x51,0x9e,0x7d,0xa8,0xb6,0x3,0x3f,0xc8,0x71,0xbe,0xba,0x3b,0x5d,0x83,0xef,0x98, -0xf9,0x2a,0x68,0x7e,0x10,0x2d,0xb1,0xff,0x13,0x1c,0xf5,0x2b,0x63,0x7e,0xd0,0xdc, -0xbf,0x4e,0xcd,0x57,0xec,0xfe,0x68,0xb8,0xc4,0xf1,0x43,0xab,0x51,0xb1,0x7c,0x65, -0xd4,0x37,0x44,0x96,0xf,0xac,0xfa,0xfd,0x30,0x47,0xf5,0xd,0x6b,0x7f,0x51,0x47, -0xfd,0xe5,0x20,0x27,0xf9,0xc5,0xc8,0xa7,0x3d,0xcb,0x87,0x73,0xe6,0x53,0x3c,0x3e, -0x36,0x3f,0xdd,0xc8,0x55,0xfd,0xaa,0x2b,0x7a,0xeb,0x57,0x1b,0x4b,0xbc,0x3e,0xbe, -0x27,0x2b,0x5a,0xfd,0xa,0xda,0xf5,0xab,0x3,0xd1,0x5b,0xbf,0x5a,0x62,0xff,0x42, -0x24,0x74,0x4f,0xab,0x5f,0x75,0xec,0xfa,0x95,0xb9,0xbf,0xa8,0xa3,0x7e,0x85,0x96, -0xd7,0x3f,0x13,0x50,0x79,0x5f,0xf5,0x39,0xf6,0x17,0x85,0xa2,0x98,0xa3,0xf9,0x41, -0x5,0x54,0x14,0xad,0x7e,0x65,0xef,0x2f,0xca,0xfa,0xe7,0x7c,0xd4,0xaf,0x34,0xdf, -0x40,0xcd,0x57,0x8f,0x72,0x9a,0xaf,0x8c,0xf6,0x23,0xb8,0x92,0xd3,0xfc,0xa2,0x4d, -0xf,0x6a,0xbe,0x42,0x5e,0x7d,0x12,0xaa,0xab,0x3e,0x4,0x73,0x9a,0xaf,0xc8,0x89, -0xda,0xff,0x49,0xa4,0x8,0x73,0xfa,0xfc,0xa0,0xbe,0x23,0xb1,0x3b,0x5f,0xb1,0xe7, -0x7,0xaf,0xe4,0xe2,0xf9,0x41,0xc1,0x97,0xaf,0x58,0xfd,0xde,0xce,0x57,0x38,0x57, -0xf9,0xca,0xff,0xfc,0x20,0xce,0x49,0x7e,0x31,0xf6,0xef,0x4,0xc0,0x9b,0xaf,0x86, -0xb9,0xf2,0xf5,0xcb,0x5e,0x5f,0x5e,0x8e,0x2f,0xf2,0xd4,0xaf,0x50,0xe,0xea,0x57, -0xa4,0xf1,0xb7,0x57,0xd9,0xfc,0x20,0x74,0xd7,0xaf,0x72,0xb1,0xbe,0x5d,0x79,0xaf, -0x7f,0x26,0x99,0xf3,0x83,0xde,0xfd,0x45,0x41,0xe,0xea,0x57,0xca,0xfb,0xfd,0x27, -0x92,0x73,0xff,0x2b,0xc7,0xfc,0xa0,0xb8,0xfc,0xf1,0x8d,0xe2,0xf7,0xfb,0xca,0xc4, -0xe9,0x73,0xd4,0xaf,0x56,0xf3,0xe0,0xfb,0x40,0xf5,0x5d,0xc6,0x9d,0xbc,0xce,0xf, -0xe2,0xc6,0xcb,0xca,0x24,0xbf,0xf5,0xa1,0x2f,0x80,0xef,0xa1,0x92,0xe7,0xf9,0x41, -0xa5,0xd1,0x57,0xd8,0xfc,0x20,0xcc,0x5f,0xbe,0xa2,0x8a,0x23,0x5f,0x75,0x3c,0xf9, -0x2a,0xf,0xcf,0x47,0x11,0x47,0xbe,0x7a,0xe4,0xc9,0x57,0x9d,0x9c,0x8d,0xbf,0xd0, -0x93,0xaf,0x1e,0xe5,0x2c,0x5f,0x41,0x4f,0xbe,0x62,0xc7,0x17,0xe5,0xdd,0x97,0xa3, -0xe3,0xab,0xe6,0x2b,0xd1,0xfb,0xfc,0x20,0x5c,0x6e,0xbe,0xfa,0x9a,0x27,0x5f,0x9, -0xde,0x7c,0x5,0x96,0x9b,0xaf,0x10,0x5b,0x7f,0x65,0xf8,0xec,0xf5,0xed,0xcc,0xb7, -0xb1,0xdc,0x7c,0xa5,0xfa,0x9c,0xf9,0x8a,0xad,0x3f,0x50,0x72,0xb1,0xff,0x95,0x9a, -0xaf,0xd0,0x1d,0x57,0xbe,0xba,0x5b,0x62,0xf9,0x2a,0x17,0xbe,0xf,0xfa,0xda,0xfc, -0x20,0xcc,0x71,0xbe,0xd2,0xe6,0xdf,0x60,0x8e,0xf3,0x95,0xe6,0x3,0x39,0xce,0x57, -0xaa,0x2f,0xbf,0xeb,0xdb,0xd5,0x7c,0x25,0xab,0xf9,0xaa,0x10,0x56,0xbf,0x82,0x39, -0xc9,0x57,0xe6,0xfc,0xa0,0xe0,0xad,0x5f,0x75,0x72,0x92,0xaf,0x8c,0xf5,0xd9,0x6c, -0x7f,0x51,0xbb,0x7e,0xf5,0x28,0x57,0xfb,0x5f,0xd9,0xfb,0x8b,0x32,0x5f,0x5e,0x9f, -0xcf,0xfb,0xc2,0xf8,0x96,0x79,0x7c,0xdb,0xa5,0x17,0xd4,0xfc,0x2,0x78,0xcf,0xf, -0xd6,0x72,0x90,0xaf,0x68,0x4b,0xea,0x4b,0x13,0xb4,0x1d,0xf6,0xfc,0xe0,0x52,0xdf, -0xf,0xd1,0x92,0xc0,0x6d,0x63,0xff,0x4e,0x7c,0x14,0xe4,0x5b,0xe6,0xfa,0xd8,0xfa, -0x13,0xe0,0x7a,0x3e,0xf,0xb2,0xfd,0x45,0xf3,0xf1,0xfc,0x20,0xad,0x63,0x70,0xe7, -0xb2,0xf3,0xf9,0x41,0xb6,0xbf,0x68,0x4e,0xd6,0xb7,0x6b,0xed,0x47,0xf2,0xfb,0xfc, -0x20,0xad,0x4b,0x20,0xcf,0xf9,0x45,0xf5,0xf5,0x27,0x4,0xe5,0xd7,0xd7,0x2,0x2f, -0xa8,0xf9,0x25,0xbf,0xfb,0x8b,0x8a,0x56,0x7e,0x39,0x9,0xf4,0x2d,0xb3,0xff,0x3, -0x56,0x7e,0x91,0xa8,0xb3,0x7e,0xe5,0xf4,0xe5,0x63,0x7f,0x6,0xdd,0x67,0xd5,0xaf, -0x9c,0xbe,0x7c,0xe4,0x2b,0xd3,0xd7,0x5,0x81,0xef,0xbf,0x5c,0xae,0xef,0xf3,0x9c, -0xfb,0x7e,0x97,0x4b,0xdf,0xb7,0xc1,0xb,0x66,0x7d,0x48,0x9f,0x4b,0x6f,0xc3,0x7c, -0xf9,0x8,0xb8,0xdd,0x37,0xe7,0xdf,0x8c,0xf3,0x2f,0x7f,0x3e,0x2d,0x5f,0x55,0x59, -0xff,0x97,0x37,0x9f,0x2,0xde,0xd0,0xf2,0x55,0xd5,0x37,0x3f,0x98,0x17,0x5f,0x5b, -0xcf,0x57,0x55,0xdf,0xfc,0xa0,0xe5,0x73,0xbc,0x9f,0x78,0x19,0xbe,0x9e,0x9e,0xaf, -0xaa,0x91,0xde,0xef,0xbc,0xc,0x5f,0x5f,0x32,0x7c,0x51,0xde,0xef,0xbc,0x1c,0x5f, -0xdf,0x3f,0xff,0x76,0x12,0xf9,0xbb,0xcd,0xff,0xfa,0xbd,0xf5,0x82,0x39,0xff,0x96, -0xe8,0xb3,0xc0,0xfd,0xf,0x2,0x3e,0x9f,0x17,0x8b,0x4b,0xf4,0x39,0xf6,0x3f,0x8, -0xf8,0x8c,0x26,0x68,0x99,0x3e,0x7b,0xfc,0xfd,0xa2,0xfa,0x50,0xde,0x7d,0x5b,0xb9, -0xf6,0x7d,0x5e,0xcc,0x79,0xfb,0xd1,0x5c,0xfb,0xc8,0x88,0x5c,0xf8,0xd2,0x1c,0xdf, -0xab,0x74,0xc1,0xfd,0x33,0xbf,0x6,0x54,0xc8,0xcd,0xf8,0x96,0x73,0x5f,0xb6,0x9f, -0xb,0xdf,0x85,0x2f,0xe6,0x7,0xad,0x83,0x5f,0x17,0xb,0x8,0x9f,0x4c,0xae,0x95, -0xbe,0xa7,0x28,0x68,0xe7,0x5a,0x9,0xe4,0xc9,0x77,0x8c,0x3a,0x6f,0x11,0x7c,0x7c, -0x2a,0x3d,0x19,0xc1,0xdb,0x67,0x67,0xe8,0xf9,0x11,0xdc,0xce,0x9b,0x4f,0x51,0x8e, -0x8f,0xc1,0x68,0x24,0x81,0x27,0x4f,0xa4,0xd6,0x8,0xde,0xca,0x97,0xef,0xe0,0x45, -0x85,0x1e,0x63,0x0,0xa1,0xa4,0x1a,0xa1,0xa8,0x32,0xf3,0xe4,0xeb,0xa1,0x83,0x7f, -0xf3,0x34,0xed,0xe1,0x5f,0xc2,0x92,0xf4,0x4b,0xcd,0x27,0x5d,0xcb,0x99,0xef,0xb7, -0x5d,0xe5,0xb0,0x87,0x3f,0x1,0xb0,0xf7,0x49,0xaf,0x7,0xc4,0xde,0x28,0x57,0xbe, -0x75,0xcd,0xa7,0xac,0xe3,0x3e,0x80,0xad,0x7e,0xab,0x5,0xc4,0xd6,0x71,0xae,0x7c, -0x3b,0xba,0x6f,0x7,0xf7,0x7b,0xb0,0xde,0x5f,0x5f,0x7,0x62,0xfd,0xb3,0x62,0x9e, -0x7c,0x42,0xb5,0xd7,0x25,0x58,0xa8,0xf5,0x5b,0x12,0xee,0x2b,0x8a,0xb8,0xa3,0x40, -0x90,0x33,0x9f,0xda,0x3f,0xb,0xb5,0xc3,0x9d,0x2b,0x5f,0x3e,0x54,0x7d,0x8f,0x2f, -0xe7,0xab,0x7f,0xbe,0x18,0x7f,0x2f,0x7c,0x17,0xbe,0xb,0xdf,0x85,0xef,0xc2,0x77, -0xe1,0xbb,0xf0,0x5d,0xf8,0x2e,0x7c,0x5f,0x28,0x1f,0x21,0x14,0x62,0xfd,0xc9,0x79, -0xee,0x7,0xd2,0xc3,0xe5,0xfa,0xa6,0xf7,0xe9,0xd6,0x29,0x11,0xa8,0xfe,0x7c,0x99, -0x59,0xe,0x3e,0x33,0xbe,0xd4,0xd1,0xff,0xbf,0xbd,0x64,0xdf,0x33,0xa4,0x78,0x34, -0xd,0xf4,0x6d,0xd1,0xff,0x2a,0x2c,0xd7,0xf7,0xd5,0x69,0x79,0xcf,0xe5,0x1b,0x3a, -0x7d,0x45,0x7a,0x6d,0xc9,0xbe,0x75,0x99,0x6e,0xc8,0x2,0x6d,0xb,0x9d,0xdd,0xe9, -0xb5,0xfa,0x58,0xa0,0x7b,0x54,0x2e,0xe,0x48,0xf1,0x4c,0x2e,0x52,0x48,0x8a,0xf4, -0xc6,0x92,0x7d,0x7f,0x7d,0x42,0xff,0xf9,0xef,0x54,0xdf,0x8d,0xcd,0x75,0xf9,0xf2, -0xf7,0x6,0xcf,0x9e,0x3e,0xa0,0x72,0xa1,0x7d,0xbf,0xf0,0xad,0x71,0x91,0xe,0xdf, -0xfe,0x2e,0x7d,0x66,0xc9,0xbe,0xe9,0xe0,0xe6,0xea,0xa0,0x4c,0x3b,0x57,0x4a,0x6f, -0xb,0x1f,0xbd,0xb0,0xff,0xec,0xa9,0x7a,0x7c,0x8f,0x3e,0x29,0x1f,0xad,0x1e,0x75, -0xe8,0x70,0xbb,0x43,0xbf,0xb5,0x6c,0x5f,0xfb,0x2b,0x97,0xda,0x25,0xda,0x79,0xbb, -0xbc,0x72,0xff,0xa9,0xc2,0x96,0xee,0x3b,0xdd,0xba,0xb9,0x5a,0xdc,0xef,0xd0,0x23, -0xd5,0xf7,0x2f,0x96,0xed,0xeb,0x18,0xfd,0xcb,0xdb,0xc2,0xca,0xdd,0xa7,0x4a,0xdb, -0x86,0x6f,0xfb,0xc6,0x6a,0xa9,0xd3,0xa1,0xa7,0xe5,0xe,0x7d,0x6a,0xe9,0xbe,0x8e, -0xe1,0xa3,0xe5,0x93,0x7f,0x28,0x5a,0x3e,0x95,0xd6,0xa1,0x67,0xe5,0xce,0xf0,0xf2, -0xb2,0x7d,0xfb,0xcc,0x57,0x3a,0xfa,0x87,0xef,0x6c,0x3d,0x73,0x7a,0xa4,0x1d,0xdf, -0x67,0x4e,0xcb,0xea,0xf1,0x95,0x85,0xce,0xde,0xb5,0xa5,0x5f,0x1f,0x45,0xcd,0xd7, -0xbe,0x42,0x37,0xc6,0x4f,0xfd,0xdb,0xf6,0x8d,0xd5,0x13,0x2a,0xaf,0xaa,0xff,0x28, -0xf,0x8a,0x74,0xba,0xb6,0xba,0xb7,0xbe,0x6c,0xdf,0xb8,0xa4,0xfb,0x6e,0xd0,0x7, -0xf2,0x53,0xf7,0xd4,0x8b,0xf9,0x4c,0xef,0x5f,0x56,0xcb,0x6a,0xff,0x32,0xbd,0x7f, -0x69,0x6f,0xc9,0xe3,0x9b,0xe3,0x3,0xb4,0xff,0x31,0x5a,0xb,0x12,0x23,0x3c,0x5c, -0xe4,0xab,0xb,0xdf,0x85,0xef,0xc2,0x77,0xe1,0xcb,0x9b,0xaf,0x9c,0x17,0xdf,0x86, -0x5c,0x56,0x73,0xc0,0x26,0xa5,0x85,0xb1,0x0,0xd4,0x31,0x64,0xcf,0xe9,0x23,0xca, -0xd2,0xef,0x7f,0x57,0x6,0xc5,0xb3,0xc1,0xb5,0x4b,0xf4,0xa1,0x9a,0x52,0xb7,0xa7, -0x25,0xfa,0x60,0xdb,0xe1,0x9b,0xde,0x5b,0xb6,0x6f,0xfa,0xcc,0xde,0xd6,0xd9,0xde, -0x95,0x7f,0x45,0xdf,0xfe,0xde,0xe6,0xb5,0x92,0x5c,0x52,0x33,0xbd,0xf3,0xab,0x7f, -0xb0,0xf4,0xf6,0x9b,0xc2,0xce,0x69,0xe7,0xda,0x19,0x2d,0x9f,0x6d,0x5f,0x29,0x9d, -0xa8,0xb7,0x97,0xeb,0x74,0x7b,0x4f,0x2e,0xad,0x3d,0x27,0xdf,0x24,0x74,0x7a,0x69, -0xe9,0xe7,0xdf,0x94,0x76,0x8e,0x3e,0x29,0x9d,0x91,0xf2,0xd9,0xc3,0x2b,0xdb,0x47, -0x9a,0xef,0x5e,0xf1,0xc1,0xf8,0xf2,0x8d,0x3f,0x18,0x5f,0xbb,0x4f,0xa7,0xbb,0x4b, -0xf7,0xc9,0xa4,0xb8,0xff,0x49,0x69,0x77,0x2a,0x9c,0xbc,0x5d,0xda,0x6e,0xb,0x74, -0xf8,0xf0,0x99,0xb2,0x7c,0xda,0xb9,0xb1,0x7e,0xf4,0x27,0xaa,0xef,0x6c,0xe9,0xbe, -0x93,0x69,0xa9,0xf3,0x8b,0xed,0x8d,0x29,0x3d,0xfa,0xef,0xdb,0xdb,0xeb,0x65,0xf5, -0xfc,0x7b,0x46,0x98,0x1e,0x75,0x6e,0xfc,0xf5,0xfe,0x27,0xcf,0xe6,0xc1,0x77,0x44, -0xb7,0xb6,0xfe,0xd7,0xf6,0x89,0x4c,0xf7,0xff,0x6c,0x7b,0x7b,0x5b,0xbb,0x3e,0x9e, -0xa1,0xed,0x61,0xe7,0xc6,0x2f,0x3a,0x9d,0x5c,0xf8,0xb6,0x68,0xa7,0xb4,0xbb,0x7d, -0x76,0x42,0xb7,0x36,0x54,0xdf,0xb6,0xee,0x5b,0x37,0x7c,0xff,0x2d,0xf,0xbe,0x12, -0xec,0x94,0xf7,0x1e,0x9e,0x9d,0xd2,0xd2,0xa6,0xe9,0x7b,0x96,0x5e,0x31,0x7c,0x1b, -0xaa,0x6f,0xb8,0xec,0xfe,0xe5,0xd2,0xe0,0xb2,0xd0,0xbe,0x76,0x69,0x48,0x56,0xd7, -0xaf,0xac,0xae,0x97,0xe8,0xde,0xfa,0xb3,0x5a,0x9f,0x7d,0xe5,0x17,0xed,0xe2,0xbe, -0xea,0xdb,0x5b,0x76,0xff,0xbc,0xa2,0xfa,0xd4,0xf1,0x63,0x38,0xbd,0xd4,0xfe,0x9a, -0x56,0xe8,0x78,0xb0,0xfe,0x2c,0x5d,0x19,0x5f,0xfe,0xca,0x2f,0x6,0xb9,0xf0,0x51, -0x8a,0x45,0x8a,0x5,0xed,0xf5,0x2e,0x48,0xd0,0xfe,0x4f,0xbb,0x69,0x3,0x5a,0xed, -0xf,0x8b,0x30,0xbf,0xf9,0xa5,0x93,0xef,0x7c,0x45,0x8a,0xf9,0xf6,0xa9,0x39,0xe6, -0x22,0x3f,0xff,0xa3,0xf3,0xfd,0x7f,0x6e,0x69,0x1,0x55,0x8,0x9e,0xa1,0x2b,0x0, -0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 -}; -//m1284p.png: 12987 bytes -*/ -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/.cproject b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/.cproject deleted file mode 100644 index 7a19556..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/.cproject +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/.project b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/.project deleted file mode 100644 index 67b1c40..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 12_m1284p_WIZNET_HTTPServer_SDCARD_pages - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.c deleted file mode 100644 index 41ee2db..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - @file httpd.c - @brief functions associated http processing - */ - -#include -#include -#include "socket.h" -#include "httpParser.h" - -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -//uint8_t BUFPUB[2048]; -uint8_t BUFPUB[256]; - -/***************************************************************************** - * Private functions - ****************************************************************************/ -static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */ -static uint8_t C2D(uint8_t c); /* Convert a character to HEX */ - -/** - @brief convert escape characters(%XX) to ASCII character - */ -void unescape_http_url( - char * url /**< pointer to be converted ( escape characters )*/ - ) -{ - int x, y; - - for (x = 0, y = 0; url[y]; ++x, ++y) { - if ((url[x] = url[y]) == '%') { - url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]); - y+=2; - } - } - url[x] = '\0'; -} - - -/** - @brief make response header such as html, gif, jpeg,etc. - */ -void make_http_response_head( - char * buf, /**< pointer to response header to be made */ - char type, /**< response type */ - uint32_t len /**< size of response header */ - ) -{ - const char * head; - char tmp[10]; - - /* file type*/ - if (type == PTYPE_HTML) head = PSTR(RES_HTMLHEAD_OK); - else if (type == PTYPE_GIF) head = PSTR(RES_GIFHEAD_OK); - else if (type == PTYPE_TEXT) head = PSTR(RES_TEXTHEAD_OK); - else if (type == PTYPE_JPEG) head = PSTR(RES_JPEGHEAD_OK); - else if (type == PTYPE_FLASH) head = PSTR(RES_FLASHHEAD_OK); - else if (type == PTYPE_XML) head = PSTR(RES_XMLHEAD_OK); - else if (type == PTYPE_CSS) head = PSTR(RES_CSSHEAD_OK); - else if (type == PTYPE_JSON) head = PSTR(RES_JSONHEAD_OK); - else if (type == PTYPE_JS) head = PSTR(RES_JSHEAD_OK); - else if (type == PTYPE_CGI) head = PSTR(RES_CGIHEAD_OK); - else if (type == PTYPE_PNG) head = PSTR(RES_PNGHEAD_OK); - else if (type == PTYPE_ICO) head = PSTR(RES_ICOHEAD_OK); - else if (type == PTYPE_TTF) head = PSTR(RES_TTFHEAD_OK); - else if (type == PTYPE_OTF) head = PSTR(RES_OTFHEAD_OK); - else if (type == PTYPE_WOFF) head = PSTR(RES_WOFFHEAD_OK); - else if (type == PTYPE_EOT) head = PSTR(RES_EOTHEAD_OK); - else if (type == PTYPE_SVG) head = PSTR(RES_SVGHEAD_OK); -#ifdef _HTTPPARSER_DEBUG_ - else - { - head = NULL; - PRINTF("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n"); - } -#else - else head = NULL; -#endif - - sprintf(tmp, "%ld", len); - strcpy_P(buf, head); - strcat(buf, tmp); - strcat(buf, "\r\n\r\n"); -} - - -/** - @brief find MIME type of a file - */ -void find_http_uri_type( - uint8_t * type, /**< type to be returned */ - uint8_t * buff /**< file name */ - ) -{ - /* Decide type according to extension*/ - - char * buf; - buf = (char *)buff; - - if (strcasestr_P(buf, PSTR(".htm")) || strcasestr_P(buf, PSTR(".html"))) *type = PTYPE_HTML; - else if (strcasestr_P(buf, PSTR(".gif"))) *type = PTYPE_GIF; - else if (strcasestr_P(buf, PSTR(".text")) || strstr_P(buf,PSTR(".txt"))) *type = PTYPE_TEXT; - else if (strcasestr_P(buf, PSTR(".jpeg")) || strstr_P(buf,PSTR(".jpg"))) *type = PTYPE_JPEG; - else if (strcasestr_P(buf, PSTR(".swf"))) *type = PTYPE_FLASH; - else if (strstr_P(buf, PSTR(".cgi")) || strstr_P(buf,PSTR(".CGI"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".json")) || strstr_P(buf,PSTR(".JSON"))) *type = PTYPE_JSON; - else if (strstr_P(buf, PSTR(".js")) || strstr_P(buf,PSTR(".JS"))) *type = PTYPE_JS; - else if (strstr_P(buf, PSTR(".CGI")) || strstr_P(buf,PSTR(".cgi"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".xml")) || strstr_P(buf,PSTR(".XML"))) *type = PTYPE_XML; - else if (strstr_P(buf, PSTR(".css")) || strstr_P(buf,PSTR(".CSS"))) *type = PTYPE_CSS; - else if (strstr_P(buf, PSTR(".png")) || strstr_P(buf,PSTR(".PNG"))) *type = PTYPE_PNG; - else if (strstr_P(buf, PSTR(".ico")) || strstr_P(buf,PSTR(".ICO"))) *type = PTYPE_ICO; - else if (strstr_P(buf, PSTR(".ttf")) || strstr_P(buf,PSTR(".TTF"))) *type = PTYPE_TTF; - else if (strstr_P(buf, PSTR(".otf")) || strstr_P(buf,PSTR(".OTF"))) *type = PTYPE_OTF; - else if (strstr_P(buf, PSTR(".woff")) || strstr_P(buf,PSTR(".WOFF"))) *type = PTYPE_WOFF; - else if (strstr_P(buf, PSTR(".eot")) || strstr_P(buf,PSTR(".EOT"))) *type = PTYPE_EOT; - else if (strstr_P(buf, PSTR(".svg")) || strstr_P(buf,PSTR(".SVG"))) *type = PTYPE_SVG; - else *type = PTYPE_ERR; -} - - -/** - @brief parse http request from a peer - */ -void parse_http_request( - st_http_request * request, /**< request to be returned */ - uint8_t * buf /**< pointer to be parsed */ - ) -{ - char * nexttok; - nexttok = strtok((char*)buf," "); - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - if(!strcmp_P(nexttok, PSTR("GET")) || !strcmp_P(nexttok,PSTR("get"))) - { - request->METHOD = METHOD_GET; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("HEAD")) || !strcmp_P(nexttok,PSTR("head"))) - { - request->METHOD = METHOD_HEAD; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("POST")) || !strcmp_P(nexttok,PSTR("post"))) - { - nexttok = strtok(NULL,"\0"); - request->METHOD = METHOD_POST; - } - else - { - request->METHOD = METHOD_ERR; - } - - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - strcpy((char *)request->URI, nexttok); -} - -#ifdef _OLD_ -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value( - char* uri, - char* param_name - ) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * name = 0; - - - if(!uri || !param_name) return 0; - - strcpy((char*)tempURI,uri); - if((name = (uint8_t*)strstr(tempURI, param_name))) - { - name += strlen(param_name) + 1; // strlen(para_name) + strlen("=") - if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0"))) - { - unescape_http_url((char *)name); - replacetochar(name, '+', ' '); - } - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s",param_name,name); -#endif - - return name; -} -#else -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value(char* uri, char* param_name) -{ - - uint8_t * name = 0; - uint8_t * ret = BUFPUB; - uint8_t * pos2; - uint16_t len = 0, content_len = 0; - uint8_t tmp_buf[10]={0x00, }; - - if(!uri || !param_name) return 0; - - /***************/ - mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf); - content_len = ATOI(tmp_buf, 10); - uri = strstr(uri, "\r\n\r\n"); - uri += 4; - uri[content_len] = 0; - /***************/ - - if((name = (uint8_t *)strstr(uri, param_name))) - { - name += strlen(param_name) + 1; - pos2 = (uint8_t*)strstr((char*)name, "&"); - if(!pos2) - { - pos2 = name + strlen((char*)name); - } - len = pos2 - name; - - if(len) - { - ret[len] = 0; - strncpy((char*)ret,(char*)name, len); - unescape_http_url((char *)ret); - replacetochar(ret, '+' ,' '); - //ret[len] = 0; - //ret[strlen((int8*)ret)] = 0; - //printf("len=%d\r\n",len); - } - else - { - ret[0] = 0; - } - } - else - { - return 0; - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s\r\n", param_name, ret); -#endif - return ret; -} -#endif - -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * uri_name; - - if(!uri) return 0; - - strcpy(tempURI, (char *)uri); - - uri_name = (uint8_t *)strtok(tempURI, " ?"); - - if(strcmp((char *)uri_name,"/")) uri_name++; - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_name); -#endif - - return uri_name; -} -#else - -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf) -{ - uint8_t * uri_ptr; - if(!uri) return 0; - - strcpy((char *)uri_buf, (char *)uri); - - uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?"); - - if(strcmp((char *)uri_ptr,"/")) uri_ptr++; - strcpy((char *)uri_buf, (char *)uri_ptr); - -#ifdef _HTTPPARSER_DEBUG_ - PRINTF(" uri_name = %s\r\n", uri_buf); -#endif - - return 1; -} - -#endif - -void inet_addr_(uint8_t * addr, uint8_t *ip) -{ - uint8_t i; - uint8_t taddr[30]; - uint8_t * nexttok; - uint8_t num; - - strcpy((char *)taddr, (char *)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (uint8_t *)strtok((char *)nexttok, "."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10); - else num = ATOI(nexttok,10); - ip[i] = num; - nexttok = NULL; - } -} - - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; -// debug_2013_11_25 -// while (*str !=0) - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -/** - * @brief Check strings and then execute callback function by each string. - * @param src The information of URI - * @param s1 The start string to be researched - * @param s2 The end string to be researched - * @param sub The string between s1 and s2 - * @return The length value atfer working - */ -void mid(char* src, char* s1, char* s2, char* sub) -{ - char* sub1; - char* sub2; - uint16_t n; - - sub1=strstr((char*)src,(char*)s1); - sub1+=strlen((char*)s1); - sub2=strstr((char*)sub1,(char*)s2); - - n=sub2-sub1; - strncpy((char*)sub,(char*)sub1,n); - sub[n]='\0'; -} - -//////////////////////////////////////////////////////////////////// -// Static functions -//////////////////////////////////////////////////////////////////// - -/** -@brief replace the specified character in a string with new character -*/ -static void replacetochar( - uint8_t * str, /**< pointer to be replaced */ - uint8_t oldchar, /**< old character */ - uint8_t newchar /**< new character */ - ) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == oldchar) str[x] = newchar; -} - -/** -@brief CONVERT CHAR INTO HEX -@return HEX - -This function converts HEX(0-F) to a character -*/ -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - - - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.h deleted file mode 100644 index c289c2e..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - @file httpd.h - @brief Define Constants and fucntions associated with HTTP protocol. - */ - -#include -#include "../../globals.h" - -#ifndef __HTTPPARSER_H__ -#define __HTTPPARSER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#define _HTTPPARSER_DEBUG_ - -#define HTTP_SERVER_PORT 80 /**< HTTP server well-known port number */ - -/* HTTP Method */ -#define METHOD_ERR 0 /**< Error Method. */ -#define METHOD_GET 1 /**< GET Method. */ -#define METHOD_HEAD 2 /**< HEAD Method. */ -#define METHOD_POST 3 /**< POST Method. */ - -/* HTTP GET Method */ -#define PTYPE_ERR 0 /**< Error file. */ -#define PTYPE_HTML 1 /**< HTML file. */ -#define PTYPE_GIF 2 /**< GIF file. */ -#define PTYPE_TEXT 3 /**< TEXT file. */ -#define PTYPE_JPEG 4 /**< JPEG file. */ -#define PTYPE_FLASH 5 /**< FLASH file. */ -#define PTYPE_MPEG 6 /**< MPEG file. */ -#define PTYPE_PDF 7 /**< PDF file. */ -#define PTYPE_CGI 8 /**< CGI file. */ -#define PTYPE_XML 9 /**< XML file. */ -#define PTYPE_CSS 10 /**< CSS file. */ -#define PTYPE_JS 11 /**< JavaScript file. */ -#define PTYPE_JSON 12 /**< JSON (JavaScript Standard Object Notation) file. */ -#define PTYPE_PNG 13 /**< PNG file. */ -#define PTYPE_ICO 14 /**< ICON file. */ - -#define PTYPE_TTF 20 /**< Font type: TTF file. */ -#define PTYPE_OTF 21 /**< Font type: OTF file. */ -#define PTYPE_WOFF 22 /**< Font type: WOFF file. */ -#define PTYPE_EOT 23 /**< Font type: EOT file. */ -#define PTYPE_SVG 24 /**< Font type: SVG file. */ - - -/* HTTP response */ -#define STATUS_OK 200 -#define STATUS_CREATED 201 -#define STATUS_ACCEPTED 202 -#define STATUS_NO_CONTENT 204 -#define STATUS_MV_PERM 301 -#define STATUS_MV_TEMP 302 -#define STATUS_NOT_MODIF 304 -#define STATUS_BAD_REQ 400 -#define STATUS_UNAUTH 401 -#define STATUS_FORBIDDEN 403 -#define STATUS_NOT_FOUND 404 -#define STATUS_INT_SERR 500 -#define STATUS_NOT_IMPL 501 -#define STATUS_BAD_GATEWAY 502 -#define STATUS_SERV_UNAVAIL 503 - -/* HTML Doc. for ERROR */ -static const char PROGMEM ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n\r\n\r\nSorry, the page you requested was not found.\r\n\r\n\r\n\0"; -static const char PROGMEM ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n\r\n\r\nInvalid request.\r\n\r\n\r\n\0"; - -/* HTML Doc. for CGI result */ -#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response header for HTML*/ -#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for TEXT */ -#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " - -/* Response head for GIF */ -#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: " - -/* Response head for JPEG */ -#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: " - -/* Response head for PNG */ -#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: " - -/* Response head for FLASH */ -#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: " - -/* Response head for XML */ -#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for CSS */ -#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: " - -/* Response head for JavaScript */ -#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: " - -/* Response head for JSON */ -#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " - -/* Response head for ICO */ -#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: " - -/* Response head for CGI */ -#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response head for TTF, Font */ -#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: " - -/* Response head for OTF, Font */ -#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: " - -/* Response head for WOFF, Font */ -#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: " - -/* Response head for EOT, Font */ -#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: " - -/* Response head for SVG, Font */ -#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: " - -/** - @brief Structure of HTTP REQUEST - */ - -//#define MAX_URI_SIZE 1461 -#define MAX_URI_SIZE 512 - -typedef struct _st_http_request -{ - uint8_t METHOD; /**< request method(METHOD_GET...). */ - uint8_t TYPE; /**< request type(PTYPE_HTML...). */ - uint8_t URI[MAX_URI_SIZE]; /**< request file name. */ -}st_http_request; - -// HTTP Parsing functions -void unescape_http_url(char * url); /* convert escape character to ascii */ -void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */ -void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */ -void make_http_response_head(char *, char, uint32_t); /* make response header */ -uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */ -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */ -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri); -#endif - -// Utility functions -uint16_t ATOI(uint8_t * str, uint8_t base); -void mid(char* src, char* s1, char* s2, char* sub); -void inet_addr_(uint8_t * addr, uint8_t * ip); - -#ifdef __cplusplus -} -#endif - -#endif /* end of __HTTPPARSER_H__ */ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.c deleted file mode 100644 index d3e38f4..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.c +++ /dev/null @@ -1,878 +0,0 @@ -#include -#include -#include - -#include "socket.h" -#include "wizchip_conf.h" - -#include "httpServer.h" -#include "httpParser.h" -#include "httpUtil.h" - -#include "../../globals.h" //add AVR specific useful headers - - -#define DATA_BUF_SIZE HTTPD_MAX_BUF_SIZE -/***************************************************************************** - * Private types/enumerations/variables - ****************************************************************************/ -static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, }; -static st_http_request * http_request; /**< Pointer to received HTTP request */ -static st_http_request * parsed_http_request; /**< Pointer to parsed HTTP request */ -static uint8_t * http_response; /**< Pointer to HTTP response */ - -// ## For Debugging -//static uint8_t uri_buf[128]; -// Number of registered web content in code flash memory -static uint16_t total_content_cnt = 0; -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -uint8_t * pHTTP_TX; -uint8_t * pHTTP_RX; - -volatile uint32_t httpServer_tick_1s = 0; -st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }; -httpServer_webContent web_content[MAX_CONTENT_CALLBACK]; - -#ifdef _USE_SDCARD_ -//static FIL fs; // FatFs: File object -static FRESULT fr; // FatFs: File function return code -#endif -/***************************************************************************** - * Private functions - ****************************************************************************/ -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist); -static uint8_t getHTTPSocketNum(uint8_t seqnum); -static int8_t getHTTPSequenceNum(uint8_t socket); -static int8_t http_disconnect(uint8_t sn); - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request); - -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status); - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len); - -/***************************************************************************** - * Public functions - ****************************************************************************/ -// Callback functions definition: MCU Reset / WDT Reset -void default_mcu_reset(void) {;} -void default_wdt_reset(void) {;} -void (*HTTPServer_ReStart)(void) = default_mcu_reset; -void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset; - -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist) -{ - uint8_t i; - - for(i = 0; i < cnt; i++) - { - // Mapping the H/W socket numbers to the sequential index numbers - HTTPSock_Num[i] = socklist[i]; - } -} - -static uint8_t getHTTPSocketNum(uint8_t seqnum) -{ - // Return the 'H/W socket number' corresponding to the index number - return HTTPSock_Num[seqnum]; -} - -static int8_t getHTTPSequenceNum(uint8_t socket) -{ - uint8_t i; - - for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++) - if(HTTPSock_Num[i] == socket) return i; - - return -1; -} - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist) -{ - // User's shared buffer - pHTTP_TX = tx_buf; - pHTTP_RX = rx_buf; - - // H/W Socket number mapping - httpServer_Sockinit(cnt, socklist); -} - - -/* Register the call back functions for HTTP Server */ -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)) -{ - // Callback: HW Reset and WDT reset function for each MCU platforms - if(mcu_reset) HTTPServer_ReStart = mcu_reset; - if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset; -} - - - -void httpServer_run_avr(uint8_t seqnum) -{ - uint8_t s; // socket number - uint16_t len; - uint32_t gettime = 0; - -#ifdef _HTTPSERVER_DEBUG_ - uint8_t destip[4] = {0, }; - uint16_t destport = 0; -#endif - - http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request - parsed_http_request = (st_http_request *)pHTTP_TX; - - // Get the H/W socket number - s = getHTTPSocketNum(seqnum); - - /* HTTP Service Start */ - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - } - - // HTTP Process states - switch(HTTPSock_Status[seqnum].sock_status) - { - - case STATE_HTTP_IDLE : - if ((len = getSn_RX_RSR(s)) > 0) - { - if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; - len = recv(s, (uint8_t *)http_request, len); - - *(((uint8_t *)http_request) + len) = '\0'; - - parse_http_request(parsed_http_request, (uint8_t *)http_request); -#ifdef _HTTPSERVER_DEBUG_ - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("\r\n"); - PRINTF("> HTTPSocket[%d] : HTTP Request received ", s); - PRINTF("from %d.%d.%d.%d : %u\r\n", destip[0], destip[1], destip[2], destip[3], destport); -#endif -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -#endif - // HTTP 'response' handler; includes send_http_response_header / body function - http_process_handler_avr(s, parsed_http_request); - - gettime = get_httpServer_timecount(); - // Check the TX socket buffer for End of HTTP response sends - while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) - { - if((get_httpServer_timecount() - gettime) > 3) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -#endif - break; - } - } - - if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; - else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end - } - break; - - case STATE_HTTP_RES_INPROC : - /* Repeat: Send the remain parts of HTTP responses */ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); - PRINTF("\r\n> HTTPSocket[%d] : Re-Open the requested content\r\n", s); //_delay_ms(200); -#endif -/* -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - - if((fr = f_open(&fs, (const char *)HTTPSock_Status[seqnum].file_name, FA_READ)) == 0) - { -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); - if((fr = f_lseek(&fs, HTTPSock_Status[seqnum].file_offset)) != 0) - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif - } - else - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif -*/ - // Repeatedly send remaining data to client - send_http_response_body_avr(s, 0, http_response, 0, 0); - - if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - - case STATE_HTTP_RES_DONE : -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -#endif - // Socket file info structure re-initialize - HTTPSock_Status[seqnum].file_len = 0; - HTTPSock_Status[seqnum].file_offset = 0; - HTTPSock_Status[seqnum].file_start = 0; - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; - -#ifdef _USE_SDCARD_ - f_close(&HTTPSock_Status[seqnum].fs); -#endif -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif - http_disconnect(s); - break; - - default : - break; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : CLOSED\r\n", s); -#endif - if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: - listen(s); - break; - - case SOCK_LISTEN: - break; - - default : - break; - - } // end of switch - -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif -} - -//////////////////////////////////////////// -// Private Functions -//////////////////////////////////////////// -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status) -{ - switch(http_status) - { - case STATUS_OK: // HTTP/1.1 200 OK - if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s); -#endif - make_http_response_head((char*)http_response, content_type, body_len); - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s); -#endif - // CGI/XML type request does not respond HTTP header to client - http_status = 0; - } - break; - case STATUS_BAD_REQ: // HTTP/1.1 400 OK -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s); -#endif - memcpy_P(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE)); - break; - case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s); -#endif - memcpy_P(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE)); - break; - default: - break; - } - - // Send the HTTP Response 'header' - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response)); -#endif - send(s, http_response, strlen((char *)http_response)); - } -} - - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -{ - int8_t get_seqnum; - uint32_t send_len; - - uint8_t flag_datasend_end = 0; - -#ifdef _USE_SDCARD_ - uint16_t blocklen; -#endif -#ifdef _USE_FLASH_ - uint32_t addr = 0; -#endif - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - // Send the HTTP Response 'body'; requested file - if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### - { - if (file_len > DATA_BUF_SIZE - 1) - { - HTTPSock_Status[get_seqnum].file_start = start_addr; - HTTPSock_Status[get_seqnum].file_len = file_len; - send_len = DATA_BUF_SIZE - 1; - -///////////////////////////////////////////////////////////////////////////////////////////////// -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) - memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); - strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -#endif -///////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -#endif - } - else - { - // Send process end - send_len = file_len; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (1)HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -#endif - } -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -#endif - } - else // remained parts - { -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; - } -#endif - send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; - - if(send_len > DATA_BUF_SIZE - 1) - { - send_len = DATA_BUF_SIZE - 1; - //HTTPSock_Status[get_seqnum]->file_offset += send_len; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (2)HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -#endif - // Send process end - flag_datasend_end = 1; - } -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -#endif - } - -/*****************************************************/ - //HTTPSock_Status[get_seqnum]->storage_type == NONE - //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH - //HTTPSock_Status[get_seqnum]->storage_type == SDCARD - //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -/*****************************************************/ - - if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) - { - if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; - read_userReg_webContent_avr(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); - } -#ifdef _USE_SDCARD_ - else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) - { - // Data read from SD Card - //PRINTF("++SDCARD f_read(..)\r\n"); - fr = f_read(&HTTPSock_Status[get_seqnum].fs, &buf[0], send_len, (void *)&blocklen); - if(fr != FR_OK) - { - send_len = 0; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -#endif - } - else - { - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } - } -#endif - -#ifdef _USE_FLASH_ - else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - // Data read from external data flash memory - read_from_flashbuf(addr, &buf[0], send_len); - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } -#endif - else - { - send_len = 0; - } - // Requested content send to HTTP client -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -#endif - - if(send_len) send(s, buf, send_len); - else flag_datasend_end = 1; - - if(flag_datasend_end) - { - HTTPSock_Status[get_seqnum].file_start = 0; - HTTPSock_Status[get_seqnum].file_len = 0; - HTTPSock_Status[get_seqnum].file_offset = 0; - flag_datasend_end = 0; - } - else - { - HTTPSock_Status[get_seqnum].file_offset += send_len; -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -#endif - } - -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -#ifdef _USE_SDCARD_ - //Should not close here - //f_close(&fs); -#endif -// ## 20141219 added end -} - - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len) -{ - uint16_t send_len = 0; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s); -#endif - //send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body); - send_len = sprintf_P((char *)buf, PSTR("%S%d\r\n\r\n%s"), PSTR(RES_CGIHEAD_OK), file_len, http_body); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len); -#endif - - send(s, buf, send_len); -} - - -static int8_t http_disconnect(uint8_t sn) -{ - setSn_CR(sn,Sn_CR_DISCON); - /* wait to process the command... */ - while(getSn_CR(sn)); - - return SOCK_OK; -} - - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request) -{ - uint8_t * uri_name; - uint32_t content_addr = 0; - uint16_t content_num = 0; - uint32_t file_len = 0; - - uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; - - uint16_t http_status; - int8_t get_seqnum; - uint8_t content_found; - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - http_status = 0; - http_response = pHTTP_RX; - file_len = 0; - - //method Analyze - switch (p_http_request->METHOD) - { - case METHOD_ERR : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - - case METHOD_HEAD : - case METHOD_GET : - get_http_uri_name(p_http_request->URI, uri_buf); - uri_name = uri_buf; - - if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html - if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); - if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); - find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); - PRINTF("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); - PRINTF("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -#endif - - if (p_http_request->TYPE == PTYPE_ERR) - { - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - return; - } - else if(p_http_request->TYPE == PTYPE_CGI) - { - content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++CODEFLASH FIND..\r\n"); //_delay_ms(200); -#endif - // Find the User registered index for web content - if(find_userReg_webContent_avr(uri_buf, &content_num, &file_len)) - { - content_found = 1; // Web content found in code flash memory - content_addr = (uint32_t)content_num; - HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on CODEFLASH\r\n"); -#endif - } - // Not CGI request, Web content in 'SD card' or 'Data flash' requested -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - if((fr = f_open(&HTTPSock_Status[get_seqnum].fs, (const char *)uri_name, FA_READ)) == 0) - { - content_found = 1; // file open succeed - - file_len = HTTPSock_Status[get_seqnum].fs.fsize; - //content_addr = fs.sclust; //? - content_addr = HTTPSock_Status[get_seqnum].fs.fptr; //much better - HTTPSock_Status[get_seqnum].storage_type = SDCARD; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); -#endif - } -#elif _USE_FLASH_ - else if(/* Read content from Dataflash */) - { - content_found = 1; - HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; - ; // To do - } -#endif - else - { - content_found = 0; // fail to find content - } - - if(!content_found) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -#endif - http_status = STATUS_NOT_FOUND; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -#endif - http_status = STATUS_OK; - } - - // Send HTTP header - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -#endif - send_http_response_header(s, p_http_request->TYPE, file_len, http_status); - } - - // Send HTTP body (content) - if(http_status == STATUS_OK) - { - send_http_response_body_avr(s, uri_name, http_response, content_addr, file_len); - } - } - break; - - case METHOD_POST : - mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); - uri_name = uri_buf; - find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); - PRINTF("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); - PRINTF("Type = %d\r\n", p_http_request->TYPE); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process - { - content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -#endif - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); - - // Reset the H/W for apply to the change configuration information - if(content_found == HTTP_RESET) HTTPServer_ReStart(); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else // HTTP POST Method; Content not found - { - send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); - } - break; - - default : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - } -} - - -void httpServer_time_handler(void) -{ - httpServer_tick_1s++; -} - -uint32_t get_httpServer_timecount(void) -{ - return httpServer_tick_1s; -} -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content) -{ - uint16_t name_len; - uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - content_len = strlen_P((const char *)content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len) -{ - uint16_t name_len; - //uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - //content_len = (uint32_t) sizeof(content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -uint8_t display_reg_webContent_list_avr(void) -{ - uint16_t i; - uint8_t ret; - - if(total_content_cnt == 0) - { - PRINTF(">> Web content file not found\r\n"); - ret = 0; - } - else - { - PRINTF("\r\n=== List of Web content in code flash ===\r\n"); - for(i = 0; i < total_content_cnt; i++) - { - PRINTF(" [%d] ", i+1); - PRINTF("%s, ", web_content[i].content_name); - PRINTF("%ld byte\r\n", web_content[i].content_len); - - - if(web_content[i].content_len < 30) - { - PRINTF("[%s]\r\n", web_content[i].content); - } - else - { - PRINTF("[ ... ]\r\n"); - } - //Dump head 16 bytes every file.. - /* - else - { - const char PROGMEM * tst_char = web_content[i].content; - if(strstr_P(web_content[i].content_name,PSTR("favicon.ico"))==NULL) - { - //ASCII Dump first 0x10 symbols, for all files without - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - else - { - //HEX dump first 0x10 symbols, for - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - } - */ - wdt_reset(); // WDT reset at least every sec - - } - PRINTF("=========================================\r\n\r\n"); - ret = 1; - } - - return ret; -} - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -{ - uint16_t i; - uint8_t ret = 0; // '0' means 'File Not Found' - - for(i = 0; i < total_content_cnt; i++) - { - if(!strcmp((const char *)content_name, (const char *)web_content[i].content_name)) - { - *file_len = web_content[i].content_len; - *content_num = i; - ret = 1; // If the requested content found, ret set to '1' (Found) - break; - } - } - return ret; -} - - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -{ - uint16_t ret = 0; - uint8_t * ptr; - - if(content_num > total_content_cnt) return 0; - - ptr = web_content[content_num].content; - if(offset) ptr += offset; - - //strncpy_P((char *)buf, (const char *)ptr, size); //not suit for case binary data - memcpy_P((char *)buf, (const char *)ptr, size); - *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - - //ret = strlen((void *)buf); //Useless for memcpy_P - ret = 0; //All ok - return ret; -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.h deleted file mode 100644 index 094d869..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - @file httpServer.h - @brief Define constants and functions related HTTP Web server. - */ - -#include - -#ifndef __HTTPSERVER_H__ -#define __HTTPSERVER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -// HTTP Server debug message enable -#define _HTTPSERVER_DEBUG_ - -//#define INITIAL_WEBPAGE "index.html" -#define INITIAL_WEBPAGE "index.htm" -#define M_INITIAL_WEBPAGE "m/index.html" -#define MOBILE_INITIAL_WEBPAGE "mobile/index.html" - -/* Web Server Content Storage Select */ -#define _USE_SDCARD_ -#ifndef _USE_SDCARD_ -//#define _USE_FLASH_ -#endif - -#ifdef _USE_SDCARD_ -#include "ff.h" // header file for FatFs library (FAT file system) -#endif - -#if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_) -#define _NOTUSED_STORAGE_ -#endif - - -/* Watchdog timer */ -//#define _USE_WATCHDOG_ - -/********************************************* -* HTTP Process states list -*********************************************/ -#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */ -#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */ -#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */ -#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */ -#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */ - -/********************************************* -* HTTP Simple Return Value -*********************************************/ -#define HTTP_FAILED 0 -#define HTTP_OK 1 -#define HTTP_RESET 2 - -/********************************************* -* HTTP Content NAME length -*********************************************/ -//#define MAX_CONTENT_NAME_LEN 128 ? Wastefull -#define MAX_CONTENT_NAME_LEN 16 - -/********************************************* -* HTTP Timeout -*********************************************/ -#define HTTP_MAX_TIMEOUT_SEC 3 // Sec. - -typedef enum -{ - NONE, ///< Web storage none - CODEFLASH, ///< Code flash memory - SDCARD, ///< SD card - DATAFLASH ///< External data flash memory -}StorageType; - -typedef struct _st_http_socket -{ - uint8_t sock_status; - uint8_t file_name[MAX_CONTENT_NAME_LEN]; - uint32_t file_start; - uint32_t file_len; - uint32_t file_offset; // (start addr + sent size...) - uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ... - FIL fs; // FatFs: File object -}st_http_socket; - -// Web content structure for file in code flash memory -#define MAX_CONTENT_CALLBACK 20 - -typedef struct _httpServer_webContent -{ - uint8_t * content_name; - uint32_t content_len; - uint8_t * content; -}httpServer_webContent; - - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist); -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)); - -void httpServer_run_avr(uint8_t seqnum); - -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content); - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len); - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); - -uint8_t display_reg_webContent_list_avr(void); - -/* - * @brief HTTP Server 1sec Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void httpServer_time_handler(void); -uint32_t get_httpServer_timecount(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.c deleted file mode 100644 index 77c9a9d..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file httpUtil.c - * @brief HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -#include "httpUtil.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - - if(predefined_get_cgi_processor(uri_name, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - ; - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} - -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - uint8_t val = 0; - - if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - val = 1; - len = sprintf((char *)buf, "%d", val); - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.h deleted file mode 100644 index f2c384a..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file httpUtil.h - * @brief Header File for HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __HTTPUTIL_H__ -#define __HTTPUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "httpServer.h" -#include "httpParser.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len); -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.htm b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.htm deleted file mode 100644 index c8c7178..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.htm +++ /dev/null @@ -1,43 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input - - - - - - - - - -
- - -
- -
- -
-
- - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.js b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.js deleted file mode 100644 index b5974d3..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.js +++ /dev/null @@ -1,57 +0,0 @@ -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawgraph(o); -} -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} -function AinDrawgraph(o) -{ - var pin = o.ain_p; - var val = o.ain_v; - $('ain_v'+pin).style.width = val*500/1023+'px'; -} -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); setTimeout('getAin6_update()', 500); -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.htm b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.htm deleted file mode 100644 index ee671fb..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.htm +++ /dev/null @@ -1,27 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input Gauge - - - - - - - - - -
- - -
- - -
-
- - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.js b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.js deleted file mode 100644 index 7c309a7..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.js +++ /dev/null @@ -1,87 +0,0 @@ -google.load('visualization', '1', - { - packages:['gauge'] - } -); google.setOnLoadCallback(AinDrawGoogleGauge); - -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawGoogleGauge(o); -} - -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} - -function AinDrawGoogleGauge(o) -{ - var val = o.ain_v; - //var temp_val = Number(((((val*3300)/1023)-500)/10).toFixed(2)); - var temp_val = Number(val); //here in range 0..1023 - if(isNaN(temp_val)) temp_val = 0; - var data = google.visualization.arrayToDataTable([['Label', 'Value'],['ADC6', 80]]); - var options = - { - width: 400, - height: 120, - max: 1023, - min: 0, - greenFrom: 0, - greenTo: 512, - redFrom: 918, - redTo: 1023, - yellowFrom: 714, - yellowTo: 918, - majorTicks: ['0', '512', '1023'], - minorTicks: 5 - }; - var chart = new google.visualization.Gauge(document.getElementById('chart_div')); - data.setValue(0, 1, temp_val); - chart.draw(data, options); -} - -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getAin6_update()', 500); -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ajax.js b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ajax.js deleted file mode 100644 index 01c6bb7..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/ajax.js +++ /dev/null @@ -1,68 +0,0 @@ -function AJAX(a, e) -{ - var c = d(); - c.onreadystatechange = b; - function d() - { - if(window.XMLHttpRequest) - { - return new XMLHttpRequest() - } - else - { - if(window.ActiveXObject) - { - return new ActiveXObject("Microsoft.XMLHTTP") - } - } - } - function b() - { - if(c.readyState==4) - { - if(c.status==200) - { - if(e) - { - e(c.responseText) - } - } - } - } - this.doGet = function() - { - c.open("GET", a, true); c.send(null) - }; - this.doPost = function(f) - { - c.open("POST", a, true); - c.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - c.setRequestHeader("ISAJAX", "yes"); - c.send(f) - } -} -function $(a) -{ - return document.getElementById(a) -} -function $$(a) -{ - return document.getElementsByName(a) -} -function $$_ie(a, c) -{ - if(!a) - { - a = "*" - } - var b = document.getElementsByTagName(a); - var e = []; for(var d = 0; d -#(c) Ibragimov M. Russia Togliatty 19/08/2014 -# .PS used for build <***.h> from images(*.gif, *.jpg), *.css, static htm(l) pages, javascript etc.. -import sys, os -if len(sys.argv) < 2: - sys.exit('Usage: %s file-name' % sys.argv[0]) - -file_name = sys.argv[1] -if not os.path.exists(sys.argv[1]): - sys.exit('ERROR: Filename %s was not found!' % file_name) -else: - print('File %s is OK!' % file_name) -file_out = file_name.replace(".", "_") + ".h" -print('File_to_write is: %s' % file_out) -fhex = open(file_out, "w") -fhex_str = 'const char %s[] PROGMEM = {' % file_name.replace(".", "_") -print(fhex_str) -fhex.write(fhex_str + '\n') -with open(file_name, "rb") as f: - byte = f.read(1) - i = 0 - fhex_size = 0 - _str = "" - while byte != "": - # Do stuff with byte. - _byte = f.read(1) - fhex_size = fhex_size + 1 - if _byte != "": - #print ('%s, ' % hex(ord(byte))) - _str = _str + "%s," % hex(ord(byte)) - else: - #Last byte wo <,> - #print hex(ord(byte)) - _str = _str + "%s" % hex(ord(byte)) - if i < 15: - print _str - fhex.write(_str + '\n') - byte = _byte; - i = i + 1; - if i > 15: - i = 0; - print _str - fhex.write(_str + '\n') - _str = "" -print'};' -fhex.write('};\n') -_str = '%s: %d bytes' % (file_name, fhex_size) -print(_str); -fhex.write('//' + _str + '\n'); -fhex.close() diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/brd_wiz.png b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/brd_wiz.png deleted file mode 100644 index 90d075a..0000000 Binary files a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/brd_wiz.png and /dev/null differ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.htm b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.htm deleted file mode 100644 index 191f317..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.htm +++ /dev/null @@ -1,24 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Digital I/O v1.1 - - - - - - - - -

LED1: unknown..

- -
- -
-
- - - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.js b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.js deleted file mode 100644 index 5d1d164..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.js +++ /dev/null @@ -1,93 +0,0 @@ -function DioCallback(o) -{ - var pin = o.dio_p; - $('txtdio_s'+pin).value = o.dio_s; - $('txtdio_d'+pin).value = o.dio_d; -} -function led1Callback(o) -{ - $('led1_txt').innerHTML = o.led1_txt; -} -function getDio(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - oUpdate = new AJAX('get_dio'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); -} -function setDiostate(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_s'+p).value;*/ - var v = o.attributes['s'].value; - dout = new AJAX('set_diostate.cgi', - function(t) - { - try - { - /*eval(t);*/ - document.getElementById('led1_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function setDiodir(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_d'+p).value;*/ - var v = o.attributes['d'].value; - dout = new AJAX('set_diodir.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function getled1() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_led1.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getled1()', 3000); -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/favicon.ico b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/favicon.ico deleted file mode 100644 index f63da06..0000000 Binary files a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/favicon.ico and /dev/null differ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/img.htm b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/img.htm deleted file mode 100644 index f609e83..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/img.htm +++ /dev/null @@ -1,14 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Image - - - - - - -
wizwebserver.png
- - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/index.htm b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/index.htm deleted file mode 100644 index 758f904..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/index.htm +++ /dev/null @@ -1,25 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server - - - - -
- W5500-AtMEGA1284p Web Server Demopage -

- Network Information
- Base64 Image Data
-
- Board Schematic
- Mounting Scheme
-
- Ex1> Digital I/O
- Ex2> Analog Input
- Ex3> Analog Input: Google Gauge Chart
-
- Device Information
- - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.htm b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.htm deleted file mode 100644 index fdc64f6..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.htm +++ /dev/null @@ -1,18 +0,0 @@ - - - - - W5500-AtMEGA1284p Device Info - - - - - - -
- W5500-AtMEGA1284p Device Information -

-

..

- diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.js b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.js deleted file mode 100644 index 145be40..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.js +++ /dev/null @@ -1,21 +0,0 @@ -function getInfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_info.cgi', function(t) - { - try - { - //*eval(t); - document.getElementById('info_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); oUpdate.doGet(); - } - , 300); setTimeout('getInfo()', 3000); -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/m1284p.png b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/m1284p.png deleted file mode 100644 index a6dc8a3..0000000 Binary files a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/m1284p.png and /dev/null differ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.htm b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.htm deleted file mode 100644 index 581ba6e..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.htm +++ /dev/null @@ -1,33 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Network Info - - - - - - - -
- W5500-AtMEGA1284p Web Server Network Information -

- -
    -
  • - -
  • - -
  • - -
  • - -
  • -
- - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.js b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.js deleted file mode 100644 index ca5ca0a..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.js +++ /dev/null @@ -1,37 +0,0 @@ -function NetinfoCallback(o) -{ - $('txtmac').value = o.mac; - $('txtip').value = o.ip; - $('txtgw').value = o.gw; - $('txtsn').value = o.sn; - $('txtdns').value = o.dns; - if(typeof(window.external)!='undefined') - { - obj = $$_ie('input', 'dhcp'); - } - else - { - obj = $$('dhcp'); - } -} -function getNetinfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_netinfo.cgi', function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 1500); -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/clean.bat b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/clean.bat deleted file mode 100644 index 9977613..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/clean.bat +++ /dev/null @@ -1,3 +0,0 @@ -del *.b#* -del *.s#* -pause diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ccsbcs.c.unicode b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/diskio.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ffconf.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ffconf.h deleted file mode 100644 index bcaba72..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_READONLY 1 -/* 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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/integer.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/globals.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/globals.h deleted file mode 100644 index 1806a53..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/globals.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -#include "Internet/httpServer_avr/httpParser.h" -//******************************* Fat FS declare related: END - - -#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<= 2 */ -//static FIL File; /* File object. there are _FS_LOCK file objects available, >= 2. */ - -#endif /* GLOBALS_H_ */ diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/main.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/main.c deleted file mode 100644 index eef6269..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/main.c +++ /dev/null @@ -1,787 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Internet/httpServer_avr/httpServer.h" -//#include "webpage.h" - -#define _MAIN_DEBUG_ - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - - -//#include "Application/loopback/loopback.h" -//#include "Application/webserver_simple/webserver_simple.h" - -/* - * (12) Try move pages to SD-CARD reader FatFS - * TODO - * OK 1) Try create minimal to SD-READER, include FatFS from <02_m1284p_FATFS_Chang_tst> and test working - * OK 2) Read all pages from (11) to folder this project, then move it in root folder SD-Reader and test working - * OK 3) Clean code (done on v2.4b) - * OK 4) Remove unused files from project (done on v2.4b) - * OK 5) Need to handle for every opened socket!! Because without this server is freeze, while download several large files - * at once from SD-CARD. (done on v2.4c) - * Add and debug f_open(&fs, ..)/??f_close(&fs, ..) to: - * http_process_handler_avr (here actually already implemented..) - * OK + add f_open(&fs, ..) in STATE_HTTP_RES_INPROC before - * f_close(&fs) add to and comment out in - * Works stable but download speed slow (~40-50kb/sec ~80kb/sec with SPI 4MHZ && _HTTPSERVER_DEBUG_ = ON), because on every download file for every transfer TCP-IP packet proceed sequence: f_open(&fs, ..)/f_lseek(&fs, /f_close(&fs, ..) - * OK 6) Optimize (5) - Add to <_st_http_socket> structure to avoid multiple re-open downloaded file - * Works faster: ~80kb/sec with SPI 4MHZ && _HTTPSERVER_DEBUG_ = ON, ~110kb/sec SPI 4MHZ && _HTTPSERVER_DEBUG_ = OFF, ~150kb/sec ~80kb/sec with SPI 8MHZ && _HTTPSERVER_DEBUG_ = OFF - * (done on v2.4d) - * - * (11) Try move all pages saved at from RAM to FLASH address space - * Example of flash data access look at: - * <01_m1284p_bb00_minimum_PSTR_webpage_test> - * <09_m1284p_WIZNET_simple_webserver> - * - * Success initial porting on 10/12/2018 - FREE RAM on webserver: 7936 bytes (From total 16kbytes)! - * NEED further optimization to AVR_RAM->AVR_FLASH point (damn Harvard architecture :( )! - * - * It works on AtMega1284p(16kbytes RAM), but need TODO finish (DONE on v2.3b 12/12/2018)!! - * - * TODO DONE: - * After v2.3 optimization: - * (+4kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 2048 see )) : FREE RAM on webserver: 10372 bytes - much better! (RAM enough for AtMega1284/AtMega2560 ie. AVR with 8-16Kb RAM) - * (+1kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 512 see )) : FREE RAM on webserver: 13444 bytes - awesome! (RAM enough for AtMega644/AtMega128 ie. AVR with 4Kb RAM) - * - * OK 1) Father optimization / (v2.3 12/12/2018) - * OK 2) Father optimization / (v2.3 12/12/2018) - * OK 3) Rename httpServer.*->httpServer_avr.*, httpParser.*->httpParser_avr.*, httpUtil.*->httpUtil_avr.* (v2.3b 12/12/2018) - * Actually made another way: rename parent folder to - * OK 4) Fix not correct showed value on (v2.2 12/12/2018) - * OK 5) Correct indentation in all <*.html> and <*.js> sources and repack it again in . (v2.2 12/12/2018) - * OK 6) Add to webserver (v2.1 12/12/2018) + also added binary files support in webserver via: , bin2hex_v2.py - * 7) Publish sources in my github, wiznetmuseim, avrfreaks etc.. (optional) - * - * (10) Try repeat example HTTPServer_LPC11E36_LPCXpresso on AVR Mega1284p (All pages still in RAM) - * Here used to WEB-server handle cgi-like requests, with AJAX + JSON - * Description here: - * http://wiznetmuseum.com/portfolio-items/w5500-evb-web-server/ - * - * To better undestand AJAX look here (actually here used AJAX + XHTML): - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-automatically-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/AJAX-read-switches-analog/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-XML-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-gauge/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-IO/ - * - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * For prepare binary data (some image data, like favicon.ico) use script. - * Example usage: - * >bin2hex_v2.py favicon.ico - * >out favicon_ico.h - * After that insert into end content from favicon.ico; - * Then use this resource in www server like (look in ): - * reg_httpServer_binContent_avr(PSTR("favicon.ico"),favicon_ico, (uint32_t)sizeof(favicon_ico)); // favicon.ico : webserver icon - * - * - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example (bin2hex_v2.py BETTER SUIT for AVR!!): - * https://tomeko.net/online_tools/file_to_hex.php?lang=en - * - * (9) Simple webserver, based on code from: - * http://www.ermicro.com/blog/?p=1773 - * Article: Integrating Wiznet W5100, WIZ811MJ network module with Atmel AVR Microcontroller - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~10..12.2018 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v2.4d Static IP HTTP_server SDCARD Pages WIZNET_5500 ETHERNET 19/12/2018\r\n"; // Program name - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -inline unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - //In this demo all www content saved onto SD-Card (you must copy all from folder to ROOT SD-Card) -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - //uint32_t timer_link_1sec = millis(); - uint32_t timer_httpd_1sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } - } - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - } // End of user's code - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - //loopback_tcps(0,ethBuf0,5000); - //loopback_udps(1, ethBuf1, 3000); - - //Use WEBbrowser to connect to webserver: http://192.168.0.199/index.html - //websrv_simple(2, ethBuf2_WEBSRV, 80); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //Not used here, because led1 handle via websrv - /* - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - */ - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/spi.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 128 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/userHandler.c b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/userHandler.c deleted file mode 100644 index 6d0e5d1..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/userHandler.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file userHandler.c - * @brief User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -//#include "board.h" -#include "httpUtil.h" -#include "userHandler.h" -//#include "adcHandler.h" -#include "wizchip_conf.h" -#include "globals.h" - -/* Unavailable Pins (W5500-EVB component preempted) */ -// >> UART Rx/Tx : D0 (Rx), D1 (Tx) -// >> W5500 SPI(SPI0) : D11 (MOSI), D12 (MISO), D13 (SCK) - -/* On-board Devices */ -// >> Input : D14 (SW1) / D15 (SW2) -// >> Input : AIN (Potentiometer / TEMP.Sensor) -// >> Output : D8 (LED R) / D9 (LED G) / D10 (LED B) - -/* NXP LPC11Exx GPIO functions */ -// GPIO: Pin state -//Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); - -// GPIO: Pin direction -//Chip_GPIO_GetPinDIR((LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); - -// Pre-defined Get CGI functions -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_netinfo(uint8_t * buf, uint16_t * len); -void make_json_led1(uint8_t * buf, uint16_t * len); -void make_info(uint8_t * buf, uint16_t * len); - -// Pre-defined Set CGI functions -int8_t set_diodir(uint8_t * uri); -int8_t set_diostate(uint8_t * uri); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len) -{ - //return 0; //Just a stub, not used yet.. - //uint8_t ret = 1; // ret = 1 means 'uri_name' matched - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched - uint8_t cgibuf[14] = {0, }; - int8_t cgi_dio = -1; - int8_t cgi_ain = -1; - - uint8_t i; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { -// // to do -// ;//make_json_todo(buf, len); - } - else if(strcmp_P((const char *)uri_name,PSTR("get_netinfo.cgi")) == 0) - { - make_json_netinfo(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_led1.cgi")) == 0) - { - make_json_led1(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_info.cgi")) == 0) - { - make_info(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else - { -// // get_dio0.cgi ~ get_dio15.cgi -// for(i = 0; i < DIOn; i++) -// { -// memset(cgibuf, 0x00, 14); -// sprintf((char *)cgibuf, "get_dio%d.cgi", i); -// if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) -// { -// make_json_dio(buf, len, i); -// cgi_dio = i; -// break; -// } -// } -// -// if(cgi_dio < 0) - //Analog Ins reading get_ain0.cgi ~ get_ain7.cgi - if(1) - { - // get_ain0.cgi ~ get_ain5.cgi (A0 - A5), get_ain6.cgi for on-board potentiometer / Temp.Sensor - LPC11Exx - //for(i = 0; i < AINn; i++) //for LPC11xx - for(i = 0; i < 8; i++) //for AVR Mega1284p, available AIN0..AIN7 - { - memset(cgibuf, 0x00, 14); - sprintf((char *)cgibuf, "get_ain%d.cgi", i); - if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) - { - make_json_ain(buf, len, i); - cgi_ain = i; - ret = 1; - break; - } - } - } - -// if((cgi_dio < 0) && (cgi_ain < 0)) ret = 0; - } - - return ret; -} - - -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len) -{ -// return 0; //Just a stub, not used yet.. - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched -// uint8_t ret = 1; // ret = '1' means 'uri_name' matched - uint8_t val = 0; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { - // to do - ;//val = todo(uri); - //*len = sprintf((char *)buf, "%d", val); - } -// // Digital I/O; dio_s, dio_d -// else if(strcmp_P((const char *)uri_name,PSTR("set_diodir.cgi")) == 0) -// { -// //val = set_diodir(uri); -// //printf_P(PSTR("+++set_diodir.cgi uri_name: %s; uri: %s;\r\n")); -// *len = sprintf_P((char *)buf, PSTR("%d"), val); -// ret = 1; -// } - else if(strcmp((const char *)uri_name, "set_diostate.cgi") == 0) - { - //When uri_name=set_diostate.cgi, and uri HTTP POST request which contains something like: - //pin=8&val=1; or pin=8&val=1; (look && ) - - /* - This is LPC11xx handler - val = set_diostate(uri); - len = sprintf((char *)buf, "%d", val); - len ret = 1; - */ - - - //!!Just for debug - PRINTF("\r\n+++set_diostate.cgi uri_name: %s\r\nuri: %s\r\n", uri_name, uri); - - //Parse URI (Very dirty!!) - if(strstr_P(uri,PSTR("pin=LED1&val=0"))) - { - led1_low(); - *len = sprintf_P((char *)buf, PSTR("LED1: OFF")); - ret = 1; - } - else if(strstr_P(uri,PSTR("pin=LED1&val=1"))) - { - led1_high(); - *len = sprintf_P((char *)buf, PSTR("LED1: ON")); - ret = 1; - } - else - { - //*len = sprintf_P((char *)buf, PSTR("%d"), -1); - *len = sprintf_P((char *)buf, PSTR("???")); - ret = 1; - } - } -// else -// { -// ret = 0; -// } -// - return ret; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Get CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin) -//{ -// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// -// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\ -// \"dio_s\":\"%d\",\ -// \"dio_d\":\"%d\"\ -// });", -// pin, // Digital io pin number -// pin_state, // Digital io status -// pin_dir // Digital io directions -// ); -//} -// -void make_json_led1(uint8_t * buf, uint16_t * len) -{ - if(led1_read()) - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: ON\"});")); //Send back LED1 state via call-back function - } - else - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: OFF\"});")); //Send back LED1 state via call-back function - } - -} - -void make_info(uint8_t * buf, uint16_t * len) -{ - /* - * Send program metrics: - * Program name - * time-date compile - * MCU info - * free ram info - * uptime device - */ - *len = sprintf_P((char *)buf,PSTR(\ - "
%S"\
-			"Compiled at: %S %S\r\n"\
-			"MCU is: %S; CLK is: %luHz\r\n"\
-			"Free RAM: %dbytes\r\n"\
-			"Uptime: %lusec\r\n
"),\ - str_prog_name,\ - compile_time, compile_date,\ - str_mcu, F_CPU,\ - freeRam(),\ - millis()/1000); -} - -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin) -{ - *len = sprintf_P((char *)buf,PSTR( "AinCallback({\"ain_p\":\"%d\",\ - \"ain_v\":\"%d\"\ - });"), - pin, // ADC input pin number - //get_ADC_val(pin) // ADC input value for LPC11xx - adc_read(pin) // ADC input value for AVR - ); -} - -void make_json_netinfo(uint8_t * buf, uint16_t * len) -{ - wiz_NetInfo netinfo; - ctlnetwork(CN_GET_NETINFO, (void*) &netinfo); - - // DHCP: 1 - Static, 2 - DHCP - *len = sprintf_P((char *)buf,PSTR( "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\ - \"ip\":\"%d.%d.%d.%d\",\ - \"gw\":\"%d.%d.%d.%d\",\ - \"sn\":\"%d.%d.%d.%d\",\ - \"dns\":\"%d.%d.%d.%d\",\ - \"dhcp\":\"%d\"\ - });"), - netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5], - netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3], - netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3], - netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3], - netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3], - netinfo.dhcp - ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Set CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//int8_t set_diodir(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // Direction; NotUsed/Input/Output -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > Output) val = Output; -// } -// } -// -// if(val == Input) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input -// else Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -// -// return pin; -//} -// -//int8_t set_diostate(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // State; high(on)/low(off) -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > On) val = On; -// } -// -// if(val == On) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High -// else Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -// } -// -// return pin; -//} diff --git a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/userHandler.h b/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/userHandler.h deleted file mode 100644 index 1f9af30..0000000 --- a/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/userHandler.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file userHandler.h - * @brief Header File for User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __USERHANDLER_H -#define __USERHANDLER_H - -#include -//#define _WEB_DEBUG_ - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Public Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined CGI Interface Functions Handler -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP GET Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP POST Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - - -#endif - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/.cproject b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/.cproject deleted file mode 100644 index 7a19556..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/.cproject +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/.project b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/.project deleted file mode 100644 index 8b63bee..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 12_m644p_WIZNET_HTTPServer_SDCARD_pages - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.c deleted file mode 100644 index 41ee2db..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - @file httpd.c - @brief functions associated http processing - */ - -#include -#include -#include "socket.h" -#include "httpParser.h" - -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -//uint8_t BUFPUB[2048]; -uint8_t BUFPUB[256]; - -/***************************************************************************** - * Private functions - ****************************************************************************/ -static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */ -static uint8_t C2D(uint8_t c); /* Convert a character to HEX */ - -/** - @brief convert escape characters(%XX) to ASCII character - */ -void unescape_http_url( - char * url /**< pointer to be converted ( escape characters )*/ - ) -{ - int x, y; - - for (x = 0, y = 0; url[y]; ++x, ++y) { - if ((url[x] = url[y]) == '%') { - url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]); - y+=2; - } - } - url[x] = '\0'; -} - - -/** - @brief make response header such as html, gif, jpeg,etc. - */ -void make_http_response_head( - char * buf, /**< pointer to response header to be made */ - char type, /**< response type */ - uint32_t len /**< size of response header */ - ) -{ - const char * head; - char tmp[10]; - - /* file type*/ - if (type == PTYPE_HTML) head = PSTR(RES_HTMLHEAD_OK); - else if (type == PTYPE_GIF) head = PSTR(RES_GIFHEAD_OK); - else if (type == PTYPE_TEXT) head = PSTR(RES_TEXTHEAD_OK); - else if (type == PTYPE_JPEG) head = PSTR(RES_JPEGHEAD_OK); - else if (type == PTYPE_FLASH) head = PSTR(RES_FLASHHEAD_OK); - else if (type == PTYPE_XML) head = PSTR(RES_XMLHEAD_OK); - else if (type == PTYPE_CSS) head = PSTR(RES_CSSHEAD_OK); - else if (type == PTYPE_JSON) head = PSTR(RES_JSONHEAD_OK); - else if (type == PTYPE_JS) head = PSTR(RES_JSHEAD_OK); - else if (type == PTYPE_CGI) head = PSTR(RES_CGIHEAD_OK); - else if (type == PTYPE_PNG) head = PSTR(RES_PNGHEAD_OK); - else if (type == PTYPE_ICO) head = PSTR(RES_ICOHEAD_OK); - else if (type == PTYPE_TTF) head = PSTR(RES_TTFHEAD_OK); - else if (type == PTYPE_OTF) head = PSTR(RES_OTFHEAD_OK); - else if (type == PTYPE_WOFF) head = PSTR(RES_WOFFHEAD_OK); - else if (type == PTYPE_EOT) head = PSTR(RES_EOTHEAD_OK); - else if (type == PTYPE_SVG) head = PSTR(RES_SVGHEAD_OK); -#ifdef _HTTPPARSER_DEBUG_ - else - { - head = NULL; - PRINTF("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n"); - } -#else - else head = NULL; -#endif - - sprintf(tmp, "%ld", len); - strcpy_P(buf, head); - strcat(buf, tmp); - strcat(buf, "\r\n\r\n"); -} - - -/** - @brief find MIME type of a file - */ -void find_http_uri_type( - uint8_t * type, /**< type to be returned */ - uint8_t * buff /**< file name */ - ) -{ - /* Decide type according to extension*/ - - char * buf; - buf = (char *)buff; - - if (strcasestr_P(buf, PSTR(".htm")) || strcasestr_P(buf, PSTR(".html"))) *type = PTYPE_HTML; - else if (strcasestr_P(buf, PSTR(".gif"))) *type = PTYPE_GIF; - else if (strcasestr_P(buf, PSTR(".text")) || strstr_P(buf,PSTR(".txt"))) *type = PTYPE_TEXT; - else if (strcasestr_P(buf, PSTR(".jpeg")) || strstr_P(buf,PSTR(".jpg"))) *type = PTYPE_JPEG; - else if (strcasestr_P(buf, PSTR(".swf"))) *type = PTYPE_FLASH; - else if (strstr_P(buf, PSTR(".cgi")) || strstr_P(buf,PSTR(".CGI"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".json")) || strstr_P(buf,PSTR(".JSON"))) *type = PTYPE_JSON; - else if (strstr_P(buf, PSTR(".js")) || strstr_P(buf,PSTR(".JS"))) *type = PTYPE_JS; - else if (strstr_P(buf, PSTR(".CGI")) || strstr_P(buf,PSTR(".cgi"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".xml")) || strstr_P(buf,PSTR(".XML"))) *type = PTYPE_XML; - else if (strstr_P(buf, PSTR(".css")) || strstr_P(buf,PSTR(".CSS"))) *type = PTYPE_CSS; - else if (strstr_P(buf, PSTR(".png")) || strstr_P(buf,PSTR(".PNG"))) *type = PTYPE_PNG; - else if (strstr_P(buf, PSTR(".ico")) || strstr_P(buf,PSTR(".ICO"))) *type = PTYPE_ICO; - else if (strstr_P(buf, PSTR(".ttf")) || strstr_P(buf,PSTR(".TTF"))) *type = PTYPE_TTF; - else if (strstr_P(buf, PSTR(".otf")) || strstr_P(buf,PSTR(".OTF"))) *type = PTYPE_OTF; - else if (strstr_P(buf, PSTR(".woff")) || strstr_P(buf,PSTR(".WOFF"))) *type = PTYPE_WOFF; - else if (strstr_P(buf, PSTR(".eot")) || strstr_P(buf,PSTR(".EOT"))) *type = PTYPE_EOT; - else if (strstr_P(buf, PSTR(".svg")) || strstr_P(buf,PSTR(".SVG"))) *type = PTYPE_SVG; - else *type = PTYPE_ERR; -} - - -/** - @brief parse http request from a peer - */ -void parse_http_request( - st_http_request * request, /**< request to be returned */ - uint8_t * buf /**< pointer to be parsed */ - ) -{ - char * nexttok; - nexttok = strtok((char*)buf," "); - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - if(!strcmp_P(nexttok, PSTR("GET")) || !strcmp_P(nexttok,PSTR("get"))) - { - request->METHOD = METHOD_GET; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("HEAD")) || !strcmp_P(nexttok,PSTR("head"))) - { - request->METHOD = METHOD_HEAD; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("POST")) || !strcmp_P(nexttok,PSTR("post"))) - { - nexttok = strtok(NULL,"\0"); - request->METHOD = METHOD_POST; - } - else - { - request->METHOD = METHOD_ERR; - } - - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - strcpy((char *)request->URI, nexttok); -} - -#ifdef _OLD_ -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value( - char* uri, - char* param_name - ) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * name = 0; - - - if(!uri || !param_name) return 0; - - strcpy((char*)tempURI,uri); - if((name = (uint8_t*)strstr(tempURI, param_name))) - { - name += strlen(param_name) + 1; // strlen(para_name) + strlen("=") - if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0"))) - { - unescape_http_url((char *)name); - replacetochar(name, '+', ' '); - } - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s",param_name,name); -#endif - - return name; -} -#else -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value(char* uri, char* param_name) -{ - - uint8_t * name = 0; - uint8_t * ret = BUFPUB; - uint8_t * pos2; - uint16_t len = 0, content_len = 0; - uint8_t tmp_buf[10]={0x00, }; - - if(!uri || !param_name) return 0; - - /***************/ - mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf); - content_len = ATOI(tmp_buf, 10); - uri = strstr(uri, "\r\n\r\n"); - uri += 4; - uri[content_len] = 0; - /***************/ - - if((name = (uint8_t *)strstr(uri, param_name))) - { - name += strlen(param_name) + 1; - pos2 = (uint8_t*)strstr((char*)name, "&"); - if(!pos2) - { - pos2 = name + strlen((char*)name); - } - len = pos2 - name; - - if(len) - { - ret[len] = 0; - strncpy((char*)ret,(char*)name, len); - unescape_http_url((char *)ret); - replacetochar(ret, '+' ,' '); - //ret[len] = 0; - //ret[strlen((int8*)ret)] = 0; - //printf("len=%d\r\n",len); - } - else - { - ret[0] = 0; - } - } - else - { - return 0; - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s\r\n", param_name, ret); -#endif - return ret; -} -#endif - -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * uri_name; - - if(!uri) return 0; - - strcpy(tempURI, (char *)uri); - - uri_name = (uint8_t *)strtok(tempURI, " ?"); - - if(strcmp((char *)uri_name,"/")) uri_name++; - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_name); -#endif - - return uri_name; -} -#else - -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf) -{ - uint8_t * uri_ptr; - if(!uri) return 0; - - strcpy((char *)uri_buf, (char *)uri); - - uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?"); - - if(strcmp((char *)uri_ptr,"/")) uri_ptr++; - strcpy((char *)uri_buf, (char *)uri_ptr); - -#ifdef _HTTPPARSER_DEBUG_ - PRINTF(" uri_name = %s\r\n", uri_buf); -#endif - - return 1; -} - -#endif - -void inet_addr_(uint8_t * addr, uint8_t *ip) -{ - uint8_t i; - uint8_t taddr[30]; - uint8_t * nexttok; - uint8_t num; - - strcpy((char *)taddr, (char *)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (uint8_t *)strtok((char *)nexttok, "."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10); - else num = ATOI(nexttok,10); - ip[i] = num; - nexttok = NULL; - } -} - - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; -// debug_2013_11_25 -// while (*str !=0) - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -/** - * @brief Check strings and then execute callback function by each string. - * @param src The information of URI - * @param s1 The start string to be researched - * @param s2 The end string to be researched - * @param sub The string between s1 and s2 - * @return The length value atfer working - */ -void mid(char* src, char* s1, char* s2, char* sub) -{ - char* sub1; - char* sub2; - uint16_t n; - - sub1=strstr((char*)src,(char*)s1); - sub1+=strlen((char*)s1); - sub2=strstr((char*)sub1,(char*)s2); - - n=sub2-sub1; - strncpy((char*)sub,(char*)sub1,n); - sub[n]='\0'; -} - -//////////////////////////////////////////////////////////////////// -// Static functions -//////////////////////////////////////////////////////////////////// - -/** -@brief replace the specified character in a string with new character -*/ -static void replacetochar( - uint8_t * str, /**< pointer to be replaced */ - uint8_t oldchar, /**< old character */ - uint8_t newchar /**< new character */ - ) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == oldchar) str[x] = newchar; -} - -/** -@brief CONVERT CHAR INTO HEX -@return HEX - -This function converts HEX(0-F) to a character -*/ -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - - - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.h deleted file mode 100644 index c289c2e..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpParser.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - @file httpd.h - @brief Define Constants and fucntions associated with HTTP protocol. - */ - -#include -#include "../../globals.h" - -#ifndef __HTTPPARSER_H__ -#define __HTTPPARSER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#define _HTTPPARSER_DEBUG_ - -#define HTTP_SERVER_PORT 80 /**< HTTP server well-known port number */ - -/* HTTP Method */ -#define METHOD_ERR 0 /**< Error Method. */ -#define METHOD_GET 1 /**< GET Method. */ -#define METHOD_HEAD 2 /**< HEAD Method. */ -#define METHOD_POST 3 /**< POST Method. */ - -/* HTTP GET Method */ -#define PTYPE_ERR 0 /**< Error file. */ -#define PTYPE_HTML 1 /**< HTML file. */ -#define PTYPE_GIF 2 /**< GIF file. */ -#define PTYPE_TEXT 3 /**< TEXT file. */ -#define PTYPE_JPEG 4 /**< JPEG file. */ -#define PTYPE_FLASH 5 /**< FLASH file. */ -#define PTYPE_MPEG 6 /**< MPEG file. */ -#define PTYPE_PDF 7 /**< PDF file. */ -#define PTYPE_CGI 8 /**< CGI file. */ -#define PTYPE_XML 9 /**< XML file. */ -#define PTYPE_CSS 10 /**< CSS file. */ -#define PTYPE_JS 11 /**< JavaScript file. */ -#define PTYPE_JSON 12 /**< JSON (JavaScript Standard Object Notation) file. */ -#define PTYPE_PNG 13 /**< PNG file. */ -#define PTYPE_ICO 14 /**< ICON file. */ - -#define PTYPE_TTF 20 /**< Font type: TTF file. */ -#define PTYPE_OTF 21 /**< Font type: OTF file. */ -#define PTYPE_WOFF 22 /**< Font type: WOFF file. */ -#define PTYPE_EOT 23 /**< Font type: EOT file. */ -#define PTYPE_SVG 24 /**< Font type: SVG file. */ - - -/* HTTP response */ -#define STATUS_OK 200 -#define STATUS_CREATED 201 -#define STATUS_ACCEPTED 202 -#define STATUS_NO_CONTENT 204 -#define STATUS_MV_PERM 301 -#define STATUS_MV_TEMP 302 -#define STATUS_NOT_MODIF 304 -#define STATUS_BAD_REQ 400 -#define STATUS_UNAUTH 401 -#define STATUS_FORBIDDEN 403 -#define STATUS_NOT_FOUND 404 -#define STATUS_INT_SERR 500 -#define STATUS_NOT_IMPL 501 -#define STATUS_BAD_GATEWAY 502 -#define STATUS_SERV_UNAVAIL 503 - -/* HTML Doc. for ERROR */ -static const char PROGMEM ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n\r\n\r\nSorry, the page you requested was not found.\r\n\r\n\r\n\0"; -static const char PROGMEM ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n\r\n\r\nInvalid request.\r\n\r\n\r\n\0"; - -/* HTML Doc. for CGI result */ -#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response header for HTML*/ -#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for TEXT */ -#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " - -/* Response head for GIF */ -#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: " - -/* Response head for JPEG */ -#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: " - -/* Response head for PNG */ -#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: " - -/* Response head for FLASH */ -#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: " - -/* Response head for XML */ -#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for CSS */ -#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: " - -/* Response head for JavaScript */ -#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: " - -/* Response head for JSON */ -#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " - -/* Response head for ICO */ -#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: " - -/* Response head for CGI */ -#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response head for TTF, Font */ -#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: " - -/* Response head for OTF, Font */ -#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: " - -/* Response head for WOFF, Font */ -#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: " - -/* Response head for EOT, Font */ -#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: " - -/* Response head for SVG, Font */ -#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: " - -/** - @brief Structure of HTTP REQUEST - */ - -//#define MAX_URI_SIZE 1461 -#define MAX_URI_SIZE 512 - -typedef struct _st_http_request -{ - uint8_t METHOD; /**< request method(METHOD_GET...). */ - uint8_t TYPE; /**< request type(PTYPE_HTML...). */ - uint8_t URI[MAX_URI_SIZE]; /**< request file name. */ -}st_http_request; - -// HTTP Parsing functions -void unescape_http_url(char * url); /* convert escape character to ascii */ -void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */ -void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */ -void make_http_response_head(char *, char, uint32_t); /* make response header */ -uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */ -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */ -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri); -#endif - -// Utility functions -uint16_t ATOI(uint8_t * str, uint8_t base); -void mid(char* src, char* s1, char* s2, char* sub); -void inet_addr_(uint8_t * addr, uint8_t * ip); - -#ifdef __cplusplus -} -#endif - -#endif /* end of __HTTPPARSER_H__ */ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.c deleted file mode 100644 index b64931c..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.c +++ /dev/null @@ -1,879 +0,0 @@ -#include -#include -#include - -#include "socket.h" -#include "wizchip_conf.h" - -#include "httpServer.h" -#include "httpParser.h" -#include "httpUtil.h" - -#include "../../globals.h" //add AVR specific useful headers - - -#define DATA_BUF_SIZE HTTPD_MAX_BUF_SIZE -/***************************************************************************** - * Private types/enumerations/variables - ****************************************************************************/ -static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, }; -static st_http_request * http_request; /**< Pointer to received HTTP request */ -static st_http_request * parsed_http_request; /**< Pointer to parsed HTTP request */ -static uint8_t * http_response; /**< Pointer to HTTP response */ - -// ## For Debugging -//static uint8_t uri_buf[128]; -// Number of registered web content in code flash memory -static uint16_t total_content_cnt = 0; -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -uint8_t * pHTTP_TX; -uint8_t * pHTTP_RX; - -volatile uint32_t httpServer_tick_1s = 0; -//st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }; // For MEGA1284/MEGA2560 -st_http_socket HTTPSock_Status[4] = { {STATE_HTTP_IDLE, }, }; //For MEGA644p (optimized for RAM size) -httpServer_webContent web_content[MAX_CONTENT_CALLBACK]; - -#ifdef _USE_SDCARD_ -//static FIL fs; // FatFs: File object -static FRESULT fr; // FatFs: File function return code -#endif -/***************************************************************************** - * Private functions - ****************************************************************************/ -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist); -static uint8_t getHTTPSocketNum(uint8_t seqnum); -static int8_t getHTTPSequenceNum(uint8_t socket); -static int8_t http_disconnect(uint8_t sn); - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request); - -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status); - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len); - -/***************************************************************************** - * Public functions - ****************************************************************************/ -// Callback functions definition: MCU Reset / WDT Reset -void default_mcu_reset(void) {;} -void default_wdt_reset(void) {;} -void (*HTTPServer_ReStart)(void) = default_mcu_reset; -void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset; - -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist) -{ - uint8_t i; - - for(i = 0; i < cnt; i++) - { - // Mapping the H/W socket numbers to the sequential index numbers - HTTPSock_Num[i] = socklist[i]; - } -} - -static uint8_t getHTTPSocketNum(uint8_t seqnum) -{ - // Return the 'H/W socket number' corresponding to the index number - return HTTPSock_Num[seqnum]; -} - -static int8_t getHTTPSequenceNum(uint8_t socket) -{ - uint8_t i; - - for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++) - if(HTTPSock_Num[i] == socket) return i; - - return -1; -} - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist) -{ - // User's shared buffer - pHTTP_TX = tx_buf; - pHTTP_RX = rx_buf; - - // H/W Socket number mapping - httpServer_Sockinit(cnt, socklist); -} - - -/* Register the call back functions for HTTP Server */ -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)) -{ - // Callback: HW Reset and WDT reset function for each MCU platforms - if(mcu_reset) HTTPServer_ReStart = mcu_reset; - if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset; -} - - - -void httpServer_run_avr(uint8_t seqnum) -{ - uint8_t s; // socket number - uint16_t len; - uint32_t gettime = 0; - -#ifdef _HTTPSERVER_DEBUG_ - uint8_t destip[4] = {0, }; - uint16_t destport = 0; -#endif - - http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request - parsed_http_request = (st_http_request *)pHTTP_TX; - - // Get the H/W socket number - s = getHTTPSocketNum(seqnum); - - /* HTTP Service Start */ - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - } - - // HTTP Process states - switch(HTTPSock_Status[seqnum].sock_status) - { - - case STATE_HTTP_IDLE : - if ((len = getSn_RX_RSR(s)) > 0) - { - if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; - len = recv(s, (uint8_t *)http_request, len); - - *(((uint8_t *)http_request) + len) = '\0'; - - parse_http_request(parsed_http_request, (uint8_t *)http_request); -#ifdef _HTTPSERVER_DEBUG_ - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("\r\n"); - PRINTF("> HTTPSocket[%d] : HTTP Request received ", s); - PRINTF("from %d.%d.%d.%d : %u\r\n", destip[0], destip[1], destip[2], destip[3], destport); -#endif -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -#endif - // HTTP 'response' handler; includes send_http_response_header / body function - http_process_handler_avr(s, parsed_http_request); - - gettime = get_httpServer_timecount(); - // Check the TX socket buffer for End of HTTP response sends - while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) - { - if((get_httpServer_timecount() - gettime) > 3) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -#endif - break; - } - } - - if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; - else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end - } - break; - - case STATE_HTTP_RES_INPROC : - /* Repeat: Send the remain parts of HTTP responses */ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); - PRINTF("\r\n> HTTPSocket[%d] : Re-Open the requested content\r\n", s); //_delay_ms(200); -#endif -/* -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - - if((fr = f_open(&fs, (const char *)HTTPSock_Status[seqnum].file_name, FA_READ)) == 0) - { -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); - if((fr = f_lseek(&fs, HTTPSock_Status[seqnum].file_offset)) != 0) - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif - } - else - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif -*/ - // Repeatedly send remaining data to client - send_http_response_body_avr(s, 0, http_response, 0, 0); - - if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - - case STATE_HTTP_RES_DONE : -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -#endif - // Socket file info structure re-initialize - HTTPSock_Status[seqnum].file_len = 0; - HTTPSock_Status[seqnum].file_offset = 0; - HTTPSock_Status[seqnum].file_start = 0; - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; - -#ifdef _USE_SDCARD_ - f_close(&HTTPSock_Status[seqnum].fs); -#endif -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif - http_disconnect(s); - break; - - default : - break; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : CLOSED\r\n", s); -#endif - if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: - listen(s); - break; - - case SOCK_LISTEN: - break; - - default : - break; - - } // end of switch - -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif -} - -//////////////////////////////////////////// -// Private Functions -//////////////////////////////////////////// -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status) -{ - switch(http_status) - { - case STATUS_OK: // HTTP/1.1 200 OK - if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s); -#endif - make_http_response_head((char*)http_response, content_type, body_len); - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s); -#endif - // CGI/XML type request does not respond HTTP header to client - http_status = 0; - } - break; - case STATUS_BAD_REQ: // HTTP/1.1 400 OK -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s); -#endif - memcpy_P(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE)); - break; - case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s); -#endif - memcpy_P(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE)); - break; - default: - break; - } - - // Send the HTTP Response 'header' - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response)); -#endif - send(s, http_response, strlen((char *)http_response)); - } -} - - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -{ - int8_t get_seqnum; - uint32_t send_len; - - uint8_t flag_datasend_end = 0; - -#ifdef _USE_SDCARD_ - uint16_t blocklen; -#endif -#ifdef _USE_FLASH_ - uint32_t addr = 0; -#endif - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - // Send the HTTP Response 'body'; requested file - if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### - { - if (file_len > DATA_BUF_SIZE - 1) - { - HTTPSock_Status[get_seqnum].file_start = start_addr; - HTTPSock_Status[get_seqnum].file_len = file_len; - send_len = DATA_BUF_SIZE - 1; - -///////////////////////////////////////////////////////////////////////////////////////////////// -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) - memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); - strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -#endif -///////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -#endif - } - else - { - // Send process end - send_len = file_len; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (1)HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -#endif - } -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -#endif - } - else // remained parts - { -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; - } -#endif - send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; - - if(send_len > DATA_BUF_SIZE - 1) - { - send_len = DATA_BUF_SIZE - 1; - //HTTPSock_Status[get_seqnum]->file_offset += send_len; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (2)HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -#endif - // Send process end - flag_datasend_end = 1; - } -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -#endif - } - -/*****************************************************/ - //HTTPSock_Status[get_seqnum]->storage_type == NONE - //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH - //HTTPSock_Status[get_seqnum]->storage_type == SDCARD - //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -/*****************************************************/ - - if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) - { - if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; - read_userReg_webContent_avr(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); - } -#ifdef _USE_SDCARD_ - else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) - { - // Data read from SD Card - //PRINTF("++SDCARD f_read(..)\r\n"); - fr = f_read(&HTTPSock_Status[get_seqnum].fs, &buf[0], send_len, (void *)&blocklen); - if(fr != FR_OK) - { - send_len = 0; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -#endif - } - else - { - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } - } -#endif - -#ifdef _USE_FLASH_ - else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - // Data read from external data flash memory - read_from_flashbuf(addr, &buf[0], send_len); - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } -#endif - else - { - send_len = 0; - } - // Requested content send to HTTP client -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -#endif - - if(send_len) send(s, buf, send_len); - else flag_datasend_end = 1; - - if(flag_datasend_end) - { - HTTPSock_Status[get_seqnum].file_start = 0; - HTTPSock_Status[get_seqnum].file_len = 0; - HTTPSock_Status[get_seqnum].file_offset = 0; - flag_datasend_end = 0; - } - else - { - HTTPSock_Status[get_seqnum].file_offset += send_len; -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -#endif - } - -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -#ifdef _USE_SDCARD_ - //Should not close here - //f_close(&fs); -#endif -// ## 20141219 added end -} - - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len) -{ - uint16_t send_len = 0; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s); -#endif - //send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body); - send_len = sprintf_P((char *)buf, PSTR("%S%d\r\n\r\n%s"), PSTR(RES_CGIHEAD_OK), file_len, http_body); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len); -#endif - - send(s, buf, send_len); -} - - -static int8_t http_disconnect(uint8_t sn) -{ - setSn_CR(sn,Sn_CR_DISCON); - /* wait to process the command... */ - while(getSn_CR(sn)); - - return SOCK_OK; -} - - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request) -{ - uint8_t * uri_name; - uint32_t content_addr = 0; - uint16_t content_num = 0; - uint32_t file_len = 0; - - uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; - - uint16_t http_status; - int8_t get_seqnum; - uint8_t content_found; - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - http_status = 0; - http_response = pHTTP_RX; - file_len = 0; - - //method Analyze - switch (p_http_request->METHOD) - { - case METHOD_ERR : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - - case METHOD_HEAD : - case METHOD_GET : - get_http_uri_name(p_http_request->URI, uri_buf); - uri_name = uri_buf; - - if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html - if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); - if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); - find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); - PRINTF("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); - PRINTF("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -#endif - - if (p_http_request->TYPE == PTYPE_ERR) - { - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - return; - } - else if(p_http_request->TYPE == PTYPE_CGI) - { - content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++CODEFLASH FIND..\r\n"); //_delay_ms(200); -#endif - // Find the User registered index for web content - if(find_userReg_webContent_avr(uri_buf, &content_num, &file_len)) - { - content_found = 1; // Web content found in code flash memory - content_addr = (uint32_t)content_num; - HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on CODEFLASH\r\n"); -#endif - } - // Not CGI request, Web content in 'SD card' or 'Data flash' requested -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - if((fr = f_open(&HTTPSock_Status[get_seqnum].fs, (const char *)uri_name, FA_READ)) == 0) - { - content_found = 1; // file open succeed - - file_len = HTTPSock_Status[get_seqnum].fs.fsize; - //content_addr = fs.sclust; //? - content_addr = HTTPSock_Status[get_seqnum].fs.fptr; //much better - HTTPSock_Status[get_seqnum].storage_type = SDCARD; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); -#endif - } -#elif _USE_FLASH_ - else if(/* Read content from Dataflash */) - { - content_found = 1; - HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; - ; // To do - } -#endif - else - { - content_found = 0; // fail to find content - } - - if(!content_found) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -#endif - http_status = STATUS_NOT_FOUND; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -#endif - http_status = STATUS_OK; - } - - // Send HTTP header - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -#endif - send_http_response_header(s, p_http_request->TYPE, file_len, http_status); - } - - // Send HTTP body (content) - if(http_status == STATUS_OK) - { - send_http_response_body_avr(s, uri_name, http_response, content_addr, file_len); - } - } - break; - - case METHOD_POST : - mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); - uri_name = uri_buf; - find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); - PRINTF("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); - PRINTF("Type = %d\r\n", p_http_request->TYPE); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process - { - content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -#endif - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); - - // Reset the H/W for apply to the change configuration information - if(content_found == HTTP_RESET) HTTPServer_ReStart(); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else // HTTP POST Method; Content not found - { - send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); - } - break; - - default : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - } -} - - -void httpServer_time_handler(void) -{ - httpServer_tick_1s++; -} - -uint32_t get_httpServer_timecount(void) -{ - return httpServer_tick_1s; -} -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content) -{ - uint16_t name_len; - uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - content_len = strlen_P((const char *)content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len) -{ - uint16_t name_len; - //uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - //content_len = (uint32_t) sizeof(content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -uint8_t display_reg_webContent_list_avr(void) -{ - uint16_t i; - uint8_t ret; - - if(total_content_cnt == 0) - { - PRINTF(">> Web content file not found\r\n"); - ret = 0; - } - else - { - PRINTF("\r\n=== List of Web content in code flash ===\r\n"); - for(i = 0; i < total_content_cnt; i++) - { - PRINTF(" [%d] ", i+1); - PRINTF("%s, ", web_content[i].content_name); - PRINTF("%ld byte\r\n", web_content[i].content_len); - - - if(web_content[i].content_len < 30) - { - PRINTF("[%s]\r\n", web_content[i].content); - } - else - { - PRINTF("[ ... ]\r\n"); - } - //Dump head 16 bytes every file.. - /* - else - { - const char PROGMEM * tst_char = web_content[i].content; - if(strstr_P(web_content[i].content_name,PSTR("favicon.ico"))==NULL) - { - //ASCII Dump first 0x10 symbols, for all files without - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - else - { - //HEX dump first 0x10 symbols, for - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - } - */ - wdt_reset(); // WDT reset at least every sec - - } - PRINTF("=========================================\r\n\r\n"); - ret = 1; - } - - return ret; -} - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -{ - uint16_t i; - uint8_t ret = 0; // '0' means 'File Not Found' - - for(i = 0; i < total_content_cnt; i++) - { - if(!strcmp((const char *)content_name, (const char *)web_content[i].content_name)) - { - *file_len = web_content[i].content_len; - *content_num = i; - ret = 1; // If the requested content found, ret set to '1' (Found) - break; - } - } - return ret; -} - - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -{ - uint16_t ret = 0; - uint8_t * ptr; - - if(content_num > total_content_cnt) return 0; - - ptr = web_content[content_num].content; - if(offset) ptr += offset; - - //strncpy_P((char *)buf, (const char *)ptr, size); //not suit for case binary data - memcpy_P((char *)buf, (const char *)ptr, size); - *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - - //ret = strlen((void *)buf); //Useless for memcpy_P - ret = 0; //All ok - return ret; -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.h deleted file mode 100644 index 094d869..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpServer.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - @file httpServer.h - @brief Define constants and functions related HTTP Web server. - */ - -#include - -#ifndef __HTTPSERVER_H__ -#define __HTTPSERVER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -// HTTP Server debug message enable -#define _HTTPSERVER_DEBUG_ - -//#define INITIAL_WEBPAGE "index.html" -#define INITIAL_WEBPAGE "index.htm" -#define M_INITIAL_WEBPAGE "m/index.html" -#define MOBILE_INITIAL_WEBPAGE "mobile/index.html" - -/* Web Server Content Storage Select */ -#define _USE_SDCARD_ -#ifndef _USE_SDCARD_ -//#define _USE_FLASH_ -#endif - -#ifdef _USE_SDCARD_ -#include "ff.h" // header file for FatFs library (FAT file system) -#endif - -#if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_) -#define _NOTUSED_STORAGE_ -#endif - - -/* Watchdog timer */ -//#define _USE_WATCHDOG_ - -/********************************************* -* HTTP Process states list -*********************************************/ -#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */ -#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */ -#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */ -#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */ -#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */ - -/********************************************* -* HTTP Simple Return Value -*********************************************/ -#define HTTP_FAILED 0 -#define HTTP_OK 1 -#define HTTP_RESET 2 - -/********************************************* -* HTTP Content NAME length -*********************************************/ -//#define MAX_CONTENT_NAME_LEN 128 ? Wastefull -#define MAX_CONTENT_NAME_LEN 16 - -/********************************************* -* HTTP Timeout -*********************************************/ -#define HTTP_MAX_TIMEOUT_SEC 3 // Sec. - -typedef enum -{ - NONE, ///< Web storage none - CODEFLASH, ///< Code flash memory - SDCARD, ///< SD card - DATAFLASH ///< External data flash memory -}StorageType; - -typedef struct _st_http_socket -{ - uint8_t sock_status; - uint8_t file_name[MAX_CONTENT_NAME_LEN]; - uint32_t file_start; - uint32_t file_len; - uint32_t file_offset; // (start addr + sent size...) - uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ... - FIL fs; // FatFs: File object -}st_http_socket; - -// Web content structure for file in code flash memory -#define MAX_CONTENT_CALLBACK 20 - -typedef struct _httpServer_webContent -{ - uint8_t * content_name; - uint32_t content_len; - uint8_t * content; -}httpServer_webContent; - - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist); -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)); - -void httpServer_run_avr(uint8_t seqnum); - -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content); - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len); - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); - -uint8_t display_reg_webContent_list_avr(void); - -/* - * @brief HTTP Server 1sec Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void httpServer_time_handler(void); -uint32_t get_httpServer_timecount(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.c deleted file mode 100644 index 77c9a9d..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file httpUtil.c - * @brief HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -#include "httpUtil.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - - if(predefined_get_cgi_processor(uri_name, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - ; - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} - -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - uint8_t val = 0; - - if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - val = 1; - len = sprintf((char *)buf, "%d", val); - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.h deleted file mode 100644 index f2c384a..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/Internet/httpServer_avr/httpUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file httpUtil.h - * @brief Header File for HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __HTTPUTIL_H__ -#define __HTTPUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "httpServer.h" -#include "httpParser.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len); -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.htm b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.htm deleted file mode 100644 index c8c7178..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.htm +++ /dev/null @@ -1,43 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input - - - - - - - - - -
- - -
- -
- -
-
- - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.js b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.js deleted file mode 100644 index b5974d3..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain.js +++ /dev/null @@ -1,57 +0,0 @@ -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawgraph(o); -} -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} -function AinDrawgraph(o) -{ - var pin = o.ain_p; - var val = o.ain_v; - $('ain_v'+pin).style.width = val*500/1023+'px'; -} -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); setTimeout('getAin6_update()', 500); -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.htm b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.htm deleted file mode 100644 index ee671fb..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.htm +++ /dev/null @@ -1,27 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input Gauge - - - - - - - - - -
- - -
- - -
-
- - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.js b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.js deleted file mode 100644 index 7c309a7..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ain_gaug.js +++ /dev/null @@ -1,87 +0,0 @@ -google.load('visualization', '1', - { - packages:['gauge'] - } -); google.setOnLoadCallback(AinDrawGoogleGauge); - -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawGoogleGauge(o); -} - -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} - -function AinDrawGoogleGauge(o) -{ - var val = o.ain_v; - //var temp_val = Number(((((val*3300)/1023)-500)/10).toFixed(2)); - var temp_val = Number(val); //here in range 0..1023 - if(isNaN(temp_val)) temp_val = 0; - var data = google.visualization.arrayToDataTable([['Label', 'Value'],['ADC6', 80]]); - var options = - { - width: 400, - height: 120, - max: 1023, - min: 0, - greenFrom: 0, - greenTo: 512, - redFrom: 918, - redTo: 1023, - yellowFrom: 714, - yellowTo: 918, - majorTicks: ['0', '512', '1023'], - minorTicks: 5 - }; - var chart = new google.visualization.Gauge(document.getElementById('chart_div')); - data.setValue(0, 1, temp_val); - chart.draw(data, options); -} - -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getAin6_update()', 500); -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ajax.js b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ajax.js deleted file mode 100644 index 01c6bb7..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/ajax.js +++ /dev/null @@ -1,68 +0,0 @@ -function AJAX(a, e) -{ - var c = d(); - c.onreadystatechange = b; - function d() - { - if(window.XMLHttpRequest) - { - return new XMLHttpRequest() - } - else - { - if(window.ActiveXObject) - { - return new ActiveXObject("Microsoft.XMLHTTP") - } - } - } - function b() - { - if(c.readyState==4) - { - if(c.status==200) - { - if(e) - { - e(c.responseText) - } - } - } - } - this.doGet = function() - { - c.open("GET", a, true); c.send(null) - }; - this.doPost = function(f) - { - c.open("POST", a, true); - c.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - c.setRequestHeader("ISAJAX", "yes"); - c.send(f) - } -} -function $(a) -{ - return document.getElementById(a) -} -function $$(a) -{ - return document.getElementsByName(a) -} -function $$_ie(a, c) -{ - if(!a) - { - a = "*" - } - var b = document.getElementsByTagName(a); - var e = []; for(var d = 0; d -#(c) Ibragimov M. Russia Togliatty 19/08/2014 -# .PS used for build <***.h> from images(*.gif, *.jpg), *.css, static htm(l) pages, javascript etc.. -import sys, os -if len(sys.argv) < 2: - sys.exit('Usage: %s file-name' % sys.argv[0]) - -file_name = sys.argv[1] -if not os.path.exists(sys.argv[1]): - sys.exit('ERROR: Filename %s was not found!' % file_name) -else: - print('File %s is OK!' % file_name) -file_out = file_name.replace(".", "_") + ".h" -print('File_to_write is: %s' % file_out) -fhex = open(file_out, "w") -fhex_str = 'const char %s[] PROGMEM = {' % file_name.replace(".", "_") -print(fhex_str) -fhex.write(fhex_str + '\n') -with open(file_name, "rb") as f: - byte = f.read(1) - i = 0 - fhex_size = 0 - _str = "" - while byte != "": - # Do stuff with byte. - _byte = f.read(1) - fhex_size = fhex_size + 1 - if _byte != "": - #print ('%s, ' % hex(ord(byte))) - _str = _str + "%s," % hex(ord(byte)) - else: - #Last byte wo <,> - #print hex(ord(byte)) - _str = _str + "%s" % hex(ord(byte)) - if i < 15: - print _str - fhex.write(_str + '\n') - byte = _byte; - i = i + 1; - if i > 15: - i = 0; - print _str - fhex.write(_str + '\n') - _str = "" -print'};' -fhex.write('};\n') -_str = '%s: %d bytes' % (file_name, fhex_size) -print(_str); -fhex.write('//' + _str + '\n'); -fhex.close() diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/brd_wiz.png b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/brd_wiz.png deleted file mode 100644 index 90d075a..0000000 Binary files a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/brd_wiz.png and /dev/null differ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.htm b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.htm deleted file mode 100644 index 191f317..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.htm +++ /dev/null @@ -1,24 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Digital I/O v1.1 - - - - - - - - -

LED1: unknown..

- -
- -
-
- - - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.js b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.js deleted file mode 100644 index 5d1d164..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/dio.js +++ /dev/null @@ -1,93 +0,0 @@ -function DioCallback(o) -{ - var pin = o.dio_p; - $('txtdio_s'+pin).value = o.dio_s; - $('txtdio_d'+pin).value = o.dio_d; -} -function led1Callback(o) -{ - $('led1_txt').innerHTML = o.led1_txt; -} -function getDio(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - oUpdate = new AJAX('get_dio'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); -} -function setDiostate(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_s'+p).value;*/ - var v = o.attributes['s'].value; - dout = new AJAX('set_diostate.cgi', - function(t) - { - try - { - /*eval(t);*/ - document.getElementById('led1_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function setDiodir(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_d'+p).value;*/ - var v = o.attributes['d'].value; - dout = new AJAX('set_diodir.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function getled1() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_led1.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getled1()', 3000); -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/favicon.ico b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/favicon.ico deleted file mode 100644 index f63da06..0000000 Binary files a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/favicon.ico and /dev/null differ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/img.htm b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/img.htm deleted file mode 100644 index f609e83..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/img.htm +++ /dev/null @@ -1,14 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Image - - - - - - -
wizwebserver.png
- - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/index.htm b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/index.htm deleted file mode 100644 index 758f904..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/index.htm +++ /dev/null @@ -1,25 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server - - - - -
- W5500-AtMEGA1284p Web Server Demopage -

- Network Information
- Base64 Image Data
-
- Board Schematic
- Mounting Scheme
-
- Ex1> Digital I/O
- Ex2> Analog Input
- Ex3> Analog Input: Google Gauge Chart
-
- Device Information
- - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.htm b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.htm deleted file mode 100644 index fdc64f6..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.htm +++ /dev/null @@ -1,18 +0,0 @@ - - - - - W5500-AtMEGA1284p Device Info - - - - - - -
- W5500-AtMEGA1284p Device Information -

-

..

- diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.js b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.js deleted file mode 100644 index 145be40..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/info.js +++ /dev/null @@ -1,21 +0,0 @@ -function getInfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_info.cgi', function(t) - { - try - { - //*eval(t); - document.getElementById('info_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); oUpdate.doGet(); - } - , 300); setTimeout('getInfo()', 3000); -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/m1284p.png b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/m1284p.png deleted file mode 100644 index a6dc8a3..0000000 Binary files a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/m1284p.png and /dev/null differ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.htm b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.htm deleted file mode 100644 index 581ba6e..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.htm +++ /dev/null @@ -1,33 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Network Info - - - - - - - -
- W5500-AtMEGA1284p Web Server Network Information -

- -
    -
  • - -
  • - -
  • - -
  • - -
  • -
- - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.js b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.js deleted file mode 100644 index ca5ca0a..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/WWW/netinfo.js +++ /dev/null @@ -1,37 +0,0 @@ -function NetinfoCallback(o) -{ - $('txtmac').value = o.mac; - $('txtip').value = o.ip; - $('txtgw').value = o.gw; - $('txtsn').value = o.sn; - $('txtdns').value = o.dns; - if(typeof(window.external)!='undefined') - { - obj = $$_ie('input', 'dhcp'); - } - else - { - obj = $$('dhcp'); - } -} -function getNetinfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_netinfo.cgi', function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 1500); -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/clean.bat b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/clean.bat deleted file mode 100644 index 9977613..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/clean.bat +++ /dev/null @@ -1,3 +0,0 @@ -del *.b#* -del *.s#* -pause diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ccsbcs.c.unicode b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/diskio.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ffconf.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ffconf.h deleted file mode 100644 index bcaba72..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_READONLY 1 -/* 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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/integer.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/globals.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/globals.h deleted file mode 100644 index 8bebfdf..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/globals.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -#include "Internet/httpServer_avr/httpParser.h" -//******************************* Fat FS declare related: END - - -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1<= 2 */ -//static FIL File; /* File object. there are _FS_LOCK file objects available, >= 2. */ - -#endif /* GLOBALS_H_ */ diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/main.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/main.c deleted file mode 100644 index bae4cb0..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/main.c +++ /dev/null @@ -1,801 +0,0 @@ -/* - * main.c - * - * Created on: 22 нояб. 2018 г. - * Author: maxx - */ -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Internet/httpServer_avr/httpServer.h" -//#include "webpage.h" - -#define _MAIN_DEBUG_ - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - - -//#include "Application/loopback/loopback.h" -//#include "Application/webserver_simple/webserver_simple.h" - -/* - * (12) Try move pages to SD-CARD reader FatFS - * TODO - * OK 1) Try create minimal to SD-READER, include FatFS from <02_m1284p_FATFS_Chang_tst> and test working - * OK 2) Read all pages from (11) to folder this project, then move it in root folder SD-Reader and test working - * OK 3) Clean code (done on v2.4b) - * OK 4) Remove unused files from project (done on v2.4b) - * OK 5) Need to handle for every opened socket!! Because without this server is freeze, while download several large files - * at once from SD-CARD. (done on v2.4c) - * Add and debug f_open(&fs, ..)/??f_close(&fs, ..) to: - * http_process_handler_avr (here actually already implemented..) - * OK + add f_open(&fs, ..) in STATE_HTTP_RES_INPROC before - * f_close(&fs) add to and comment out in - * Works stable but download speed slow (~40-50kb/sec ~80kb/sec with SPI 4MHZ && _HTTPSERVER_DEBUG_ = ON), because on every download file for every transfer TCP-IP packet proceed sequence: f_open(&fs, ..)/f_lseek(&fs, /f_close(&fs, ..) - * OK 6) Optimize (5) - Add to <_st_http_socket> structure to avoid multiple re-open downloaded file - * Works faster: ~80kb/sec with SPI 4MHZ && _HTTPSERVER_DEBUG_ = ON, ~110kb/sec SPI 4MHZ && _HTTPSERVER_DEBUG_ = OFF, ~150kb/sec ~80kb/sec with SPI 8MHZ && _HTTPSERVER_DEBUG_ = OFF - * (done on v2.4d) - * OK 7) Trying compile project with ATMega644p (4KB RAM), reduced size used RAM. - * Success - in worst case ~390 RAM free (HTTPD 4 Sockets per 512 bytes) with turned on _HTTPSERVER_DEBUG_ - * (Changed: - * globals.h - 26 #define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - * main.c - 415 #define MAX_HTTPSOCK 4 - * 416 uint8_t socknumlist[] = {0, 1, 2, 3}; - * - * httpServer.c - 36 st_http_socket HTTPSock_Status[4] = { {STATE_HTTP_IDLE, }, }; //For MEGA644p (optimized for RAM size) - * ) - * (done on v2.4e-tiny) - * (11) Try move all pages saved at from RAM to FLASH address space - * Example of flash data access look at: - * <01_m1284p_bb00_minimum_PSTR_webpage_test> - * <09_m1284p_WIZNET_simple_webserver> - * - * Success initial porting on 10/12/2018 - FREE RAM on webserver: 7936 bytes (From total 16kbytes)! - * NEED further optimization to AVR_RAM->AVR_FLASH point (damn Harvard architecture :( )! - * - * It works on AtMega1284p(16kbytes RAM), but need TODO finish (DONE on v2.3b 12/12/2018)!! - * - * TODO DONE: - * After v2.3 optimization: - * (+4kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 2048 see )) : FREE RAM on webserver: 10372 bytes - much better! (RAM enough for AtMega1284/AtMega2560 ie. AVR with 8-16Kb RAM) - * (+1kb HTTP Buffers READ-WRITE(with HTTPD_MAX_BUF_SIZE 512 see )) : FREE RAM on webserver: 13444 bytes - awesome! (RAM enough for AtMega644/AtMega128 ie. AVR with 4Kb RAM) - * - * OK 1) Father optimization / (v2.3 12/12/2018) - * OK 2) Father optimization / (v2.3 12/12/2018) - * OK 3) Rename httpServer.*->httpServer_avr.*, httpParser.*->httpParser_avr.*, httpUtil.*->httpUtil_avr.* (v2.3b 12/12/2018) - * Actually made another way: rename parent folder to - * OK 4) Fix not correct showed value on (v2.2 12/12/2018) - * OK 5) Correct indentation in all <*.html> and <*.js> sources and repack it again in . (v2.2 12/12/2018) - * OK 6) Add to webserver (v2.1 12/12/2018) + also added binary files support in webserver via: , bin2hex_v2.py - * 7) Publish sources in my github, wiznetmuseim, avrfreaks etc.. (optional) - * - * (10) Try repeat example HTTPServer_LPC11E36_LPCXpresso on AVR Mega1284p (All pages still in RAM) - * Here used to WEB-server handle cgi-like requests, with AJAX + JSON - * Description here: - * http://wiznetmuseum.com/portfolio-items/w5500-evb-web-server/ - * - * To better undestand AJAX look here (actually here used AJAX + XHTML): - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/web-server-read-switch-automatically-using-AJAX/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/AJAX-read-switches-analog/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-AJAX-XML-web-server/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-gauge/ - * https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-IO/ - * - * To online encode text file to C source use online utility (Text->Cpp): - * https://tomeko.net/online_tools/cpp_text_escape.php?lang=en - * add option (this is for good reading into browser, as source code) - * after that insert in any text editor and replace <\n"> sequence to <\n"\> (this is for recognize multiple string into C-source headers) - * - * For prepare binary data (some image data, like favicon.ico) use script. - * Example usage: - * >bin2hex_v2.py favicon.ico - * >out favicon_ico.h - * After that insert into end content from favicon.ico; - * Then use this resource in www server like (look in ): - * reg_httpServer_binContent_avr(PSTR("favicon.ico"),favicon_ico, (uint32_t)sizeof(favicon_ico)); // favicon.ico : webserver icon - * - * - * - * Also can use File->HEX (BIN2HEX) - for prepare images for example (bin2hex_v2.py BETTER SUIT for AVR!!): - * https://tomeko.net/online_tools/file_to_hex.php?lang=en - * - * (9) Simple webserver, based on code from: - * http://www.ermicro.com/blog/?p=1773 - * Article: Integrating Wiznet W5100, WIZ811MJ network module with Atmel AVR Microcontroller - * - * (3) Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping on static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~10..12.2018 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega644p v2.4e-tiny Static IP HTTP_server SDCARD Pages WIZNET_5500 ETHERNET 06/02/2019\r\n"; // Program name - -/* - * m1284p minimum template, with one button & one led - */ - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -inline unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - //In this demo all www content saved onto SD-Card (you must copy all from folder to ROOT SD-Card) -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - //uint32_t timer_link_1sec = millis(); - uint32_t timer_httpd_1sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } - } - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - } // End of user's code - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - //loopback_tcps(0,ethBuf0,5000); - //loopback_udps(1, ethBuf1, 3000); - - //Use WEBbrowser to connect to webserver: http://192.168.0.199/index.html - //websrv_simple(2, ethBuf2_WEBSRV, 80); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - //Not used here, because led1 handle via websrv - /* - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - } - */ - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/spi.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 128 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/userHandler.c b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/userHandler.c deleted file mode 100644 index 6d0e5d1..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/userHandler.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file userHandler.c - * @brief User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -//#include "board.h" -#include "httpUtil.h" -#include "userHandler.h" -//#include "adcHandler.h" -#include "wizchip_conf.h" -#include "globals.h" - -/* Unavailable Pins (W5500-EVB component preempted) */ -// >> UART Rx/Tx : D0 (Rx), D1 (Tx) -// >> W5500 SPI(SPI0) : D11 (MOSI), D12 (MISO), D13 (SCK) - -/* On-board Devices */ -// >> Input : D14 (SW1) / D15 (SW2) -// >> Input : AIN (Potentiometer / TEMP.Sensor) -// >> Output : D8 (LED R) / D9 (LED G) / D10 (LED B) - -/* NXP LPC11Exx GPIO functions */ -// GPIO: Pin state -//Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); - -// GPIO: Pin direction -//Chip_GPIO_GetPinDIR((LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); - -// Pre-defined Get CGI functions -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_netinfo(uint8_t * buf, uint16_t * len); -void make_json_led1(uint8_t * buf, uint16_t * len); -void make_info(uint8_t * buf, uint16_t * len); - -// Pre-defined Set CGI functions -int8_t set_diodir(uint8_t * uri); -int8_t set_diostate(uint8_t * uri); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len) -{ - //return 0; //Just a stub, not used yet.. - //uint8_t ret = 1; // ret = 1 means 'uri_name' matched - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched - uint8_t cgibuf[14] = {0, }; - int8_t cgi_dio = -1; - int8_t cgi_ain = -1; - - uint8_t i; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { -// // to do -// ;//make_json_todo(buf, len); - } - else if(strcmp_P((const char *)uri_name,PSTR("get_netinfo.cgi")) == 0) - { - make_json_netinfo(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_led1.cgi")) == 0) - { - make_json_led1(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_info.cgi")) == 0) - { - make_info(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else - { -// // get_dio0.cgi ~ get_dio15.cgi -// for(i = 0; i < DIOn; i++) -// { -// memset(cgibuf, 0x00, 14); -// sprintf((char *)cgibuf, "get_dio%d.cgi", i); -// if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) -// { -// make_json_dio(buf, len, i); -// cgi_dio = i; -// break; -// } -// } -// -// if(cgi_dio < 0) - //Analog Ins reading get_ain0.cgi ~ get_ain7.cgi - if(1) - { - // get_ain0.cgi ~ get_ain5.cgi (A0 - A5), get_ain6.cgi for on-board potentiometer / Temp.Sensor - LPC11Exx - //for(i = 0; i < AINn; i++) //for LPC11xx - for(i = 0; i < 8; i++) //for AVR Mega1284p, available AIN0..AIN7 - { - memset(cgibuf, 0x00, 14); - sprintf((char *)cgibuf, "get_ain%d.cgi", i); - if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) - { - make_json_ain(buf, len, i); - cgi_ain = i; - ret = 1; - break; - } - } - } - -// if((cgi_dio < 0) && (cgi_ain < 0)) ret = 0; - } - - return ret; -} - - -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len) -{ -// return 0; //Just a stub, not used yet.. - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched -// uint8_t ret = 1; // ret = '1' means 'uri_name' matched - uint8_t val = 0; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { - // to do - ;//val = todo(uri); - //*len = sprintf((char *)buf, "%d", val); - } -// // Digital I/O; dio_s, dio_d -// else if(strcmp_P((const char *)uri_name,PSTR("set_diodir.cgi")) == 0) -// { -// //val = set_diodir(uri); -// //printf_P(PSTR("+++set_diodir.cgi uri_name: %s; uri: %s;\r\n")); -// *len = sprintf_P((char *)buf, PSTR("%d"), val); -// ret = 1; -// } - else if(strcmp((const char *)uri_name, "set_diostate.cgi") == 0) - { - //When uri_name=set_diostate.cgi, and uri HTTP POST request which contains something like: - //pin=8&val=1; or pin=8&val=1; (look && ) - - /* - This is LPC11xx handler - val = set_diostate(uri); - len = sprintf((char *)buf, "%d", val); - len ret = 1; - */ - - - //!!Just for debug - PRINTF("\r\n+++set_diostate.cgi uri_name: %s\r\nuri: %s\r\n", uri_name, uri); - - //Parse URI (Very dirty!!) - if(strstr_P(uri,PSTR("pin=LED1&val=0"))) - { - led1_low(); - *len = sprintf_P((char *)buf, PSTR("LED1: OFF")); - ret = 1; - } - else if(strstr_P(uri,PSTR("pin=LED1&val=1"))) - { - led1_high(); - *len = sprintf_P((char *)buf, PSTR("LED1: ON")); - ret = 1; - } - else - { - //*len = sprintf_P((char *)buf, PSTR("%d"), -1); - *len = sprintf_P((char *)buf, PSTR("???")); - ret = 1; - } - } -// else -// { -// ret = 0; -// } -// - return ret; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Get CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin) -//{ -// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// -// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\ -// \"dio_s\":\"%d\",\ -// \"dio_d\":\"%d\"\ -// });", -// pin, // Digital io pin number -// pin_state, // Digital io status -// pin_dir // Digital io directions -// ); -//} -// -void make_json_led1(uint8_t * buf, uint16_t * len) -{ - if(led1_read()) - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: ON\"});")); //Send back LED1 state via call-back function - } - else - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: OFF\"});")); //Send back LED1 state via call-back function - } - -} - -void make_info(uint8_t * buf, uint16_t * len) -{ - /* - * Send program metrics: - * Program name - * time-date compile - * MCU info - * free ram info - * uptime device - */ - *len = sprintf_P((char *)buf,PSTR(\ - "
%S"\
-			"Compiled at: %S %S\r\n"\
-			"MCU is: %S; CLK is: %luHz\r\n"\
-			"Free RAM: %dbytes\r\n"\
-			"Uptime: %lusec\r\n
"),\ - str_prog_name,\ - compile_time, compile_date,\ - str_mcu, F_CPU,\ - freeRam(),\ - millis()/1000); -} - -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin) -{ - *len = sprintf_P((char *)buf,PSTR( "AinCallback({\"ain_p\":\"%d\",\ - \"ain_v\":\"%d\"\ - });"), - pin, // ADC input pin number - //get_ADC_val(pin) // ADC input value for LPC11xx - adc_read(pin) // ADC input value for AVR - ); -} - -void make_json_netinfo(uint8_t * buf, uint16_t * len) -{ - wiz_NetInfo netinfo; - ctlnetwork(CN_GET_NETINFO, (void*) &netinfo); - - // DHCP: 1 - Static, 2 - DHCP - *len = sprintf_P((char *)buf,PSTR( "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\ - \"ip\":\"%d.%d.%d.%d\",\ - \"gw\":\"%d.%d.%d.%d\",\ - \"sn\":\"%d.%d.%d.%d\",\ - \"dns\":\"%d.%d.%d.%d\",\ - \"dhcp\":\"%d\"\ - });"), - netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5], - netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3], - netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3], - netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3], - netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3], - netinfo.dhcp - ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Set CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//int8_t set_diodir(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // Direction; NotUsed/Input/Output -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > Output) val = Output; -// } -// } -// -// if(val == Input) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input -// else Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -// -// return pin; -//} -// -//int8_t set_diostate(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // State; high(on)/low(off) -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > On) val = On; -// } -// -// if(val == On) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High -// else Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -// } -// -// return pin; -//} diff --git a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/userHandler.h b/12_m644p_WIZNET_HTTPServer_SDCARD_pages/userHandler.h deleted file mode 100644 index 1f9af30..0000000 --- a/12_m644p_WIZNET_HTTPServer_SDCARD_pages/userHandler.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file userHandler.h - * @brief Header File for User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __USERHANDLER_H -#define __USERHANDLER_H - -#include -//#define _WEB_DEBUG_ - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Public Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined CGI Interface Functions Handler -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP GET Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP POST Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - - -#endif - diff --git a/14_m1284p_WIZNET_FTPC_FATFS/.cproject b/14_m1284p_WIZNET_FTPC_FATFS/.cproject deleted file mode 100644 index aaf6ee5..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/.cproject +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/14_m1284p_WIZNET_FTPC_FATFS/.project b/14_m1284p_WIZNET_FTPC_FATFS/.project deleted file mode 100644 index c6f8714..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 14_m1284p_WIZNET_FTPC_FATFS - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Application/loopback/loopback.c b/14_m1284p_WIZNET_FTPC_FATFS/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Application/loopback/loopback.h b/14_m1284p_WIZNET_FTPC_FATFS/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/W5500/w5500.c b/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/W5500/w5500.h b/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/socket.c b/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/socket.h b/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/wizchip_conf.c b/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/wizchip_conf.h b/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Internet/FTPClient_avr/ftpc.c b/14_m1284p_WIZNET_FTPC_FATFS/Internet/FTPClient_avr/ftpc.c deleted file mode 100644 index 59a33b6..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Internet/FTPClient_avr/ftpc.c +++ /dev/null @@ -1,923 +0,0 @@ -#include "ftpc.h" -//FTP Data socket Connected - -un_l2cval remote_ip; -uint16_t remote_port; -un_l2cval local_ip; -uint16_t local_port; -uint8_t connect_state_control_ftpc = 0; -uint8_t connect_state_data_ftpc = 0; -uint8_t gModeActivePassiveflag = 0; -//uint8_t FTP_SRV_destip[4] = {192, 168, 0, 100}; // For FTP client examples; destination network info - WORK STATION IP -//uint8_t FTP_SRV_destip[4] = {192, 168, 1, 81}; // For FTP client examples; destination network info - HOME STATION IP -uint16_t FTP_SRV_destport = 21; // For FTP client examples; destination network info -uint8_t gMenuStart = 0; -uint8_t gDataSockReady = 0; -uint8_t gDataPutGetStart = 0; -static uint8_t gMsgBuf[20]={0,}; - -//dir waiting -//put waiting -//Rcvd Command: - -struct ftpc ftpc; -struct Command Command; - -/* -uint8_t ftpc_try(uint8_t * src_ip) -{ - ftpc.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - strcpy(ftpc.workingdir, "/"); - //uint8_t sock_res_open; - //socket(CTRL_SOCK, Sn_MR_TCP, FTP_destport, 0); //SF_IO_NONBLOCK - socket(CTRL_SOCK, Sn_MR_TCP, FTP_destport, SF_IO_NONBLOCK); - - connect(CTRL_SOCK, FTP_destip, FTP_destport); - - //Wait connection to FTP Server - if(Sn_SR(CTRL_SOCK) != SOCK_ESTABLISHED) // check the tcp connect success - { - PRINTF("FTP Client Wait CTRL_SOCK connect..\r\n"); - close(CTRL_SOCK); - wdt_reset(); - _delay_ms(1000); - return 0; - } - else - { - close(CTRL_SOCK); - wdt_reset(); - _delay_ms(1000); - return 1; - } -} -*/ - -void ftpc_init(uint8_t * src_ip) -{ - ftpc.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - strcpy(ftpc.workingdir, "/"); - socket(CTRL_SOCK, Sn_MR_TCP, FTP_SRV_destport, 0x0); //- Blocking type - ugly, when sure that FTP server exist -} - -uint8_t ftpc_run(uint8_t * dbuf) -{ -#ifndef Need_UARTGetCharBlocking_func - uint16_t size = 0; - long ret = 0; - uint32_t send_byte, recv_byte; - uint32_t blocklen; - uint32_t remain_filesize; - uint32_t remain_datasize; - uint8_t msg_c; - uint8_t dat[50]={0,}; - uint32_t totalSize = 0, availableSize = 0; - - switch(getSn_SR(CTRL_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_control_ftpc){ - PRINTF("%d:[SOCK_ESTABLISHED]FTP Connected\r\n", CTRL_SOCK); - strcpy(ftpc.workingdir, "/"); - connect_state_control_ftpc = 1; - } - if(gMenuStart){ - gMenuStart = 0; - PRINTF("\r\n----------------------------------------\r\n"); - PRINTF("Press menu key\r\n"); - PRINTF("----------------------------------------\r\n"); - PRINTF("1> View FTP Server Directory\r\n"); - PRINTF("2> View SDCARD Directory\r\n"); - PRINTF("3> Sets the type of file to be transferred. Current state : %s\r\n", (ftpc.type==ASCII_TYPE)?"Ascii":"Binary"); - PRINTF("4> Sets Data Connection. Current state : %s\r\n", (ftpc.dsock_mode==ACTIVE_MODE)?"Active":"Passive"); - PRINTF("5> Put File to Server\r\n"); - PRINTF("6> Get File from Server\r\n"); -#if defined(F_FILESYSTEM) - PRINTF("7> Delete File from SDCARD\r\n"); -#endif - PRINTF("8> Delete File from FTP Server\r\n"); - PRINTF("9> Execute custom command onto FTP Server\r\n"); - PRINTF("T> Test message\r\n"); - PRINTF("S> Status board (FreeRam and UpTime)\r\n"); - PRINTF("R> Reboot board\r\n"); - PRINTF("----------------------------------------\r\n"); - while(1){ - msg_c=ftp_getc(); - if((msg_c=='t')||(msg_c=='T')){ - PRINTF("\r\nTest message: Hello!\r\n"); - gMenuStart = 1; - _delay_ms(100); - uart0_rx_flash(); - break; - } - else if((msg_c=='s')||(msg_c=='S')){ - PRINTF("\r\nUptime: %lu sec\r\nFreeRam: %u bytes\r\n", millis()/1000, freeRam()); - gMenuStart = 1; - _delay_ms(100); - uart0_rx_flash(); - break; - } - else if((msg_c=='r')||(msg_c=='R')){ - PRINTF("\r\nReboot the board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - break; - } - else if(msg_c=='1'){ - _delay_ms(100); - uart0_rx_flash(); - - if(ftpc.dsock_mode==PASSIVE_MODE){ - sprintf(dat,"PASV\r\n"); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - Command.First = f_dir; - break; - } - else{ - wiz_NetInfo gWIZNETINFO; - ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO); - sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff)); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - Command.First = f_dir; - - gModeActivePassiveflag = 1; - break; - } - break; - } - else if(msg_c=='5'){ - _delay_ms(100); - uart0_rx_flash(); - if(ftpc.dsock_mode==PASSIVE_MODE){ - sprintf(dat,"PASV\r\n"); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - Command.First = f_put; - break; - } - else{ - wiz_NetInfo gWIZNETINFO; - ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO); - sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff)); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - Command.First = f_put; - - gModeActivePassiveflag = 1; - break; - } - } - else if(msg_c=='6'){ - _delay_ms(100); - uart0_rx_flash(); - if(ftpc.dsock_mode==PASSIVE_MODE){ - sprintf(dat,"PASV\r\n"); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - Command.First = f_get; - break; - } - else{ - wiz_NetInfo gWIZNETINFO; - ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO); - sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff)); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - Command.First = f_get; - - gModeActivePassiveflag = 1; - break; - } - } - else if(msg_c=='2'){ - _delay_ms(100); - uart0_rx_flash(); -#if defined(F_FILESYSTEM) - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir(ftpc.workingdir); //Works OK - PRINTF ("===============================================\r\n\r\n"); - //scan_files(ftpc.workingdir, dbuf, (int *)&size); //Broken implementation - //PRINTF("\r\n%s\r\n", dbuf); -#else - if (strncmp(ftpc.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0) - size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n"); - PRINTF("\r\n%s\r\n", dbuf); -#endif - gMenuStart = 1; - break; - } - else if(msg_c=='3'){ - PRINTF("\r\n1> ASCII\r\n"); - PRINTF("2> BINARY\r\n"); - _delay_ms(100); - uart0_rx_flash(); - while(1){ - msg_c=ftp_getc(); - _delay_ms(100); - uart0_rx_flash(); - if(msg_c=='1'){ - sprintf(dat,"TYPE %c\r\n", TransferAscii); - ftpc.type = ASCII_TYPE; - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - } - else if(msg_c=='2'){ - sprintf(dat,"TYPE %c\r\n", TransferBinary); - ftpc.type = IMAGE_TYPE; - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - } - else{ - PRINTF("\r\nRetry...\r\n"); - } - } - break; - } - else if(msg_c=='4'){ - PRINTF("\r\n1> ACTIVE\r\n"); - PRINTF("2> PASSIVE(Disabled)\r\n"); - _delay_ms(100); - uart0_rx_flash(); - while(1){ - msg_c=ftp_getc(); - _delay_ms(100); - uart0_rx_flash(); - if(msg_c=='1'){ - ftpc.dsock_mode=ACTIVE_MODE; - break; - } - else if(msg_c=='2'){ - //PASSIVE mode with bugs, so disabled - //ftpc.dsock_mode=PASSIVE_MODE; - ftpc.dsock_mode=ACTIVE_MODE; - break; - } - else{ - PRINTF("\r\nRetry...\r\n"); - } - } - gMenuStart = 1; - break; - } -#if defined(F_FILESYSTEM) - else if(msg_c=='7'){ - PRINTF(">del filename (SD-CARD)?"); - _delay_ms(100); - uart0_rx_flash(); - sprintf(ftpc.filename, "/%s\r\n", User_Keyboard_MSG()); - if (f_unlink((const char *)ftpc.filename) != 0){ - PRINTF("\r\nCould not delete.\r\n"); - } - else{ - PRINTF("\r\nDeleted.\r\n"); - } - gMenuStart = 1; - break; - } -#endif - else if(msg_c=='8'){ - _delay_ms(100); - uart0_rx_flash(); - PRINTF(">del filename (FTPD)?"); - _delay_ms(100); - uart0_rx_flash(); - sprintf(dat,"DELE %s\r\n", User_Keyboard_MSG()); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - - //Should not used here - //gModeActivePassiveflag = 1; - break; - } - else if(msg_c=='9'){ - _delay_ms(100); - uart0_rx_flash(); - PRINTF(">FTPD execute command(HELP etc..)?"); - _delay_ms(100); - uart0_rx_flash(); - sprintf(dat,"%s\r\n", User_Keyboard_MSG()); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - - //Should not used here - //gModeActivePassiveflag = 0; - break; - } - else if((msg_c == '\r')||(msg_c == '\n')) - { - //Suppress CR and LF symbols - //gMenuStart = 1; - _delay_ms(100); - uart0_rx_flash(); - } - else{ - PRINTF("\r\n??Unknown command: <%c>\r\nRetry...\r\n", msg_c); - _delay_ms(100); - uart0_rx_flash(); - //gMenuStart = 1; - //break; - } - } - } - if(gDataSockReady){ - gDataSockReady = 0; - switch(Command.First){ - case f_dir: - sprintf(dat,"LIST\r\n"); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - case f_put: - PRINTF(">put file name?"); - sprintf(dat,"STOR %s\r\n", User_Keyboard_MSG()); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - case f_get: - PRINTF(">get file name?"); - sprintf(dat,"RETR %s\r\n", User_Keyboard_MSG()); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - default: - PRINTF("Command.First = default\r\n"); - break; - } - } - if((size = getSn_RX_RSR(CTRL_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur. - memset(dbuf, 0, _MAX_SS_FTP); - if(size > _MAX_SS_FTP) size = _MAX_SS_FTP - 1; - ret = recv(CTRL_SOCK,dbuf,size); - dbuf[ret] = '\0'; - if(ret != size) - { - if(ret==SOCK_BUSY) return 0; - if(ret < 0){ - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); - close(CTRL_SOCK); - return ret; - } - } - PRINTF("\r\nRcvd Command: %s\r\n", dbuf); - proc_ftpc((char *)dbuf); - } - break; - case SOCK_CLOSE_WAIT : - PRINTF("%d:CloseWait\r\n",CTRL_SOCK); - if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret; - PRINTF("%d:Closed\r\n",CTRL_SOCK); - break; - case SOCK_CLOSED : - PRINTF("%d:FTPStart\r\n",CTRL_SOCK); - if((ret=socket(CTRL_SOCK, Sn_MR_TCP, FTP_SRV_destport, 0x0)) != CTRL_SOCK){ - PRINTF("%d:socket() error:%ld\r\n", CTRL_SOCK, ret); - close(CTRL_SOCK); - return ret; - } - break; - case SOCK_INIT : - PRINTF("%d:[SOCK_INIT]Opened\r\n",CTRL_SOCK); - if((ret = connect(CTRL_SOCK, FTP_SRV_destip, FTP_SRV_destport)) != SOCK_OK){ - PRINTF("%d:Connect error\r\n",CTRL_SOCK); - return ret; - } - connect_state_control_ftpc = 0; - PRINTF("%d:[SOCK_INIT]Connectting...\r\n",CTRL_SOCK); - break; - default : - break; - } - switch(getSn_SR(DATA_SOCK)){ - case SOCK_ESTABLISHED : - if(!connect_state_data_ftpc){ - PRINTF("%d:FTP Data socket Connected\r\n", DATA_SOCK); - connect_state_data_ftpc = 1; - } - if(gDataPutGetStart){ - switch(Command.Second){ - case s_dir: - PRINTF("dir waiting...\r\n"); - _delay_ms(1); - - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ //#1 if .. Don't need to check SOCKERR_BUSY because it doesn't not occur. - - uint32_t timer_dir_list = millis(); - wdt_reset(); - - PRINTF("\r\nFTP server root file list:\r\n"); - PRINTF ("===============================================\r\n"); - while(1)//#1 while(1) - { - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ //#2 if .. Don't need to check SOCKERR_BUSY because it doesn't not occur. - //!!Debug only - //PRINTF("\r\n++SIZE of FILE %lu\r\n", remain_datasize); - while(1)//#2 while(1) - { - memset(dbuf, 0, _MAX_SS_FTP); - if(remain_datasize > (_MAX_SS_FTP-1)) recv_byte = _MAX_SS_FTP-1; - else recv_byte = remain_datasize; - ret = recv(DATA_SOCK, dbuf, recv_byte); - remain_datasize -= ret; - //!!Debug only - //PRINTF("\r\n++ ret: %lu; recv_byte: %lu, remain_datasize: %lu\r\n", ret, recv_byte, remain_datasize); - if(ret != recv_byte){ - if(ret==SOCK_BUSY) return 0; - if(ret < 0){ - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); - close(DATA_SOCK); - return ret; - } - } - else - { - dbuf[ret] = '\0'; - //PRINTF("\r\nRcvd Data:\n\r%s\n\r", dbuf); - PRINTF("%s", dbuf); - } - if(remain_datasize <= 0) break; - }//#2 while(1) - //GET packets from dir_list store time tag - timer_dir_list = millis(); - wdt_reset(); - }//#2 if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - else - { - if((millis()-timer_dir_list)>FTP_DIR_LIST_PAUSE) - { - //If on packet ~ 0.5..3sec break receive dir list - break; - } - }//#2 if.. else - }//#1 while(1) - //Here when all list data received - PRINTF ("===============================================\r\n"); - gDataPutGetStart = 0; - Command.Second = s_nocmd; - }//#1 if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - - break; - case s_put: - PRINTF("put waiting...\r\n"); - _delay_ms(1); - - if(strlen(ftpc.workingdir) == 1) - sprintf(ftpc.filename, "/%s", (uint8_t *)gMsgBuf); - else - sprintf(ftpc.filename, "%s/%s", ftpc.workingdir, (uint8_t *)gMsgBuf); -#if defined(F_FILESYSTEM) - ftpc.fr = f_open(&(ftpc.fil), (const char *)ftpc.filename, FA_READ); - if(ftpc.fr == FR_OK){ - remain_filesize = ftpc.fil.fsize; - PRINTF("f_open return FR_OK\r\n"); - //!!Debug only - //PRINTF("\r\n++SIZE of FILE %lu\r\n", remain_filesize); - do{ - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTP); - if(remain_filesize > _MAX_SS_FTP) - send_byte = _MAX_SS_FTP; - else - send_byte = remain_filesize; - //!!Debug only - //PRINTF("++SEND BYTE %lu\r\n", send_byte); - ftpc.fr = f_read(&(ftpc.fil), (void *)dbuf, send_byte , (UINT *)&blocklen); - if(ftpc.fr != FR_OK){ - break; - } - PRINTF("#"); - int32_t _send_size; - _send_size = send(DATA_SOCK, dbuf,(uint16_t) blocklen); - //remain_filesize -= blocklen; - remain_filesize -= (uint32_t)_send_size; - - //!!Debug only - //PRINTF("++REMAIN SIZE of FILE %lu\r\n\r\n", remain_filesize); - }while(remain_filesize != 0); - PRINTF("\r\nFile read finished\r\n"); - ftpc.fr = f_close(&(ftpc.fil)); - } - else{ - PRINTF("File Open Error: %d\r\n", ftpc.fr); - ftpc.fr = f_close(&(ftpc.fil)); - } -#else - remain_filesize = strlen(ftpc.filename); - do{ - memset(dbuf, 0, _MAX_SS_FTP); - blocklen = sprintf(dbuf, "%s", ftpc.filename); - PRINTF("########## dbuf:%s\r\n", dbuf); - send(DATA_SOCK, dbuf, blocklen); - remain_filesize -= blocklen; - }while(remain_filesize != 0); -#endif - gDataPutGetStart = 0; - Command.Second = s_nocmd; - disconnect(DATA_SOCK); - break; - case s_get: - PRINTF("get waiting...\r\n"); - _delay_ms(1); - - if(strlen(ftpc.workingdir) == 1) - sprintf(ftpc.filename, "/%s", (uint8_t *)gMsgBuf); - else - sprintf(ftpc.filename, "%s/%s", ftpc.workingdir, (uint8_t *)gMsgBuf); -#if defined(F_FILESYSTEM) - ftpc.fr = f_open(&(ftpc.fil), (const char *)ftpc.filename, FA_CREATE_ALWAYS | FA_WRITE); - if(ftpc.fr == FR_OK){ - PRINTF("f_open return FR_OK\r\n"); - while(1){ //while #1.. - wdt_reset(); - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){//if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - //!!Debug only - //PRINTF("++Arrive new packet: remain_datasize %lu\r\n\r\n", remain_datasize); - while(1){//while #2.. - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTP); - if(remain_datasize > _MAX_SS_FTP) recv_byte = _MAX_SS_FTP; - else recv_byte = remain_datasize; - ret = recv(DATA_SOCK, dbuf,(uint16_t) recv_byte); - uint16_t _blocklen; - ftpc.fr = f_write(&(ftpc.fil), (const void *)dbuf, (UINT)ret, (UINT *)&_blocklen); - remain_datasize -= _blocklen; - if(ftpc.fr != FR_OK){ - PRINTF("f_write failed\r\n"); - break; - } - if(remain_datasize <= 0) break; - PRINTF("#"); - f_sync(&(ftpc.fil)); //Flush data to SDCARD from cache - //!!Debug only - //PRINTF("++remain_datasize: %lu\r\n\r\n", remain_datasize); - }//while #2.. - if(ftpc.fr != FR_OK){ - PRINTF("f_write failed\r\n"); - break; - } - }//if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) break; - } - }// //while #1.. - PRINTF("\r\nFile write finished\r\n"); - ftpc.fr = f_close(&(ftpc.fil)); - gDataPutGetStart = 0; - }else{ - PRINTF("File Open Error: %d\r\n", ftpc.fr); - } -#else - while(1){ - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - memset(dbuf, 0, _MAX_SS_FTP); - if(remain_datasize > _MAX_SS_FTP) - recv_byte = _MAX_SS_FTP; - else - recv_byte = remain_datasize; - ret = recv(DATA_SOCK, dbuf, recv_byte); - PRINTF("########## dbuf:%s\r\n", dbuf); - remain_datasize -= ret; - if(remain_datasize <= 0) - break; - } - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } - gDataPutGetStart = 0; - Command.Second = s_nocmd; -#endif - break; - default: - PRINTF("Command.Second = default\r\n"); - break; - } - } - break; - case SOCK_CLOSE_WAIT : - PRINTF("%d:CloseWait\r\n",DATA_SOCK); - if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret; - PRINTF("%d:Closed\r\n",DATA_SOCK); - break; - case SOCK_CLOSED : - if(ftpc.dsock_state == DATASOCK_READY){ - if(ftpc.dsock_mode == PASSIVE_MODE){ - PRINTF("%d:FTPDataStart [PASSIVE_MODE], port : %u\r\n",DATA_SOCK, local_port); - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK){ - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); - close(DATA_SOCK); - return ret; - } - local_port++; - if(local_port > 50000) - //local_port = 35000; - local_port -= 20000; - }else{ - PRINTF("%d:FTPDataStart [ACTIVE_MODE], port : %u\r\n",DATA_SOCK, local_port); - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK){ - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); - close(DATA_SOCK); - return ret; - } - local_port++; - if(local_port > 50000) - //local_port = 35000; - local_port -= 20000; - } - ftpc.dsock_state = DATASOCK_START; - } - break; - - case SOCK_INIT : - PRINTF("%d:Opened\r\n",DATA_SOCK); - if(ftpc.dsock_mode == ACTIVE_MODE){ - if( (ret = listen(DATA_SOCK)) != SOCK_OK){ - PRINTF("%d:Listen error\r\n",DATA_SOCK); - return ret; - } - gDataSockReady = 1; - PRINTF("%d:Listen ok\r\n",DATA_SOCK); - }else{ - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ - PRINTF("%d:Connect error\r\n", DATA_SOCK); - return ret; - } - gDataSockReady = 1; - } - connect_state_data_ftpc = 0; - break; - default : - break; - } -#endif - return 0; -} - -char proc_ftpc(char * buf) -{ - uint16_t Responses; - uint8_t dat[30]={0,}; - - Responses =(buf[0]-'0')*100+(buf[1]-'0')*10+(buf[2]-'0'); - - switch(Responses){ - case R_530: /* 530 Permission denied */ - PRINTF("\r\n??USER/PASS not correct..\r\n"); - - //var.1 Reboot the board on incorrect user-pass (Used on defined AUTOLOGON_ANONYMOUS) - PRINTF("\r\nReboot the board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - - //var.2 Try re-login (Used on undefined AUTOLOGON_ANONYMOUS) - //PRINTF("Try re-login\r\n"); - - //Should not used here on both variants - /*break;*/ - case R_220: /* Service ready for new user. */ - PRINTF("\r\nInput your User ID > "); -#ifdef AUTOLOGON_ANONYMOUS - _delay_ms(100), sprintf(dat,"USER %s\r\n", "anonymous"); //Use default for test purposes - PRINTF("anonymous"); -#else - sprintf(dat,"USER %s\r\n", User_Keyboard_MSG()); -#endif - PRINTF("\r\n"); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - - case R_331: /* User name okay, need password. */ - PRINTF("\r\nInput your Password > "); -#ifdef AUTOLOGON_ANONYMOUS - _delay_ms(100), sprintf(dat,"PASS %s\r\n", "1234"); //Use default for test purposes - PRINTF("1234"); -#else - sprintf(dat,"PASS %s\r\n", User_Keyboard_MSG()); -#endif - PRINTF("\r\n"); - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - case R_230: /* User logged in, proceed */ - PRINTF("\r\nUser logged in, proceed\r\n"); - - sprintf(dat,"TYPE %c\r\n", TransferAscii); - ftpc.type = ASCII_TYPE; - send(CTRL_SOCK, (uint8_t *)dat, strlen(dat)); - break; - case R_250: /* Deleted file success */ - //PRINTF("\r\nDeleted file success\r\n"); - gMenuStart = 1; - break; - case R_550: /*Can't delete file */ - //PRINTF("\r\nCan't delete file\r\n"); - gMenuStart = 1; - break; - case R_200: - if((ftpc.dsock_mode==ACTIVE_MODE)&&gModeActivePassiveflag){ - ftpc.dsock_state = DATASOCK_READY; - gModeActivePassiveflag = 0; - } - else{ - gMenuStart = 1; - } - break; - case R_150: - switch(Command.First){ - case f_dir: - Command.First = f_nocmd; - Command.Second = s_dir; - gDataPutGetStart = 1; - break; - case f_get: - Command.First = f_nocmd; - Command.Second = s_get; - gDataPutGetStart = 1; - break; - case f_put: - Command.First = f_nocmd; - Command.Second = s_put; - gDataPutGetStart = 1; - break; - default : - PRINTF("Command.First = default\r\n"); - break; - } - break; - case R_226: - gMenuStart = 1; - break; - case R_227: - if (pportc(buf) == -1){ - PRINTF("Bad port syntax\r\n"); - } - else{ - PRINTF("Go Open Data Sock...\r\n "); - ftpc.dsock_mode = PASSIVE_MODE; - ftpc.dsock_state = DATASOCK_READY; - } - break; - default: - PRINTF("\r\nDefault Status = %d\r\n",(uint16_t)Responses); - gDataSockReady = 1; - break; - } - return 1; -} -int pportc(char * arg) -{ - int i; - char* tok=0; - strtok(arg,"("); - for (i = 0; i < 4; i++) - { - if(i==0) tok = strtok(NULL,",\r\n"); - else tok = strtok(NULL,","); - remote_ip.cVal[i] = (uint8_t)atoi(tok, 10); - if (!tok){ - PRINTF("bad pport : %s\r\n", arg); - return -1; - } - } - remote_port = 0; - for (i = 0; i < 2; i++){ - tok = strtok(NULL,",\r\n"); - remote_port <<= 8; - remote_port += atoi(tok, 10); - if (!tok){ - PRINTF("bad pport : %s\r\n", arg); - return -1; - } - } - PRINTF("ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); - return 0; -} - -uint8_t* User_Keyboard_MSG() -{ - uint8_t i=0; - uart0_rx_flash(); //Flash UART RX on enter this function - memset(gMsgBuf, 0, sizeof(gMsgBuf)); //Clear all Input buffer - do{ - if(i == sizeof(gMsgBuf)) - { - i = 0; //Overflow input buffer protection - } - gMsgBuf[i] = ftp_getc(); - i++; - }while(gMsgBuf[i-1]!=0x0d); //Wait '\r' symbol - gMsgBuf[i-1]=0; - return gMsgBuf; -} - -/* - * Inserted from earlier realize FAT FS -> - * FAT file system module R0.10c (C)ChaN, 2014 - */ -FRESULT scan_files(char* path, char *buf, int * buf_len) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i, len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ - char date_str[15]; - int date_str_ptr = 0; -#if _USE_LFN == 1 - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - i = strlen(path); - //printf("strlen of path: %s %d \r\n", path, i); - for(;;){ - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN == 1 - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - switch((fno.fdate >> 5) & 0x0f) - { - case 1: - len = sprintf(date_str, "JAN "); - break; - case 2: - len = sprintf(date_str, "FEB "); - break; - case 3: - len = sprintf(date_str, "MAR "); - break; - case 4: - len = sprintf(date_str, "APR "); - break; - case 5: - len = sprintf(date_str, "MAY "); - break; - case 6: - len = sprintf(date_str, "JUN "); - break; - case 7: - len = sprintf(date_str, "JUL "); - break; - case 8: - len = sprintf(date_str, "AUG "); - break; - case 9: - len = sprintf(date_str, "SEP "); - break; - case 10: - len = sprintf(date_str, "OCT "); - break; - case 11: - len = sprintf(date_str, "NOV "); - break; - case 12: - len = sprintf(date_str, "DEC "); - break; - } - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%d ", (fno.fdate & 0x1f)); - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%d", (((fno.fdate >> 9) & 0x7f) + 1980)); - date_str_ptr = 0; - //printf("date str : %s \r\n", date_str); - - if(fno.fattrib & AM_DIR) - { - sprintf(buf + buf_ptr, "d"); - }else - { - sprintf(buf + buf_ptr, "-"); - } - buf_ptr++; - // drwxr-xr-x 1 ftp ftp 0 Apr 07 2014 $RECYCLE.BIN\r\n - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - buf_ptr += len; - //printf("fn: %s \r\n", fn); - - } - //*buf_len = strlen(buf); - //printf("%s", buf); - //printf("\r\nbuf_len : %d, sizeof(buf): %d\r\n", buf_len, sizeof(buf)); - //f_closedir(&dir); - } - return res; -} diff --git a/14_m1284p_WIZNET_FTPC_FATFS/Internet/FTPClient_avr/ftpc.h b/14_m1284p_WIZNET_FTPC_FATFS/Internet/FTPClient_avr/ftpc.h deleted file mode 100644 index d9d5b00..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/Internet/FTPClient_avr/ftpc.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef _FTPC_H_ -#define _FTPC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -//#include "stdio_private.h" -#include "socket.h" - -#include "../../globals.h" //add AVR specific useful headers - -#define F_APP_FTPC - -#define AUTOLOGON_ANONYMOUS - -#define FTP_DIR_LIST_PAUSE 500 /*500ms..3000ms*/ - -/* If your target support a file system, you have to activate this feature and implement. */ -#define F_FILESYSTEM - -/* Change to your Chipset Uart function, you have to activate this feature and implement. - * Change!! -> Board_UARTGetCharBlocking() - * Below is an example of a function of lpc_chip library. */ -//#define ftp_getc() Board_UARTGetCharBlocking() - -#ifdef F_FILESYSTEM -#include "ff.h" -#endif - -#ifndef ftp_getc() -//#define Need_UARTGetCharBlocking_func -#define ftp_getc() uart0_receive() -#else -/* Change library - * Change!! -> board_api.h, - * Below is an example of a function of lpc_chip library. */ -#include "board_api.h" -#endif - - -#define LINELEN 100 - -#ifndef F_FILESYSTEM -#define _MAX_SS_FTP 2048 -#endif - -#define CTRL_SOCK 2 -#define DATA_SOCK 3 - -/* FTP Responses */ -#define R_150 150 /* File status ok; opening data conn */ -#define R_200 200 /* 'Generic' command ok */ -#define R_220 220 /* Service ready for new user. */ -#define R_226 226 /* Closing data connection. File transfer/abort successful */ -#define R_227 227 /* Entering passive mode (h1,h2,h3,h4,p1,p2) */ -#define R_230 230 /* User logged in, proceed */ -#define R_250 250 /* Deleted file success */ -#define R_331 331 /* User name okay, need password. */ -#define R_530 530 /* 530 Permission denied */ -#define R_550 550 /* Can't delete file */ - -#define TransferAscii 'A' -#define TransferBinary 'I' - -enum ftpc_type { - ASCII_TYPE, - IMAGE_TYPE, -}; - -enum ftpc_datasock_state{ - DATASOCK_IDLE, - DATASOCK_READY, - DATASOCK_START -}; - -enum ftpc_datasock_mode{ - PASSIVE_MODE, - ACTIVE_MODE -}; -enum CommandFirst { - f_nocmd, - f_dir, - f_put, - f_get, -}; -enum CommandSecond { - s_nocmd, - s_dir, - s_put, - s_get, -}; -struct Command { - enum CommandFirst First; - enum CommandSecond Second; -}; -struct ftpc { - uint8_t control; /* Control stream */ - uint8_t data; /* Data stream */ - - enum ftpc_type type; /* Transfer type */ - - enum ftpc_datasock_state dsock_state; - enum ftpc_datasock_mode dsock_mode; - - char workingdir[LINELEN]; - char filename[LINELEN]; - -#ifdef F_FILESYSTEM - FIL fil; // FatFs File objects - FRESULT fr; // FatFs function common result code -#endif -}; - -#ifndef un_I2cval -typedef union _un_l2cval { - uint32_t lVal; - uint8_t cVal[4]; -}un_l2cval; -#endif - -void ftpc_init(uint8_t * src_ip); -uint8_t ftpc_run(uint8_t * dbuf); -char proc_ftpc(char * buf); -int pportc(char * arg); -uint8_t* User_Keyboard_MSG(); - -FRESULT scan_files(char* path, char* buf, int * buf_len); - -#ifdef __cplusplus -} -#endif - -#endif // _FTPC_H_ diff --git a/14_m1284p_WIZNET_FTPC_FATFS/ff/ccsbcs.c.unicode b/14_m1284p_WIZNET_FTPC_FATFS/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/14_m1284p_WIZNET_FTPC_FATFS/ff/diskio.h b/14_m1284p_WIZNET_FTPC_FATFS/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/14_m1284p_WIZNET_FTPC_FATFS/ff/ff.c b/14_m1284p_WIZNET_FTPC_FATFS/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/14_m1284p_WIZNET_FTPC_FATFS/ff/ff.h b/14_m1284p_WIZNET_FTPC_FATFS/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/14_m1284p_WIZNET_FTPC_FATFS/ff/ffconf.h b/14_m1284p_WIZNET_FTPC_FATFS/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/14_m1284p_WIZNET_FTPC_FATFS/ff/integer.h b/14_m1284p_WIZNET_FTPC_FATFS/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/14_m1284p_WIZNET_FTPC_FATFS/globals.h b/14_m1284p_WIZNET_FTPC_FATFS/globals.h deleted file mode 100644 index 30b55a3..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/globals.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -//#include "Internet/httpServer_avr/httpParser.h" -FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - - -//Should not use here -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -//FTP Server IP (look at ) -extern uint8_t FTP_SRV_destip[4]; - -//#define _MAX_SS_FTP 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -#define _MAX_SS_FTP 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); -extern char uart0_receive(void); -extern void uart0_rx_flash(void); -extern void ls_dir(char* path); -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/FTPClient_avr/ftpc.h" - -#define _MAIN_DEBUG_ - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration - -//FTP Server IP -uint8_t FTP_SRV_destip[4] = {192, 168, 0, 100}; // For FTP client examples; destination network info - WORK STATION IP - -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration - -uint8_t FTP_SRV_destip[4] = {192, 168, 1, 81}; // For FTP client examples; destination network info - HOME STATION IP -#endif - - - -uint8_t gFTPBUF[_MAX_SS_FTP]; -/* - * (14) FTP client (Active) +FATFS SDCARD (PC-side checked on Win7 ) - * Notes: tested only Active mode with ASCII type (Not sure that PASV mode works properly..). - * TODO: - * OK 1. Without exist FTP server (PC side), device reset always (decide not fix yet..) - * OK 2. <1> command (ls FTP server contents) received no more then _MAXX_SS(512) bytes - need to fix - * Full implement Done with _MAX_SS_FTP=512 checked on ~35 elements show OK (~2362 bytes received) - * !!Below is deprecated decision (read above)!! - * Change at ftpc: _MAX_SS (512 bytes) to _MAX_SS_FTP (2048 bytes - defined at ) - now show OK ~ 25-30 elements from FTPD directory - * (to full implement need fix at: -~355 line - if(gDataPutGetStart){ - switch(Command.Second){ - case s_dir: - PRINTF("dir waiting...\r\n"); - if((size = getSn_RX_RSR(DATA_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur. - PRINTF("ok\r\n"); - memset(dbuf, 0, _MAX_SS_FTP); - if(size > _MAX_SS_FTP) size = _MAX_SS_FTP - 1; - ret = recv(DATA_SOCK,dbuf,size); - * - * ) - * OK 3. <2> command (ls client side FATFS SDCARD contents)file name is empty (problem in scan_files()) - need to fix - * OK 4. Auto-login to anonymous(pass:1234) for test purposes (look at - Responses [R_220/R_331] ) - * OK 5. Add serial terminal session commands (look at ): - * . Test Message - * . Sta (uptime and freeram) - * . Reboot the board - * - * OK 6. Fix baud-rate issue on 115200bps 16Mhz - * OK 7. Add reaction on after not correct authorization - * (Add at - Responses R_530) - Reboot the board - * OK 8. Test and fix command: 5> Put File to Server (checked only active mode(passive not tested)) - * OK 9. Test and fix command: 6> Get File from Server - * OK 10. Add command: 8> Delete File from FTP server - * OK 11.Try add abilities to execute custom FTP server command. (Something like NOOP, HELP etc..) - * OK 12. Disable PASV mode (Tested - with bugs) - * - * - * (3) WIZNET loopback + FATFS (as template) - * + Added FATFS init (from <02_m1284p_FATFS_Chang_tst>), - * Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~12.2018 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.2 FTP client && FATFS SDCARD WIZNET_5500 ETHERNET 28/12/2018\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* UART0 Baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); - - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} - -//Blocking read UART RX (need for FTP Client) -char uart0_receive(void) -{ - unsigned int c; - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - //Suppress NEW LINE (It harm dialog with FTP server) - if((char)c != '\n') - { - uart_putc((char)c); - return (char)c ; - } - else - { - c = UART_NO_DATA; - } - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -/* -void spi_speed_tst(void) -{ - // Here on SPI pins: MOSI 400Khz freq out, on SCLK 3.2MhzOUT - while(1) - { - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - } -} -*/ - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - //spi_speed_tst(); / Here on SPI pins: MOSI 400Khz freq out, on SCLK 3.2MhzOUT (Witk SPI CLK 4Mhz) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - //FTP Client initialize -#if defined(F_APP_FTPC) -/* - while(1) - { - //Try connect to FTP server (unblocking type) - PRINTF("Trying connect to FTPD.. "); - if(ftpc_try(netInfo.ip)) - { - //FTP server is OK, re-connect in working block mode, go to main loop. - ftpc_init(netInfo.ip); - PRINTF(" OK\r\n"); - break; - } - PRINTF(" ERROR\r\n"); - //FTP server not respond, wait 1 second then try connect again - wdt_reset(); - _delay_ms(1000); - //ftpc_try(netInfo.ip); - //break; - } -*/ - ftpc_init(netInfo.ip); -#endif - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - //loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - //loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - - //FTP Client RUN, use on PC side for example -#if defined(F_APP_FTPC) - ftpc_run(gFTPBUF); -#endif - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - - //Shouldn't used here: use command instead in serial terminal session - /* - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } - */ - - //Check ETHERNET PHY link - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - //PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - PRINTF("SW1 is pressed, Reboot the board..\r\n"); - while(1); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - } - - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/14_m1284p_WIZNET_FTPC_FATFS/spi.c b/14_m1284p_WIZNET_FTPC_FATFS/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/14_m1284p_WIZNET_FTPC_FATFS/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/15_m1284p_WIZNET_FTPD_FATFS/.cproject b/15_m1284p_WIZNET_FTPD_FATFS/.cproject deleted file mode 100644 index 9721ded..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/.cproject +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/15_m1284p_WIZNET_FTPD_FATFS/.project b/15_m1284p_WIZNET_FTPD_FATFS/.project deleted file mode 100644 index 7a80080..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 15_m1284p_WIZNET_FTPD_FATFS - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Application/loopback/loopback.c b/15_m1284p_WIZNET_FTPD_FATFS/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Application/loopback/loopback.h b/15_m1284p_WIZNET_FTPD_FATFS/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/W5500/w5500.c b/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/W5500/w5500.h b/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/socket.c b/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/socket.h b/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/wizchip_conf.c b/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/wizchip_conf.h b/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/ftpd.c b/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/ftpd.c deleted file mode 100644 index db3a596..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/ftpd.c +++ /dev/null @@ -1,1268 +0,0 @@ -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.c -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : FTP daemon. (AVR-GCC Compiler) -*/ - -#include -#include -#include -#include -#include -//#include "stdio_private.h" -#include "socket.h" -#include "ftpd.h" - -/* Command table */ -static char *commands[] = { - "user", - "acct", - "pass", - "type", - "list", - "cwd", - "dele", - "name", - "quit", - "retr", - "stor", - "port", - "nlst", - "pwd", - "xpwd", - "mkd", - "xmkd", - "xrmd", - "rmd ", - "stru", - "mode", - "syst", - "xmd5", - "xcwd", - "feat", - "pasv", - "size", - "mlsd", - "appe", - NULL -}; - -#if 0 -/* Response messages */ -char banner[] = "220 %s FTP version %s ready.\r\n"; -char badcmd[] = "500 Unknown command '%s'\r\n"; -char binwarn[] = "100 Warning: type is ASCII and %s appears to be binary\r\n"; -char unsupp[] = "500 Unsupported command or option\r\n"; -char givepass[] = "331 Enter PASS command\r\n"; -char logged[] = "230 Logged in\r\n"; -char typeok[] = "200 Type %s OK\r\n"; -char only8[] = "501 Only logical bytesize 8 supported\r\n"; -char deleok[] = "250 File deleted\r\n"; -char mkdok[] = "200 MKD ok\r\n"; -char delefail[] = "550 Delete failed: %s\r\n"; -char pwdmsg[] = "257 \"%s\" is current directory\r\n"; -char badtype[] = "501 Unknown type \"%s\"\r\n"; -char badport[] = "501 Bad port syntax\r\n"; -char unimp[] = "502 Command does not implemented yet.\r\n"; -char bye[] = "221 Goodbye!\r\n"; -char nodir[] = "553 Can't read directory \"%s\": %s\r\n"; -char cantopen[] = "550 Can't read file \"%s\": %s\r\n"; -char sending[] = "150 Opening data connection for %s (%d.%d.%d.%d,%d)\r\n"; -char cantmake[] = "553 Can't create \"%s\": %s\r\n"; -char writerr[] = "552 Write error: %s\r\n"; -char portok[] = "200 PORT command successful.\r\n"; -char rxok[] = "226 Transfer complete.\r\n"; -char txok[] = "226 Transfer complete.\r\n"; -char noperm[] = "550 Permission denied\r\n"; -char noconn[] = "425 Data connection reset\r\n"; -char lowmem[] = "421 System overloaded, try again later\r\n"; -char notlog[] = "530 Please log in with USER and PASS\r\n"; -char userfirst[] = "503 Login with USER first.\r\n"; -char okay[] = "200 Ok\r\n"; -char syst[] = "215 %s Type: L%d Version: %s\r\n"; -char sizefail[] = "550 File not found\r\n"; -#endif - -un_l2cval remote_ip; -uint16_t remote_port; -un_l2cval local_ip; -uint16_t local_port; -uint8_t connect_state_control = 0; -uint8_t connect_state_data = 0; - -struct ftpd ftp; - -int current_year = 2014; -int current_month = 12; -int current_day = 31; -int current_hour = 10; -int current_min = 10; -int current_sec = 30; - -//int fsprintf(uint8_t s, const char *format, ...) -//{ -// int i; -///* -// char buf[LINELEN]; -// FILE f; -// va_list ap; -// -// f.flags = __SWR | __SSTR; -// f.buf = buf; -// f.size = INT_MAX; -// va_start(ap, format); -// i = vfprintf(&f, format, ap); -// va_end(ap); -// buf[f.len] = 0; -// -// send(s, (uint8_t *)buf, strlen(buf)); -//*/ -// return i; -//} - -void ftpd_init(uint8_t * src_ip) -{ - ftp.state = FTPS_NOT_LOGIN; - ftp.current_cmd = NO_CMD; - ftp.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - - strcpy(ftp.workingdir, "/"); - - socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0); -} - -/* - * From: FatFs - FAT file system module R0.10c - */ -int get_filesize(char* path, char *filename) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i, len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ -#if _USE_LFN - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - if(*path == 0x00) - res = f_opendir(&dir, "/"); - else - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - for(;;){ - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - if(!strcmp(fn, filename)) - { - if(fno.fattrib & AM_DIR){ - //printf("\r\n%s/%s is a directory\r\n", path, filename); - return 0; - } - return fno.fsize; - } - } - //printf("\r\n%s/%s was not found\r\n", path, filename); - //f_closedir(&dir); - } - return -1; -} - -/* - * Inserted from earlier realize FAT FS -> - * FAT file system module R0.10c (C)ChaN, 2014 - */ -/* - * Preferable structure of out see here: - * https://files.stairways.com/other/ftp-list-specs-info.txt - * - * something like: - -rw------- 1 peter 848 Dec 14 11:22 00README.txt -or - - whatever you feel like 848 Dec 14 11:22 00README.txt - - * also - * http://cr.yp.to/ftp/list/binls.html - * -/bin/ls format is a series of lines terminated by \015\012. Servers using /bin/ls format need to be prepared to generate lines in the following form: - - -rw-r--r-- 1 owner group 213 Aug 26 16:31 README - -The line contains - - - for a regular file or d for a directory; - the literal string rw-r--r-- 1 owner group for a regular file, or rwxr-xr-x 1 owner group for a directory; - the file size in decimal right-justified in a 13-byte field; - a three-letter month name, first letter capitalized; - a day number right-justified in a 3-byte field; - a space and a 2-digit hour number; - a colon and a 2-digit minute number; - a space and the abbreviated pathname of the file. - */ -FRESULT scan_files(char* path, char *buf, int * items_count) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i; - int len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ - char date_str[21]; - int date_str_ptr = 0; - int file_read_count = 0; - int file_read_count_10 = 0; - uint16_t size_dbuf = 0; -#if _USE_LFN == 1 - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - i = strlen(path); - //printf("strlen of path: %s %d \r\n", path, i); - for(;;){ - wdt_reset(); - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN == 1 - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; - - //Print out yet only first 30 files for full info - //if(file_read_count > 30) - //Print out yet only first 45 files for short info - /* - if(file_read_count > 45) - { - break; - } - */ - //!!Debug only - file_read_count++; -#if defined(_FTP_DEBUG_) - PRINTF("%02u:%9lu %s\r\n", (file_read_count+file_read_count_10), fno.fsize, fn); -#endif -#endif - //Encode date file like this (time show no correct, so remove): - //Aug 26 2018 - switch((fno.fdate >> 5) & 0x0f) - { - case 1: - len = SPRINTF(date_str, "JAN "); - break; - case 2: - len = SPRINTF(date_str, "FEB "); - break; - case 3: - len = SPRINTF(date_str, "MAR "); - break; - case 4: - len = SPRINTF(date_str, "APR "); - break; - case 5: - len = SPRINTF(date_str, "MAY "); - break; - case 6: - len = SPRINTF(date_str, "JUN "); - break; - case 7: - len = SPRINTF(date_str, "JUL "); - break; - case 8: - len = SPRINTF(date_str, "AUG "); - break; - case 9: - len = SPRINTF(date_str, "SEP "); - break; - case 10: - len = SPRINTF(date_str, "OCT "); - break; - case 11: - len = SPRINTF(date_str, "NOV "); - break; - case 12: - len = SPRINTF(date_str, "DEC "); - break; - } - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%2d ", (fno.fdate & 0x1f)); - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%d ", (((fno.fdate >> 9) & 0x7f) + 1980)); - //Time show not correct, so remove - /* - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%02u:%02u", (fno.ftime >> 11), (fno.ftime >> 5) & 63); - */ - date_str_ptr = 0; - - //printf("date str : %s \r\n", date_str); - - //Directory or file prefix - if(fno.fattrib & AM_DIR) - { - SPRINTF(buf + buf_ptr, "d"); - }else - { - SPRINTF(buf + buf_ptr, "-"); - } - buf_ptr++; - //Should not use here - /* - // drwxr-xr-x 1 ftp ftp 0 Apr 07 2014 $RECYCLE.BIN\r\n - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %u %s %s\r\n", fno.fsize, date_str, fn); - - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %s\r\n", fn); - - - //len = sprintf(buf + buf_ptr, " %6lu %s\r\n",fno.fsize, fn);// - Good minimum, but not seen on WinSCP - - - //len = sprintf(buf + buf_ptr, " %s\r\n", fn);// - Good minimum, but not seen on WinSCP - */ - - //Full with fake data - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) - - //Short without access rights and owner with fake data - /* - len = SPRINTF(buf + buf_ptr, " 1 %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) without access rights and owner - */ - - //Medium with real data file, without access rights and owner - len = SPRINTF(buf + buf_ptr, " 1 %9lu %s %s\r\n", fno.fsize, date_str, fn); //- Works on WinSCP with real data (OK) without access rights and owner - - buf_ptr += len; - - if(file_read_count > 9) - { - //Send out info about files in 10 items maximum - file_read_count = 0; - file_read_count_10 += 10; - //*buf_len = strlen(buf); - - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - - buf_ptr = 0; - - } - - //printf("fn: %s \r\n", fn); - - } - //Send out last packet with files numbers 1..9 - if(file_read_count) - { - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - } - - //*buf_len = strlen(buf); - *items_count = file_read_count + file_read_count_10; //Return number of sending file - //printf("%s", buf); - //printf("\r\nbuf_len : %d, sizeof(buf): %d\r\n", buf_len, sizeof(buf)); - f_closedir(&dir); - } - return res; -} - -uint8_t ftpd_run(uint8_t * dbuf) -{ - uint16_t size = 0, i; - long ret = 0; - uint32_t blocklen, send_byte, recv_byte; - uint32_t remain_filesize; - uint32_t remain_datasize; -#if defined(F_FILESYSTEM) - //FILINFO fno; -#endif - - //memset(dbuf, 0, sizeof(_MAX_SS_FTPD)); - - switch(getSn_SR(CTRL_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_control) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Connected\r\n", CTRL_SOCK); -#endif - //fsprintf(CTRL_SOCK, banner, HOSTNAME, VERSION); - strcpy(ftp.workingdir, "/"); - SPRINTF((char *)dbuf, "220 %s FTP version %s ready.\r\n", HOSTNAME, VERSION); - ret = send(CTRL_SOCK, (uint8_t *)dbuf, strlen((const char *)dbuf)); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - connect_state_control = 1; - } - -#if defined(_FTP_DEBUG_) - //printf("ftp socket %d\r\n", CTRL_SOCK); -#endif - - if((size = getSn_RX_RSR(CTRL_SOCK)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { -#if defined(_FTP_DEBUG_) - PRINTF("size: %d\r\n", size); -#endif - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(size > _MAX_SS_FTPD) size = _MAX_SS_FTPD - 1; - - ret = recv(CTRL_SOCK,dbuf,size); - dbuf[ret] = '\0'; - if(ret != size) - { - if(ret==SOCK_BUSY) return 0; - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("Rcvd Command: %s", dbuf); -#endif - proc_ftpd((char *)dbuf); - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",CTRL_SOCK); -#endif - if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",CTRL_SOCK); -#endif - break; - - case SOCK_CLOSED : -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPStart\r\n",CTRL_SOCK); -#endif - if((ret=socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0)) != CTRL_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", CTRL_SOCK, ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",CTRL_SOCK); -#endif - //strcpy(ftp.workingdir, "/"); - if( (ret = listen(CTRL_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",CTRL_SOCK); -#endif - return ret; - } - connect_state_control = 0; - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",CTRL_SOCK); -#endif - break; - - default : - break; - } - -#if 1 - switch(getSn_SR(DATA_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_data) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Data socket Connected\r\n", DATA_SOCK); -#endif - connect_state_data = 1; - } - - switch(ftp.current_cmd) - { - case LIST_CMD: - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("previous size: %u\r\n", size); -#endif -#if defined(F_FILESYSTEM) - scan_files(ftp.workingdir, dbuf, (int *)&size); -#endif -#if defined(_FTP_DEBUG_) - PRINTF("Items count: %u\r\n", size); - //PRINTF("%s\r\n", dbuf); -#endif -#if !defined(F_FILESYSTEM) - if (strncmp(ftp.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0) - size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n"); -#endif - /* - size = strlen(dbuf); - send(DATA_SOCK, dbuf, size); - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - */ - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - break; - - case RETR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to retrieve : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_READ); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ - remain_filesize = ftp.fil.fsize; -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - do{ -#if defined(_FTP_DEBUG_) - //printf("remained file size: %d\r\n", ftp.fil.fsize); -#endif - wdt_reset(); - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_filesize > _MAX_SS_FTPD) - send_byte = _MAX_SS_FTPD; - else - send_byte = remain_filesize; - - - uint16_t _blocklen; - ftp.fr = f_read(&(ftp.fil), dbuf, send_byte ,&_blocklen); - if(ftp.fr != FR_OK) - break; -#if defined(_FTP_DEBUG_) - PRINTF("#"); - //printf("----->fsize:%d recv:%d len:%d \r\n", remain_filesize, send_byte, blocklen); - //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - uint32_t send_size; - send_size = send(DATA_SOCK, dbuf, _blocklen); - //remain_filesize -= blocklen; - remain_filesize -= send_size; - }while(remain_filesize != 0); -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile read finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } -#else - remain_filesize = strlen(ftp.filename); - - do{ - memset(dbuf, 0, _MAX_SS_FTPD); - - blocklen = sprintf(dbuf, "%s", ftp.filename); - - printf("########## dbuf:%s\r\n", dbuf); - - send(DATA_SOCK, dbuf, blocklen); - remain_filesize -= blocklen; - }while(remain_filesize != 0); - -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case STOR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to store : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_CREATE_ALWAYS | FA_WRITE); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - while(1){ - wdt_reset(); - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf,(uint16_t) recv_byte); -#if defined(_FTP_DEBUG_) - //PRINTF("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - - uint16_t _blocklen; - ftp.fr = f_write(&(ftp.fil), dbuf, (UINT)ret, &_blocklen); -#if defined(_FTP_DEBUG_) - //PRINTF("----->dsize:%lu recv:%lu len:%u \r\n", remain_datasize, ret, _blocklen); -#endif - remain_datasize -= (uint32_t)_blocklen; - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - - if(remain_datasize <= 0) - break; - } - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - -#if defined(_FTP_DEBUG_) - PRINTF("#"); -#endif - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile write finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } - - //fno.fdate = (WORD)(((current_year - 1980) << 9) | (current_month << 5) | current_day); - //fno.ftime = (WORD)((current_hour << 11) | (current_min << 5) | (current_sec >> 1)); - //f_utime((const char *)ftp.filename, &fno); -#else - while(1){ - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf, recv_byte); - - printf("########## dbuf:%s\r\n", dbuf); - - remain_datasize -= ret; - - if(remain_datasize <= 0) - break; - } - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case NO_CMD: - default: - break; - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",DATA_SOCK); -#endif - if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",DATA_SOCK); -#endif - break; - - case SOCK_CLOSED : - if(ftp.dsock_state == DATASOCK_READY) - { - if(ftp.dsock_mode == PASSIVE_MODE){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[PASSIV_MODE], port : %u\r\n",DATA_SOCK, local_port); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - - local_port++; - if(local_port > 50000) - local_port = 35000; - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[ACTIVE_MODE], port : %u\r\n",DATA_SOCK, IPPORT_FTPD); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, IPPORT_FTPD, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - } - - ftp.dsock_state = DATASOCK_START; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",DATA_SOCK); -#endif - if(ftp.dsock_mode == PASSIVE_MODE){ - if( (ret = listen(DATA_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",DATA_SOCK); -#endif - return ret; - } - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",DATA_SOCK); -#endif - }else{ - - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#1\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { -#if defined(_FTP_DEBUG_) - PRINTF("DATA_SOCK Connect#1 OK\r\n"); -#endif - } - //Try to FIX STOR command - } - connect_state_data = 0; - break; - - default : - break; - } -#endif - - return 0; -} - -char proc_ftpd(char * buf) -{ - char **cmdp, *cp, *arg, *tmpstr; - char sendbuf[200]; - int slen; - long ret; - - - /* Translate first word to lower case */ - for (cp = buf; *cp != ' ' && *cp != '\0'; cp++) - *cp = tolower(*cp); - - /* Find command in table; if not present, return syntax error */ - for (cmdp = commands; *cmdp != NULL; cmdp++) - if (strncmp(*cmdp, buf, strlen(*cmdp)) == 0) - break; - - if (*cmdp == NULL) - { - //fsprintf(CTRL_SOCK, badcmd, buf); - slen = SPRINTF(sendbuf, "500 Unknown command '%s'\r\n", buf); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - /* Allow only USER, PASS and QUIT before logging in */ - if (ftp.state == FTPS_NOT_LOGIN) - { - switch(cmdp - commands) - { - case USER_CMD: - case PASS_CMD: - case QUIT_CMD: - break; - default: - //fsprintf(CTRL_SOCK, notlog); - slen = SPRINTF(sendbuf, "530 Please log in with USER and PASS\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - } - - arg = &buf[strlen(*cmdp)]; - while(*arg == ' ') arg++; - - /* Execute specific command */ - switch (cmdp - commands) - { - case USER_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("USER_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - strcpy(ftp.username, arg); - //fsprintf(CTRL_SOCK, givepass); - slen = SPRINTF(sendbuf, "331 Enter PASS command\r\n"); - ret = send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case PASS_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("PASS_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - ftplogin(arg); - break; - - case TYPE_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - switch(arg[0]) - { - case 'A': - case 'a': /* Ascii */ - ftp.type = ASCII_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case 'B': - case 'b': /* Binary */ - case 'I': - case 'i': /* Image */ - ftp.type = IMAGE_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badtype, arg); - slen = SPRINTF(sendbuf, "501 Unknown type \"%s\"\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - break; - - case FEAT_CMD : - slen = SPRINTF(sendbuf, "211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST size*;type*;create*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 END\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case QUIT_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("QUIT_CMD\r\n"); -#endif - //fsprintf(CTRL_SOCK, bye); - slen = SPRINTF(sendbuf, "221 Goodbye!\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(CTRL_SOCK); - break; - - case RETR_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("RETR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = sprintf(sendbuf, "150 Opening data channel for file downloand from server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = RETR_CMD; - break; - - case APPE_CMD : - case STOR_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("STOR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "150 Opening data channel for file upload to server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = STOR_CMD; - /* - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#2\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { - //!!Debug only!! - PRINTF("DATA_SOCK Connect#2 OK\r\n"); - } - */ - //Try to FIX STOR command - connect_state_data = 0; - break; - - case PORT_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("PORT_CMD\r\n"); -#endif - if (pport(arg) == -1){ - //fsprintf(CTRL_SOCK, badport); - slen = SPRINTF(sendbuf, "501 Bad port syntax\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } else{ - //fsprintf(CTRL_SOCK, portok); - ftp.dsock_mode = ACTIVE_MODE; - ftp.dsock_state = DATASOCK_READY; - slen = SPRINTF(sendbuf, "200 PORT command successful.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } - break; - - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("MLSD_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = MLSD_CMD; - break; - - case LIST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("LIST_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = LIST_CMD; - break; - - case NLST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("NLST_CMD\r\n"); -#endif - break; - - case SYST_CMD: - slen = SPRINTF(sendbuf, "215 UNIX emulated by WIZnet\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PWD_CMD: - case XPWD_CMD: - slen = SPRINTF(sendbuf, "257 \"%s\" is current directory.\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PASV_CMD: - slen = SPRINTF(sendbuf, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", local_ip.cVal[0], local_ip.cVal[1], local_ip.cVal[2], local_ip.cVal[3], local_port >> 8, local_port & 0x00ff); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(DATA_SOCK); - ftp.dsock_mode = PASSIVE_MODE; - ftp.dsock_state = DATASOCK_READY; -#if defined(_FTP_DEBUG_) - PRINTF("PASV port: %u\r\n", local_port); -#endif - break; - - case SIZE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = _MAX_SS_FTPD; -#endif - if(slen > 0) - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - else - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - else - { - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case CWD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - arg[slen - 3] = 0x00; - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = 0; -#endif - *tmpstr = '/'; - if(slen == 0){ - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - else - { - slen = SPRINTF(sendbuf, "550 CWD failed. \"%s\"\r\n", arg); - } - } - else - { - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case MKD_CMD: - case XMKD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_mkdir(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Can't create directory. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "257 MKD command successful. \"%s\"\r\n", arg); - //strcpy(ftp.workingdir, arg); - } -#else - slen = SPRINTF(sendbuf, "550 Can't create directory. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case DELE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_unlink(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Could not delete. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "250 Deleted. \"%s\"\r\n", arg); - } -#else - slen = SPRINTF(sendbuf, "550 Could not delete. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case XCWD_CMD: - case ACCT_CMD: - case XRMD_CMD: - case RMD_CMD: - case STRU_CMD: - case MODE_CMD: - case XMD5_CMD: - //fsprintf(CTRL_SOCK, unimp); - slen = SPRINTF(sendbuf, "502 Command does not implemented yet.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badcmd, arg); - slen = SPRINTF(sendbuf, "500 Unknown command \'%s\'\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - - return 1; -} - - -char ftplogin(char * pass) -{ - char sendbuf[100]; - int slen = 0; - - //memset(sendbuf, 0, DATA_BUF_SIZE); - -#if defined(_FTP_DEBUG_) - PRINTF("%s logged in\r\n", ftp.username); -#endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - - return 1; -} - -int pport(char * arg) -{ - int i; - char* tok=0; - - for (i = 0; i < 4; i++) - { - if(i==0) tok = strtok(arg,",\r\n"); - else tok = strtok(NULL,","); - remote_ip.cVal[i] = (uint8_t)atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } - remote_port = 0; - for (i = 0; i < 2; i++) - { - tok = strtok(NULL,",\r\n"); - remote_port <<= 8; - remote_port += atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - - return 0; -} - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil) -{ -#if defined(_FTP_DEBUG_) - PRINTF("File System pointer : %08X\r\n", fil->fs); - PRINTF("File System mount ID : %d\r\n", fil->id); - PRINTF("File status flag : %08X\r\n", fil->flag); - PRINTF("File System pads : %08X\r\n", fil->err); - PRINTF("File read write pointer : %08X\r\n", fil->fptr); - PRINTF("File size : %08X\r\n", fil->fsize); - PRINTF("File start cluster : %08X\r\n", fil->sclust); - PRINTF("current cluster : %08X\r\n", fil->clust); - PRINTF("current data sector : %08X\r\n", fil->dsect); - PRINTF("dir entry sector : %08X\r\n", fil->dir_sect); - PRINTF("dir entry pointer : %08X\r\n", fil->dir_ptr); -#endif -} -#endif diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/ftpd.h b/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/ftpd.h deleted file mode 100644 index 4b855e5..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/ftpd.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _FTPD_H_ -#define _FTPD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.h -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : Header file of FTP daemon. (AVR-GCC Compiler) -*/ - -#include - -#include "../../globals.h" //add AVR specific useful headers - -#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement. - -#if defined(F_FILESYSTEM) -#include "ff.h" -#endif - -#define F_APP_FTP -#define _FTP_DEBUG_ - - -#define LINELEN 100 -//#define DATA_BUF_SIZE 100 -#if !defined(F_FILESYSTEM) -#define _MAX_SS 512 -#endif - -#define CTRL_SOCK 2 -#define DATA_SOCK 3 - -#define IPPORT_FTPD 20 /* FTP Data port */ -#define IPPORT_FTP 21 /* FTP Control port */ - -#define HOSTNAME "iinChip" -#define VERSION "1.0" - -#define FILENAME "a.txt" - -/* FTP commands */ -enum ftp_cmd { - USER_CMD, - ACCT_CMD, - PASS_CMD, - TYPE_CMD, - LIST_CMD, - CWD_CMD, - DELE_CMD, - NAME_CMD, - QUIT_CMD, - RETR_CMD, - STOR_CMD, - PORT_CMD, - NLST_CMD, - PWD_CMD, - XPWD_CMD, - MKD_CMD, - XMKD_CMD, - XRMD_CMD, - RMD_CMD, - STRU_CMD, - MODE_CMD, - SYST_CMD, - XMD5_CMD, - XCWD_CMD, - FEAT_CMD, - PASV_CMD, - SIZE_CMD, - MLSD_CMD, - APPE_CMD, - NO_CMD, -}; - -enum ftp_type { - ASCII_TYPE, - IMAGE_TYPE, - LOGICAL_TYPE -}; - -enum ftp_state { - FTPS_NOT_LOGIN, - FTPS_LOGIN -}; - -enum datasock_state{ - DATASOCK_IDLE, - DATASOCK_READY, - DATASOCK_START -}; - -enum datasock_mode{ - PASSIVE_MODE, - ACTIVE_MODE -}; - -struct ftpd { - uint8_t control; /* Control stream */ - uint8_t data; /* Data stream */ - - enum ftp_type type; /* Transfer type */ - enum ftp_state state; - - enum ftp_cmd current_cmd; - - enum datasock_state dsock_state; - enum datasock_mode dsock_mode; - - char username[LINELEN]; /* Arg to USER command */ - char workingdir[LINELEN]; - char filename[LINELEN]; - -#if defined(F_FILESYSTEM) - FIL fil; // FatFs File objects - FRESULT fr; // FatFs function common result code -#endif - -}; - -#ifndef un_I2cval -typedef union _un_l2cval { - uint32_t lVal; - uint8_t cVal[4]; -}un_l2cval; -#endif - -void ftpd_init(uint8_t * src_ip); -uint8_t ftpd_run(uint8_t * dbuf); -char proc_ftpd(char * buf); -char ftplogin(char * pass); -int pport(char * arg); - -int sendit(char * command); -int recvit(char * command); - -long sendfile(uint8_t s, char * command); -long recvfile(uint8_t s); - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil); -#endif - -#ifdef __cplusplus -} -#endif - -#endif // _FTPD_H_ diff --git a/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/stdio_private.h b/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/stdio_private.h deleted file mode 100644 index 90c3a0d..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/Internet/FTPServer_avr/stdio_private.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2002, Joerg Wunsch - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * Neither the name of the copyright holders nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - -//struct __file { -// char *buf; /* buffer pointer */ -// unsigned char unget; /* ungetc() buffer */ -// uint8_t flags; /* flags, see below */ -//#define __SRD 0x0001 /* OK to read */ -//#define __SWR 0x0002 /* OK to write */ -//#define __SSTR 0x0004 /* this is an sprintf/snprintf string */ -//#define __SPGM 0x0008 /* fmt string is in progmem */ -//#define __SERR 0x0010 /* found error */ -//#define __SEOF 0x0020 /* found EOF */ -//#define __SUNGET 0x040 /* ungetc() happened */ -//#if 0 -///* possible future extensions, will require uint16_t flags */ -//#define __SRW 0x0080 /* open for reading & writing */ -//#define __SLBF 0x0100 /* line buffered */ -//#define __SNBF 0x0200 /* unbuffered */ -//#define __SMBF 0x0400 /* buf is from malloc */ -//#endif -// int size; /* size of buffer */ -// int len; /* characters read or written so far */ -// int (*put)(char); /* function to write one char to device */ -// int (*get)(void); /* function to read one char from device */ -//}; - -/* values for PRINTF_LEVEL */ -#define PRINTF_MIN 1 -#define PRINTF_STD 2 -#define PRINTF_FLT 3 - -/* values for SCANF_LEVEL */ -#define SCANF_MIN 1 -#define SCANF_STD 2 -#define SCANF_FLT 3 - -#ifdef __cplusplus -} -#endif diff --git a/15_m1284p_WIZNET_FTPD_FATFS/ff/ccsbcs.c.unicode b/15_m1284p_WIZNET_FTPD_FATFS/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/15_m1284p_WIZNET_FTPD_FATFS/ff/diskio.h b/15_m1284p_WIZNET_FTPD_FATFS/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/15_m1284p_WIZNET_FTPD_FATFS/ff/ff.c b/15_m1284p_WIZNET_FTPD_FATFS/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/15_m1284p_WIZNET_FTPD_FATFS/ff/ff.h b/15_m1284p_WIZNET_FTPD_FATFS/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/15_m1284p_WIZNET_FTPD_FATFS/ff/ffconf.h b/15_m1284p_WIZNET_FTPD_FATFS/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/15_m1284p_WIZNET_FTPD_FATFS/ff/integer.h b/15_m1284p_WIZNET_FTPD_FATFS/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/15_m1284p_WIZNET_FTPD_FATFS/globals.h b/15_m1284p_WIZNET_FTPD_FATFS/globals.h deleted file mode 100644 index aab91f2..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/globals.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -//#include "Internet/httpServer_avr/httpParser.h" -FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - - -//Should not use here -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -//FTP Server IP (look at ) -//extern uint8_t FTP_SRV_destip[4]; - - -//#define _MAX_SS_FTP 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTP 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough - -//#define _MAX_SS_FTPD 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTPD 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough -#define _MAX_SS_FTPD _MAX_SS - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define SPRINTF(__S, FORMAT, args...) sprintf_P(__S, PSTR(FORMAT),##args) - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); -extern char uart0_receive(void); -extern void uart0_rx_flash(void); -extern void ls_dir(char* path); -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/FTPServer_avr/ftpd.h" - -#define _MAIN_DEBUG_ - -#define CHK_RAM_LEAKAGE -#define CHK_UPTIME - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//uint8_t gFTPBUF[_MAX_SS_FTPD + 988]; //1500 bytes - Don't need since v1.3 -uint8_t gFTPBUF[_MAX_SS_FTPD]; //512 bytes - -/* -//FTP Server IP -uint8_t FTP_SRV_destip[4] = {192, 168, 0, 100}; // For FTP client examples; destination network info - WORK STATION IP -//uint8_t FTP_SRV_destip[4] = {192, 168, 1, 81}; // For FTP client examples; destination network info - HOME STATION IP - -uint8_t gFTPBUF[_MAX_SS_FTP]; -*/ -/* - * (15) FTP Server +FATFS SDCARD (PC-side checked on Win7 / WIN7 (console client)) - * TODO: - * OK (v1.1) 1. doesn't work properly on WinSCP, but WIN7 ftp command OK. - Fix it (in first approach with fake data show first ~45 elements from root SD-CARD FTPD) - * Works with WinSCP put/get/delete/refresh - Marvelous! - * PS. Checked work with the next FTP clients (WIN7): - * WINSCP, - * ftp - native WIN7 (terminal-style), - * TotalCommander - need to add new type server with the next template: d ? SSSSSSSSS TTT DD YYYY nnnnnnnnnnnn - * - * OK (v1.1) 2. WIN7 ftp (i.e. downloading file from FTPD SDCARD-device to PC, see ) - works but after download file, progress line still filling ~ 3-5 sec. - Fix it. - * OK (v1.1) 3. WIN7 ftp (i.e. uploading file from PC to FTPD SDCARD-device, see ) - not work properly, device just reboot. - Fix it. - * OK (v1.2) 4. RAM usage optimize : - * OK (v1.1) A) printf(..) change to PRINTF(..) (i.e. printf_P(..)) - * OK (v1.2) B) sprintf(..) change to SPRINTF(..) (i.e. sprintf_P(..)) - Save ~ 900 bytes RAM - * 5. Optimize : - * OK (v1.3) A) To show ALL elements add inside -send(DATA_SOCK, dbuf, size); in portion by 10 elements - until All elements being sent - * OK (v1.3) B) Show real DATE(without TIME) of file from SD-CARD FTPD (Show only DATE without TIME (time showed with error, to show correct need to implement MLST and LMSD extension commands, defined in RFC 3659 )) - * OK (v1.3) C) Try decrease: gFTPBUF[_MAX_SS_FTPD]; //512 bytes - for save RAM resources (optional) - * OK (v1.4) Fix <_FTP_DEBUG_> in undefined state (at ftpd.c), further optimize (at ftpd.c) - * - * (14) FTP client (Active) +FATFS SDCARD (PC-side checked on Win7 ) - * Notes: tested only Active mode with ASCII type (Not sure that PASV mode works properly..). - * TODO: - * OK 1. Without exist FTP server (PC side), device reset always (decide not fix yet..) - * OK 2. <1> command (ls FTP server contents) received no more then _MAXX_SS(512) bytes - need to fix - * Full implement Done with _MAX_SS_FTP=512 checked on ~35 elements show OK (~2362 bytes received) - * !!Below is deprecated decision (read above)!! - * Change at ftpc: _MAX_SS (512 bytes) to _MAX_SS_FTP (2048 bytes - defined at ) - now show OK ~ 25-30 elements from FTPD directory - * (to full implement need fix at: -~355 line - if(gDataPutGetStart){ - switch(Command.Second){ - case s_dir: - PRINTF("dir waiting...\r\n"); - if((size = getSn_RX_RSR(DATA_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur. - PRINTF("ok\r\n"); - memset(dbuf, 0, _MAX_SS_FTP); - if(size > _MAX_SS_FTP) size = _MAX_SS_FTP - 1; - ret = recv(DATA_SOCK,dbuf,size); - * - * ) - * OK 3. <2> command (ls client side FATFS SDCARD contents)file name is empty (problem in scan_files()) - need to fix - * OK 4. Auto-login to anonymous(pass:1234) for test purposes (look at - Responses [R_220/R_331] ) - * OK 5. Add serial terminal session commands (look at ): - * . Test Message - * . Sta (uptime and freeram) - * . Reboot the board - * - * OK 6. Fix baud-rate issue on 115200bps 16Mhz - * OK 7. Add reaction on after not correct authorization - * (Add at - Responses R_530) - Reboot the board - * OK 8. Test and fix command: 5> Put File to Server (checked only active mode(passive not tested)) - * OK 9. Test and fix command: 6> Get File from Server - * OK 10. Add command: 8> Delete File from FTP server - * OK 11.Try add abilities to execute custom FTP server command. (Something like NOOP, HELP etc..) - * OK 12. Disable PASV mode (Tested - with bugs) - * - * - * (3) WIZNET loopback + FATFS (as template) - * + Added FATFS init (from <02_m1284p_FATFS_Chang_tst>), - * Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~12.2018 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.4 FTP server && FATFS SDCARD WIZNET_5500 ETHERNET 12/01/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* UART0 Baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); - - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} - -//Blocking read UART RX (need for FTP Client) -char uart0_receive(void) -{ - unsigned int c; - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - //Suppress NEW LINE (It harm dialog with FTP server) - if((char)c != '\n') - { - uart_putc((char)c); - return (char)c ; - } - else - { - c = UART_NO_DATA; - } - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -/* -void spi_speed_tst(void) -{ - // Here on SPI pins: MOSI 400Khz freq out, on SCLK 3.2MhzOUT - while(1) - { - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - SPI_WRITE(0xF0); - } -} -*/ - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - //spi_speed_tst(); / Here on SPI pins: MOSI 400Khz freq out, on SCLK 3.2MhzOUT (Witk SPI CLK 4Mhz) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//TODO: Add here FTP server initialize -#if defined(F_APP_FTP) - ftpd_init(netInfo.ip); -#endif - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - /* - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - */ - - //TODO: Add here FTP server instance -#if defined(F_APP_FTP) - ftpd_run(gFTPBUF); -#endif - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - static uint16_t j_ram = 0; - if(j_ram++%60 == 0) - { - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - } -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - static uint16_t j_uptime = 0; - if(j_uptime++%60 == 0) - { - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); - } -#endif - - //Check ETHERNET PHY link - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - //PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - PRINTF("SW1 is pressed, Reboot the board..\r\n"); - while(1); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - } - - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/15_m1284p_WIZNET_FTPD_FATFS/spi.c b/15_m1284p_WIZNET_FTPD_FATFS/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/15_m1284p_WIZNET_FTPD_FATFS/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.cproject b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.cproject deleted file mode 100644 index b4a63a0..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.cproject +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.project b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.project deleted file mode 100644 index 8a498c0..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c deleted file mode 100644 index db3a596..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c +++ /dev/null @@ -1,1268 +0,0 @@ -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.c -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : FTP daemon. (AVR-GCC Compiler) -*/ - -#include -#include -#include -#include -#include -//#include "stdio_private.h" -#include "socket.h" -#include "ftpd.h" - -/* Command table */ -static char *commands[] = { - "user", - "acct", - "pass", - "type", - "list", - "cwd", - "dele", - "name", - "quit", - "retr", - "stor", - "port", - "nlst", - "pwd", - "xpwd", - "mkd", - "xmkd", - "xrmd", - "rmd ", - "stru", - "mode", - "syst", - "xmd5", - "xcwd", - "feat", - "pasv", - "size", - "mlsd", - "appe", - NULL -}; - -#if 0 -/* Response messages */ -char banner[] = "220 %s FTP version %s ready.\r\n"; -char badcmd[] = "500 Unknown command '%s'\r\n"; -char binwarn[] = "100 Warning: type is ASCII and %s appears to be binary\r\n"; -char unsupp[] = "500 Unsupported command or option\r\n"; -char givepass[] = "331 Enter PASS command\r\n"; -char logged[] = "230 Logged in\r\n"; -char typeok[] = "200 Type %s OK\r\n"; -char only8[] = "501 Only logical bytesize 8 supported\r\n"; -char deleok[] = "250 File deleted\r\n"; -char mkdok[] = "200 MKD ok\r\n"; -char delefail[] = "550 Delete failed: %s\r\n"; -char pwdmsg[] = "257 \"%s\" is current directory\r\n"; -char badtype[] = "501 Unknown type \"%s\"\r\n"; -char badport[] = "501 Bad port syntax\r\n"; -char unimp[] = "502 Command does not implemented yet.\r\n"; -char bye[] = "221 Goodbye!\r\n"; -char nodir[] = "553 Can't read directory \"%s\": %s\r\n"; -char cantopen[] = "550 Can't read file \"%s\": %s\r\n"; -char sending[] = "150 Opening data connection for %s (%d.%d.%d.%d,%d)\r\n"; -char cantmake[] = "553 Can't create \"%s\": %s\r\n"; -char writerr[] = "552 Write error: %s\r\n"; -char portok[] = "200 PORT command successful.\r\n"; -char rxok[] = "226 Transfer complete.\r\n"; -char txok[] = "226 Transfer complete.\r\n"; -char noperm[] = "550 Permission denied\r\n"; -char noconn[] = "425 Data connection reset\r\n"; -char lowmem[] = "421 System overloaded, try again later\r\n"; -char notlog[] = "530 Please log in with USER and PASS\r\n"; -char userfirst[] = "503 Login with USER first.\r\n"; -char okay[] = "200 Ok\r\n"; -char syst[] = "215 %s Type: L%d Version: %s\r\n"; -char sizefail[] = "550 File not found\r\n"; -#endif - -un_l2cval remote_ip; -uint16_t remote_port; -un_l2cval local_ip; -uint16_t local_port; -uint8_t connect_state_control = 0; -uint8_t connect_state_data = 0; - -struct ftpd ftp; - -int current_year = 2014; -int current_month = 12; -int current_day = 31; -int current_hour = 10; -int current_min = 10; -int current_sec = 30; - -//int fsprintf(uint8_t s, const char *format, ...) -//{ -// int i; -///* -// char buf[LINELEN]; -// FILE f; -// va_list ap; -// -// f.flags = __SWR | __SSTR; -// f.buf = buf; -// f.size = INT_MAX; -// va_start(ap, format); -// i = vfprintf(&f, format, ap); -// va_end(ap); -// buf[f.len] = 0; -// -// send(s, (uint8_t *)buf, strlen(buf)); -//*/ -// return i; -//} - -void ftpd_init(uint8_t * src_ip) -{ - ftp.state = FTPS_NOT_LOGIN; - ftp.current_cmd = NO_CMD; - ftp.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - - strcpy(ftp.workingdir, "/"); - - socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0); -} - -/* - * From: FatFs - FAT file system module R0.10c - */ -int get_filesize(char* path, char *filename) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i, len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ -#if _USE_LFN - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - if(*path == 0x00) - res = f_opendir(&dir, "/"); - else - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - for(;;){ - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - if(!strcmp(fn, filename)) - { - if(fno.fattrib & AM_DIR){ - //printf("\r\n%s/%s is a directory\r\n", path, filename); - return 0; - } - return fno.fsize; - } - } - //printf("\r\n%s/%s was not found\r\n", path, filename); - //f_closedir(&dir); - } - return -1; -} - -/* - * Inserted from earlier realize FAT FS -> - * FAT file system module R0.10c (C)ChaN, 2014 - */ -/* - * Preferable structure of out see here: - * https://files.stairways.com/other/ftp-list-specs-info.txt - * - * something like: - -rw------- 1 peter 848 Dec 14 11:22 00README.txt -or - - whatever you feel like 848 Dec 14 11:22 00README.txt - - * also - * http://cr.yp.to/ftp/list/binls.html - * -/bin/ls format is a series of lines terminated by \015\012. Servers using /bin/ls format need to be prepared to generate lines in the following form: - - -rw-r--r-- 1 owner group 213 Aug 26 16:31 README - -The line contains - - - for a regular file or d for a directory; - the literal string rw-r--r-- 1 owner group for a regular file, or rwxr-xr-x 1 owner group for a directory; - the file size in decimal right-justified in a 13-byte field; - a three-letter month name, first letter capitalized; - a day number right-justified in a 3-byte field; - a space and a 2-digit hour number; - a colon and a 2-digit minute number; - a space and the abbreviated pathname of the file. - */ -FRESULT scan_files(char* path, char *buf, int * items_count) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i; - int len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ - char date_str[21]; - int date_str_ptr = 0; - int file_read_count = 0; - int file_read_count_10 = 0; - uint16_t size_dbuf = 0; -#if _USE_LFN == 1 - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - i = strlen(path); - //printf("strlen of path: %s %d \r\n", path, i); - for(;;){ - wdt_reset(); - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN == 1 - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; - - //Print out yet only first 30 files for full info - //if(file_read_count > 30) - //Print out yet only first 45 files for short info - /* - if(file_read_count > 45) - { - break; - } - */ - //!!Debug only - file_read_count++; -#if defined(_FTP_DEBUG_) - PRINTF("%02u:%9lu %s\r\n", (file_read_count+file_read_count_10), fno.fsize, fn); -#endif -#endif - //Encode date file like this (time show no correct, so remove): - //Aug 26 2018 - switch((fno.fdate >> 5) & 0x0f) - { - case 1: - len = SPRINTF(date_str, "JAN "); - break; - case 2: - len = SPRINTF(date_str, "FEB "); - break; - case 3: - len = SPRINTF(date_str, "MAR "); - break; - case 4: - len = SPRINTF(date_str, "APR "); - break; - case 5: - len = SPRINTF(date_str, "MAY "); - break; - case 6: - len = SPRINTF(date_str, "JUN "); - break; - case 7: - len = SPRINTF(date_str, "JUL "); - break; - case 8: - len = SPRINTF(date_str, "AUG "); - break; - case 9: - len = SPRINTF(date_str, "SEP "); - break; - case 10: - len = SPRINTF(date_str, "OCT "); - break; - case 11: - len = SPRINTF(date_str, "NOV "); - break; - case 12: - len = SPRINTF(date_str, "DEC "); - break; - } - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%2d ", (fno.fdate & 0x1f)); - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%d ", (((fno.fdate >> 9) & 0x7f) + 1980)); - //Time show not correct, so remove - /* - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%02u:%02u", (fno.ftime >> 11), (fno.ftime >> 5) & 63); - */ - date_str_ptr = 0; - - //printf("date str : %s \r\n", date_str); - - //Directory or file prefix - if(fno.fattrib & AM_DIR) - { - SPRINTF(buf + buf_ptr, "d"); - }else - { - SPRINTF(buf + buf_ptr, "-"); - } - buf_ptr++; - //Should not use here - /* - // drwxr-xr-x 1 ftp ftp 0 Apr 07 2014 $RECYCLE.BIN\r\n - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %u %s %s\r\n", fno.fsize, date_str, fn); - - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %s\r\n", fn); - - - //len = sprintf(buf + buf_ptr, " %6lu %s\r\n",fno.fsize, fn);// - Good minimum, but not seen on WinSCP - - - //len = sprintf(buf + buf_ptr, " %s\r\n", fn);// - Good minimum, but not seen on WinSCP - */ - - //Full with fake data - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) - - //Short without access rights and owner with fake data - /* - len = SPRINTF(buf + buf_ptr, " 1 %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) without access rights and owner - */ - - //Medium with real data file, without access rights and owner - len = SPRINTF(buf + buf_ptr, " 1 %9lu %s %s\r\n", fno.fsize, date_str, fn); //- Works on WinSCP with real data (OK) without access rights and owner - - buf_ptr += len; - - if(file_read_count > 9) - { - //Send out info about files in 10 items maximum - file_read_count = 0; - file_read_count_10 += 10; - //*buf_len = strlen(buf); - - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - - buf_ptr = 0; - - } - - //printf("fn: %s \r\n", fn); - - } - //Send out last packet with files numbers 1..9 - if(file_read_count) - { - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - } - - //*buf_len = strlen(buf); - *items_count = file_read_count + file_read_count_10; //Return number of sending file - //printf("%s", buf); - //printf("\r\nbuf_len : %d, sizeof(buf): %d\r\n", buf_len, sizeof(buf)); - f_closedir(&dir); - } - return res; -} - -uint8_t ftpd_run(uint8_t * dbuf) -{ - uint16_t size = 0, i; - long ret = 0; - uint32_t blocklen, send_byte, recv_byte; - uint32_t remain_filesize; - uint32_t remain_datasize; -#if defined(F_FILESYSTEM) - //FILINFO fno; -#endif - - //memset(dbuf, 0, sizeof(_MAX_SS_FTPD)); - - switch(getSn_SR(CTRL_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_control) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Connected\r\n", CTRL_SOCK); -#endif - //fsprintf(CTRL_SOCK, banner, HOSTNAME, VERSION); - strcpy(ftp.workingdir, "/"); - SPRINTF((char *)dbuf, "220 %s FTP version %s ready.\r\n", HOSTNAME, VERSION); - ret = send(CTRL_SOCK, (uint8_t *)dbuf, strlen((const char *)dbuf)); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - connect_state_control = 1; - } - -#if defined(_FTP_DEBUG_) - //printf("ftp socket %d\r\n", CTRL_SOCK); -#endif - - if((size = getSn_RX_RSR(CTRL_SOCK)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { -#if defined(_FTP_DEBUG_) - PRINTF("size: %d\r\n", size); -#endif - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(size > _MAX_SS_FTPD) size = _MAX_SS_FTPD - 1; - - ret = recv(CTRL_SOCK,dbuf,size); - dbuf[ret] = '\0'; - if(ret != size) - { - if(ret==SOCK_BUSY) return 0; - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("Rcvd Command: %s", dbuf); -#endif - proc_ftpd((char *)dbuf); - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",CTRL_SOCK); -#endif - if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",CTRL_SOCK); -#endif - break; - - case SOCK_CLOSED : -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPStart\r\n",CTRL_SOCK); -#endif - if((ret=socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0)) != CTRL_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", CTRL_SOCK, ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",CTRL_SOCK); -#endif - //strcpy(ftp.workingdir, "/"); - if( (ret = listen(CTRL_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",CTRL_SOCK); -#endif - return ret; - } - connect_state_control = 0; - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",CTRL_SOCK); -#endif - break; - - default : - break; - } - -#if 1 - switch(getSn_SR(DATA_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_data) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Data socket Connected\r\n", DATA_SOCK); -#endif - connect_state_data = 1; - } - - switch(ftp.current_cmd) - { - case LIST_CMD: - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("previous size: %u\r\n", size); -#endif -#if defined(F_FILESYSTEM) - scan_files(ftp.workingdir, dbuf, (int *)&size); -#endif -#if defined(_FTP_DEBUG_) - PRINTF("Items count: %u\r\n", size); - //PRINTF("%s\r\n", dbuf); -#endif -#if !defined(F_FILESYSTEM) - if (strncmp(ftp.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0) - size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n"); -#endif - /* - size = strlen(dbuf); - send(DATA_SOCK, dbuf, size); - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - */ - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - break; - - case RETR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to retrieve : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_READ); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ - remain_filesize = ftp.fil.fsize; -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - do{ -#if defined(_FTP_DEBUG_) - //printf("remained file size: %d\r\n", ftp.fil.fsize); -#endif - wdt_reset(); - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_filesize > _MAX_SS_FTPD) - send_byte = _MAX_SS_FTPD; - else - send_byte = remain_filesize; - - - uint16_t _blocklen; - ftp.fr = f_read(&(ftp.fil), dbuf, send_byte ,&_blocklen); - if(ftp.fr != FR_OK) - break; -#if defined(_FTP_DEBUG_) - PRINTF("#"); - //printf("----->fsize:%d recv:%d len:%d \r\n", remain_filesize, send_byte, blocklen); - //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - uint32_t send_size; - send_size = send(DATA_SOCK, dbuf, _blocklen); - //remain_filesize -= blocklen; - remain_filesize -= send_size; - }while(remain_filesize != 0); -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile read finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } -#else - remain_filesize = strlen(ftp.filename); - - do{ - memset(dbuf, 0, _MAX_SS_FTPD); - - blocklen = sprintf(dbuf, "%s", ftp.filename); - - printf("########## dbuf:%s\r\n", dbuf); - - send(DATA_SOCK, dbuf, blocklen); - remain_filesize -= blocklen; - }while(remain_filesize != 0); - -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case STOR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to store : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_CREATE_ALWAYS | FA_WRITE); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - while(1){ - wdt_reset(); - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf,(uint16_t) recv_byte); -#if defined(_FTP_DEBUG_) - //PRINTF("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - - uint16_t _blocklen; - ftp.fr = f_write(&(ftp.fil), dbuf, (UINT)ret, &_blocklen); -#if defined(_FTP_DEBUG_) - //PRINTF("----->dsize:%lu recv:%lu len:%u \r\n", remain_datasize, ret, _blocklen); -#endif - remain_datasize -= (uint32_t)_blocklen; - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - - if(remain_datasize <= 0) - break; - } - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - -#if defined(_FTP_DEBUG_) - PRINTF("#"); -#endif - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile write finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } - - //fno.fdate = (WORD)(((current_year - 1980) << 9) | (current_month << 5) | current_day); - //fno.ftime = (WORD)((current_hour << 11) | (current_min << 5) | (current_sec >> 1)); - //f_utime((const char *)ftp.filename, &fno); -#else - while(1){ - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf, recv_byte); - - printf("########## dbuf:%s\r\n", dbuf); - - remain_datasize -= ret; - - if(remain_datasize <= 0) - break; - } - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case NO_CMD: - default: - break; - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",DATA_SOCK); -#endif - if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",DATA_SOCK); -#endif - break; - - case SOCK_CLOSED : - if(ftp.dsock_state == DATASOCK_READY) - { - if(ftp.dsock_mode == PASSIVE_MODE){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[PASSIV_MODE], port : %u\r\n",DATA_SOCK, local_port); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - - local_port++; - if(local_port > 50000) - local_port = 35000; - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[ACTIVE_MODE], port : %u\r\n",DATA_SOCK, IPPORT_FTPD); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, IPPORT_FTPD, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - } - - ftp.dsock_state = DATASOCK_START; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",DATA_SOCK); -#endif - if(ftp.dsock_mode == PASSIVE_MODE){ - if( (ret = listen(DATA_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",DATA_SOCK); -#endif - return ret; - } - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",DATA_SOCK); -#endif - }else{ - - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#1\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { -#if defined(_FTP_DEBUG_) - PRINTF("DATA_SOCK Connect#1 OK\r\n"); -#endif - } - //Try to FIX STOR command - } - connect_state_data = 0; - break; - - default : - break; - } -#endif - - return 0; -} - -char proc_ftpd(char * buf) -{ - char **cmdp, *cp, *arg, *tmpstr; - char sendbuf[200]; - int slen; - long ret; - - - /* Translate first word to lower case */ - for (cp = buf; *cp != ' ' && *cp != '\0'; cp++) - *cp = tolower(*cp); - - /* Find command in table; if not present, return syntax error */ - for (cmdp = commands; *cmdp != NULL; cmdp++) - if (strncmp(*cmdp, buf, strlen(*cmdp)) == 0) - break; - - if (*cmdp == NULL) - { - //fsprintf(CTRL_SOCK, badcmd, buf); - slen = SPRINTF(sendbuf, "500 Unknown command '%s'\r\n", buf); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - /* Allow only USER, PASS and QUIT before logging in */ - if (ftp.state == FTPS_NOT_LOGIN) - { - switch(cmdp - commands) - { - case USER_CMD: - case PASS_CMD: - case QUIT_CMD: - break; - default: - //fsprintf(CTRL_SOCK, notlog); - slen = SPRINTF(sendbuf, "530 Please log in with USER and PASS\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - } - - arg = &buf[strlen(*cmdp)]; - while(*arg == ' ') arg++; - - /* Execute specific command */ - switch (cmdp - commands) - { - case USER_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("USER_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - strcpy(ftp.username, arg); - //fsprintf(CTRL_SOCK, givepass); - slen = SPRINTF(sendbuf, "331 Enter PASS command\r\n"); - ret = send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case PASS_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("PASS_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - ftplogin(arg); - break; - - case TYPE_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - switch(arg[0]) - { - case 'A': - case 'a': /* Ascii */ - ftp.type = ASCII_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case 'B': - case 'b': /* Binary */ - case 'I': - case 'i': /* Image */ - ftp.type = IMAGE_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badtype, arg); - slen = SPRINTF(sendbuf, "501 Unknown type \"%s\"\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - break; - - case FEAT_CMD : - slen = SPRINTF(sendbuf, "211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST size*;type*;create*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 END\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case QUIT_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("QUIT_CMD\r\n"); -#endif - //fsprintf(CTRL_SOCK, bye); - slen = SPRINTF(sendbuf, "221 Goodbye!\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(CTRL_SOCK); - break; - - case RETR_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("RETR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = sprintf(sendbuf, "150 Opening data channel for file downloand from server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = RETR_CMD; - break; - - case APPE_CMD : - case STOR_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("STOR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "150 Opening data channel for file upload to server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = STOR_CMD; - /* - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#2\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { - //!!Debug only!! - PRINTF("DATA_SOCK Connect#2 OK\r\n"); - } - */ - //Try to FIX STOR command - connect_state_data = 0; - break; - - case PORT_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("PORT_CMD\r\n"); -#endif - if (pport(arg) == -1){ - //fsprintf(CTRL_SOCK, badport); - slen = SPRINTF(sendbuf, "501 Bad port syntax\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } else{ - //fsprintf(CTRL_SOCK, portok); - ftp.dsock_mode = ACTIVE_MODE; - ftp.dsock_state = DATASOCK_READY; - slen = SPRINTF(sendbuf, "200 PORT command successful.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } - break; - - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("MLSD_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = MLSD_CMD; - break; - - case LIST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("LIST_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = LIST_CMD; - break; - - case NLST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("NLST_CMD\r\n"); -#endif - break; - - case SYST_CMD: - slen = SPRINTF(sendbuf, "215 UNIX emulated by WIZnet\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PWD_CMD: - case XPWD_CMD: - slen = SPRINTF(sendbuf, "257 \"%s\" is current directory.\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PASV_CMD: - slen = SPRINTF(sendbuf, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", local_ip.cVal[0], local_ip.cVal[1], local_ip.cVal[2], local_ip.cVal[3], local_port >> 8, local_port & 0x00ff); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(DATA_SOCK); - ftp.dsock_mode = PASSIVE_MODE; - ftp.dsock_state = DATASOCK_READY; -#if defined(_FTP_DEBUG_) - PRINTF("PASV port: %u\r\n", local_port); -#endif - break; - - case SIZE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = _MAX_SS_FTPD; -#endif - if(slen > 0) - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - else - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - else - { - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case CWD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - arg[slen - 3] = 0x00; - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = 0; -#endif - *tmpstr = '/'; - if(slen == 0){ - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - else - { - slen = SPRINTF(sendbuf, "550 CWD failed. \"%s\"\r\n", arg); - } - } - else - { - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case MKD_CMD: - case XMKD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_mkdir(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Can't create directory. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "257 MKD command successful. \"%s\"\r\n", arg); - //strcpy(ftp.workingdir, arg); - } -#else - slen = SPRINTF(sendbuf, "550 Can't create directory. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case DELE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_unlink(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Could not delete. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "250 Deleted. \"%s\"\r\n", arg); - } -#else - slen = SPRINTF(sendbuf, "550 Could not delete. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case XCWD_CMD: - case ACCT_CMD: - case XRMD_CMD: - case RMD_CMD: - case STRU_CMD: - case MODE_CMD: - case XMD5_CMD: - //fsprintf(CTRL_SOCK, unimp); - slen = SPRINTF(sendbuf, "502 Command does not implemented yet.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badcmd, arg); - slen = SPRINTF(sendbuf, "500 Unknown command \'%s\'\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - - return 1; -} - - -char ftplogin(char * pass) -{ - char sendbuf[100]; - int slen = 0; - - //memset(sendbuf, 0, DATA_BUF_SIZE); - -#if defined(_FTP_DEBUG_) - PRINTF("%s logged in\r\n", ftp.username); -#endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - - return 1; -} - -int pport(char * arg) -{ - int i; - char* tok=0; - - for (i = 0; i < 4; i++) - { - if(i==0) tok = strtok(arg,",\r\n"); - else tok = strtok(NULL,","); - remote_ip.cVal[i] = (uint8_t)atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } - remote_port = 0; - for (i = 0; i < 2; i++) - { - tok = strtok(NULL,",\r\n"); - remote_port <<= 8; - remote_port += atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - - return 0; -} - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil) -{ -#if defined(_FTP_DEBUG_) - PRINTF("File System pointer : %08X\r\n", fil->fs); - PRINTF("File System mount ID : %d\r\n", fil->id); - PRINTF("File status flag : %08X\r\n", fil->flag); - PRINTF("File System pads : %08X\r\n", fil->err); - PRINTF("File read write pointer : %08X\r\n", fil->fptr); - PRINTF("File size : %08X\r\n", fil->fsize); - PRINTF("File start cluster : %08X\r\n", fil->sclust); - PRINTF("current cluster : %08X\r\n", fil->clust); - PRINTF("current data sector : %08X\r\n", fil->dsect); - PRINTF("dir entry sector : %08X\r\n", fil->dir_sect); - PRINTF("dir entry pointer : %08X\r\n", fil->dir_ptr); -#endif -} -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h deleted file mode 100644 index 8057eb9..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _FTPD_H_ -#define _FTPD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.h -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : Header file of FTP daemon. (AVR-GCC Compiler) -*/ - -#include - -#include "../../globals.h" //add AVR specific useful headers - -#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement. - -#if defined(F_FILESYSTEM) -#include "ff.h" -#endif - -#define F_APP_FTP -//#define _FTP_DEBUG_ - - -#define LINELEN 100 -//#define DATA_BUF_SIZE 100 -#if !defined(F_FILESYSTEM) -#define _MAX_SS 512 -#endif - -#define CTRL_SOCK 2 -#define DATA_SOCK 3 - -#define IPPORT_FTPD 20 /* FTP Data port */ -#define IPPORT_FTP 21 /* FTP Control port */ - -#define HOSTNAME "iinChip" -#define VERSION "1.0" - -#define FILENAME "a.txt" - -/* FTP commands */ -enum ftp_cmd { - USER_CMD, - ACCT_CMD, - PASS_CMD, - TYPE_CMD, - LIST_CMD, - CWD_CMD, - DELE_CMD, - NAME_CMD, - QUIT_CMD, - RETR_CMD, - STOR_CMD, - PORT_CMD, - NLST_CMD, - PWD_CMD, - XPWD_CMD, - MKD_CMD, - XMKD_CMD, - XRMD_CMD, - RMD_CMD, - STRU_CMD, - MODE_CMD, - SYST_CMD, - XMD5_CMD, - XCWD_CMD, - FEAT_CMD, - PASV_CMD, - SIZE_CMD, - MLSD_CMD, - APPE_CMD, - NO_CMD, -}; - -enum ftp_type { - ASCII_TYPE, - IMAGE_TYPE, - LOGICAL_TYPE -}; - -enum ftp_state { - FTPS_NOT_LOGIN, - FTPS_LOGIN -}; - -enum datasock_state{ - DATASOCK_IDLE, - DATASOCK_READY, - DATASOCK_START -}; - -enum datasock_mode{ - PASSIVE_MODE, - ACTIVE_MODE -}; - -struct ftpd { - uint8_t control; /* Control stream */ - uint8_t data; /* Data stream */ - - enum ftp_type type; /* Transfer type */ - enum ftp_state state; - - enum ftp_cmd current_cmd; - - enum datasock_state dsock_state; - enum datasock_mode dsock_mode; - - char username[LINELEN]; /* Arg to USER command */ - char workingdir[LINELEN]; - char filename[LINELEN]; - -#if defined(F_FILESYSTEM) - FIL fil; // FatFs File objects - FRESULT fr; // FatFs function common result code -#endif - -}; - -#ifndef un_I2cval -typedef union _un_l2cval { - uint32_t lVal; - uint8_t cVal[4]; -}un_l2cval; -#endif - -void ftpd_init(uint8_t * src_ip); -uint8_t ftpd_run(uint8_t * dbuf); -char proc_ftpd(char * buf); -char ftplogin(char * pass); -int pport(char * arg); - -int sendit(char * command); -int recvit(char * command); - -long sendfile(uint8_t s, char * command); -long recvfile(uint8_t s); - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil); -#endif - -#ifdef __cplusplus -} -#endif - -#endif // _FTPD_H_ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h deleted file mode 100644 index 90c3a0d..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2002, Joerg Wunsch - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * Neither the name of the copyright holders nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - -//struct __file { -// char *buf; /* buffer pointer */ -// unsigned char unget; /* ungetc() buffer */ -// uint8_t flags; /* flags, see below */ -//#define __SRD 0x0001 /* OK to read */ -//#define __SWR 0x0002 /* OK to write */ -//#define __SSTR 0x0004 /* this is an sprintf/snprintf string */ -//#define __SPGM 0x0008 /* fmt string is in progmem */ -//#define __SERR 0x0010 /* found error */ -//#define __SEOF 0x0020 /* found EOF */ -//#define __SUNGET 0x040 /* ungetc() happened */ -//#if 0 -///* possible future extensions, will require uint16_t flags */ -//#define __SRW 0x0080 /* open for reading & writing */ -//#define __SLBF 0x0100 /* line buffered */ -//#define __SNBF 0x0200 /* unbuffered */ -//#define __SMBF 0x0400 /* buf is from malloc */ -//#endif -// int size; /* size of buffer */ -// int len; /* characters read or written so far */ -// int (*put)(char); /* function to write one char to device */ -// int (*get)(void); /* function to read one char from device */ -//}; - -/* values for PRINTF_LEVEL */ -#define PRINTF_MIN 1 -#define PRINTF_STD 2 -#define PRINTF_FLT 3 - -/* values for SCANF_LEVEL */ -#define SCANF_MIN 1 -#define SCANF_STD 2 -#define SCANF_FLT 3 - -#ifdef __cplusplus -} -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.c deleted file mode 100644 index 41ee2db..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - @file httpd.c - @brief functions associated http processing - */ - -#include -#include -#include "socket.h" -#include "httpParser.h" - -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -//uint8_t BUFPUB[2048]; -uint8_t BUFPUB[256]; - -/***************************************************************************** - * Private functions - ****************************************************************************/ -static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */ -static uint8_t C2D(uint8_t c); /* Convert a character to HEX */ - -/** - @brief convert escape characters(%XX) to ASCII character - */ -void unescape_http_url( - char * url /**< pointer to be converted ( escape characters )*/ - ) -{ - int x, y; - - for (x = 0, y = 0; url[y]; ++x, ++y) { - if ((url[x] = url[y]) == '%') { - url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]); - y+=2; - } - } - url[x] = '\0'; -} - - -/** - @brief make response header such as html, gif, jpeg,etc. - */ -void make_http_response_head( - char * buf, /**< pointer to response header to be made */ - char type, /**< response type */ - uint32_t len /**< size of response header */ - ) -{ - const char * head; - char tmp[10]; - - /* file type*/ - if (type == PTYPE_HTML) head = PSTR(RES_HTMLHEAD_OK); - else if (type == PTYPE_GIF) head = PSTR(RES_GIFHEAD_OK); - else if (type == PTYPE_TEXT) head = PSTR(RES_TEXTHEAD_OK); - else if (type == PTYPE_JPEG) head = PSTR(RES_JPEGHEAD_OK); - else if (type == PTYPE_FLASH) head = PSTR(RES_FLASHHEAD_OK); - else if (type == PTYPE_XML) head = PSTR(RES_XMLHEAD_OK); - else if (type == PTYPE_CSS) head = PSTR(RES_CSSHEAD_OK); - else if (type == PTYPE_JSON) head = PSTR(RES_JSONHEAD_OK); - else if (type == PTYPE_JS) head = PSTR(RES_JSHEAD_OK); - else if (type == PTYPE_CGI) head = PSTR(RES_CGIHEAD_OK); - else if (type == PTYPE_PNG) head = PSTR(RES_PNGHEAD_OK); - else if (type == PTYPE_ICO) head = PSTR(RES_ICOHEAD_OK); - else if (type == PTYPE_TTF) head = PSTR(RES_TTFHEAD_OK); - else if (type == PTYPE_OTF) head = PSTR(RES_OTFHEAD_OK); - else if (type == PTYPE_WOFF) head = PSTR(RES_WOFFHEAD_OK); - else if (type == PTYPE_EOT) head = PSTR(RES_EOTHEAD_OK); - else if (type == PTYPE_SVG) head = PSTR(RES_SVGHEAD_OK); -#ifdef _HTTPPARSER_DEBUG_ - else - { - head = NULL; - PRINTF("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n"); - } -#else - else head = NULL; -#endif - - sprintf(tmp, "%ld", len); - strcpy_P(buf, head); - strcat(buf, tmp); - strcat(buf, "\r\n\r\n"); -} - - -/** - @brief find MIME type of a file - */ -void find_http_uri_type( - uint8_t * type, /**< type to be returned */ - uint8_t * buff /**< file name */ - ) -{ - /* Decide type according to extension*/ - - char * buf; - buf = (char *)buff; - - if (strcasestr_P(buf, PSTR(".htm")) || strcasestr_P(buf, PSTR(".html"))) *type = PTYPE_HTML; - else if (strcasestr_P(buf, PSTR(".gif"))) *type = PTYPE_GIF; - else if (strcasestr_P(buf, PSTR(".text")) || strstr_P(buf,PSTR(".txt"))) *type = PTYPE_TEXT; - else if (strcasestr_P(buf, PSTR(".jpeg")) || strstr_P(buf,PSTR(".jpg"))) *type = PTYPE_JPEG; - else if (strcasestr_P(buf, PSTR(".swf"))) *type = PTYPE_FLASH; - else if (strstr_P(buf, PSTR(".cgi")) || strstr_P(buf,PSTR(".CGI"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".json")) || strstr_P(buf,PSTR(".JSON"))) *type = PTYPE_JSON; - else if (strstr_P(buf, PSTR(".js")) || strstr_P(buf,PSTR(".JS"))) *type = PTYPE_JS; - else if (strstr_P(buf, PSTR(".CGI")) || strstr_P(buf,PSTR(".cgi"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".xml")) || strstr_P(buf,PSTR(".XML"))) *type = PTYPE_XML; - else if (strstr_P(buf, PSTR(".css")) || strstr_P(buf,PSTR(".CSS"))) *type = PTYPE_CSS; - else if (strstr_P(buf, PSTR(".png")) || strstr_P(buf,PSTR(".PNG"))) *type = PTYPE_PNG; - else if (strstr_P(buf, PSTR(".ico")) || strstr_P(buf,PSTR(".ICO"))) *type = PTYPE_ICO; - else if (strstr_P(buf, PSTR(".ttf")) || strstr_P(buf,PSTR(".TTF"))) *type = PTYPE_TTF; - else if (strstr_P(buf, PSTR(".otf")) || strstr_P(buf,PSTR(".OTF"))) *type = PTYPE_OTF; - else if (strstr_P(buf, PSTR(".woff")) || strstr_P(buf,PSTR(".WOFF"))) *type = PTYPE_WOFF; - else if (strstr_P(buf, PSTR(".eot")) || strstr_P(buf,PSTR(".EOT"))) *type = PTYPE_EOT; - else if (strstr_P(buf, PSTR(".svg")) || strstr_P(buf,PSTR(".SVG"))) *type = PTYPE_SVG; - else *type = PTYPE_ERR; -} - - -/** - @brief parse http request from a peer - */ -void parse_http_request( - st_http_request * request, /**< request to be returned */ - uint8_t * buf /**< pointer to be parsed */ - ) -{ - char * nexttok; - nexttok = strtok((char*)buf," "); - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - if(!strcmp_P(nexttok, PSTR("GET")) || !strcmp_P(nexttok,PSTR("get"))) - { - request->METHOD = METHOD_GET; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("HEAD")) || !strcmp_P(nexttok,PSTR("head"))) - { - request->METHOD = METHOD_HEAD; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("POST")) || !strcmp_P(nexttok,PSTR("post"))) - { - nexttok = strtok(NULL,"\0"); - request->METHOD = METHOD_POST; - } - else - { - request->METHOD = METHOD_ERR; - } - - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - strcpy((char *)request->URI, nexttok); -} - -#ifdef _OLD_ -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value( - char* uri, - char* param_name - ) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * name = 0; - - - if(!uri || !param_name) return 0; - - strcpy((char*)tempURI,uri); - if((name = (uint8_t*)strstr(tempURI, param_name))) - { - name += strlen(param_name) + 1; // strlen(para_name) + strlen("=") - if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0"))) - { - unescape_http_url((char *)name); - replacetochar(name, '+', ' '); - } - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s",param_name,name); -#endif - - return name; -} -#else -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value(char* uri, char* param_name) -{ - - uint8_t * name = 0; - uint8_t * ret = BUFPUB; - uint8_t * pos2; - uint16_t len = 0, content_len = 0; - uint8_t tmp_buf[10]={0x00, }; - - if(!uri || !param_name) return 0; - - /***************/ - mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf); - content_len = ATOI(tmp_buf, 10); - uri = strstr(uri, "\r\n\r\n"); - uri += 4; - uri[content_len] = 0; - /***************/ - - if((name = (uint8_t *)strstr(uri, param_name))) - { - name += strlen(param_name) + 1; - pos2 = (uint8_t*)strstr((char*)name, "&"); - if(!pos2) - { - pos2 = name + strlen((char*)name); - } - len = pos2 - name; - - if(len) - { - ret[len] = 0; - strncpy((char*)ret,(char*)name, len); - unescape_http_url((char *)ret); - replacetochar(ret, '+' ,' '); - //ret[len] = 0; - //ret[strlen((int8*)ret)] = 0; - //printf("len=%d\r\n",len); - } - else - { - ret[0] = 0; - } - } - else - { - return 0; - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s\r\n", param_name, ret); -#endif - return ret; -} -#endif - -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * uri_name; - - if(!uri) return 0; - - strcpy(tempURI, (char *)uri); - - uri_name = (uint8_t *)strtok(tempURI, " ?"); - - if(strcmp((char *)uri_name,"/")) uri_name++; - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_name); -#endif - - return uri_name; -} -#else - -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf) -{ - uint8_t * uri_ptr; - if(!uri) return 0; - - strcpy((char *)uri_buf, (char *)uri); - - uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?"); - - if(strcmp((char *)uri_ptr,"/")) uri_ptr++; - strcpy((char *)uri_buf, (char *)uri_ptr); - -#ifdef _HTTPPARSER_DEBUG_ - PRINTF(" uri_name = %s\r\n", uri_buf); -#endif - - return 1; -} - -#endif - -void inet_addr_(uint8_t * addr, uint8_t *ip) -{ - uint8_t i; - uint8_t taddr[30]; - uint8_t * nexttok; - uint8_t num; - - strcpy((char *)taddr, (char *)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (uint8_t *)strtok((char *)nexttok, "."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10); - else num = ATOI(nexttok,10); - ip[i] = num; - nexttok = NULL; - } -} - - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; -// debug_2013_11_25 -// while (*str !=0) - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -/** - * @brief Check strings and then execute callback function by each string. - * @param src The information of URI - * @param s1 The start string to be researched - * @param s2 The end string to be researched - * @param sub The string between s1 and s2 - * @return The length value atfer working - */ -void mid(char* src, char* s1, char* s2, char* sub) -{ - char* sub1; - char* sub2; - uint16_t n; - - sub1=strstr((char*)src,(char*)s1); - sub1+=strlen((char*)s1); - sub2=strstr((char*)sub1,(char*)s2); - - n=sub2-sub1; - strncpy((char*)sub,(char*)sub1,n); - sub[n]='\0'; -} - -//////////////////////////////////////////////////////////////////// -// Static functions -//////////////////////////////////////////////////////////////////// - -/** -@brief replace the specified character in a string with new character -*/ -static void replacetochar( - uint8_t * str, /**< pointer to be replaced */ - uint8_t oldchar, /**< old character */ - uint8_t newchar /**< new character */ - ) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == oldchar) str[x] = newchar; -} - -/** -@brief CONVERT CHAR INTO HEX -@return HEX - -This function converts HEX(0-F) to a character -*/ -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - - - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.h deleted file mode 100644 index c289c2e..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - @file httpd.h - @brief Define Constants and fucntions associated with HTTP protocol. - */ - -#include -#include "../../globals.h" - -#ifndef __HTTPPARSER_H__ -#define __HTTPPARSER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#define _HTTPPARSER_DEBUG_ - -#define HTTP_SERVER_PORT 80 /**< HTTP server well-known port number */ - -/* HTTP Method */ -#define METHOD_ERR 0 /**< Error Method. */ -#define METHOD_GET 1 /**< GET Method. */ -#define METHOD_HEAD 2 /**< HEAD Method. */ -#define METHOD_POST 3 /**< POST Method. */ - -/* HTTP GET Method */ -#define PTYPE_ERR 0 /**< Error file. */ -#define PTYPE_HTML 1 /**< HTML file. */ -#define PTYPE_GIF 2 /**< GIF file. */ -#define PTYPE_TEXT 3 /**< TEXT file. */ -#define PTYPE_JPEG 4 /**< JPEG file. */ -#define PTYPE_FLASH 5 /**< FLASH file. */ -#define PTYPE_MPEG 6 /**< MPEG file. */ -#define PTYPE_PDF 7 /**< PDF file. */ -#define PTYPE_CGI 8 /**< CGI file. */ -#define PTYPE_XML 9 /**< XML file. */ -#define PTYPE_CSS 10 /**< CSS file. */ -#define PTYPE_JS 11 /**< JavaScript file. */ -#define PTYPE_JSON 12 /**< JSON (JavaScript Standard Object Notation) file. */ -#define PTYPE_PNG 13 /**< PNG file. */ -#define PTYPE_ICO 14 /**< ICON file. */ - -#define PTYPE_TTF 20 /**< Font type: TTF file. */ -#define PTYPE_OTF 21 /**< Font type: OTF file. */ -#define PTYPE_WOFF 22 /**< Font type: WOFF file. */ -#define PTYPE_EOT 23 /**< Font type: EOT file. */ -#define PTYPE_SVG 24 /**< Font type: SVG file. */ - - -/* HTTP response */ -#define STATUS_OK 200 -#define STATUS_CREATED 201 -#define STATUS_ACCEPTED 202 -#define STATUS_NO_CONTENT 204 -#define STATUS_MV_PERM 301 -#define STATUS_MV_TEMP 302 -#define STATUS_NOT_MODIF 304 -#define STATUS_BAD_REQ 400 -#define STATUS_UNAUTH 401 -#define STATUS_FORBIDDEN 403 -#define STATUS_NOT_FOUND 404 -#define STATUS_INT_SERR 500 -#define STATUS_NOT_IMPL 501 -#define STATUS_BAD_GATEWAY 502 -#define STATUS_SERV_UNAVAIL 503 - -/* HTML Doc. for ERROR */ -static const char PROGMEM ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n\r\n\r\nSorry, the page you requested was not found.\r\n\r\n\r\n\0"; -static const char PROGMEM ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n\r\n\r\nInvalid request.\r\n\r\n\r\n\0"; - -/* HTML Doc. for CGI result */ -#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response header for HTML*/ -#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for TEXT */ -#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " - -/* Response head for GIF */ -#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: " - -/* Response head for JPEG */ -#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: " - -/* Response head for PNG */ -#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: " - -/* Response head for FLASH */ -#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: " - -/* Response head for XML */ -#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for CSS */ -#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: " - -/* Response head for JavaScript */ -#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: " - -/* Response head for JSON */ -#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " - -/* Response head for ICO */ -#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: " - -/* Response head for CGI */ -#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response head for TTF, Font */ -#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: " - -/* Response head for OTF, Font */ -#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: " - -/* Response head for WOFF, Font */ -#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: " - -/* Response head for EOT, Font */ -#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: " - -/* Response head for SVG, Font */ -#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: " - -/** - @brief Structure of HTTP REQUEST - */ - -//#define MAX_URI_SIZE 1461 -#define MAX_URI_SIZE 512 - -typedef struct _st_http_request -{ - uint8_t METHOD; /**< request method(METHOD_GET...). */ - uint8_t TYPE; /**< request type(PTYPE_HTML...). */ - uint8_t URI[MAX_URI_SIZE]; /**< request file name. */ -}st_http_request; - -// HTTP Parsing functions -void unescape_http_url(char * url); /* convert escape character to ascii */ -void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */ -void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */ -void make_http_response_head(char *, char, uint32_t); /* make response header */ -uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */ -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */ -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri); -#endif - -// Utility functions -uint16_t ATOI(uint8_t * str, uint8_t base); -void mid(char* src, char* s1, char* s2, char* sub); -void inet_addr_(uint8_t * addr, uint8_t * ip); - -#ifdef __cplusplus -} -#endif - -#endif /* end of __HTTPPARSER_H__ */ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.c deleted file mode 100644 index d3e38f4..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.c +++ /dev/null @@ -1,878 +0,0 @@ -#include -#include -#include - -#include "socket.h" -#include "wizchip_conf.h" - -#include "httpServer.h" -#include "httpParser.h" -#include "httpUtil.h" - -#include "../../globals.h" //add AVR specific useful headers - - -#define DATA_BUF_SIZE HTTPD_MAX_BUF_SIZE -/***************************************************************************** - * Private types/enumerations/variables - ****************************************************************************/ -static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, }; -static st_http_request * http_request; /**< Pointer to received HTTP request */ -static st_http_request * parsed_http_request; /**< Pointer to parsed HTTP request */ -static uint8_t * http_response; /**< Pointer to HTTP response */ - -// ## For Debugging -//static uint8_t uri_buf[128]; -// Number of registered web content in code flash memory -static uint16_t total_content_cnt = 0; -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -uint8_t * pHTTP_TX; -uint8_t * pHTTP_RX; - -volatile uint32_t httpServer_tick_1s = 0; -st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }; -httpServer_webContent web_content[MAX_CONTENT_CALLBACK]; - -#ifdef _USE_SDCARD_ -//static FIL fs; // FatFs: File object -static FRESULT fr; // FatFs: File function return code -#endif -/***************************************************************************** - * Private functions - ****************************************************************************/ -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist); -static uint8_t getHTTPSocketNum(uint8_t seqnum); -static int8_t getHTTPSequenceNum(uint8_t socket); -static int8_t http_disconnect(uint8_t sn); - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request); - -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status); - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len); - -/***************************************************************************** - * Public functions - ****************************************************************************/ -// Callback functions definition: MCU Reset / WDT Reset -void default_mcu_reset(void) {;} -void default_wdt_reset(void) {;} -void (*HTTPServer_ReStart)(void) = default_mcu_reset; -void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset; - -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist) -{ - uint8_t i; - - for(i = 0; i < cnt; i++) - { - // Mapping the H/W socket numbers to the sequential index numbers - HTTPSock_Num[i] = socklist[i]; - } -} - -static uint8_t getHTTPSocketNum(uint8_t seqnum) -{ - // Return the 'H/W socket number' corresponding to the index number - return HTTPSock_Num[seqnum]; -} - -static int8_t getHTTPSequenceNum(uint8_t socket) -{ - uint8_t i; - - for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++) - if(HTTPSock_Num[i] == socket) return i; - - return -1; -} - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist) -{ - // User's shared buffer - pHTTP_TX = tx_buf; - pHTTP_RX = rx_buf; - - // H/W Socket number mapping - httpServer_Sockinit(cnt, socklist); -} - - -/* Register the call back functions for HTTP Server */ -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)) -{ - // Callback: HW Reset and WDT reset function for each MCU platforms - if(mcu_reset) HTTPServer_ReStart = mcu_reset; - if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset; -} - - - -void httpServer_run_avr(uint8_t seqnum) -{ - uint8_t s; // socket number - uint16_t len; - uint32_t gettime = 0; - -#ifdef _HTTPSERVER_DEBUG_ - uint8_t destip[4] = {0, }; - uint16_t destport = 0; -#endif - - http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request - parsed_http_request = (st_http_request *)pHTTP_TX; - - // Get the H/W socket number - s = getHTTPSocketNum(seqnum); - - /* HTTP Service Start */ - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - } - - // HTTP Process states - switch(HTTPSock_Status[seqnum].sock_status) - { - - case STATE_HTTP_IDLE : - if ((len = getSn_RX_RSR(s)) > 0) - { - if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; - len = recv(s, (uint8_t *)http_request, len); - - *(((uint8_t *)http_request) + len) = '\0'; - - parse_http_request(parsed_http_request, (uint8_t *)http_request); -#ifdef _HTTPSERVER_DEBUG_ - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("\r\n"); - PRINTF("> HTTPSocket[%d] : HTTP Request received ", s); - PRINTF("from %d.%d.%d.%d : %u\r\n", destip[0], destip[1], destip[2], destip[3], destport); -#endif -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -#endif - // HTTP 'response' handler; includes send_http_response_header / body function - http_process_handler_avr(s, parsed_http_request); - - gettime = get_httpServer_timecount(); - // Check the TX socket buffer for End of HTTP response sends - while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) - { - if((get_httpServer_timecount() - gettime) > 3) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -#endif - break; - } - } - - if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; - else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end - } - break; - - case STATE_HTTP_RES_INPROC : - /* Repeat: Send the remain parts of HTTP responses */ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); - PRINTF("\r\n> HTTPSocket[%d] : Re-Open the requested content\r\n", s); //_delay_ms(200); -#endif -/* -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - - if((fr = f_open(&fs, (const char *)HTTPSock_Status[seqnum].file_name, FA_READ)) == 0) - { -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); - if((fr = f_lseek(&fs, HTTPSock_Status[seqnum].file_offset)) != 0) - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif - } - else - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif -*/ - // Repeatedly send remaining data to client - send_http_response_body_avr(s, 0, http_response, 0, 0); - - if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - - case STATE_HTTP_RES_DONE : -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -#endif - // Socket file info structure re-initialize - HTTPSock_Status[seqnum].file_len = 0; - HTTPSock_Status[seqnum].file_offset = 0; - HTTPSock_Status[seqnum].file_start = 0; - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; - -#ifdef _USE_SDCARD_ - f_close(&HTTPSock_Status[seqnum].fs); -#endif -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif - http_disconnect(s); - break; - - default : - break; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : CLOSED\r\n", s); -#endif - if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: - listen(s); - break; - - case SOCK_LISTEN: - break; - - default : - break; - - } // end of switch - -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif -} - -//////////////////////////////////////////// -// Private Functions -//////////////////////////////////////////// -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status) -{ - switch(http_status) - { - case STATUS_OK: // HTTP/1.1 200 OK - if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s); -#endif - make_http_response_head((char*)http_response, content_type, body_len); - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s); -#endif - // CGI/XML type request does not respond HTTP header to client - http_status = 0; - } - break; - case STATUS_BAD_REQ: // HTTP/1.1 400 OK -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s); -#endif - memcpy_P(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE)); - break; - case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s); -#endif - memcpy_P(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE)); - break; - default: - break; - } - - // Send the HTTP Response 'header' - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response)); -#endif - send(s, http_response, strlen((char *)http_response)); - } -} - - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -{ - int8_t get_seqnum; - uint32_t send_len; - - uint8_t flag_datasend_end = 0; - -#ifdef _USE_SDCARD_ - uint16_t blocklen; -#endif -#ifdef _USE_FLASH_ - uint32_t addr = 0; -#endif - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - // Send the HTTP Response 'body'; requested file - if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### - { - if (file_len > DATA_BUF_SIZE - 1) - { - HTTPSock_Status[get_seqnum].file_start = start_addr; - HTTPSock_Status[get_seqnum].file_len = file_len; - send_len = DATA_BUF_SIZE - 1; - -///////////////////////////////////////////////////////////////////////////////////////////////// -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) - memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); - strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -#endif -///////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -#endif - } - else - { - // Send process end - send_len = file_len; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (1)HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -#endif - } -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -#endif - } - else // remained parts - { -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; - } -#endif - send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; - - if(send_len > DATA_BUF_SIZE - 1) - { - send_len = DATA_BUF_SIZE - 1; - //HTTPSock_Status[get_seqnum]->file_offset += send_len; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (2)HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -#endif - // Send process end - flag_datasend_end = 1; - } -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -#endif - } - -/*****************************************************/ - //HTTPSock_Status[get_seqnum]->storage_type == NONE - //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH - //HTTPSock_Status[get_seqnum]->storage_type == SDCARD - //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -/*****************************************************/ - - if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) - { - if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; - read_userReg_webContent_avr(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); - } -#ifdef _USE_SDCARD_ - else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) - { - // Data read from SD Card - //PRINTF("++SDCARD f_read(..)\r\n"); - fr = f_read(&HTTPSock_Status[get_seqnum].fs, &buf[0], send_len, (void *)&blocklen); - if(fr != FR_OK) - { - send_len = 0; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -#endif - } - else - { - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } - } -#endif - -#ifdef _USE_FLASH_ - else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - // Data read from external data flash memory - read_from_flashbuf(addr, &buf[0], send_len); - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } -#endif - else - { - send_len = 0; - } - // Requested content send to HTTP client -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -#endif - - if(send_len) send(s, buf, send_len); - else flag_datasend_end = 1; - - if(flag_datasend_end) - { - HTTPSock_Status[get_seqnum].file_start = 0; - HTTPSock_Status[get_seqnum].file_len = 0; - HTTPSock_Status[get_seqnum].file_offset = 0; - flag_datasend_end = 0; - } - else - { - HTTPSock_Status[get_seqnum].file_offset += send_len; -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -#endif - } - -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -#ifdef _USE_SDCARD_ - //Should not close here - //f_close(&fs); -#endif -// ## 20141219 added end -} - - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len) -{ - uint16_t send_len = 0; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s); -#endif - //send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body); - send_len = sprintf_P((char *)buf, PSTR("%S%d\r\n\r\n%s"), PSTR(RES_CGIHEAD_OK), file_len, http_body); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len); -#endif - - send(s, buf, send_len); -} - - -static int8_t http_disconnect(uint8_t sn) -{ - setSn_CR(sn,Sn_CR_DISCON); - /* wait to process the command... */ - while(getSn_CR(sn)); - - return SOCK_OK; -} - - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request) -{ - uint8_t * uri_name; - uint32_t content_addr = 0; - uint16_t content_num = 0; - uint32_t file_len = 0; - - uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; - - uint16_t http_status; - int8_t get_seqnum; - uint8_t content_found; - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - http_status = 0; - http_response = pHTTP_RX; - file_len = 0; - - //method Analyze - switch (p_http_request->METHOD) - { - case METHOD_ERR : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - - case METHOD_HEAD : - case METHOD_GET : - get_http_uri_name(p_http_request->URI, uri_buf); - uri_name = uri_buf; - - if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html - if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); - if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); - find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); - PRINTF("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); - PRINTF("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -#endif - - if (p_http_request->TYPE == PTYPE_ERR) - { - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - return; - } - else if(p_http_request->TYPE == PTYPE_CGI) - { - content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++CODEFLASH FIND..\r\n"); //_delay_ms(200); -#endif - // Find the User registered index for web content - if(find_userReg_webContent_avr(uri_buf, &content_num, &file_len)) - { - content_found = 1; // Web content found in code flash memory - content_addr = (uint32_t)content_num; - HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on CODEFLASH\r\n"); -#endif - } - // Not CGI request, Web content in 'SD card' or 'Data flash' requested -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - if((fr = f_open(&HTTPSock_Status[get_seqnum].fs, (const char *)uri_name, FA_READ)) == 0) - { - content_found = 1; // file open succeed - - file_len = HTTPSock_Status[get_seqnum].fs.fsize; - //content_addr = fs.sclust; //? - content_addr = HTTPSock_Status[get_seqnum].fs.fptr; //much better - HTTPSock_Status[get_seqnum].storage_type = SDCARD; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); -#endif - } -#elif _USE_FLASH_ - else if(/* Read content from Dataflash */) - { - content_found = 1; - HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; - ; // To do - } -#endif - else - { - content_found = 0; // fail to find content - } - - if(!content_found) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -#endif - http_status = STATUS_NOT_FOUND; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -#endif - http_status = STATUS_OK; - } - - // Send HTTP header - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -#endif - send_http_response_header(s, p_http_request->TYPE, file_len, http_status); - } - - // Send HTTP body (content) - if(http_status == STATUS_OK) - { - send_http_response_body_avr(s, uri_name, http_response, content_addr, file_len); - } - } - break; - - case METHOD_POST : - mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); - uri_name = uri_buf; - find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); - PRINTF("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); - PRINTF("Type = %d\r\n", p_http_request->TYPE); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process - { - content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -#endif - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); - - // Reset the H/W for apply to the change configuration information - if(content_found == HTTP_RESET) HTTPServer_ReStart(); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else // HTTP POST Method; Content not found - { - send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); - } - break; - - default : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - } -} - - -void httpServer_time_handler(void) -{ - httpServer_tick_1s++; -} - -uint32_t get_httpServer_timecount(void) -{ - return httpServer_tick_1s; -} -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content) -{ - uint16_t name_len; - uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - content_len = strlen_P((const char *)content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len) -{ - uint16_t name_len; - //uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - //content_len = (uint32_t) sizeof(content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -uint8_t display_reg_webContent_list_avr(void) -{ - uint16_t i; - uint8_t ret; - - if(total_content_cnt == 0) - { - PRINTF(">> Web content file not found\r\n"); - ret = 0; - } - else - { - PRINTF("\r\n=== List of Web content in code flash ===\r\n"); - for(i = 0; i < total_content_cnt; i++) - { - PRINTF(" [%d] ", i+1); - PRINTF("%s, ", web_content[i].content_name); - PRINTF("%ld byte\r\n", web_content[i].content_len); - - - if(web_content[i].content_len < 30) - { - PRINTF("[%s]\r\n", web_content[i].content); - } - else - { - PRINTF("[ ... ]\r\n"); - } - //Dump head 16 bytes every file.. - /* - else - { - const char PROGMEM * tst_char = web_content[i].content; - if(strstr_P(web_content[i].content_name,PSTR("favicon.ico"))==NULL) - { - //ASCII Dump first 0x10 symbols, for all files without - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - else - { - //HEX dump first 0x10 symbols, for - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - } - */ - wdt_reset(); // WDT reset at least every sec - - } - PRINTF("=========================================\r\n\r\n"); - ret = 1; - } - - return ret; -} - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -{ - uint16_t i; - uint8_t ret = 0; // '0' means 'File Not Found' - - for(i = 0; i < total_content_cnt; i++) - { - if(!strcmp((const char *)content_name, (const char *)web_content[i].content_name)) - { - *file_len = web_content[i].content_len; - *content_num = i; - ret = 1; // If the requested content found, ret set to '1' (Found) - break; - } - } - return ret; -} - - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -{ - uint16_t ret = 0; - uint8_t * ptr; - - if(content_num > total_content_cnt) return 0; - - ptr = web_content[content_num].content; - if(offset) ptr += offset; - - //strncpy_P((char *)buf, (const char *)ptr, size); //not suit for case binary data - memcpy_P((char *)buf, (const char *)ptr, size); - *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - - //ret = strlen((void *)buf); //Useless for memcpy_P - ret = 0; //All ok - return ret; -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.h deleted file mode 100644 index 9add8c5..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - @file httpServer.h - @brief Define constants and functions related HTTP Web server. - */ - -#include - -#ifndef __HTTPSERVER_H__ -#define __HTTPSERVER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -// HTTP Server debug message enable -//#define _HTTPSERVER_DEBUG_ - -//#define INITIAL_WEBPAGE "index.html" -#define INITIAL_WEBPAGE "index.htm" -#define M_INITIAL_WEBPAGE "m/index.html" -#define MOBILE_INITIAL_WEBPAGE "mobile/index.html" - -/* Web Server Content Storage Select */ -#define _USE_SDCARD_ -#ifndef _USE_SDCARD_ -//#define _USE_FLASH_ -#endif - -#ifdef _USE_SDCARD_ -#include "ff.h" // header file for FatFs library (FAT file system) -#endif - -#if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_) -#define _NOTUSED_STORAGE_ -#endif - - -/* Watchdog timer */ -//#define _USE_WATCHDOG_ - -/********************************************* -* HTTP Process states list -*********************************************/ -#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */ -#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */ -#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */ -#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */ -#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */ - -/********************************************* -* HTTP Simple Return Value -*********************************************/ -#define HTTP_FAILED 0 -#define HTTP_OK 1 -#define HTTP_RESET 2 - -/********************************************* -* HTTP Content NAME length -*********************************************/ -//#define MAX_CONTENT_NAME_LEN 128 ? Wasteful -#define MAX_CONTENT_NAME_LEN 16 - -/********************************************* -* HTTP Timeout -*********************************************/ -#define HTTP_MAX_TIMEOUT_SEC 3 // Sec. - -typedef enum -{ - NONE, ///< Web storage none - CODEFLASH, ///< Code flash memory - SDCARD, ///< SD card - DATAFLASH ///< External data flash memory -}StorageType; - -typedef struct _st_http_socket -{ - uint8_t sock_status; - uint8_t file_name[MAX_CONTENT_NAME_LEN]; - uint32_t file_start; - uint32_t file_len; - uint32_t file_offset; // (start addr + sent size...) - uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ... - FIL fs; // FatFs: File object -}st_http_socket; - -// Web content structure for file in code flash memory -#define MAX_CONTENT_CALLBACK 20 - -typedef struct _httpServer_webContent -{ - uint8_t * content_name; - uint32_t content_len; - uint8_t * content; -}httpServer_webContent; - - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist); -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)); - -void httpServer_run_avr(uint8_t seqnum); - -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content); - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len); - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); - -uint8_t display_reg_webContent_list_avr(void); - -/* - * @brief HTTP Server 1sec Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void httpServer_time_handler(void); -uint32_t get_httpServer_timecount(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.c deleted file mode 100644 index 77c9a9d..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file httpUtil.c - * @brief HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -#include "httpUtil.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - - if(predefined_get_cgi_processor(uri_name, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - ; - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} - -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - uint8_t val = 0; - - if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - val = 1; - len = sprintf((char *)buf, "%d", val); - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.h deleted file mode 100644 index f2c384a..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file httpUtil.h - * @brief Header File for HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __HTTPUTIL_H__ -#define __HTTPUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "httpServer.h" -#include "httpParser.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len); -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.htm b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.htm deleted file mode 100644 index c8c7178..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.htm +++ /dev/null @@ -1,43 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input - - - - - - - - - -
- - -
- -
- -
-
- - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.js b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.js deleted file mode 100644 index b5974d3..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.js +++ /dev/null @@ -1,57 +0,0 @@ -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawgraph(o); -} -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} -function AinDrawgraph(o) -{ - var pin = o.ain_p; - var val = o.ain_v; - $('ain_v'+pin).style.width = val*500/1023+'px'; -} -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); setTimeout('getAin6_update()', 500); -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.htm b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.htm deleted file mode 100644 index ee671fb..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.htm +++ /dev/null @@ -1,27 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input Gauge - - - - - - - - - -
- - -
- - -
-
- - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.js b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.js deleted file mode 100644 index 7c309a7..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.js +++ /dev/null @@ -1,87 +0,0 @@ -google.load('visualization', '1', - { - packages:['gauge'] - } -); google.setOnLoadCallback(AinDrawGoogleGauge); - -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawGoogleGauge(o); -} - -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} - -function AinDrawGoogleGauge(o) -{ - var val = o.ain_v; - //var temp_val = Number(((((val*3300)/1023)-500)/10).toFixed(2)); - var temp_val = Number(val); //here in range 0..1023 - if(isNaN(temp_val)) temp_val = 0; - var data = google.visualization.arrayToDataTable([['Label', 'Value'],['ADC6', 80]]); - var options = - { - width: 400, - height: 120, - max: 1023, - min: 0, - greenFrom: 0, - greenTo: 512, - redFrom: 918, - redTo: 1023, - yellowFrom: 714, - yellowTo: 918, - majorTicks: ['0', '512', '1023'], - minorTicks: 5 - }; - var chart = new google.visualization.Gauge(document.getElementById('chart_div')); - data.setValue(0, 1, temp_val); - chart.draw(data, options); -} - -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getAin6_update()', 500); -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ajax.js b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ajax.js deleted file mode 100644 index 01c6bb7..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ajax.js +++ /dev/null @@ -1,68 +0,0 @@ -function AJAX(a, e) -{ - var c = d(); - c.onreadystatechange = b; - function d() - { - if(window.XMLHttpRequest) - { - return new XMLHttpRequest() - } - else - { - if(window.ActiveXObject) - { - return new ActiveXObject("Microsoft.XMLHTTP") - } - } - } - function b() - { - if(c.readyState==4) - { - if(c.status==200) - { - if(e) - { - e(c.responseText) - } - } - } - } - this.doGet = function() - { - c.open("GET", a, true); c.send(null) - }; - this.doPost = function(f) - { - c.open("POST", a, true); - c.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - c.setRequestHeader("ISAJAX", "yes"); - c.send(f) - } -} -function $(a) -{ - return document.getElementById(a) -} -function $$(a) -{ - return document.getElementsByName(a) -} -function $$_ie(a, c) -{ - if(!a) - { - a = "*" - } - var b = document.getElementsByTagName(a); - var e = []; for(var d = 0; d - - - - W5500-AtMEGA1284p Web Server Digital I/O v1.1 - - - - - - - - -

LED1: unknown..

- -
- -
-
- - - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/dio.js b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/dio.js deleted file mode 100644 index 5d1d164..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/dio.js +++ /dev/null @@ -1,93 +0,0 @@ -function DioCallback(o) -{ - var pin = o.dio_p; - $('txtdio_s'+pin).value = o.dio_s; - $('txtdio_d'+pin).value = o.dio_d; -} -function led1Callback(o) -{ - $('led1_txt').innerHTML = o.led1_txt; -} -function getDio(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - oUpdate = new AJAX('get_dio'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); -} -function setDiostate(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_s'+p).value;*/ - var v = o.attributes['s'].value; - dout = new AJAX('set_diostate.cgi', - function(t) - { - try - { - /*eval(t);*/ - document.getElementById('led1_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function setDiodir(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_d'+p).value;*/ - var v = o.attributes['d'].value; - dout = new AJAX('set_diodir.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function getled1() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_led1.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getled1()', 3000); -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/favicon.ico b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/favicon.ico deleted file mode 100644 index f63da06..0000000 Binary files a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/favicon.ico and /dev/null differ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/img.htm b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/img.htm deleted file mode 100644 index f609e83..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/img.htm +++ /dev/null @@ -1,14 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Image - - - - - - -
wizwebserver.png
- - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/index.htm b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/index.htm deleted file mode 100644 index 758f904..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/index.htm +++ /dev/null @@ -1,25 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server - - - - -
- W5500-AtMEGA1284p Web Server Demopage -

- Network Information
- Base64 Image Data
-
- Board Schematic
- Mounting Scheme
-
- Ex1> Digital I/O
- Ex2> Analog Input
- Ex3> Analog Input: Google Gauge Chart
-
- Device Information
- - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.htm b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.htm deleted file mode 100644 index fdc64f6..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.htm +++ /dev/null @@ -1,18 +0,0 @@ - - - - - W5500-AtMEGA1284p Device Info - - - - - - -
- W5500-AtMEGA1284p Device Information -

-

..

- diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.js b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.js deleted file mode 100644 index 145be40..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.js +++ /dev/null @@ -1,21 +0,0 @@ -function getInfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_info.cgi', function(t) - { - try - { - //*eval(t); - document.getElementById('info_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); oUpdate.doGet(); - } - , 300); setTimeout('getInfo()', 3000); -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/m1284p.png b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/m1284p.png deleted file mode 100644 index a6dc8a3..0000000 Binary files a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/m1284p.png and /dev/null differ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.htm b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.htm deleted file mode 100644 index 581ba6e..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.htm +++ /dev/null @@ -1,33 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Network Info - - - - - - - -
- W5500-AtMEGA1284p Web Server Network Information -

- -
    -
  • - -
  • - -
  • - -
  • - -
  • -
- - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.js b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.js deleted file mode 100644 index ca5ca0a..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.js +++ /dev/null @@ -1,37 +0,0 @@ -function NetinfoCallback(o) -{ - $('txtmac').value = o.mac; - $('txtip').value = o.ip; - $('txtgw').value = o.gw; - $('txtsn').value = o.sn; - $('txtdns').value = o.dns; - if(typeof(window.external)!='undefined') - { - obj = $$_ie('input', 'dhcp'); - } - else - { - obj = $$('dhcp'); - } -} -function getNetinfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_netinfo.cgi', function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 1500); -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/diskio.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ffconf.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/integer.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.h deleted file mode 100644 index cebe8c5..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -#include "Internet/httpServer_avr/httpParser.h" -FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - - -#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -//FTP Server IP (look at ) -//extern uint8_t FTP_SRV_destip[4]; - - -//#define _MAX_SS_FTP 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTP 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough - -//#define _MAX_SS_FTPD 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTPD 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough -#define _MAX_SS_FTPD _MAX_SS - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define SPRINTF(__S, FORMAT, args...) sprintf_P(__S, PSTR(FORMAT),##args) - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); -extern char uart0_receive(void); -extern void uart0_rx_flash(void); -extern void ls_dir(char* path); -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -//#include "Application/loopback/loopback.h" -#include "Internet/httpServer_avr/httpServer.h" -#include "Internet/FTPServer_avr/ftpd.h" - -#define _MAIN_DEBUG_ - -#define CHK_RAM_LEAKAGE -#define CHK_UPTIME - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -uint8_t gFTPBUF[_MAX_SS_FTPD]; //512 bytes - -/* - * (16) HTTPD + FTPD + FATFS SDCARD - trying combine together projects: - * <12_m1284p_WIZNET_HTTPServer_SDCARD_pages_v2.4d> + <15_m1284p_WIZNET_FTPD_FATFS_v1.4> - * TODO: - * OK (v1.0)1. Initial realize with some minor optimization - * OK (v1.1)2. Add additional 60sec timer - for and events - * - * (15) FTP Server +FATFS SDCARD (PC-side checked on Win7 / WIN7 (console client)) - * TODO: - * OK (v1.1) 1. doesn't work properly on WinSCP, but WIN7 ftp command OK. - Fix it (in first approach with fake data show first ~45 elements from root SD-CARD FTPD) - * Works with WinSCP put/get/delete/refresh - Marvelous! - * PS. Checked work with the next FTP clients (WIN7): - * WINSCP, - * ftp - native WIN7 (terminal-style), - * TotalCommander - need to add new type server with the next template: d ? SSSSSSSSS TTT DD YYYY nnnnnnnnnnnn - * - * OK (v1.1) 2. WIN7 ftp (i.e. downloading file from FTPD SDCARD-device to PC, see ) - works but after download file, progress line still filling ~ 3-5 sec. - Fix it. - * OK (v1.1) 3. WIN7 ftp (i.e. uploading file from PC to FTPD SDCARD-device, see ) - not work properly, device just reboot. - Fix it. - * OK (v1.2) 4. RAM usage optimize : - * OK (v1.1) A) printf(..) change to PRINTF(..) (i.e. printf_P(..)) - * OK (v1.2) B) sprintf(..) change to SPRINTF(..) (i.e. sprintf_P(..)) - Save ~ 900 bytes RAM - * 5. Optimize : - * OK (v1.3) A) To show ALL elements add inside -send(DATA_SOCK, dbuf, size); in portion by 10 elements - until All elements being sent - * OK (v1.3) B) Show real DATE(without TIME) of file from SD-CARD FTPD (Show only DATE without TIME (time showed with error, to show correct need to implement MLST and LMSD extension commands, defined in RFC 3659 )) - * OK (v1.3) C) Try decrease: gFTPBUF[_MAX_SS_FTPD]; //512 bytes - for save RAM resources (optional) - * OK (v1.4) Fix <_FTP_DEBUG_> in undefined state (at ftpd.c), further optimize (at ftpd.c) - * - * (14) FTP client (Active) +FATFS SDCARD (PC-side checked on Win7 ) - * Notes: tested only Active mode with ASCII type (Not sure that PASV mode works properly..). - * TODO: - * OK 1. Without exist FTP server (PC side), device reset always (decide not fix yet..) - * OK 2. <1> command (ls FTP server contents) received no more then _MAXX_SS(512) bytes - need to fix - * Full implement Done with _MAX_SS_FTP=512 checked on ~35 elements show OK (~2362 bytes received) - * !!Below is deprecated decision (read above)!! - * Change at ftpc: _MAX_SS (512 bytes) to _MAX_SS_FTP (2048 bytes - defined at ) - now show OK ~ 25-30 elements from FTPD directory - * (to full implement need fix at: -~355 line - if(gDataPutGetStart){ - switch(Command.Second){ - case s_dir: - PRINTF("dir waiting...\r\n"); - if((size = getSn_RX_RSR(DATA_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur. - PRINTF("ok\r\n"); - memset(dbuf, 0, _MAX_SS_FTP); - if(size > _MAX_SS_FTP) size = _MAX_SS_FTP - 1; - ret = recv(DATA_SOCK,dbuf,size); - * - * ) - * OK 3. <2> command (ls client side FATFS SDCARD contents)file name is empty (problem in scan_files()) - need to fix - * OK 4. Auto-login to anonymous(pass:1234) for test purposes (look at - Responses [R_220/R_331] ) - * OK 5. Add serial terminal session commands (look at ): - * . Test Message - * . Sta (uptime and freeram) - * . Reboot the board - * - * OK 6. Fix baud-rate issue on 115200bps 16Mhz - * OK 7. Add reaction on after not correct authorization - * (Add at - Responses R_530) - Reboot the board - * OK 8. Test and fix command: 5> Put File to Server (checked only active mode(passive not tested)) - * OK 9. Test and fix command: 6> Get File from Server - * OK 10. Add command: 8> Delete File from FTP server - * OK 11.Try add abilities to execute custom FTP server command. (Something like NOOP, HELP etc..) - * OK 12. Disable PASV mode (Tested - with bugs) - * - * - * (3) WIZNET loopback + FATFS (as template) - * + Added FATFS init (from <02_m1284p_FATFS_Chang_tst>), - * Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~12.2018..01.2019 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.1 HTTPD and FTPD servers && FATFS SDCARD WIZNET_5500 ETHERNET 12/01/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* UART0 Baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); - - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} - -//Blocking read UART RX (need for FTP Client) -char uart0_receive(void) -{ - unsigned int c; - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - //Suppress NEW LINE (It harm dialog with FTP server) - if((char)c != '\n') - { - uart_putc((char)c); - return (char)c ; - } - else - { - c = UART_NO_DATA; - } - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//TODO: Add here FTP server initialize -#if defined(F_APP_FTP) - ftpd_init(netInfo.ip); -#endif -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - //In this demo all www content saved onto SD-Card (you must copy all from folder to ROOT SD-Card) -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - uint32_t timer_httpd_1sec = millis(); - uint32_t timer_uptime_60sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - } - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - //TODO: Add here FTP server instance -#if defined(F_APP_FTP) - ftpd_run(gFTPBUF); -#endif - - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - /* - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - */ - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - - } // End of user's code - - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - - //Check ETHERNET PHY link - //Shouldn't used here, LED1 handle via HTTPD - /* - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - /*/ - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - //PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - PRINTF("SW1 is pressed, Reboot the board..\r\n"); - while(1); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - } - - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/spi.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.c b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.c deleted file mode 100644 index 2ab80e2..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file userHandler.c - * @brief User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -//#include "board.h" -#include "httpUtil.h" -#include "userHandler.h" -//#include "adcHandler.h" -#include "wizchip_conf.h" -#include "globals.h" - -/* Unavailable Pins (W5500-EVB component preempted) */ -// >> UART Rx/Tx : D0 (Rx), D1 (Tx) -// >> W5500 SPI(SPI0) : D11 (MOSI), D12 (MISO), D13 (SCK) - -/* On-board Devices */ -// >> Input : D14 (SW1) / D15 (SW2) -// >> Input : AIN (Potentiometer / TEMP.Sensor) -// >> Output : D8 (LED R) / D9 (LED G) / D10 (LED B) - -/* NXP LPC11Exx GPIO functions */ -// GPIO: Pin state -//Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); - -// GPIO: Pin direction -//Chip_GPIO_GetPinDIR((LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); - -// Pre-defined Get CGI functions -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_netinfo(uint8_t * buf, uint16_t * len); -void make_json_led1(uint8_t * buf, uint16_t * len); -void make_info(uint8_t * buf, uint16_t * len); - -// Pre-defined Set CGI functions -int8_t set_diodir(uint8_t * uri); -int8_t set_diostate(uint8_t * uri); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len) -{ - //return 0; //Just a stub, not used yet.. - //uint8_t ret = 1; // ret = 1 means 'uri_name' matched - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched - uint8_t cgibuf[14] = {0, }; - int8_t cgi_dio = -1; - int8_t cgi_ain = -1; - - uint8_t i; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { -// // to do -// ;//make_json_todo(buf, len); - } - else if(strcmp_P((const char *)uri_name,PSTR("get_netinfo.cgi")) == 0) - { - make_json_netinfo(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_led1.cgi")) == 0) - { - make_json_led1(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_info.cgi")) == 0) - { - make_info(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else - { -// // get_dio0.cgi ~ get_dio15.cgi -// for(i = 0; i < DIOn; i++) -// { -// memset(cgibuf, 0x00, 14); -// sprintf((char *)cgibuf, "get_dio%d.cgi", i); -// if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) -// { -// make_json_dio(buf, len, i); -// cgi_dio = i; -// break; -// } -// } -// -// if(cgi_dio < 0) - //Analog Ins reading get_ain0.cgi ~ get_ain7.cgi - if(1) - { - // get_ain0.cgi ~ get_ain5.cgi (A0 - A5), get_ain6.cgi for on-board potentiometer / Temp.Sensor - LPC11Exx - //for(i = 0; i < AINn; i++) //for LPC11xx - for(i = 0; i < 8; i++) //for AVR Mega1284p, available AIN0..AIN7 - { - memset(cgibuf, 0x00, 14); - sprintf((char *)cgibuf, "get_ain%d.cgi", i); - if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) - { - make_json_ain(buf, len, i); - cgi_ain = i; - ret = 1; - break; - } - } - } - -// if((cgi_dio < 0) && (cgi_ain < 0)) ret = 0; - } - - return ret; -} - - -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len) -{ -// return 0; //Just a stub, not used yet.. - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched -// uint8_t ret = 1; // ret = '1' means 'uri_name' matched - uint8_t val = 0; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { - // to do - ;//val = todo(uri); - //*len = sprintf((char *)buf, "%d", val); - } -// // Digital I/O; dio_s, dio_d -// else if(strcmp_P((const char *)uri_name,PSTR("set_diodir.cgi")) == 0) -// { -// //val = set_diodir(uri); -// //printf_P(PSTR("+++set_diodir.cgi uri_name: %s; uri: %s;\r\n")); -// *len = sprintf_P((char *)buf, PSTR("%d"), val); -// ret = 1; -// } - else if(strcmp((const char *)uri_name, "set_diostate.cgi") == 0) - { - //When uri_name=set_diostate.cgi, and uri HTTP POST request which contains something like: - //pin=8&val=1; or pin=8&val=1; (look && ) - - /* - This is LPC11xx handler - val = set_diostate(uri); - len = sprintf((char *)buf, "%d", val); - len ret = 1; - */ - - -#ifdef _USER_HANDLER_DEBUG_ - PRINTF("\r\n+++set_diostate.cgi uri_name: %s\r\nuri: %s\r\n", uri_name, uri); -#endif - //Parse URI (Very dirty!!) - if(strstr_P(uri,PSTR("pin=LED1&val=0"))) - { - led1_low(); - *len = sprintf_P((char *)buf, PSTR("LED1: OFF")); - ret = 1; - } - else if(strstr_P(uri,PSTR("pin=LED1&val=1"))) - { - led1_high(); - *len = sprintf_P((char *)buf, PSTR("LED1: ON")); - ret = 1; - } - else - { - //*len = sprintf_P((char *)buf, PSTR("%d"), -1); - *len = sprintf_P((char *)buf, PSTR("???")); - ret = 1; - } - } -// else -// { -// ret = 0; -// } -// - return ret; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Get CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin) -//{ -// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// -// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\ -// \"dio_s\":\"%d\",\ -// \"dio_d\":\"%d\"\ -// });", -// pin, // Digital io pin number -// pin_state, // Digital io status -// pin_dir // Digital io directions -// ); -//} -// -void make_json_led1(uint8_t * buf, uint16_t * len) -{ - if(led1_read()) - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: ON\"});")); //Send back LED1 state via call-back function - } - else - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: OFF\"});")); //Send back LED1 state via call-back function - } - -} - -void make_info(uint8_t * buf, uint16_t * len) -{ - /* - * Send program metrics: - * Program name - * time-date compile - * MCU info - * free ram info - * uptime device - */ - *len = sprintf_P((char *)buf,PSTR(\ - "
%S"\
-			"Compiled at: %S %S\r\n"\
-			"MCU is: %S; CLK is: %luHz\r\n"\
-			"Free RAM: %dbytes\r\n"\
-			"Uptime: %lusec\r\n
"),\ - str_prog_name,\ - compile_time, compile_date,\ - str_mcu, F_CPU,\ - freeRam(),\ - millis()/1000); -} - -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin) -{ - *len = sprintf_P((char *)buf,PSTR( "AinCallback({\"ain_p\":\"%d\",\ - \"ain_v\":\"%d\"\ - });"), - pin, // ADC input pin number - //get_ADC_val(pin) // ADC input value for LPC11xx - adc_read(pin) // ADC input value for AVR - ); -} - -void make_json_netinfo(uint8_t * buf, uint16_t * len) -{ - wiz_NetInfo netinfo; - ctlnetwork(CN_GET_NETINFO, (void*) &netinfo); - - // DHCP: 1 - Static, 2 - DHCP - *len = sprintf_P((char *)buf,PSTR( "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\ - \"ip\":\"%d.%d.%d.%d\",\ - \"gw\":\"%d.%d.%d.%d\",\ - \"sn\":\"%d.%d.%d.%d\",\ - \"dns\":\"%d.%d.%d.%d\",\ - \"dhcp\":\"%d\"\ - });"), - netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5], - netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3], - netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3], - netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3], - netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3], - netinfo.dhcp - ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Set CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//int8_t set_diodir(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // Direction; NotUsed/Input/Output -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > Output) val = Output; -// } -// } -// -// if(val == Input) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input -// else Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -// -// return pin; -//} -// -//int8_t set_diostate(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // State; high(on)/low(off) -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > On) val = On; -// } -// -// if(val == On) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High -// else Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -// } -// -// return pin; -//} diff --git a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.h b/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.h deleted file mode 100644 index dded54a..0000000 --- a/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file userHandler.h - * @brief Header File for User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __USERHANDLER_H -#define __USERHANDLER_H - -#include -//#define _USER_HANDLER_DEBUG_ - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Public Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined CGI Interface Functions Handler -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP GET Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP POST Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - - -#endif - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.cproject b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.cproject deleted file mode 100644 index bf504d8..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.cproject +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.project b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.project deleted file mode 100644 index 91ab97e..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.h deleted file mode 100644 index 8f5a3d6..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c deleted file mode 100644 index a1621d7..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c +++ /dev/null @@ -1,1304 +0,0 @@ -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.c -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : FTP daemon. (AVR-GCC Compiler) -*/ - -#include -#include -#include -#include -#include -//#include "stdio_private.h" -#include "socket.h" -#include "ftpd.h" - -/* Command table */ -static char *commands[] = { - "user", - "acct", - "pass", - "type", - "list", - "cwd", - "dele", - "name", - "quit", - "retr", - "stor", - "port", - "nlst", - "pwd", - "xpwd", - "mkd", - "xmkd", - "xrmd", - "rmd ", - "stru", - "mode", - "syst", - "xmd5", - "xcwd", - "feat", - "pasv", - "size", - "mlsd", - "appe", - NULL -}; - -#if 0 -/* Response messages */ -char banner[] = "220 %s FTP version %s ready.\r\n"; -char badcmd[] = "500 Unknown command '%s'\r\n"; -char binwarn[] = "100 Warning: type is ASCII and %s appears to be binary\r\n"; -char unsupp[] = "500 Unsupported command or option\r\n"; -char givepass[] = "331 Enter PASS command\r\n"; -char logged[] = "230 Logged in\r\n"; -char typeok[] = "200 Type %s OK\r\n"; -char only8[] = "501 Only logical bytesize 8 supported\r\n"; -char deleok[] = "250 File deleted\r\n"; -char mkdok[] = "200 MKD ok\r\n"; -char delefail[] = "550 Delete failed: %s\r\n"; -char pwdmsg[] = "257 \"%s\" is current directory\r\n"; -char badtype[] = "501 Unknown type \"%s\"\r\n"; -char badport[] = "501 Bad port syntax\r\n"; -char unimp[] = "502 Command does not implemented yet.\r\n"; -char bye[] = "221 Goodbye!\r\n"; -char nodir[] = "553 Can't read directory \"%s\": %s\r\n"; -char cantopen[] = "550 Can't read file \"%s\": %s\r\n"; -char sending[] = "150 Opening data connection for %s (%d.%d.%d.%d,%d)\r\n"; -char cantmake[] = "553 Can't create \"%s\": %s\r\n"; -char writerr[] = "552 Write error: %s\r\n"; -char portok[] = "200 PORT command successful.\r\n"; -char rxok[] = "226 Transfer complete.\r\n"; -char txok[] = "226 Transfer complete.\r\n"; -char noperm[] = "550 Permission denied\r\n"; -char noconn[] = "425 Data connection reset\r\n"; -char lowmem[] = "421 System overloaded, try again later\r\n"; -char notlog[] = "530 Please log in with USER and PASS\r\n"; -char userfirst[] = "503 Login with USER first.\r\n"; -char okay[] = "200 Ok\r\n"; -char syst[] = "215 %s Type: L%d Version: %s\r\n"; -char sizefail[] = "550 File not found\r\n"; -#endif - -un_l2cval remote_ip; -uint16_t remote_port; -un_l2cval local_ip; -uint16_t local_port; -uint8_t connect_state_control = 0; -uint8_t connect_state_data = 0; - -struct ftpd ftp; - -int current_year = 2014; -int current_month = 12; -int current_day = 31; -int current_hour = 10; -int current_min = 10; -int current_sec = 30; - -//int fsprintf(uint8_t s, const char *format, ...) -//{ -// int i; -///* -// char buf[LINELEN]; -// FILE f; -// va_list ap; -// -// f.flags = __SWR | __SSTR; -// f.buf = buf; -// f.size = INT_MAX; -// va_start(ap, format); -// i = vfprintf(&f, format, ap); -// va_end(ap); -// buf[f.len] = 0; -// -// send(s, (uint8_t *)buf, strlen(buf)); -//*/ -// return i; -//} - -void ftpd_init(uint8_t * src_ip) -{ - ftp.state = FTPS_NOT_LOGIN; - ftp.current_cmd = NO_CMD; - ftp.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - - strcpy(ftp.workingdir, "/"); - - socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0); -} - -/* - * From: FatFs - FAT file system module R0.10c - */ -int get_filesize(char* path, char *filename) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i, len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ -#if _USE_LFN - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - if(*path == 0x00) - res = f_opendir(&dir, "/"); - else - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - for(;;){ - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - if(!strcmp(fn, filename)) - { - if(fno.fattrib & AM_DIR){ - //printf("\r\n%s/%s is a directory\r\n", path, filename); - return 0; - } - return fno.fsize; - } - } - //printf("\r\n%s/%s was not found\r\n", path, filename); - //f_closedir(&dir); - } - return -1; -} - -/* - * Inserted from earlier realize FAT FS -> - * FAT file system module R0.10c (C)ChaN, 2014 - */ -/* - * Preferable structure of out see here: - * https://files.stairways.com/other/ftp-list-specs-info.txt - * - * something like: - -rw------- 1 peter 848 Dec 14 11:22 00README.txt -or - - whatever you feel like 848 Dec 14 11:22 00README.txt - - * also - * http://cr.yp.to/ftp/list/binls.html - * -/bin/ls format is a series of lines terminated by \015\012. Servers using /bin/ls format need to be prepared to generate lines in the following form: - - -rw-r--r-- 1 owner group 213 Aug 26 16:31 README - -The line contains - - - for a regular file or d for a directory; - the literal string rw-r--r-- 1 owner group for a regular file, or rwxr-xr-x 1 owner group for a directory; - the file size in decimal right-justified in a 13-byte field; - a three-letter month name, first letter capitalized; - a day number right-justified in a 3-byte field; - a space and a 2-digit hour number; - a colon and a 2-digit minute number; - a space and the abbreviated pathname of the file. - */ -FRESULT scan_files(char* path, char *buf, int * items_count) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i; - int len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ - char date_str[21]; - int date_str_ptr = 0; - int file_read_count = 0; - int file_read_count_10 = 0; - uint16_t size_dbuf = 0; -#if _USE_LFN == 1 - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - i = strlen(path); - //printf("strlen of path: %s %d \r\n", path, i); - for(;;){ - wdt_reset(); - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN == 1 - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; - - //Print out yet only first 30 files for full info - //if(file_read_count > 30) - //Print out yet only first 45 files for short info - /* - if(file_read_count > 45) - { - break; - } - */ - //!!Debug only - file_read_count++; -#if defined(_FTP_DEBUG_) - PRINTF("%02u:%9lu %s\r\n", (file_read_count+file_read_count_10), fno.fsize, fn); -#endif -#endif - //Encode date file like this (time show no correct, so remove): - //Aug 26 2018 - switch((fno.fdate >> 5) & 0x0f) - { - case 1: - len = SPRINTF(date_str, "JAN "); - break; - case 2: - len = SPRINTF(date_str, "FEB "); - break; - case 3: - len = SPRINTF(date_str, "MAR "); - break; - case 4: - len = SPRINTF(date_str, "APR "); - break; - case 5: - len = SPRINTF(date_str, "MAY "); - break; - case 6: - len = SPRINTF(date_str, "JUN "); - break; - case 7: - len = SPRINTF(date_str, "JUL "); - break; - case 8: - len = SPRINTF(date_str, "AUG "); - break; - case 9: - len = SPRINTF(date_str, "SEP "); - break; - case 10: - len = SPRINTF(date_str, "OCT "); - break; - case 11: - len = SPRINTF(date_str, "NOV "); - break; - case 12: - len = SPRINTF(date_str, "DEC "); - break; - } - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%2d ", (fno.fdate & 0x1f)); - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%d ", (((fno.fdate >> 9) & 0x7f) + 1980)); - //Time show not correct, so remove - /* - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%02u:%02u", (fno.ftime >> 11), (fno.ftime >> 5) & 63); - */ - date_str_ptr = 0; - - //printf("date str : %s \r\n", date_str); - - //Directory or file prefix - if(fno.fattrib & AM_DIR) - { - SPRINTF(buf + buf_ptr, "d"); - }else - { - SPRINTF(buf + buf_ptr, "-"); - } - buf_ptr++; - //Should not use here - /* - // drwxr-xr-x 1 ftp ftp 0 Apr 07 2014 $RECYCLE.BIN\r\n - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %u %s %s\r\n", fno.fsize, date_str, fn); - - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %s\r\n", fn); - - - //len = sprintf(buf + buf_ptr, " %6lu %s\r\n",fno.fsize, fn);// - Good minimum, but not seen on WinSCP - - - //len = sprintf(buf + buf_ptr, " %s\r\n", fn);// - Good minimum, but not seen on WinSCP - */ - - //Full with fake data - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) - - //Short without access rights and owner with fake data - /* - len = SPRINTF(buf + buf_ptr, " 1 %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) without access rights and owner - */ - - //Medium with real data file, without access rights and owner - len = SPRINTF(buf + buf_ptr, " 1 %9lu %s %s\r\n", fno.fsize, date_str, fn); //- Works on WinSCP with real data (OK) without access rights and owner - - buf_ptr += len; - - if(file_read_count > 9) - { - //Send out info about files in 10 items maximum - file_read_count = 0; - file_read_count_10 += 10; - //*buf_len = strlen(buf); - - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - - buf_ptr = 0; - - } - - //printf("fn: %s \r\n", fn); - - } - //Send out last packet with files numbers 1..9 - if(file_read_count) - { - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - } - - //*buf_len = strlen(buf); - *items_count = file_read_count + file_read_count_10; //Return number of sending file - //printf("%s", buf); - //printf("\r\nbuf_len : %d, sizeof(buf): %d\r\n", buf_len, sizeof(buf)); - f_closedir(&dir); - } - return res; -} - -uint8_t ftpd_run(uint8_t * dbuf) -{ - uint16_t size = 0, i; - long ret = 0; - uint32_t blocklen, send_byte, recv_byte; - uint32_t remain_filesize; - uint32_t remain_datasize; -#if defined(F_FILESYSTEM) - //FILINFO fno; -#endif - - //memset(dbuf, 0, sizeof(_MAX_SS_FTPD)); - - switch(getSn_SR(CTRL_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_control) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Connected\r\n", CTRL_SOCK); -#endif - //fsprintf(CTRL_SOCK, banner, HOSTNAME, VERSION); - strcpy(ftp.workingdir, "/"); - SPRINTF((char *)dbuf, "220 %s FTP version %s ready.\r\n", HOSTNAME, VERSION); - ret = send(CTRL_SOCK, (uint8_t *)dbuf, strlen((const char *)dbuf)); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - connect_state_control = 1; - } - -#if defined(_FTP_DEBUG_) - //printf("ftp socket %d\r\n", CTRL_SOCK); -#endif - - if((size = getSn_RX_RSR(CTRL_SOCK)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { -#if defined(_FTP_DEBUG_) - PRINTF("size: %d\r\n", size); -#endif - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(size > _MAX_SS_FTPD) size = _MAX_SS_FTPD - 1; - - ret = recv(CTRL_SOCK,dbuf,size); - dbuf[ret] = '\0'; - if(ret != size) - { - if(ret==SOCK_BUSY) return 0; - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("Rcvd Command: %s", dbuf); -#endif - proc_ftpd((char *)dbuf); - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",CTRL_SOCK); -#endif - if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",CTRL_SOCK); -#endif - break; - - case SOCK_CLOSED : -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPStart\r\n",CTRL_SOCK); -#endif - if((ret=socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0)) != CTRL_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", CTRL_SOCK, ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",CTRL_SOCK); -#endif - //strcpy(ftp.workingdir, "/"); - if( (ret = listen(CTRL_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",CTRL_SOCK); -#endif - return ret; - } - connect_state_control = 0; - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",CTRL_SOCK); -#endif - break; - - default : - break; - } - -#if 1 - switch(getSn_SR(DATA_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_data) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Data socket Connected\r\n", DATA_SOCK); -#endif - connect_state_data = 1; - } - - switch(ftp.current_cmd) - { - case LIST_CMD: - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("previous size: %u\r\n", size); -#endif -#if defined(F_FILESYSTEM) - scan_files(ftp.workingdir, dbuf, (int *)&size); -#endif -#if defined(_FTP_DEBUG_) - PRINTF("Items count: %u\r\n", size); - //PRINTF("%s\r\n", dbuf); -#endif -#if !defined(F_FILESYSTEM) - if (strncmp(ftp.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0) - size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n"); -#endif - /* - size = strlen(dbuf); - send(DATA_SOCK, dbuf, size); - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - */ - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - break; - - case RETR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to retrieve : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_READ); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ - remain_filesize = ftp.fil.fsize; -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - do{ -#if defined(_FTP_DEBUG_) - //printf("remained file size: %d\r\n", ftp.fil.fsize); -#endif - wdt_reset(); - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_filesize > _MAX_SS_FTPD) - send_byte = _MAX_SS_FTPD; - else - send_byte = remain_filesize; - - - uint16_t _blocklen; - ftp.fr = f_read(&(ftp.fil), dbuf, send_byte ,&_blocklen); - if(ftp.fr != FR_OK) - break; -#if defined(_FTP_DEBUG_) - PRINTF("#"); - //printf("----->fsize:%d recv:%d len:%d \r\n", remain_filesize, send_byte, blocklen); - //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - uint32_t send_size; - send_size = send(DATA_SOCK, dbuf, _blocklen); - //remain_filesize -= blocklen; - remain_filesize -= send_size; - }while(remain_filesize != 0); -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile read finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } -#else - remain_filesize = strlen(ftp.filename); - - do{ - memset(dbuf, 0, _MAX_SS_FTPD); - - blocklen = sprintf(dbuf, "%s", ftp.filename); - - printf("########## dbuf:%s\r\n", dbuf); - - send(DATA_SOCK, dbuf, blocklen); - remain_filesize -= blocklen; - }while(remain_filesize != 0); - -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case STOR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to store : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_CREATE_ALWAYS | FA_WRITE); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - while(1){ - wdt_reset(); - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf,(uint16_t) recv_byte); -#if defined(_FTP_DEBUG_) - //PRINTF("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - - uint16_t _blocklen; - ftp.fr = f_write(&(ftp.fil), dbuf, (UINT)ret, &_blocklen); -#if defined(_FTP_DEBUG_) - //PRINTF("----->dsize:%lu recv:%lu len:%u \r\n", remain_datasize, ret, _blocklen); -#endif - remain_datasize -= (uint32_t)_blocklen; - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - - if(remain_datasize <= 0) - break; - } - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - -#if defined(_FTP_DEBUG_) - PRINTF("#"); -#endif - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile write finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } - - //fno.fdate = (WORD)(((current_year - 1980) << 9) | (current_month << 5) | current_day); - //fno.ftime = (WORD)((current_hour << 11) | (current_min << 5) | (current_sec >> 1)); - //f_utime((const char *)ftp.filename, &fno); -#else - while(1){ - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf, recv_byte); - - printf("########## dbuf:%s\r\n", dbuf); - - remain_datasize -= ret; - - if(remain_datasize <= 0) - break; - } - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); -#ifdef BOOT_EN - if (strcasestr_P((const char *)ftp.filename, PSTR("1284BOOT.BIN"))) - { - //Found event "1284BOOT.BIN" upload to SD from FTPD, rise signal to running BootLoader (via WDT reset) -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>Catch <1284BOOT.BIN> upload event, so run BOOTLOADER\r\n"); -#endif - sig_reset_board = 1; - } -#endif - break; - - case NO_CMD: - default: - break; - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",DATA_SOCK); -#endif - if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",DATA_SOCK); -#endif - break; - - case SOCK_CLOSED : - if(ftp.dsock_state == DATASOCK_READY) - { - if(ftp.dsock_mode == PASSIVE_MODE){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[PASSIV_MODE], port : %u\r\n",DATA_SOCK, local_port); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - - local_port++; - if(local_port > 50000) - local_port = 35000; - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[ACTIVE_MODE], port : %u\r\n",DATA_SOCK, IPPORT_FTPD); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, IPPORT_FTPD, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - } - - ftp.dsock_state = DATASOCK_START; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",DATA_SOCK); -#endif - if(ftp.dsock_mode == PASSIVE_MODE){ - if( (ret = listen(DATA_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",DATA_SOCK); -#endif - return ret; - } - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",DATA_SOCK); -#endif - }else{ - - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#1\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { -#if defined(_FTP_DEBUG_) - PRINTF("DATA_SOCK Connect#1 OK\r\n"); -#endif - } - //Try to FIX STOR command - } - connect_state_data = 0; - break; - - default : - break; - } -#endif - - return 0; -} - -char proc_ftpd(char * buf) -{ - char **cmdp, *cp, *arg, *tmpstr; - char sendbuf[200]; - int slen; - long ret; - - - /* Translate first word to lower case */ - for (cp = buf; *cp != ' ' && *cp != '\0'; cp++) - *cp = tolower(*cp); - - /* Find command in table; if not present, return syntax error */ - for (cmdp = commands; *cmdp != NULL; cmdp++) - if (strncmp(*cmdp, buf, strlen(*cmdp)) == 0) - break; - - if (*cmdp == NULL) - { - //fsprintf(CTRL_SOCK, badcmd, buf); - slen = SPRINTF(sendbuf, "500 Unknown command '%s'\r\n", buf); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - /* Allow only USER, PASS and QUIT before logging in */ - if (ftp.state == FTPS_NOT_LOGIN) - { - switch(cmdp - commands) - { - case USER_CMD: - case PASS_CMD: - case QUIT_CMD: - break; - default: - //fsprintf(CTRL_SOCK, notlog); - slen = SPRINTF(sendbuf, "530 Please log in with USER and PASS\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - } - - arg = &buf[strlen(*cmdp)]; - while(*arg == ' ') arg++; - - /* Execute specific command */ - switch (cmdp - commands) - { - case USER_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("USER_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - strcpy(ftp.username, arg); - //fsprintf(CTRL_SOCK, givepass); - slen = SPRINTF(sendbuf, "331 Enter PASS command\r\n"); - ret = send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case PASS_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("PASS_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - ftplogin(arg); - break; - - case TYPE_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - switch(arg[0]) - { - case 'A': - case 'a': /* Ascii */ - ftp.type = ASCII_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case 'B': - case 'b': /* Binary */ - case 'I': - case 'i': /* Image */ - ftp.type = IMAGE_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badtype, arg); - slen = SPRINTF(sendbuf, "501 Unknown type \"%s\"\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - break; - - case FEAT_CMD : - slen = SPRINTF(sendbuf, "211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST size*;type*;create*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 END\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case QUIT_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("QUIT_CMD\r\n"); -#endif - //fsprintf(CTRL_SOCK, bye); - slen = SPRINTF(sendbuf, "221 Goodbye!\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(CTRL_SOCK); - break; - - case RETR_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("RETR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = sprintf(sendbuf, "150 Opening data channel for file downloand from server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = RETR_CMD; - break; - - case APPE_CMD : - case STOR_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("STOR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "150 Opening data channel for file upload to server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = STOR_CMD; - /* - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#2\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { - //!!Debug only!! - PRINTF("DATA_SOCK Connect#2 OK\r\n"); - } - */ - //Try to FIX STOR command - connect_state_data = 0; - break; - - case PORT_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("PORT_CMD\r\n"); -#endif - if (pport(arg) == -1){ - //fsprintf(CTRL_SOCK, badport); - slen = SPRINTF(sendbuf, "501 Bad port syntax\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } else{ - //fsprintf(CTRL_SOCK, portok); - ftp.dsock_mode = ACTIVE_MODE; - ftp.dsock_state = DATASOCK_READY; - slen = SPRINTF(sendbuf, "200 PORT command successful.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } - break; - - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("MLSD_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = MLSD_CMD; - break; - - case LIST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("LIST_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = LIST_CMD; - break; - - case NLST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("NLST_CMD\r\n"); -#endif - break; - - case SYST_CMD: - slen = SPRINTF(sendbuf, "215 UNIX emulated by WIZnet\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PWD_CMD: - case XPWD_CMD: - slen = SPRINTF(sendbuf, "257 \"%s\" is current directory.\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PASV_CMD: - slen = SPRINTF(sendbuf, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", local_ip.cVal[0], local_ip.cVal[1], local_ip.cVal[2], local_ip.cVal[3], local_port >> 8, local_port & 0x00ff); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(DATA_SOCK); - ftp.dsock_mode = PASSIVE_MODE; - ftp.dsock_state = DATASOCK_READY; -#if defined(_FTP_DEBUG_) - PRINTF("PASV port: %u\r\n", local_port); -#endif - break; - - case SIZE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = _MAX_SS_FTPD; -#endif - if(slen > 0) - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - else - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - else - { - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case CWD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - arg[slen - 3] = 0x00; - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = 0; -#endif - *tmpstr = '/'; - if(slen == 0){ - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - else - { - slen = SPRINTF(sendbuf, "550 CWD failed. \"%s\"\r\n", arg); - } - } - else - { - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case MKD_CMD: - case XMKD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_mkdir(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Can't create directory. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "257 MKD command successful. \"%s\"\r\n", arg); - //strcpy(ftp.workingdir, arg); - } -#else - slen = SPRINTF(sendbuf, "550 Can't create directory. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case DELE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_unlink(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Could not delete. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "250 Deleted. \"%s\"\r\n", arg); - } -#else - slen = SPRINTF(sendbuf, "550 Could not delete. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case XCWD_CMD: - case ACCT_CMD: - case XRMD_CMD: - case RMD_CMD: - case STRU_CMD: - case MODE_CMD: - case XMD5_CMD: - //fsprintf(CTRL_SOCK, unimp); - slen = SPRINTF(sendbuf, "502 Command does not implemented yet.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badcmd, arg); - slen = SPRINTF(sendbuf, "500 Unknown command \'%s\'\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - - return 1; -} - - -char ftplogin(char * pass) -{ - char sendbuf[100]; - int slen = 0; -#ifdef FTPD_AUTH_EN - if (!strcmp(ftp.username, ftpd_user)) - { - if (!strcmp(pass, ftpd_pass)) - { - - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in OK\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - return 1; - } - - } - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in ERROR\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "530 Login authentication failed\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_NOT_LOGIN; - return 0; -#else - //memset(sendbuf, 0, DATA_BUF_SIZE); - -#if defined(_FTP_DEBUG_) - PRINTF("%s logged in\r\n", ftp.username); -#endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - - return 1; -#endif -} - -int pport(char * arg) -{ - int i; - char* tok=0; - - for (i = 0; i < 4; i++) - { - if(i==0) tok = strtok(arg,",\r\n"); - else tok = strtok(NULL,","); - remote_ip.cVal[i] = (uint8_t)atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } - remote_port = 0; - for (i = 0; i < 2; i++) - { - tok = strtok(NULL,",\r\n"); - remote_port <<= 8; - remote_port += atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - - return 0; -} - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil) -{ -#if defined(_FTP_DEBUG_) - PRINTF("File System pointer : %08X\r\n", fil->fs); - PRINTF("File System mount ID : %d\r\n", fil->id); - PRINTF("File status flag : %08X\r\n", fil->flag); - PRINTF("File System pads : %08X\r\n", fil->err); - PRINTF("File read write pointer : %08X\r\n", fil->fptr); - PRINTF("File size : %08X\r\n", fil->fsize); - PRINTF("File start cluster : %08X\r\n", fil->sclust); - PRINTF("current cluster : %08X\r\n", fil->clust); - PRINTF("current data sector : %08X\r\n", fil->dsect); - PRINTF("dir entry sector : %08X\r\n", fil->dir_sect); - PRINTF("dir entry pointer : %08X\r\n", fil->dir_ptr); -#endif -} -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h deleted file mode 100644 index 8057eb9..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _FTPD_H_ -#define _FTPD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.h -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : Header file of FTP daemon. (AVR-GCC Compiler) -*/ - -#include - -#include "../../globals.h" //add AVR specific useful headers - -#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement. - -#if defined(F_FILESYSTEM) -#include "ff.h" -#endif - -#define F_APP_FTP -//#define _FTP_DEBUG_ - - -#define LINELEN 100 -//#define DATA_BUF_SIZE 100 -#if !defined(F_FILESYSTEM) -#define _MAX_SS 512 -#endif - -#define CTRL_SOCK 2 -#define DATA_SOCK 3 - -#define IPPORT_FTPD 20 /* FTP Data port */ -#define IPPORT_FTP 21 /* FTP Control port */ - -#define HOSTNAME "iinChip" -#define VERSION "1.0" - -#define FILENAME "a.txt" - -/* FTP commands */ -enum ftp_cmd { - USER_CMD, - ACCT_CMD, - PASS_CMD, - TYPE_CMD, - LIST_CMD, - CWD_CMD, - DELE_CMD, - NAME_CMD, - QUIT_CMD, - RETR_CMD, - STOR_CMD, - PORT_CMD, - NLST_CMD, - PWD_CMD, - XPWD_CMD, - MKD_CMD, - XMKD_CMD, - XRMD_CMD, - RMD_CMD, - STRU_CMD, - MODE_CMD, - SYST_CMD, - XMD5_CMD, - XCWD_CMD, - FEAT_CMD, - PASV_CMD, - SIZE_CMD, - MLSD_CMD, - APPE_CMD, - NO_CMD, -}; - -enum ftp_type { - ASCII_TYPE, - IMAGE_TYPE, - LOGICAL_TYPE -}; - -enum ftp_state { - FTPS_NOT_LOGIN, - FTPS_LOGIN -}; - -enum datasock_state{ - DATASOCK_IDLE, - DATASOCK_READY, - DATASOCK_START -}; - -enum datasock_mode{ - PASSIVE_MODE, - ACTIVE_MODE -}; - -struct ftpd { - uint8_t control; /* Control stream */ - uint8_t data; /* Data stream */ - - enum ftp_type type; /* Transfer type */ - enum ftp_state state; - - enum ftp_cmd current_cmd; - - enum datasock_state dsock_state; - enum datasock_mode dsock_mode; - - char username[LINELEN]; /* Arg to USER command */ - char workingdir[LINELEN]; - char filename[LINELEN]; - -#if defined(F_FILESYSTEM) - FIL fil; // FatFs File objects - FRESULT fr; // FatFs function common result code -#endif - -}; - -#ifndef un_I2cval -typedef union _un_l2cval { - uint32_t lVal; - uint8_t cVal[4]; -}un_l2cval; -#endif - -void ftpd_init(uint8_t * src_ip); -uint8_t ftpd_run(uint8_t * dbuf); -char proc_ftpd(char * buf); -char ftplogin(char * pass); -int pport(char * arg); - -int sendit(char * command); -int recvit(char * command); - -long sendfile(uint8_t s, char * command); -long recvfile(uint8_t s); - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil); -#endif - -#ifdef __cplusplus -} -#endif - -#endif // _FTPD_H_ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h deleted file mode 100644 index 90c3a0d..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2002, Joerg Wunsch - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * Neither the name of the copyright holders nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - -//struct __file { -// char *buf; /* buffer pointer */ -// unsigned char unget; /* ungetc() buffer */ -// uint8_t flags; /* flags, see below */ -//#define __SRD 0x0001 /* OK to read */ -//#define __SWR 0x0002 /* OK to write */ -//#define __SSTR 0x0004 /* this is an sprintf/snprintf string */ -//#define __SPGM 0x0008 /* fmt string is in progmem */ -//#define __SERR 0x0010 /* found error */ -//#define __SEOF 0x0020 /* found EOF */ -//#define __SUNGET 0x040 /* ungetc() happened */ -//#if 0 -///* possible future extensions, will require uint16_t flags */ -//#define __SRW 0x0080 /* open for reading & writing */ -//#define __SLBF 0x0100 /* line buffered */ -//#define __SNBF 0x0200 /* unbuffered */ -//#define __SMBF 0x0400 /* buf is from malloc */ -//#endif -// int size; /* size of buffer */ -// int len; /* characters read or written so far */ -// int (*put)(char); /* function to write one char to device */ -// int (*get)(void); /* function to read one char from device */ -//}; - -/* values for PRINTF_LEVEL */ -#define PRINTF_MIN 1 -#define PRINTF_STD 2 -#define PRINTF_FLT 3 - -/* values for SCANF_LEVEL */ -#define SCANF_MIN 1 -#define SCANF_STD 2 -#define SCANF_FLT 3 - -#ifdef __cplusplus -} -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.c deleted file mode 100644 index 41ee2db..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - @file httpd.c - @brief functions associated http processing - */ - -#include -#include -#include "socket.h" -#include "httpParser.h" - -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -//uint8_t BUFPUB[2048]; -uint8_t BUFPUB[256]; - -/***************************************************************************** - * Private functions - ****************************************************************************/ -static void replacetochar(uint8_t * str, uint8_t oldchar, uint8_t newchar); /* Replace old character with new character in the string */ -static uint8_t C2D(uint8_t c); /* Convert a character to HEX */ - -/** - @brief convert escape characters(%XX) to ASCII character - */ -void unescape_http_url( - char * url /**< pointer to be converted ( escape characters )*/ - ) -{ - int x, y; - - for (x = 0, y = 0; url[y]; ++x, ++y) { - if ((url[x] = url[y]) == '%') { - url[x] = C2D(url[y+1])*0x10+C2D(url[y+2]); - y+=2; - } - } - url[x] = '\0'; -} - - -/** - @brief make response header such as html, gif, jpeg,etc. - */ -void make_http_response_head( - char * buf, /**< pointer to response header to be made */ - char type, /**< response type */ - uint32_t len /**< size of response header */ - ) -{ - const char * head; - char tmp[10]; - - /* file type*/ - if (type == PTYPE_HTML) head = PSTR(RES_HTMLHEAD_OK); - else if (type == PTYPE_GIF) head = PSTR(RES_GIFHEAD_OK); - else if (type == PTYPE_TEXT) head = PSTR(RES_TEXTHEAD_OK); - else if (type == PTYPE_JPEG) head = PSTR(RES_JPEGHEAD_OK); - else if (type == PTYPE_FLASH) head = PSTR(RES_FLASHHEAD_OK); - else if (type == PTYPE_XML) head = PSTR(RES_XMLHEAD_OK); - else if (type == PTYPE_CSS) head = PSTR(RES_CSSHEAD_OK); - else if (type == PTYPE_JSON) head = PSTR(RES_JSONHEAD_OK); - else if (type == PTYPE_JS) head = PSTR(RES_JSHEAD_OK); - else if (type == PTYPE_CGI) head = PSTR(RES_CGIHEAD_OK); - else if (type == PTYPE_PNG) head = PSTR(RES_PNGHEAD_OK); - else if (type == PTYPE_ICO) head = PSTR(RES_ICOHEAD_OK); - else if (type == PTYPE_TTF) head = PSTR(RES_TTFHEAD_OK); - else if (type == PTYPE_OTF) head = PSTR(RES_OTFHEAD_OK); - else if (type == PTYPE_WOFF) head = PSTR(RES_WOFFHEAD_OK); - else if (type == PTYPE_EOT) head = PSTR(RES_EOTHEAD_OK); - else if (type == PTYPE_SVG) head = PSTR(RES_SVGHEAD_OK); -#ifdef _HTTPPARSER_DEBUG_ - else - { - head = NULL; - PRINTF("\r\n\r\n-MAKE HEAD UNKNOWN-\r\n"); - } -#else - else head = NULL; -#endif - - sprintf(tmp, "%ld", len); - strcpy_P(buf, head); - strcat(buf, tmp); - strcat(buf, "\r\n\r\n"); -} - - -/** - @brief find MIME type of a file - */ -void find_http_uri_type( - uint8_t * type, /**< type to be returned */ - uint8_t * buff /**< file name */ - ) -{ - /* Decide type according to extension*/ - - char * buf; - buf = (char *)buff; - - if (strcasestr_P(buf, PSTR(".htm")) || strcasestr_P(buf, PSTR(".html"))) *type = PTYPE_HTML; - else if (strcasestr_P(buf, PSTR(".gif"))) *type = PTYPE_GIF; - else if (strcasestr_P(buf, PSTR(".text")) || strstr_P(buf,PSTR(".txt"))) *type = PTYPE_TEXT; - else if (strcasestr_P(buf, PSTR(".jpeg")) || strstr_P(buf,PSTR(".jpg"))) *type = PTYPE_JPEG; - else if (strcasestr_P(buf, PSTR(".swf"))) *type = PTYPE_FLASH; - else if (strstr_P(buf, PSTR(".cgi")) || strstr_P(buf,PSTR(".CGI"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".json")) || strstr_P(buf,PSTR(".JSON"))) *type = PTYPE_JSON; - else if (strstr_P(buf, PSTR(".js")) || strstr_P(buf,PSTR(".JS"))) *type = PTYPE_JS; - else if (strstr_P(buf, PSTR(".CGI")) || strstr_P(buf,PSTR(".cgi"))) *type = PTYPE_CGI; - else if (strstr_P(buf, PSTR(".xml")) || strstr_P(buf,PSTR(".XML"))) *type = PTYPE_XML; - else if (strstr_P(buf, PSTR(".css")) || strstr_P(buf,PSTR(".CSS"))) *type = PTYPE_CSS; - else if (strstr_P(buf, PSTR(".png")) || strstr_P(buf,PSTR(".PNG"))) *type = PTYPE_PNG; - else if (strstr_P(buf, PSTR(".ico")) || strstr_P(buf,PSTR(".ICO"))) *type = PTYPE_ICO; - else if (strstr_P(buf, PSTR(".ttf")) || strstr_P(buf,PSTR(".TTF"))) *type = PTYPE_TTF; - else if (strstr_P(buf, PSTR(".otf")) || strstr_P(buf,PSTR(".OTF"))) *type = PTYPE_OTF; - else if (strstr_P(buf, PSTR(".woff")) || strstr_P(buf,PSTR(".WOFF"))) *type = PTYPE_WOFF; - else if (strstr_P(buf, PSTR(".eot")) || strstr_P(buf,PSTR(".EOT"))) *type = PTYPE_EOT; - else if (strstr_P(buf, PSTR(".svg")) || strstr_P(buf,PSTR(".SVG"))) *type = PTYPE_SVG; - else *type = PTYPE_ERR; -} - - -/** - @brief parse http request from a peer - */ -void parse_http_request( - st_http_request * request, /**< request to be returned */ - uint8_t * buf /**< pointer to be parsed */ - ) -{ - char * nexttok; - nexttok = strtok((char*)buf," "); - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - if(!strcmp_P(nexttok, PSTR("GET")) || !strcmp_P(nexttok,PSTR("get"))) - { - request->METHOD = METHOD_GET; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("HEAD")) || !strcmp_P(nexttok,PSTR("head"))) - { - request->METHOD = METHOD_HEAD; - nexttok = strtok(NULL," "); - - } - else if (!strcmp_P(nexttok, PSTR("POST")) || !strcmp_P(nexttok,PSTR("post"))) - { - nexttok = strtok(NULL,"\0"); - request->METHOD = METHOD_POST; - } - else - { - request->METHOD = METHOD_ERR; - } - - if(!nexttok) - { - request->METHOD = METHOD_ERR; - return; - } - strcpy((char *)request->URI, nexttok); -} - -#ifdef _OLD_ -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value( - char* uri, - char* param_name - ) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * name = 0; - - - if(!uri || !param_name) return 0; - - strcpy((char*)tempURI,uri); - if((name = (uint8_t*)strstr(tempURI, param_name))) - { - name += strlen(param_name) + 1; // strlen(para_name) + strlen("=") - if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0"))) - { - unescape_http_url((char *)name); - replacetochar(name, '+', ' '); - } - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s",param_name,name); -#endif - - return name; -} -#else -/** - @brief get next parameter value in the request - */ -uint8_t * get_http_param_value(char* uri, char* param_name) -{ - - uint8_t * name = 0; - uint8_t * ret = BUFPUB; - uint8_t * pos2; - uint16_t len = 0, content_len = 0; - uint8_t tmp_buf[10]={0x00, }; - - if(!uri || !param_name) return 0; - - /***************/ - mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf); - content_len = ATOI(tmp_buf, 10); - uri = strstr(uri, "\r\n\r\n"); - uri += 4; - uri[content_len] = 0; - /***************/ - - if((name = (uint8_t *)strstr(uri, param_name))) - { - name += strlen(param_name) + 1; - pos2 = (uint8_t*)strstr((char*)name, "&"); - if(!pos2) - { - pos2 = name + strlen((char*)name); - } - len = pos2 - name; - - if(len) - { - ret[len] = 0; - strncpy((char*)ret,(char*)name, len); - unescape_http_url((char *)ret); - replacetochar(ret, '+' ,' '); - //ret[len] = 0; - //ret[strlen((int8*)ret)] = 0; - //printf("len=%d\r\n",len); - } - else - { - ret[0] = 0; - } - } - else - { - return 0; - } -#ifdef _HTTPPARSER_DEBUG_ - printf(" %s=%s\r\n", param_name, ret); -#endif - return ret; -} -#endif - -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri) -{ - char tempURI[MAX_URI_SIZE]; - uint8_t * uri_name; - - if(!uri) return 0; - - strcpy(tempURI, (char *)uri); - - uri_name = (uint8_t *)strtok(tempURI, " ?"); - - if(strcmp((char *)uri_name,"/")) uri_name++; - -#ifdef _HTTPPARSER_DEBUG_ - printf(" uri_name = %s\r\n", uri_name); -#endif - - return uri_name; -} -#else - -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf) -{ - uint8_t * uri_ptr; - if(!uri) return 0; - - strcpy((char *)uri_buf, (char *)uri); - - uri_ptr = (uint8_t *)strtok((char *)uri_buf, " ?"); - - if(strcmp((char *)uri_ptr,"/")) uri_ptr++; - strcpy((char *)uri_buf, (char *)uri_ptr); - -#ifdef _HTTPPARSER_DEBUG_ - PRINTF(" uri_name = %s\r\n", uri_buf); -#endif - - return 1; -} - -#endif - -void inet_addr_(uint8_t * addr, uint8_t *ip) -{ - uint8_t i; - uint8_t taddr[30]; - uint8_t * nexttok; - uint8_t num; - - strcpy((char *)taddr, (char *)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (uint8_t *)strtok((char *)nexttok, "."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = ATOI(nexttok+2,0x10); - else num = ATOI(nexttok,10); - ip[i] = num; - nexttok = NULL; - } -} - - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; -// debug_2013_11_25 -// while (*str !=0) - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -/** - * @brief Check strings and then execute callback function by each string. - * @param src The information of URI - * @param s1 The start string to be researched - * @param s2 The end string to be researched - * @param sub The string between s1 and s2 - * @return The length value atfer working - */ -void mid(char* src, char* s1, char* s2, char* sub) -{ - char* sub1; - char* sub2; - uint16_t n; - - sub1=strstr((char*)src,(char*)s1); - sub1+=strlen((char*)s1); - sub2=strstr((char*)sub1,(char*)s2); - - n=sub2-sub1; - strncpy((char*)sub,(char*)sub1,n); - sub[n]='\0'; -} - -//////////////////////////////////////////////////////////////////// -// Static functions -//////////////////////////////////////////////////////////////////// - -/** -@brief replace the specified character in a string with new character -*/ -static void replacetochar( - uint8_t * str, /**< pointer to be replaced */ - uint8_t oldchar, /**< old character */ - uint8_t newchar /**< new character */ - ) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == oldchar) str[x] = newchar; -} - -/** -@brief CONVERT CHAR INTO HEX -@return HEX - -This function converts HEX(0-F) to a character -*/ -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - - - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.h deleted file mode 100644 index c289c2e..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpParser.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - @file httpd.h - @brief Define Constants and fucntions associated with HTTP protocol. - */ - -#include -#include "../../globals.h" - -#ifndef __HTTPPARSER_H__ -#define __HTTPPARSER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#define _HTTPPARSER_DEBUG_ - -#define HTTP_SERVER_PORT 80 /**< HTTP server well-known port number */ - -/* HTTP Method */ -#define METHOD_ERR 0 /**< Error Method. */ -#define METHOD_GET 1 /**< GET Method. */ -#define METHOD_HEAD 2 /**< HEAD Method. */ -#define METHOD_POST 3 /**< POST Method. */ - -/* HTTP GET Method */ -#define PTYPE_ERR 0 /**< Error file. */ -#define PTYPE_HTML 1 /**< HTML file. */ -#define PTYPE_GIF 2 /**< GIF file. */ -#define PTYPE_TEXT 3 /**< TEXT file. */ -#define PTYPE_JPEG 4 /**< JPEG file. */ -#define PTYPE_FLASH 5 /**< FLASH file. */ -#define PTYPE_MPEG 6 /**< MPEG file. */ -#define PTYPE_PDF 7 /**< PDF file. */ -#define PTYPE_CGI 8 /**< CGI file. */ -#define PTYPE_XML 9 /**< XML file. */ -#define PTYPE_CSS 10 /**< CSS file. */ -#define PTYPE_JS 11 /**< JavaScript file. */ -#define PTYPE_JSON 12 /**< JSON (JavaScript Standard Object Notation) file. */ -#define PTYPE_PNG 13 /**< PNG file. */ -#define PTYPE_ICO 14 /**< ICON file. */ - -#define PTYPE_TTF 20 /**< Font type: TTF file. */ -#define PTYPE_OTF 21 /**< Font type: OTF file. */ -#define PTYPE_WOFF 22 /**< Font type: WOFF file. */ -#define PTYPE_EOT 23 /**< Font type: EOT file. */ -#define PTYPE_SVG 24 /**< Font type: SVG file. */ - - -/* HTTP response */ -#define STATUS_OK 200 -#define STATUS_CREATED 201 -#define STATUS_ACCEPTED 202 -#define STATUS_NO_CONTENT 204 -#define STATUS_MV_PERM 301 -#define STATUS_MV_TEMP 302 -#define STATUS_NOT_MODIF 304 -#define STATUS_BAD_REQ 400 -#define STATUS_UNAUTH 401 -#define STATUS_FORBIDDEN 403 -#define STATUS_NOT_FOUND 404 -#define STATUS_INT_SERR 500 -#define STATUS_NOT_IMPL 501 -#define STATUS_BAD_GATEWAY 502 -#define STATUS_SERV_UNAVAIL 503 - -/* HTML Doc. for ERROR */ -static const char PROGMEM ERROR_HTML_PAGE[] = "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n\r\n\r\nSorry, the page you requested was not found.\r\n\r\n\r\n\0"; -static const char PROGMEM ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n\r\n\r\nInvalid request.\r\n\r\n\r\n\0"; - -/* HTML Doc. for CGI result */ -#define HTML_HEADER "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response header for HTML*/ -#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for TEXT */ -#define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " - -/* Response head for GIF */ -#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: " - -/* Response head for JPEG */ -#define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: " - -/* Response head for PNG */ -#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length: " - -/* Response head for FLASH */ -#define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: " - -/* Response head for XML */ -#define RES_XMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nConnection: keep-alive\r\nContent-Length: " - -/* Response head for CSS */ -#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length: " - -/* Response head for JavaScript */ -#define RES_JSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/javascript\r\nContent-Length: " - -/* Response head for JSON */ -#define RES_JSONHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: " - -/* Response head for ICO */ -#define RES_ICOHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/x-icon\r\nContent-Length: " - -/* Response head for CGI */ -#define RES_CGIHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: " - -/* Response head for TTF, Font */ -#define RES_TTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-truetype\r\nContent-Length: " - -/* Response head for OTF, Font */ -#define RES_OTFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-font-opentype\r\nContent-Length: " - -/* Response head for WOFF, Font */ -#define RES_WOFFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/font-woff\r\nContent-Length: " - -/* Response head for EOT, Font */ -#define RES_EOTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.ms-fontobject\r\nContent-Length: " - -/* Response head for SVG, Font */ -#define RES_SVGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/svg+xml\r\nContent-Length: " - -/** - @brief Structure of HTTP REQUEST - */ - -//#define MAX_URI_SIZE 1461 -#define MAX_URI_SIZE 512 - -typedef struct _st_http_request -{ - uint8_t METHOD; /**< request method(METHOD_GET...). */ - uint8_t TYPE; /**< request type(PTYPE_HTML...). */ - uint8_t URI[MAX_URI_SIZE]; /**< request file name. */ -}st_http_request; - -// HTTP Parsing functions -void unescape_http_url(char * url); /* convert escape character to ascii */ -void parse_http_request(st_http_request *, uint8_t *); /* parse request from peer */ -void find_http_uri_type(uint8_t *, uint8_t *); /* find MIME type of a file */ -void make_http_response_head(char *, char, uint32_t); /* make response header */ -uint8_t * get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */ -uint8_t get_http_uri_name(uint8_t * uri, uint8_t * uri_buf); /* get the requested URI name */ -#ifdef _OLD_ -uint8_t * get_http_uri_name(uint8_t * uri); -#endif - -// Utility functions -uint16_t ATOI(uint8_t * str, uint8_t base); -void mid(char* src, char* s1, char* s2, char* sub); -void inet_addr_(uint8_t * addr, uint8_t * ip); - -#ifdef __cplusplus -} -#endif - -#endif /* end of __HTTPPARSER_H__ */ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.c deleted file mode 100644 index d3e38f4..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.c +++ /dev/null @@ -1,878 +0,0 @@ -#include -#include -#include - -#include "socket.h" -#include "wizchip_conf.h" - -#include "httpServer.h" -#include "httpParser.h" -#include "httpUtil.h" - -#include "../../globals.h" //add AVR specific useful headers - - -#define DATA_BUF_SIZE HTTPD_MAX_BUF_SIZE -/***************************************************************************** - * Private types/enumerations/variables - ****************************************************************************/ -static uint8_t HTTPSock_Num[_WIZCHIP_SOCK_NUM_] = {0, }; -static st_http_request * http_request; /**< Pointer to received HTTP request */ -static st_http_request * parsed_http_request; /**< Pointer to parsed HTTP request */ -static uint8_t * http_response; /**< Pointer to HTTP response */ - -// ## For Debugging -//static uint8_t uri_buf[128]; -// Number of registered web content in code flash memory -static uint16_t total_content_cnt = 0; -/***************************************************************************** - * Public types/enumerations/variables - ****************************************************************************/ -uint8_t * pHTTP_TX; -uint8_t * pHTTP_RX; - -volatile uint32_t httpServer_tick_1s = 0; -st_http_socket HTTPSock_Status[_WIZCHIP_SOCK_NUM_] = { {STATE_HTTP_IDLE, }, }; -httpServer_webContent web_content[MAX_CONTENT_CALLBACK]; - -#ifdef _USE_SDCARD_ -//static FIL fs; // FatFs: File object -static FRESULT fr; // FatFs: File function return code -#endif -/***************************************************************************** - * Private functions - ****************************************************************************/ -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist); -static uint8_t getHTTPSocketNum(uint8_t seqnum); -static int8_t getHTTPSequenceNum(uint8_t socket); -static int8_t http_disconnect(uint8_t sn); - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request); - -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status); - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len); - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len); - -/***************************************************************************** - * Public functions - ****************************************************************************/ -// Callback functions definition: MCU Reset / WDT Reset -void default_mcu_reset(void) {;} -void default_wdt_reset(void) {;} -void (*HTTPServer_ReStart)(void) = default_mcu_reset; -void (*HTTPServer_WDT_Reset)(void) = default_wdt_reset; - -void httpServer_Sockinit(uint8_t cnt, uint8_t * socklist) -{ - uint8_t i; - - for(i = 0; i < cnt; i++) - { - // Mapping the H/W socket numbers to the sequential index numbers - HTTPSock_Num[i] = socklist[i]; - } -} - -static uint8_t getHTTPSocketNum(uint8_t seqnum) -{ - // Return the 'H/W socket number' corresponding to the index number - return HTTPSock_Num[seqnum]; -} - -static int8_t getHTTPSequenceNum(uint8_t socket) -{ - uint8_t i; - - for(i = 0; i < _WIZCHIP_SOCK_NUM_; i++) - if(HTTPSock_Num[i] == socket) return i; - - return -1; -} - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist) -{ - // User's shared buffer - pHTTP_TX = tx_buf; - pHTTP_RX = rx_buf; - - // H/W Socket number mapping - httpServer_Sockinit(cnt, socklist); -} - - -/* Register the call back functions for HTTP Server */ -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)) -{ - // Callback: HW Reset and WDT reset function for each MCU platforms - if(mcu_reset) HTTPServer_ReStart = mcu_reset; - if(wdt_reset) HTTPServer_WDT_Reset = wdt_reset; -} - - - -void httpServer_run_avr(uint8_t seqnum) -{ - uint8_t s; // socket number - uint16_t len; - uint32_t gettime = 0; - -#ifdef _HTTPSERVER_DEBUG_ - uint8_t destip[4] = {0, }; - uint16_t destport = 0; -#endif - - http_request = (st_http_request *)pHTTP_RX; // Structure of HTTP Request - parsed_http_request = (st_http_request *)pHTTP_TX; - - // Get the H/W socket number - s = getHTTPSocketNum(seqnum); - - /* HTTP Service Start */ - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - } - - // HTTP Process states - switch(HTTPSock_Status[seqnum].sock_status) - { - - case STATE_HTTP_IDLE : - if ((len = getSn_RX_RSR(s)) > 0) - { - if (len > DATA_BUF_SIZE) len = DATA_BUF_SIZE; - len = recv(s, (uint8_t *)http_request, len); - - *(((uint8_t *)http_request) + len) = '\0'; - - parse_http_request(parsed_http_request, (uint8_t *)http_request); -#ifdef _HTTPSERVER_DEBUG_ - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("\r\n"); - PRINTF("> HTTPSocket[%d] : HTTP Request received ", s); - PRINTF("from %d.%d.%d.%d : %u\r\n", destip[0], destip[1], destip[2], destip[3], destport); -#endif -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE\r\n", s); -#endif - // HTTP 'response' handler; includes send_http_response_header / body function - http_process_handler_avr(s, parsed_http_request); - - gettime = get_httpServer_timecount(); - // Check the TX socket buffer for End of HTTP response sends - while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024)) - { - if((get_httpServer_timecount() - gettime) > 3) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_REQ_DONE: TX Buffer clear timeout\r\n", s); -#endif - break; - } - } - - if(HTTPSock_Status[seqnum].file_len > 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_INPROC; - else HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; // Send the 'HTTP response' end - } - break; - - case STATE_HTTP_RES_INPROC : - /* Repeat: Send the remain parts of HTTP responses */ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_INPROC\r\n", s); - PRINTF("\r\n> HTTPSocket[%d] : Re-Open the requested content\r\n", s); //_delay_ms(200); -#endif -/* -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - - if((fr = f_open(&fs, (const char *)HTTPSock_Status[seqnum].file_name, FA_READ)) == 0) - { -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); - if((fr = f_lseek(&fs, HTTPSock_Status[seqnum].file_offset)) != 0) - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif - } - else - { - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - } -#endif -*/ - // Repeatedly send remaining data to client - send_http_response_body_avr(s, 0, http_response, 0, 0); - - if(HTTPSock_Status[seqnum].file_len == 0) HTTPSock_Status[seqnum].sock_status = STATE_HTTP_RES_DONE; - break; - - case STATE_HTTP_RES_DONE : -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [State] STATE_HTTP_RES_DONE\r\n", s); -#endif - // Socket file info structure re-initialize - HTTPSock_Status[seqnum].file_len = 0; - HTTPSock_Status[seqnum].file_offset = 0; - HTTPSock_Status[seqnum].file_start = 0; - HTTPSock_Status[seqnum].sock_status = STATE_HTTP_IDLE; - -#ifdef _USE_SDCARD_ - f_close(&HTTPSock_Status[seqnum].fs); -#endif -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif - http_disconnect(s); - break; - - default : - break; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : ClOSE_WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : CLOSED\r\n", s); -#endif - if(socket(s, Sn_MR_TCP, HTTP_SERVER_PORT, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: - listen(s); - break; - - case SOCK_LISTEN: - break; - - default : - break; - - } // end of switch - -#ifdef _USE_WATCHDOG_ - HTTPServer_WDT_Reset(); -#endif -} - -//////////////////////////////////////////// -// Private Functions -//////////////////////////////////////////// -static void send_http_response_header(uint8_t s, uint8_t content_type, uint32_t body_len, uint16_t http_status) -{ - switch(http_status) - { - case STATUS_OK: // HTTP/1.1 200 OK - if((content_type != PTYPE_CGI) && (content_type != PTYPE_XML)) // CGI/XML type request does not respond HTTP header - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_OK\r\n", s); -#endif - make_http_response_head((char*)http_response, content_type, body_len); - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - NONE / CGI or XML\r\n", s); -#endif - // CGI/XML type request does not respond HTTP header to client - http_status = 0; - } - break; - case STATUS_BAD_REQ: // HTTP/1.1 400 OK -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_BAD_REQ\r\n", s); -#endif - memcpy_P(http_response, ERROR_REQUEST_PAGE, sizeof(ERROR_REQUEST_PAGE)); - break; - case STATUS_NOT_FOUND: // HTTP/1.1 404 Not Found -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header - STATUS_NOT_FOUND\r\n", s); -#endif - memcpy_P(http_response, ERROR_HTML_PAGE, sizeof(ERROR_HTML_PAGE)); - break; - default: - break; - } - - // Send the HTTP Response 'header' - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response Header [ %d ]byte\r\n", s, (uint16_t)strlen((char *)http_response)); -#endif - send(s, http_response, strlen((char *)http_response)); - } -} - - -static void send_http_response_body_avr(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len) -{ - int8_t get_seqnum; - uint32_t send_len; - - uint8_t flag_datasend_end = 0; - -#ifdef _USE_SDCARD_ - uint16_t blocklen; -#endif -#ifdef _USE_FLASH_ - uint32_t addr = 0; -#endif - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - // Send the HTTP Response 'body'; requested file - if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ### - { - if (file_len > DATA_BUF_SIZE - 1) - { - HTTPSock_Status[get_seqnum].file_start = start_addr; - HTTPSock_Status[get_seqnum].file_len = file_len; - send_len = DATA_BUF_SIZE - 1; - -///////////////////////////////////////////////////////////////////////////////////////////////// -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) - memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN); - strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n", s, HTTPSock_Status[get_seqnum].file_name); -#endif -///////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - file len [ %ld ]byte\r\n", s, file_len); -#endif - } - else - { - // Send process end - send_len = file_len; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (1)HTTP Response end - file len [ %ld ]byte\r\n", s, send_len); -#endif - } -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr; -#endif - } - else // remained parts - { -#ifdef _USE_FLASH_ - if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset; - } -#endif - send_len = HTTPSock_Status[get_seqnum].file_len - HTTPSock_Status[get_seqnum].file_offset; - - if(send_len > DATA_BUF_SIZE - 1) - { - send_len = DATA_BUF_SIZE - 1; - //HTTPSock_Status[get_seqnum]->file_offset += send_len; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : (2)HTTP Response end - file len [ %ld ]byte\r\n", s, HTTPSock_Status[get_seqnum].file_len); -#endif - // Send process end - flag_datasend_end = 1; - } -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - send len [ %ld ]byte\r\n", s, send_len); -#endif - } - -/*****************************************************/ - //HTTPSock_Status[get_seqnum]->storage_type == NONE - //HTTPSock_Status[get_seqnum]->storage_type == CODEFLASH - //HTTPSock_Status[get_seqnum]->storage_type == SDCARD - //HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH -/*****************************************************/ - - if(HTTPSock_Status[get_seqnum].storage_type == CODEFLASH) - { - if(HTTPSock_Status[get_seqnum].file_len) start_addr = HTTPSock_Status[get_seqnum].file_start; - read_userReg_webContent_avr(start_addr, &buf[0], HTTPSock_Status[get_seqnum].file_offset, send_len); - } -#ifdef _USE_SDCARD_ - else if(HTTPSock_Status[get_seqnum].storage_type == SDCARD) - { - // Data read from SD Card - //PRINTF("++SDCARD f_read(..)\r\n"); - fr = f_read(&HTTPSock_Status[get_seqnum].fs, &buf[0], send_len, (void *)&blocklen); - if(fr != FR_OK) - { - send_len = 0; -#ifdef _HTTPSERVER_DEBUG_ - printf("> HTTPSocket[%d] : [FatFs] Error code return: %d (File Read) / HTTP Send Failed - %s\r\n", s, fr, HTTPSock_Status[get_seqnum].file_name); -#endif - } - else - { - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } - } -#endif - -#ifdef _USE_FLASH_ - else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) - { - // Data read from external data flash memory - read_from_flashbuf(addr, &buf[0], send_len); - *(buf+send_len+1) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - } -#endif - else - { - send_len = 0; - } - // Requested content send to HTTP client -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [Send] HTTP Response body [ %ld ]byte\r\n", s, send_len); -#endif - - if(send_len) send(s, buf, send_len); - else flag_datasend_end = 1; - - if(flag_datasend_end) - { - HTTPSock_Status[get_seqnum].file_start = 0; - HTTPSock_Status[get_seqnum].file_len = 0; - HTTPSock_Status[get_seqnum].file_offset = 0; - flag_datasend_end = 0; - } - else - { - HTTPSock_Status[get_seqnum].file_offset += send_len; -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response body - offset [ %ld ]\r\n", s, HTTPSock_Status[get_seqnum].file_offset); -#endif - } - -// ## 20141219 Eric added, for 'File object structure' (fs) allocation reduced (8 -> 1) -#ifdef _USE_SDCARD_ - //Should not close here - //f_close(&fs); -#endif -// ## 20141219 added end -} - - -static void send_http_response_cgi(uint8_t s, uint8_t * buf, uint8_t * http_body, uint16_t file_len) -{ - uint16_t send_len = 0; - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - CGI\r\n", s); -#endif - //send_len = sprintf((char *)buf, "%s%d\r\n\r\n%s", RES_CGIHEAD_OK, file_len, http_body); - send_len = sprintf_P((char *)buf, PSTR("%S%d\r\n\r\n%s"), PSTR(RES_CGIHEAD_OK), file_len, http_body); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : HTTP Response Header + Body - send len [ %d ]byte\r\n", s, send_len); -#endif - - send(s, buf, send_len); -} - - -static int8_t http_disconnect(uint8_t sn) -{ - setSn_CR(sn,Sn_CR_DISCON); - /* wait to process the command... */ - while(getSn_CR(sn)); - - return SOCK_OK; -} - - -static void http_process_handler_avr(uint8_t s, st_http_request * p_http_request) -{ - uint8_t * uri_name; - uint32_t content_addr = 0; - uint16_t content_num = 0; - uint32_t file_len = 0; - - uint8_t uri_buf[MAX_URI_SIZE]={0x00, }; - - uint16_t http_status; - int8_t get_seqnum; - uint8_t content_found; - - if((get_seqnum = getHTTPSequenceNum(s)) == -1) return; // exception handling; invalid number - - http_status = 0; - http_response = pHTTP_RX; - file_len = 0; - - //method Analyze - switch (p_http_request->METHOD) - { - case METHOD_ERR : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - - case METHOD_HEAD : - case METHOD_GET : - get_http_uri_name(p_http_request->URI, uri_buf); - uri_name = uri_buf; - - if (!strcmp((char *)uri_name, "/")) strcpy((char *)uri_name, INITIAL_WEBPAGE); // If URI is "/", respond by index.html - if (!strcmp((char *)uri_name, "m")) strcpy((char *)uri_name, M_INITIAL_WEBPAGE); - if (!strcmp((char *)uri_name, "mobile")) strcpy((char *)uri_name, MOBILE_INITIAL_WEBPAGE); - find_http_uri_type(&p_http_request->TYPE, uri_name); // Checking requested file types (HTML, TEXT, GIF, JPEG and Etc. are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method GET\r\n", s); - PRINTF("> HTTPSocket[%d] : Request Type = %d\r\n", s, p_http_request->TYPE); - PRINTF("> HTTPSocket[%d] : Request URI = %s\r\n", s, uri_name); -#endif - - if (p_http_request->TYPE == PTYPE_ERR) - { - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - return; - } - else if(p_http_request->TYPE == PTYPE_CGI) - { - content_found = http_get_cgi_handler(uri_name, pHTTP_TX, &file_len); - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, http_response, pHTTP_TX, (uint16_t)file_len); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++CODEFLASH FIND..\r\n"); //_delay_ms(200); -#endif - // Find the User registered index for web content - if(find_userReg_webContent_avr(uri_buf, &content_num, &file_len)) - { - content_found = 1; // Web content found in code flash memory - content_addr = (uint32_t)content_num; - HTTPSock_Status[get_seqnum].storage_type = CODEFLASH; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on CODEFLASH\r\n"); -#endif - } - // Not CGI request, Web content in 'SD card' or 'Data flash' requested -#ifdef _USE_SDCARD_ -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : Searching the requested content\r\n", s); //_delay_ms(200); - //PRINTF("++SDFLASH FIND..\r\n"); //_delay_ms(200); -#endif - if((fr = f_open(&HTTPSock_Status[get_seqnum].fs, (const char *)uri_name, FA_READ)) == 0) - { - content_found = 1; // file open succeed - - file_len = HTTPSock_Status[get_seqnum].fs.fsize; - //content_addr = fs.sclust; //? - content_addr = HTTPSock_Status[get_seqnum].fs.fptr; //much better - HTTPSock_Status[get_seqnum].storage_type = SDCARD; -#ifdef _HTTPSERVER_DEBUG_ - //PRINTF("++Content found on SDCARD\r\n"); -#endif - } -#elif _USE_FLASH_ - else if(/* Read content from Dataflash */) - { - content_found = 1; - HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH; - ; // To do - } -#endif - else - { - content_found = 0; // fail to find content - } - - if(!content_found) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Unknown Page Request\r\n", s); -#endif - http_status = STATUS_NOT_FOUND; - } - else - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Find Content [%s] ok - Start [%ld] len [ %ld ]byte\r\n", s, uri_name, content_addr, file_len); -#endif - http_status = STATUS_OK; - } - - // Send HTTP header - if(http_status) - { -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : Requested content len = [ %ld ]byte\r\n", s, file_len); -#endif - send_http_response_header(s, p_http_request->TYPE, file_len, http_status); - } - - // Send HTTP body (content) - if(http_status == STATUS_OK) - { - send_http_response_body_avr(s, uri_name, http_response, content_addr, file_len); - } - } - break; - - case METHOD_POST : - mid((char *)p_http_request->URI, "/", " HTTP", (char *)uri_buf); - uri_name = uri_buf; - find_http_uri_type(&p_http_request->TYPE, uri_name); // Check file type (HTML, TEXT, GIF, JPEG are included) - -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("\r\n> HTTPSocket[%d] : HTTP Method POST\r\n", s); - PRINTF("> HTTPSocket[%d] : Request URI = %s ", s, uri_name); - PRINTF("Type = %d\r\n", p_http_request->TYPE); -#endif - - if(p_http_request->TYPE == PTYPE_CGI) // HTTP POST Method; CGI Process - { - content_found = http_post_cgi_handler(uri_name, p_http_request, http_response, &file_len); -#ifdef _HTTPSERVER_DEBUG_ - PRINTF("> HTTPSocket[%d] : [CGI: %s] / Response len [ %ld ]byte\r\n", s, content_found?"Content found":"Content not found", file_len); -#endif - if(content_found && (file_len <= (DATA_BUF_SIZE-(strlen(RES_CGIHEAD_OK)+8)))) - { - send_http_response_cgi(s, pHTTP_TX, http_response, (uint16_t)file_len); - - // Reset the H/W for apply to the change configuration information - if(content_found == HTTP_RESET) HTTPServer_ReStart(); - } - else - { - send_http_response_header(s, PTYPE_CGI, 0, STATUS_NOT_FOUND); - } - } - else // HTTP POST Method; Content not found - { - send_http_response_header(s, 0, 0, STATUS_NOT_FOUND); - } - break; - - default : - http_status = STATUS_BAD_REQ; - send_http_response_header(s, 0, 0, http_status); - break; - } -} - - -void httpServer_time_handler(void) -{ - httpServer_tick_1s++; -} - -uint32_t get_httpServer_timecount(void) -{ - return httpServer_tick_1s; -} -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content) -{ - uint16_t name_len; - uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - content_len = strlen_P((const char *)content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len) -{ - uint16_t name_len; - //uint32_t content_len; - - if(content_name == NULL || content == NULL) - { - return; - } - else if(total_content_cnt >= MAX_CONTENT_CALLBACK) - { - return; - } - - name_len = strlen_P((const char *)content_name); - //content_len = (uint32_t) sizeof(content); - - web_content[total_content_cnt].content_name = malloc(name_len+1); - strcpy_P((char *)web_content[total_content_cnt].content_name, (const char *)content_name); - web_content[total_content_cnt].content_len = content_len; - web_content[total_content_cnt].content = content; - - total_content_cnt++; -} - -uint8_t display_reg_webContent_list_avr(void) -{ - uint16_t i; - uint8_t ret; - - if(total_content_cnt == 0) - { - PRINTF(">> Web content file not found\r\n"); - ret = 0; - } - else - { - PRINTF("\r\n=== List of Web content in code flash ===\r\n"); - for(i = 0; i < total_content_cnt; i++) - { - PRINTF(" [%d] ", i+1); - PRINTF("%s, ", web_content[i].content_name); - PRINTF("%ld byte\r\n", web_content[i].content_len); - - - if(web_content[i].content_len < 30) - { - PRINTF("[%s]\r\n", web_content[i].content); - } - else - { - PRINTF("[ ... ]\r\n"); - } - //Dump head 16 bytes every file.. - /* - else - { - const char PROGMEM * tst_char = web_content[i].content; - if(strstr_P(web_content[i].content_name,PSTR("favicon.ico"))==NULL) - { - //ASCII Dump first 0x10 symbols, for all files without - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:%c]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - else - { - //HEX dump first 0x10 symbols, for - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - PRINTF("[0x%04X:0x%02X]\r\n",tst_char, pgm_read_byte(tst_char++)); - } - } - */ - wdt_reset(); // WDT reset at least every sec - - } - PRINTF("=========================================\r\n\r\n"); - ret = 1; - } - - return ret; -} - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len) -{ - uint16_t i; - uint8_t ret = 0; // '0' means 'File Not Found' - - for(i = 0; i < total_content_cnt; i++) - { - if(!strcmp((const char *)content_name, (const char *)web_content[i].content_name)) - { - *file_len = web_content[i].content_len; - *content_num = i; - ret = 1; // If the requested content found, ret set to '1' (Found) - break; - } - } - return ret; -} - - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size) -{ - uint16_t ret = 0; - uint8_t * ptr; - - if(content_num > total_content_cnt) return 0; - - ptr = web_content[content_num].content; - if(offset) ptr += offset; - - //strncpy_P((char *)buf, (const char *)ptr, size); //not suit for case binary data - memcpy_P((char *)buf, (const char *)ptr, size); - *(buf+size) = 0; // Insert '/0' for indicates the 'End of String' (null terminated) - - //ret = strlen((void *)buf); //Useless for memcpy_P - ret = 0; //All ok - return ret; -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.h deleted file mode 100644 index 9add8c5..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpServer.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - @file httpServer.h - @brief Define constants and functions related HTTP Web server. - */ - -#include - -#ifndef __HTTPSERVER_H__ -#define __HTTPSERVER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -// HTTP Server debug message enable -//#define _HTTPSERVER_DEBUG_ - -//#define INITIAL_WEBPAGE "index.html" -#define INITIAL_WEBPAGE "index.htm" -#define M_INITIAL_WEBPAGE "m/index.html" -#define MOBILE_INITIAL_WEBPAGE "mobile/index.html" - -/* Web Server Content Storage Select */ -#define _USE_SDCARD_ -#ifndef _USE_SDCARD_ -//#define _USE_FLASH_ -#endif - -#ifdef _USE_SDCARD_ -#include "ff.h" // header file for FatFs library (FAT file system) -#endif - -#if !defined(_USE_SDCARD_) && !defined(_USE_FLASH_) -#define _NOTUSED_STORAGE_ -#endif - - -/* Watchdog timer */ -//#define _USE_WATCHDOG_ - -/********************************************* -* HTTP Process states list -*********************************************/ -#define STATE_HTTP_IDLE 0 /* IDLE, Waiting for data received (TCP established) */ -#define STATE_HTTP_REQ_INPROC 1 /* Received HTTP request from HTTP client */ -#define STATE_HTTP_REQ_DONE 2 /* The end of HTTP request parse */ -#define STATE_HTTP_RES_INPROC 3 /* Sending the HTTP response to HTTP client (in progress) */ -#define STATE_HTTP_RES_DONE 4 /* The end of HTTP response send (HTTP transaction ended) */ - -/********************************************* -* HTTP Simple Return Value -*********************************************/ -#define HTTP_FAILED 0 -#define HTTP_OK 1 -#define HTTP_RESET 2 - -/********************************************* -* HTTP Content NAME length -*********************************************/ -//#define MAX_CONTENT_NAME_LEN 128 ? Wasteful -#define MAX_CONTENT_NAME_LEN 16 - -/********************************************* -* HTTP Timeout -*********************************************/ -#define HTTP_MAX_TIMEOUT_SEC 3 // Sec. - -typedef enum -{ - NONE, ///< Web storage none - CODEFLASH, ///< Code flash memory - SDCARD, ///< SD card - DATAFLASH ///< External data flash memory -}StorageType; - -typedef struct _st_http_socket -{ - uint8_t sock_status; - uint8_t file_name[MAX_CONTENT_NAME_LEN]; - uint32_t file_start; - uint32_t file_len; - uint32_t file_offset; // (start addr + sent size...) - uint8_t storage_type; // Storage type; Code flash, SDcard, Data flash ... - FIL fs; // FatFs: File object -}st_http_socket; - -// Web content structure for file in code flash memory -#define MAX_CONTENT_CALLBACK 20 - -typedef struct _httpServer_webContent -{ - uint8_t * content_name; - uint32_t content_len; - uint8_t * content; -}httpServer_webContent; - - -void httpServer_init(uint8_t * tx_buf, uint8_t * rx_buf, uint8_t cnt, uint8_t * socklist); -void reg_httpServer_cbfunc(void(*mcu_reset)(void), void(*wdt_reset)(void)); - -void httpServer_run_avr(uint8_t seqnum); - -void reg_httpServer_webContent_avr(const uint8_t * content_name,const uint8_t * content); - -void reg_httpServer_binContent_avr(const uint8_t * content_name,const uint8_t * content, const uint32_t content_len); - -uint8_t find_userReg_webContent_avr(uint8_t * content_name, uint16_t * content_num, uint32_t * file_len); - -uint16_t read_userReg_webContent_avr(uint16_t content_num, uint8_t * buf, uint32_t offset, uint16_t size); - -uint8_t display_reg_webContent_list_avr(void); - -/* - * @brief HTTP Server 1sec Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void httpServer_time_handler(void); -uint32_t get_httpServer_timecount(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.c deleted file mode 100644 index 77c9a9d..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file httpUtil.c - * @brief HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -#include "httpUtil.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - - if(predefined_get_cgi_processor(uri_name, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - ; - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} - -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len) -{ - uint8_t ret = HTTP_OK; - uint16_t len = 0; - uint8_t val = 0; - - if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len)) - { - ; - } - else if(strcmp((const char *)uri_name, "example.cgi") == 0) - { - // To do - val = 1; - len = sprintf((char *)buf, "%d", val); - } - else - { - // CGI file not found - ret = HTTP_FAILED; - } - - if(ret) *file_len = len; - return ret; -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.h deleted file mode 100644 index f2c384a..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/Internet/httpServer_avr/httpUtil.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file httpUtil.h - * @brief Header File for HTTP Server Utilities - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __HTTPUTIL_H__ -#define __HTTPUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "httpServer.h" -#include "httpParser.h" - -uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len); -uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.htm b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.htm deleted file mode 100644 index c8c7178..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.htm +++ /dev/null @@ -1,43 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input - - - - - - - - - -
- - -
- -
- -
-
- - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.js b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.js deleted file mode 100644 index b5974d3..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain.js +++ /dev/null @@ -1,57 +0,0 @@ -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawgraph(o); -} -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} -function AinDrawgraph(o) -{ - var pin = o.ain_p; - var val = o.ain_v; - $('ain_v'+pin).style.width = val*500/1023+'px'; -} -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); setTimeout('getAin6_update()', 500); -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.htm b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.htm deleted file mode 100644 index ee671fb..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.htm +++ /dev/null @@ -1,27 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Analog Input Gauge - - - - - - - - - -
- - -
- - -
-
- - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.js b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.js deleted file mode 100644 index 7c309a7..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ain_gaug.js +++ /dev/null @@ -1,87 +0,0 @@ -google.load('visualization', '1', - { - packages:['gauge'] - } -); google.setOnLoadCallback(AinDrawGoogleGauge); - -function AinCallback(o) -{ - var pin = o.ain_p; - $('txtain_v'+pin).value = o.ain_v; - AinDrawGoogleGauge(o); -} - -function getAin(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); -} - -function AinDrawGoogleGauge(o) -{ - var val = o.ain_v; - //var temp_val = Number(((((val*3300)/1023)-500)/10).toFixed(2)); - var temp_val = Number(val); //here in range 0..1023 - if(isNaN(temp_val)) temp_val = 0; - var data = google.visualization.arrayToDataTable([['Label', 'Value'],['ADC6', 80]]); - var options = - { - width: 400, - height: 120, - max: 1023, - min: 0, - greenFrom: 0, - greenTo: 512, - redFrom: 918, - redTo: 1023, - yellowFrom: 714, - yellowTo: 918, - majorTicks: ['0', '512', '1023'], - minorTicks: 5 - }; - var chart = new google.visualization.Gauge(document.getElementById('chart_div')); - data.setValue(0, 1, temp_val); - chart.draw(data, options); -} - -function getAin6_update() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_ain6.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getAin6_update()', 500); -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ajax.js b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ajax.js deleted file mode 100644 index 01c6bb7..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/ajax.js +++ /dev/null @@ -1,68 +0,0 @@ -function AJAX(a, e) -{ - var c = d(); - c.onreadystatechange = b; - function d() - { - if(window.XMLHttpRequest) - { - return new XMLHttpRequest() - } - else - { - if(window.ActiveXObject) - { - return new ActiveXObject("Microsoft.XMLHTTP") - } - } - } - function b() - { - if(c.readyState==4) - { - if(c.status==200) - { - if(e) - { - e(c.responseText) - } - } - } - } - this.doGet = function() - { - c.open("GET", a, true); c.send(null) - }; - this.doPost = function(f) - { - c.open("POST", a, true); - c.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - c.setRequestHeader("ISAJAX", "yes"); - c.send(f) - } -} -function $(a) -{ - return document.getElementById(a) -} -function $$(a) -{ - return document.getElementsByName(a) -} -function $$_ie(a, c) -{ - if(!a) - { - a = "*" - } - var b = document.getElementsByTagName(a); - var e = []; for(var d = 0; d - - - - W5500-AtMEGA1284p Web Server Digital I/O v1.1 - - - - - - - - -

LED1: unknown..

- -
- -
-
- - - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/dio.js b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/dio.js deleted file mode 100644 index 5d1d164..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/dio.js +++ /dev/null @@ -1,93 +0,0 @@ -function DioCallback(o) -{ - var pin = o.dio_p; - $('txtdio_s'+pin).value = o.dio_s; - $('txtdio_d'+pin).value = o.dio_d; -} -function led1Callback(o) -{ - $('led1_txt').innerHTML = o.led1_txt; -} -function getDio(o) -{ - var p = o.attributes['pin'].value; - var oUpdate; - oUpdate = new AJAX('get_dio'+p+'.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); -} -function setDiostate(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_s'+p).value;*/ - var v = o.attributes['s'].value; - dout = new AJAX('set_diostate.cgi', - function(t) - { - try - { - /*eval(t);*/ - document.getElementById('led1_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function setDiodir(o) -{ - var p = o.attributes['pin'].value; - /*var v=$('txtdio_d'+p).value;*/ - var v = o.attributes['d'].value; - dout = new AJAX('set_diodir.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - dout.doPost('pin='+p+'&val='+v); -} -function getled1() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_led1.cgi', - function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 300); - setTimeout('getled1()', 3000); -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/favicon.ico b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/favicon.ico deleted file mode 100644 index f63da06..0000000 Binary files a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/favicon.ico and /dev/null differ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/img.htm b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/img.htm deleted file mode 100644 index f609e83..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/img.htm +++ /dev/null @@ -1,14 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Image - - - - - - -
wizwebserver.png
- - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/index.htm b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/index.htm deleted file mode 100644 index 758f904..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/index.htm +++ /dev/null @@ -1,25 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server - - - - -
- W5500-AtMEGA1284p Web Server Demopage -

- Network Information
- Base64 Image Data
-
- Board Schematic
- Mounting Scheme
-
- Ex1> Digital I/O
- Ex2> Analog Input
- Ex3> Analog Input: Google Gauge Chart
-
- Device Information
- - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.htm b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.htm deleted file mode 100644 index fdc64f6..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.htm +++ /dev/null @@ -1,18 +0,0 @@ - - - - - W5500-AtMEGA1284p Device Info - - - - - - -
- W5500-AtMEGA1284p Device Information -

-

..

- diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.js b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.js deleted file mode 100644 index 145be40..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/info.js +++ /dev/null @@ -1,21 +0,0 @@ -function getInfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_info.cgi', function(t) - { - try - { - //*eval(t); - document.getElementById('info_txt').innerHTML = t; - } - catch(e) - { - alert(e); - } - } - ); oUpdate.doGet(); - } - , 300); setTimeout('getInfo()', 3000); -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/m1284p.png b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/m1284p.png deleted file mode 100644 index a6dc8a3..0000000 Binary files a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/m1284p.png and /dev/null differ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.htm b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.htm deleted file mode 100644 index 581ba6e..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.htm +++ /dev/null @@ -1,33 +0,0 @@ - - - - - W5500-AtMEGA1284p Web Server Network Info - - - - - - - -
- W5500-AtMEGA1284p Web Server Network Information -

- -
    -
  • - -
  • - -
  • - -
  • - -
  • -
- - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.js b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.js deleted file mode 100644 index ca5ca0a..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/WWW/netinfo.js +++ /dev/null @@ -1,37 +0,0 @@ -function NetinfoCallback(o) -{ - $('txtmac').value = o.mac; - $('txtip').value = o.ip; - $('txtgw').value = o.gw; - $('txtsn').value = o.sn; - $('txtdns').value = o.dns; - if(typeof(window.external)!='undefined') - { - obj = $$_ie('input', 'dhcp'); - } - else - { - obj = $$('dhcp'); - } -} -function getNetinfo() -{ - var oUpdate; - setTimeout(function() - { - oUpdate = new AJAX('get_netinfo.cgi', function(t) - { - try - { - eval(t); - } - catch(e) - { - alert(e); - } - } - ); - oUpdate.doGet(); - } - , 1500); -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/diskio.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ffconf.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/integer.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.c deleted file mode 100644 index 6097df6..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//FTPD user-pass -#ifdef FTPD_AUTH_EN -const char ftpd_user[] = "user1234"; -const char ftpd_pass[] = "open_sesame"; -#endif diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.h deleted file mode 100644 index 2a0cafd..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/globals.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Internet/httpServer_avr/httpParser.h" -FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - - -#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -//FTP Server IP (look at ) -//extern uint8_t FTP_SRV_destip[4]; - - -//#define _MAX_SS_FTP 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTP 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough - -//#define _MAX_SS_FTPD 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTPD 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough -#define _MAX_SS_FTPD _MAX_SS - -//Enable BootLoader Running -#define BOOT_EN -//Disable BootLoader Running -//#undef BOOT_EN - -//Enable Bootloader debug message -#define BOOT_DEBUG -//Disable Bootloader debug message -//#undef BOOT_DEBUG - -//Enabled FTPD authorize -#define FTPD_AUTH_EN - -#ifdef FTPD_AUTH_EN -extern const char ftpd_user[]; -extern const char ftpd_pass[]; -#endif - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define SPRINTF(__S, FORMAT, args...) sprintf_P(__S, PSTR(FORMAT),##args) - -#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); -extern char uart0_receive(void); -extern void uart0_rx_flash(void); -extern void ls_dir(char* path); -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -//#include "Application/loopback/loopback.h" -#include "Internet/httpServer_avr/httpServer.h" -#include "Internet/FTPServer_avr/ftpd.h" - -uint8_t gFTPBUF[_MAX_SS_FTPD]; //512 bytes - -/* - * (17) Combine together (16) + abilities to enter BootLoader (reset with WDT), - * when occur event upload via FTPD to SD file with name <1284BOOT.BIN> (see STOR_CMD into ) - * TODO: - * OK (v1.2) - * OK (v1.2a) Some minor changes, added key - * OK (v1.2b) Some minor changes - * OK (v1.2d) Changed bootable image to 1284BOOT.BIN - * OK (v1.2e) Add FTPD authorization abilities (look FTPD_AUTH_EN in globals.h/globals.c) - * Notes. - * Works in pair with BootLoader project: - * Also see to set correct fuses - * - * (16) HTTPD + FTPD + FATFS SDCARD - trying combine together projects: - * <12_m1284p_WIZNET_HTTPServer_SDCARD_pages_v2.4d> + <15_m1284p_WIZNET_FTPD_FATFS_v1.4> - * TODO: - * OK (v1.0)1. Initial realize with some minor optimization - * OK (v1.1)2. Add additional 60sec timer - for and events - * - * (15) FTP Server +FATFS SDCARD (PC-side checked on Win7 / WIN7 (console client)) - * TODO: - * OK (v1.1) 1. doesn't work properly on WinSCP, but WIN7 ftp command OK. - Fix it (in first approach with fake data show first ~45 elements from root SD-CARD FTPD) - * Works with WinSCP put/get/delete/refresh - Marvelous! - * PS. Checked work with the next FTP clients (WIN7): - * WINSCP, - * ftp - native WIN7 (terminal-style), - * TotalCommander - need to add new type server with the next template: d ? SSSSSSSSS TTT DD YYYY nnnnnnnnnnnn - * - * OK (v1.1) 2. WIN7 ftp (i.e. downloading file from FTPD SDCARD-device to PC, see ) - works but after download file, progress line still filling ~ 3-5 sec. - Fix it. - * OK (v1.1) 3. WIN7 ftp (i.e. uploading file from PC to FTPD SDCARD-device, see ) - not work properly, device just reboot. - Fix it. - * OK (v1.2) 4. RAM usage optimize : - * OK (v1.1) A) printf(..) change to PRINTF(..) (i.e. printf_P(..)) - * OK (v1.2) B) sprintf(..) change to SPRINTF(..) (i.e. sprintf_P(..)) - Save ~ 900 bytes RAM - * 5. Optimize : - * OK (v1.3) A) To show ALL elements add inside -send(DATA_SOCK, dbuf, size); in portion by 10 elements - until All elements being sent - * OK (v1.3) B) Show real DATE(without TIME) of file from SD-CARD FTPD (Show only DATE without TIME (time showed with error, to show correct need to implement MLST and LMSD extension commands, defined in RFC 3659 )) - * OK (v1.3) C) Try decrease: gFTPBUF[_MAX_SS_FTPD]; //512 bytes - for save RAM resources (optional) - * OK (v1.4) Fix <_FTP_DEBUG_> in undefined state (at ftpd.c), further optimize (at ftpd.c) - * - * (14) FTP client (Active) +FATFS SDCARD (PC-side checked on Win7 ) - * Notes: tested only Active mode with ASCII type (Not sure that PASV mode works properly..). - * TODO: - * OK 1. Without exist FTP server (PC side), device reset always (decide not fix yet..) - * OK 2. <1> command (ls FTP server contents) received no more then _MAXX_SS(512) bytes - need to fix - * Full implement Done with _MAX_SS_FTP=512 checked on ~35 elements show OK (~2362 bytes received) - * !!Below is deprecated decision (read above)!! - * Change at ftpc: _MAX_SS (512 bytes) to _MAX_SS_FTP (2048 bytes - defined at ) - now show OK ~ 25-30 elements from FTPD directory - * (to full implement need fix at: -~355 line - if(gDataPutGetStart){ - switch(Command.Second){ - case s_dir: - PRINTF("dir waiting...\r\n"); - if((size = getSn_RX_RSR(DATA_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur. - PRINTF("ok\r\n"); - memset(dbuf, 0, _MAX_SS_FTP); - if(size > _MAX_SS_FTP) size = _MAX_SS_FTP - 1; - ret = recv(DATA_SOCK,dbuf,size); - * - * ) - * OK 3. <2> command (ls client side FATFS SDCARD contents)file name is empty (problem in scan_files()) - need to fix - * OK 4. Auto-login to anonymous(pass:1234) for test purposes (look at - Responses [R_220/R_331] ) - * OK 5. Add serial terminal session commands (look at ): - * . Test Message - * . Sta (uptime and freeram) - * . Reboot the board - * - * OK 6. Fix baud-rate issue on 115200bps 16Mhz - * OK 7. Add reaction on after not correct authorization - * (Add at - Responses R_530) - Reboot the board - * OK 8. Test and fix command: 5> Put File to Server (checked only active mode(passive not tested)) - * OK 9. Test and fix command: 6> Get File from Server - * OK 10. Add command: 8> Delete File from FTP server - * OK 11.Try add abilities to execute custom FTP server command. (Something like NOOP, HELP etc..) - * OK 12. Disable PASV mode (Tested - with bugs) - * - * - * (3) WIZNET loopback + FATFS (as template) - * + Added FATFS init (from <02_m1284p_FATFS_Chang_tst>), - * Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~12.2018..01.2019 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days -#ifdef BOOT_EN -volatile unsigned char sig_reset_board; // Flag to reset board -#endif -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.2e BootLoaded HTTPD and FTPD servers && FATFS SDCARD WIZNET_5500 ETHERNET 15/02/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* UART0 Baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); - - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} - -//Blocking read UART RX (need for FTP Client) -char uart0_receive(void) -{ - unsigned int c; - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - //Suppress NEW LINE (It harm dialog with FTP server) - if((char)c != '\n') - { - uart_putc((char)c); - return (char)c ; - } - else - { - c = UART_NO_DATA; - } - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -#ifdef BOOT_EN -void fatfs_delete(const char * fn) -{ - FRESULT fr; - FILINFO fno; - - - fr = f_stat(fn, &fno); - switch (fr) { - - case FR_OK: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER: File <%s> is exist, so remove it.. ", fn); -#endif - fr = f_unlink(fn); -#ifdef BOOT_DEBUG - if(fr == FR_OK) - { - PRINTF(" OK\r\n"); - } - else - { - PRINTF(" ERROR\r\n"); - } -#endif - break; - - default: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER. File <%s> isn't exist..\r\n", fn); -#endif - break; - } -} -#endif - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -int main() -{ -#ifdef BOOT_EN - sig_reset_board = 0; // CLear flag to reset board -#endif - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - -#ifdef BOOT_EN - //Delete <1284BOOT.BIN> for BootLoader working properly - fatfs_delete("1284BOOT.BIN"); - //Test message - PRINTF("\r\n++Test message from new code #11\r\n"); -#endif - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//TODO: Add here FTP server initialize -#if defined(F_APP_FTP) - ftpd_init(netInfo.ip); -#endif -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - //In this demo all www content saved onto SD-Card (you must copy all from folder to ROOT SD-Card) -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - uint32_t timer_httpd_1sec = millis(); - uint32_t timer_uptime_60sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - } - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - //TODO: Add here FTP server instance -#if defined(F_APP_FTP) - ftpd_run(gFTPBUF); -#endif - - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - /* - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - */ - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - - } // End of user's code - - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - -#ifdef BOOT_EN - //Check signal to reset board (with additional pause 2-3 sec, to close ftp STOR transaction) - if(sig_reset_board) - { - - if(sig_reset_board++ > 3) - { - //If signal raised (3 sec) - reset the board (via WDT) to enter BootLoader - while(1) - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - _delay_ms(1000); - - } - } - else - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - } - } -#endif - //Check ETHERNET PHY link - //Shouldn't used here, LED1 handle via HTTPD - /* - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - /*/ - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - //PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - PRINTF("SW1 is pressed, Reboot the board..\r\n"); - while(1); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - } - - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/spi.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.c b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.c deleted file mode 100644 index 2ab80e2..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.c +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file userHandler.c - * @brief User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#include -#include -#include -//#include "board.h" -#include "httpUtil.h" -#include "userHandler.h" -//#include "adcHandler.h" -#include "wizchip_conf.h" -#include "globals.h" - -/* Unavailable Pins (W5500-EVB component preempted) */ -// >> UART Rx/Tx : D0 (Rx), D1 (Tx) -// >> W5500 SPI(SPI0) : D11 (MOSI), D12 (MISO), D13 (SCK) - -/* On-board Devices */ -// >> Input : D14 (SW1) / D15 (SW2) -// >> Input : AIN (Potentiometer / TEMP.Sensor) -// >> Output : D8 (LED R) / D9 (LED G) / D10 (LED B) - -/* NXP LPC11Exx GPIO functions */ -// GPIO: Pin state -//Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); -//Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); - -// GPIO: Pin direction -//Chip_GPIO_GetPinDIR((LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -//Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); - -// Pre-defined Get CGI functions -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin); -void make_json_netinfo(uint8_t * buf, uint16_t * len); -void make_json_led1(uint8_t * buf, uint16_t * len); -void make_info(uint8_t * buf, uint16_t * len); - -// Pre-defined Set CGI functions -int8_t set_diodir(uint8_t * uri); -int8_t set_diostate(uint8_t * uri); - -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len) -{ - //return 0; //Just a stub, not used yet.. - //uint8_t ret = 1; // ret = 1 means 'uri_name' matched - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched - uint8_t cgibuf[14] = {0, }; - int8_t cgi_dio = -1; - int8_t cgi_ain = -1; - - uint8_t i; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { -// // to do -// ;//make_json_todo(buf, len); - } - else if(strcmp_P((const char *)uri_name,PSTR("get_netinfo.cgi")) == 0) - { - make_json_netinfo(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_led1.cgi")) == 0) - { - make_json_led1(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else if(strcmp_P((const char *)uri_name,PSTR("get_info.cgi")) == 0) - { - make_info(buf, len); - ret = 1; // ret = 1 means 'uri_name' matched - } - else - { -// // get_dio0.cgi ~ get_dio15.cgi -// for(i = 0; i < DIOn; i++) -// { -// memset(cgibuf, 0x00, 14); -// sprintf((char *)cgibuf, "get_dio%d.cgi", i); -// if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) -// { -// make_json_dio(buf, len, i); -// cgi_dio = i; -// break; -// } -// } -// -// if(cgi_dio < 0) - //Analog Ins reading get_ain0.cgi ~ get_ain7.cgi - if(1) - { - // get_ain0.cgi ~ get_ain5.cgi (A0 - A5), get_ain6.cgi for on-board potentiometer / Temp.Sensor - LPC11Exx - //for(i = 0; i < AINn; i++) //for LPC11xx - for(i = 0; i < 8; i++) //for AVR Mega1284p, available AIN0..AIN7 - { - memset(cgibuf, 0x00, 14); - sprintf((char *)cgibuf, "get_ain%d.cgi", i); - if(strcmp((const char *)uri_name, (const char *)cgibuf) == 0) - { - make_json_ain(buf, len, i); - cgi_ain = i; - ret = 1; - break; - } - } - } - -// if((cgi_dio < 0) && (cgi_ain < 0)) ret = 0; - } - - return ret; -} - - -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len) -{ -// return 0; //Just a stub, not used yet.. - uint8_t ret = 0; // ret = 0 means 'uri_name' not matched -// uint8_t ret = 1; // ret = '1' means 'uri_name' matched - uint8_t val = 0; - - if(strcmp_P((const char *)uri_name,PSTR("todo.cgi")) == 0) - { - // to do - ;//val = todo(uri); - //*len = sprintf((char *)buf, "%d", val); - } -// // Digital I/O; dio_s, dio_d -// else if(strcmp_P((const char *)uri_name,PSTR("set_diodir.cgi")) == 0) -// { -// //val = set_diodir(uri); -// //printf_P(PSTR("+++set_diodir.cgi uri_name: %s; uri: %s;\r\n")); -// *len = sprintf_P((char *)buf, PSTR("%d"), val); -// ret = 1; -// } - else if(strcmp((const char *)uri_name, "set_diostate.cgi") == 0) - { - //When uri_name=set_diostate.cgi, and uri HTTP POST request which contains something like: - //pin=8&val=1; or pin=8&val=1; (look && ) - - /* - This is LPC11xx handler - val = set_diostate(uri); - len = sprintf((char *)buf, "%d", val); - len ret = 1; - */ - - -#ifdef _USER_HANDLER_DEBUG_ - PRINTF("\r\n+++set_diostate.cgi uri_name: %s\r\nuri: %s\r\n", uri_name, uri); -#endif - //Parse URI (Very dirty!!) - if(strstr_P(uri,PSTR("pin=LED1&val=0"))) - { - led1_low(); - *len = sprintf_P((char *)buf, PSTR("LED1: OFF")); - ret = 1; - } - else if(strstr_P(uri,PSTR("pin=LED1&val=1"))) - { - led1_high(); - *len = sprintf_P((char *)buf, PSTR("LED1: ON")); - ret = 1; - } - else - { - //*len = sprintf_P((char *)buf, PSTR("%d"), -1); - *len = sprintf_P((char *)buf, PSTR("???")); - ret = 1; - } - } -// else -// { -// ret = 0; -// } -// - return ret; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Get CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin) -//{ -// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -// -// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\ -// \"dio_s\":\"%d\",\ -// \"dio_d\":\"%d\"\ -// });", -// pin, // Digital io pin number -// pin_state, // Digital io status -// pin_dir // Digital io directions -// ); -//} -// -void make_json_led1(uint8_t * buf, uint16_t * len) -{ - if(led1_read()) - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: ON\"});")); //Send back LED1 state via call-back function - } - else - { - *len = sprintf_P((char *)buf,PSTR( "led1Callback({\"led1_txt\":\"LED1: OFF\"});")); //Send back LED1 state via call-back function - } - -} - -void make_info(uint8_t * buf, uint16_t * len) -{ - /* - * Send program metrics: - * Program name - * time-date compile - * MCU info - * free ram info - * uptime device - */ - *len = sprintf_P((char *)buf,PSTR(\ - "
%S"\
-			"Compiled at: %S %S\r\n"\
-			"MCU is: %S; CLK is: %luHz\r\n"\
-			"Free RAM: %dbytes\r\n"\
-			"Uptime: %lusec\r\n
"),\ - str_prog_name,\ - compile_time, compile_date,\ - str_mcu, F_CPU,\ - freeRam(),\ - millis()/1000); -} - -void make_json_ain(uint8_t * buf, uint16_t * len, uint8_t pin) -{ - *len = sprintf_P((char *)buf,PSTR( "AinCallback({\"ain_p\":\"%d\",\ - \"ain_v\":\"%d\"\ - });"), - pin, // ADC input pin number - //get_ADC_val(pin) // ADC input value for LPC11xx - adc_read(pin) // ADC input value for AVR - ); -} - -void make_json_netinfo(uint8_t * buf, uint16_t * len) -{ - wiz_NetInfo netinfo; - ctlnetwork(CN_GET_NETINFO, (void*) &netinfo); - - // DHCP: 1 - Static, 2 - DHCP - *len = sprintf_P((char *)buf,PSTR( "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\ - \"ip\":\"%d.%d.%d.%d\",\ - \"gw\":\"%d.%d.%d.%d\",\ - \"sn\":\"%d.%d.%d.%d\",\ - \"dns\":\"%d.%d.%d.%d\",\ - \"dhcp\":\"%d\"\ - });"), - netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5], - netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3], - netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3], - netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3], - netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3], - netinfo.dhcp - ); -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined Set CGI functions -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//int8_t set_diodir(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // Direction; NotUsed/Input/Output -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > Output) val = Output; -// } -// } -// -// if(val == Input) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input -// else Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -// -// return pin; -//} -// -//int8_t set_diostate(uint8_t * uri) -//{ -// uint8_t * param; -// uint8_t pin = 0, val = 0; -// -// if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15 -// { -// pin = (uint8_t)ATOI(param, 10); -// if(pin > 15) return -1; -// -// if((param = get_http_param_value((char *)uri, "val"))) // State; high(on)/low(off) -// { -// val = (uint8_t)ATOI(param, 10); -// if(val > On) val = On; -// } -// -// if(val == On) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High -// else Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -// } -// -// return pin; -//} diff --git a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.h b/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.h deleted file mode 100644 index dded54a..0000000 --- a/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/userHandler.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file userHandler.h - * @brief Header File for User Control Example - * @version 1.0 - * @date 2014/07/15 - * @par Revision - * 2014/07/15 - 1.0 Release - * @author - * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved. - */ - -#ifndef __USERHANDLER_H -#define __USERHANDLER_H - -#include -//#define _USER_HANDLER_DEBUG_ - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Public Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pre-defined CGI Interface Functions Handler -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len); -uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len); - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP GET Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// HTTP POST Method CGI Functions -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// to do - - -#endif - diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.cproject b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.cproject deleted file mode 100644 index bf504d8..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.cproject +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.project b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.project deleted file mode 100644 index 318201c..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded deleted file mode 100644 index 71ddb3c..0000000 Binary files a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded and /dev/null differ diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded.readme b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded.readme deleted file mode 100644 index 202c088..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded.readme +++ /dev/null @@ -1,18 +0,0 @@ -Synopsis: -1284BOOT.BIN.bootloaded - precompiled binary for use with bootloader zevero for m1284p - -IP specs in this binary: -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration - -How to use: -Just copy 1284BOOT.BIN.bootloaded to root SD-card (FAT32 FS) as 1284BOOT.BIN, -then insert SD-card into m1284p system (with bootloader zevero flashed before), -and reboot m1284p system. - -maxxir -23.03.2019 10:27:11 diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h deleted file mode 100644 index 5a3a7d9..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../../globals.h" -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE ETH_LOOPBACK_MAX_BUF_SIZE -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c deleted file mode 100644 index a1621d7..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c +++ /dev/null @@ -1,1304 +0,0 @@ -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.c -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : FTP daemon. (AVR-GCC Compiler) -*/ - -#include -#include -#include -#include -#include -//#include "stdio_private.h" -#include "socket.h" -#include "ftpd.h" - -/* Command table */ -static char *commands[] = { - "user", - "acct", - "pass", - "type", - "list", - "cwd", - "dele", - "name", - "quit", - "retr", - "stor", - "port", - "nlst", - "pwd", - "xpwd", - "mkd", - "xmkd", - "xrmd", - "rmd ", - "stru", - "mode", - "syst", - "xmd5", - "xcwd", - "feat", - "pasv", - "size", - "mlsd", - "appe", - NULL -}; - -#if 0 -/* Response messages */ -char banner[] = "220 %s FTP version %s ready.\r\n"; -char badcmd[] = "500 Unknown command '%s'\r\n"; -char binwarn[] = "100 Warning: type is ASCII and %s appears to be binary\r\n"; -char unsupp[] = "500 Unsupported command or option\r\n"; -char givepass[] = "331 Enter PASS command\r\n"; -char logged[] = "230 Logged in\r\n"; -char typeok[] = "200 Type %s OK\r\n"; -char only8[] = "501 Only logical bytesize 8 supported\r\n"; -char deleok[] = "250 File deleted\r\n"; -char mkdok[] = "200 MKD ok\r\n"; -char delefail[] = "550 Delete failed: %s\r\n"; -char pwdmsg[] = "257 \"%s\" is current directory\r\n"; -char badtype[] = "501 Unknown type \"%s\"\r\n"; -char badport[] = "501 Bad port syntax\r\n"; -char unimp[] = "502 Command does not implemented yet.\r\n"; -char bye[] = "221 Goodbye!\r\n"; -char nodir[] = "553 Can't read directory \"%s\": %s\r\n"; -char cantopen[] = "550 Can't read file \"%s\": %s\r\n"; -char sending[] = "150 Opening data connection for %s (%d.%d.%d.%d,%d)\r\n"; -char cantmake[] = "553 Can't create \"%s\": %s\r\n"; -char writerr[] = "552 Write error: %s\r\n"; -char portok[] = "200 PORT command successful.\r\n"; -char rxok[] = "226 Transfer complete.\r\n"; -char txok[] = "226 Transfer complete.\r\n"; -char noperm[] = "550 Permission denied\r\n"; -char noconn[] = "425 Data connection reset\r\n"; -char lowmem[] = "421 System overloaded, try again later\r\n"; -char notlog[] = "530 Please log in with USER and PASS\r\n"; -char userfirst[] = "503 Login with USER first.\r\n"; -char okay[] = "200 Ok\r\n"; -char syst[] = "215 %s Type: L%d Version: %s\r\n"; -char sizefail[] = "550 File not found\r\n"; -#endif - -un_l2cval remote_ip; -uint16_t remote_port; -un_l2cval local_ip; -uint16_t local_port; -uint8_t connect_state_control = 0; -uint8_t connect_state_data = 0; - -struct ftpd ftp; - -int current_year = 2014; -int current_month = 12; -int current_day = 31; -int current_hour = 10; -int current_min = 10; -int current_sec = 30; - -//int fsprintf(uint8_t s, const char *format, ...) -//{ -// int i; -///* -// char buf[LINELEN]; -// FILE f; -// va_list ap; -// -// f.flags = __SWR | __SSTR; -// f.buf = buf; -// f.size = INT_MAX; -// va_start(ap, format); -// i = vfprintf(&f, format, ap); -// va_end(ap); -// buf[f.len] = 0; -// -// send(s, (uint8_t *)buf, strlen(buf)); -//*/ -// return i; -//} - -void ftpd_init(uint8_t * src_ip) -{ - ftp.state = FTPS_NOT_LOGIN; - ftp.current_cmd = NO_CMD; - ftp.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - - strcpy(ftp.workingdir, "/"); - - socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0); -} - -/* - * From: FatFs - FAT file system module R0.10c - */ -int get_filesize(char* path, char *filename) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i, len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ -#if _USE_LFN - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - if(*path == 0x00) - res = f_opendir(&dir, "/"); - else - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - for(;;){ - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - if(!strcmp(fn, filename)) - { - if(fno.fattrib & AM_DIR){ - //printf("\r\n%s/%s is a directory\r\n", path, filename); - return 0; - } - return fno.fsize; - } - } - //printf("\r\n%s/%s was not found\r\n", path, filename); - //f_closedir(&dir); - } - return -1; -} - -/* - * Inserted from earlier realize FAT FS -> - * FAT file system module R0.10c (C)ChaN, 2014 - */ -/* - * Preferable structure of out see here: - * https://files.stairways.com/other/ftp-list-specs-info.txt - * - * something like: - -rw------- 1 peter 848 Dec 14 11:22 00README.txt -or - - whatever you feel like 848 Dec 14 11:22 00README.txt - - * also - * http://cr.yp.to/ftp/list/binls.html - * -/bin/ls format is a series of lines terminated by \015\012. Servers using /bin/ls format need to be prepared to generate lines in the following form: - - -rw-r--r-- 1 owner group 213 Aug 26 16:31 README - -The line contains - - - for a regular file or d for a directory; - the literal string rw-r--r-- 1 owner group for a regular file, or rwxr-xr-x 1 owner group for a directory; - the file size in decimal right-justified in a 13-byte field; - a three-letter month name, first letter capitalized; - a day number right-justified in a 3-byte field; - a space and a 2-digit hour number; - a colon and a 2-digit minute number; - a space and the abbreviated pathname of the file. - */ -FRESULT scan_files(char* path, char *buf, int * items_count) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i; - int len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ - char date_str[21]; - int date_str_ptr = 0; - int file_read_count = 0; - int file_read_count_10 = 0; - uint16_t size_dbuf = 0; -#if _USE_LFN == 1 - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - i = strlen(path); - //printf("strlen of path: %s %d \r\n", path, i); - for(;;){ - wdt_reset(); - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN == 1 - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; - - //Print out yet only first 30 files for full info - //if(file_read_count > 30) - //Print out yet only first 45 files for short info - /* - if(file_read_count > 45) - { - break; - } - */ - //!!Debug only - file_read_count++; -#if defined(_FTP_DEBUG_) - PRINTF("%02u:%9lu %s\r\n", (file_read_count+file_read_count_10), fno.fsize, fn); -#endif -#endif - //Encode date file like this (time show no correct, so remove): - //Aug 26 2018 - switch((fno.fdate >> 5) & 0x0f) - { - case 1: - len = SPRINTF(date_str, "JAN "); - break; - case 2: - len = SPRINTF(date_str, "FEB "); - break; - case 3: - len = SPRINTF(date_str, "MAR "); - break; - case 4: - len = SPRINTF(date_str, "APR "); - break; - case 5: - len = SPRINTF(date_str, "MAY "); - break; - case 6: - len = SPRINTF(date_str, "JUN "); - break; - case 7: - len = SPRINTF(date_str, "JUL "); - break; - case 8: - len = SPRINTF(date_str, "AUG "); - break; - case 9: - len = SPRINTF(date_str, "SEP "); - break; - case 10: - len = SPRINTF(date_str, "OCT "); - break; - case 11: - len = SPRINTF(date_str, "NOV "); - break; - case 12: - len = SPRINTF(date_str, "DEC "); - break; - } - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%2d ", (fno.fdate & 0x1f)); - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%d ", (((fno.fdate >> 9) & 0x7f) + 1980)); - //Time show not correct, so remove - /* - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%02u:%02u", (fno.ftime >> 11), (fno.ftime >> 5) & 63); - */ - date_str_ptr = 0; - - //printf("date str : %s \r\n", date_str); - - //Directory or file prefix - if(fno.fattrib & AM_DIR) - { - SPRINTF(buf + buf_ptr, "d"); - }else - { - SPRINTF(buf + buf_ptr, "-"); - } - buf_ptr++; - //Should not use here - /* - // drwxr-xr-x 1 ftp ftp 0 Apr 07 2014 $RECYCLE.BIN\r\n - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %u %s %s\r\n", fno.fsize, date_str, fn); - - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %s\r\n", fn); - - - //len = sprintf(buf + buf_ptr, " %6lu %s\r\n",fno.fsize, fn);// - Good minimum, but not seen on WinSCP - - - //len = sprintf(buf + buf_ptr, " %s\r\n", fn);// - Good minimum, but not seen on WinSCP - */ - - //Full with fake data - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) - - //Short without access rights and owner with fake data - /* - len = SPRINTF(buf + buf_ptr, " 1 %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) without access rights and owner - */ - - //Medium with real data file, without access rights and owner - len = SPRINTF(buf + buf_ptr, " 1 %9lu %s %s\r\n", fno.fsize, date_str, fn); //- Works on WinSCP with real data (OK) without access rights and owner - - buf_ptr += len; - - if(file_read_count > 9) - { - //Send out info about files in 10 items maximum - file_read_count = 0; - file_read_count_10 += 10; - //*buf_len = strlen(buf); - - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - - buf_ptr = 0; - - } - - //printf("fn: %s \r\n", fn); - - } - //Send out last packet with files numbers 1..9 - if(file_read_count) - { - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - } - - //*buf_len = strlen(buf); - *items_count = file_read_count + file_read_count_10; //Return number of sending file - //printf("%s", buf); - //printf("\r\nbuf_len : %d, sizeof(buf): %d\r\n", buf_len, sizeof(buf)); - f_closedir(&dir); - } - return res; -} - -uint8_t ftpd_run(uint8_t * dbuf) -{ - uint16_t size = 0, i; - long ret = 0; - uint32_t blocklen, send_byte, recv_byte; - uint32_t remain_filesize; - uint32_t remain_datasize; -#if defined(F_FILESYSTEM) - //FILINFO fno; -#endif - - //memset(dbuf, 0, sizeof(_MAX_SS_FTPD)); - - switch(getSn_SR(CTRL_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_control) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Connected\r\n", CTRL_SOCK); -#endif - //fsprintf(CTRL_SOCK, banner, HOSTNAME, VERSION); - strcpy(ftp.workingdir, "/"); - SPRINTF((char *)dbuf, "220 %s FTP version %s ready.\r\n", HOSTNAME, VERSION); - ret = send(CTRL_SOCK, (uint8_t *)dbuf, strlen((const char *)dbuf)); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - connect_state_control = 1; - } - -#if defined(_FTP_DEBUG_) - //printf("ftp socket %d\r\n", CTRL_SOCK); -#endif - - if((size = getSn_RX_RSR(CTRL_SOCK)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { -#if defined(_FTP_DEBUG_) - PRINTF("size: %d\r\n", size); -#endif - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(size > _MAX_SS_FTPD) size = _MAX_SS_FTPD - 1; - - ret = recv(CTRL_SOCK,dbuf,size); - dbuf[ret] = '\0'; - if(ret != size) - { - if(ret==SOCK_BUSY) return 0; - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("Rcvd Command: %s", dbuf); -#endif - proc_ftpd((char *)dbuf); - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",CTRL_SOCK); -#endif - if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",CTRL_SOCK); -#endif - break; - - case SOCK_CLOSED : -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPStart\r\n",CTRL_SOCK); -#endif - if((ret=socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0)) != CTRL_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", CTRL_SOCK, ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",CTRL_SOCK); -#endif - //strcpy(ftp.workingdir, "/"); - if( (ret = listen(CTRL_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",CTRL_SOCK); -#endif - return ret; - } - connect_state_control = 0; - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",CTRL_SOCK); -#endif - break; - - default : - break; - } - -#if 1 - switch(getSn_SR(DATA_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_data) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Data socket Connected\r\n", DATA_SOCK); -#endif - connect_state_data = 1; - } - - switch(ftp.current_cmd) - { - case LIST_CMD: - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("previous size: %u\r\n", size); -#endif -#if defined(F_FILESYSTEM) - scan_files(ftp.workingdir, dbuf, (int *)&size); -#endif -#if defined(_FTP_DEBUG_) - PRINTF("Items count: %u\r\n", size); - //PRINTF("%s\r\n", dbuf); -#endif -#if !defined(F_FILESYSTEM) - if (strncmp(ftp.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0) - size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n"); -#endif - /* - size = strlen(dbuf); - send(DATA_SOCK, dbuf, size); - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - */ - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - break; - - case RETR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to retrieve : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_READ); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ - remain_filesize = ftp.fil.fsize; -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - do{ -#if defined(_FTP_DEBUG_) - //printf("remained file size: %d\r\n", ftp.fil.fsize); -#endif - wdt_reset(); - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_filesize > _MAX_SS_FTPD) - send_byte = _MAX_SS_FTPD; - else - send_byte = remain_filesize; - - - uint16_t _blocklen; - ftp.fr = f_read(&(ftp.fil), dbuf, send_byte ,&_blocklen); - if(ftp.fr != FR_OK) - break; -#if defined(_FTP_DEBUG_) - PRINTF("#"); - //printf("----->fsize:%d recv:%d len:%d \r\n", remain_filesize, send_byte, blocklen); - //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - uint32_t send_size; - send_size = send(DATA_SOCK, dbuf, _blocklen); - //remain_filesize -= blocklen; - remain_filesize -= send_size; - }while(remain_filesize != 0); -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile read finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } -#else - remain_filesize = strlen(ftp.filename); - - do{ - memset(dbuf, 0, _MAX_SS_FTPD); - - blocklen = sprintf(dbuf, "%s", ftp.filename); - - printf("########## dbuf:%s\r\n", dbuf); - - send(DATA_SOCK, dbuf, blocklen); - remain_filesize -= blocklen; - }while(remain_filesize != 0); - -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case STOR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to store : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_CREATE_ALWAYS | FA_WRITE); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - while(1){ - wdt_reset(); - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf,(uint16_t) recv_byte); -#if defined(_FTP_DEBUG_) - //PRINTF("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - - uint16_t _blocklen; - ftp.fr = f_write(&(ftp.fil), dbuf, (UINT)ret, &_blocklen); -#if defined(_FTP_DEBUG_) - //PRINTF("----->dsize:%lu recv:%lu len:%u \r\n", remain_datasize, ret, _blocklen); -#endif - remain_datasize -= (uint32_t)_blocklen; - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - - if(remain_datasize <= 0) - break; - } - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - -#if defined(_FTP_DEBUG_) - PRINTF("#"); -#endif - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile write finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } - - //fno.fdate = (WORD)(((current_year - 1980) << 9) | (current_month << 5) | current_day); - //fno.ftime = (WORD)((current_hour << 11) | (current_min << 5) | (current_sec >> 1)); - //f_utime((const char *)ftp.filename, &fno); -#else - while(1){ - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf, recv_byte); - - printf("########## dbuf:%s\r\n", dbuf); - - remain_datasize -= ret; - - if(remain_datasize <= 0) - break; - } - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); -#ifdef BOOT_EN - if (strcasestr_P((const char *)ftp.filename, PSTR("1284BOOT.BIN"))) - { - //Found event "1284BOOT.BIN" upload to SD from FTPD, rise signal to running BootLoader (via WDT reset) -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>Catch <1284BOOT.BIN> upload event, so run BOOTLOADER\r\n"); -#endif - sig_reset_board = 1; - } -#endif - break; - - case NO_CMD: - default: - break; - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",DATA_SOCK); -#endif - if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",DATA_SOCK); -#endif - break; - - case SOCK_CLOSED : - if(ftp.dsock_state == DATASOCK_READY) - { - if(ftp.dsock_mode == PASSIVE_MODE){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[PASSIV_MODE], port : %u\r\n",DATA_SOCK, local_port); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - - local_port++; - if(local_port > 50000) - local_port = 35000; - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[ACTIVE_MODE], port : %u\r\n",DATA_SOCK, IPPORT_FTPD); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, IPPORT_FTPD, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - } - - ftp.dsock_state = DATASOCK_START; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",DATA_SOCK); -#endif - if(ftp.dsock_mode == PASSIVE_MODE){ - if( (ret = listen(DATA_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",DATA_SOCK); -#endif - return ret; - } - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",DATA_SOCK); -#endif - }else{ - - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#1\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { -#if defined(_FTP_DEBUG_) - PRINTF("DATA_SOCK Connect#1 OK\r\n"); -#endif - } - //Try to FIX STOR command - } - connect_state_data = 0; - break; - - default : - break; - } -#endif - - return 0; -} - -char proc_ftpd(char * buf) -{ - char **cmdp, *cp, *arg, *tmpstr; - char sendbuf[200]; - int slen; - long ret; - - - /* Translate first word to lower case */ - for (cp = buf; *cp != ' ' && *cp != '\0'; cp++) - *cp = tolower(*cp); - - /* Find command in table; if not present, return syntax error */ - for (cmdp = commands; *cmdp != NULL; cmdp++) - if (strncmp(*cmdp, buf, strlen(*cmdp)) == 0) - break; - - if (*cmdp == NULL) - { - //fsprintf(CTRL_SOCK, badcmd, buf); - slen = SPRINTF(sendbuf, "500 Unknown command '%s'\r\n", buf); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - /* Allow only USER, PASS and QUIT before logging in */ - if (ftp.state == FTPS_NOT_LOGIN) - { - switch(cmdp - commands) - { - case USER_CMD: - case PASS_CMD: - case QUIT_CMD: - break; - default: - //fsprintf(CTRL_SOCK, notlog); - slen = SPRINTF(sendbuf, "530 Please log in with USER and PASS\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - } - - arg = &buf[strlen(*cmdp)]; - while(*arg == ' ') arg++; - - /* Execute specific command */ - switch (cmdp - commands) - { - case USER_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("USER_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - strcpy(ftp.username, arg); - //fsprintf(CTRL_SOCK, givepass); - slen = SPRINTF(sendbuf, "331 Enter PASS command\r\n"); - ret = send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case PASS_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("PASS_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - ftplogin(arg); - break; - - case TYPE_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - switch(arg[0]) - { - case 'A': - case 'a': /* Ascii */ - ftp.type = ASCII_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case 'B': - case 'b': /* Binary */ - case 'I': - case 'i': /* Image */ - ftp.type = IMAGE_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badtype, arg); - slen = SPRINTF(sendbuf, "501 Unknown type \"%s\"\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - break; - - case FEAT_CMD : - slen = SPRINTF(sendbuf, "211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST size*;type*;create*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 END\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case QUIT_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("QUIT_CMD\r\n"); -#endif - //fsprintf(CTRL_SOCK, bye); - slen = SPRINTF(sendbuf, "221 Goodbye!\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(CTRL_SOCK); - break; - - case RETR_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("RETR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = sprintf(sendbuf, "150 Opening data channel for file downloand from server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = RETR_CMD; - break; - - case APPE_CMD : - case STOR_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("STOR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "150 Opening data channel for file upload to server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = STOR_CMD; - /* - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#2\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { - //!!Debug only!! - PRINTF("DATA_SOCK Connect#2 OK\r\n"); - } - */ - //Try to FIX STOR command - connect_state_data = 0; - break; - - case PORT_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("PORT_CMD\r\n"); -#endif - if (pport(arg) == -1){ - //fsprintf(CTRL_SOCK, badport); - slen = SPRINTF(sendbuf, "501 Bad port syntax\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } else{ - //fsprintf(CTRL_SOCK, portok); - ftp.dsock_mode = ACTIVE_MODE; - ftp.dsock_state = DATASOCK_READY; - slen = SPRINTF(sendbuf, "200 PORT command successful.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } - break; - - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("MLSD_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = MLSD_CMD; - break; - - case LIST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("LIST_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = LIST_CMD; - break; - - case NLST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("NLST_CMD\r\n"); -#endif - break; - - case SYST_CMD: - slen = SPRINTF(sendbuf, "215 UNIX emulated by WIZnet\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PWD_CMD: - case XPWD_CMD: - slen = SPRINTF(sendbuf, "257 \"%s\" is current directory.\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PASV_CMD: - slen = SPRINTF(sendbuf, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", local_ip.cVal[0], local_ip.cVal[1], local_ip.cVal[2], local_ip.cVal[3], local_port >> 8, local_port & 0x00ff); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(DATA_SOCK); - ftp.dsock_mode = PASSIVE_MODE; - ftp.dsock_state = DATASOCK_READY; -#if defined(_FTP_DEBUG_) - PRINTF("PASV port: %u\r\n", local_port); -#endif - break; - - case SIZE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = _MAX_SS_FTPD; -#endif - if(slen > 0) - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - else - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - else - { - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case CWD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - arg[slen - 3] = 0x00; - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = 0; -#endif - *tmpstr = '/'; - if(slen == 0){ - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - else - { - slen = SPRINTF(sendbuf, "550 CWD failed. \"%s\"\r\n", arg); - } - } - else - { - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case MKD_CMD: - case XMKD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_mkdir(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Can't create directory. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "257 MKD command successful. \"%s\"\r\n", arg); - //strcpy(ftp.workingdir, arg); - } -#else - slen = SPRINTF(sendbuf, "550 Can't create directory. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case DELE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_unlink(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Could not delete. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "250 Deleted. \"%s\"\r\n", arg); - } -#else - slen = SPRINTF(sendbuf, "550 Could not delete. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case XCWD_CMD: - case ACCT_CMD: - case XRMD_CMD: - case RMD_CMD: - case STRU_CMD: - case MODE_CMD: - case XMD5_CMD: - //fsprintf(CTRL_SOCK, unimp); - slen = SPRINTF(sendbuf, "502 Command does not implemented yet.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badcmd, arg); - slen = SPRINTF(sendbuf, "500 Unknown command \'%s\'\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - - return 1; -} - - -char ftplogin(char * pass) -{ - char sendbuf[100]; - int slen = 0; -#ifdef FTPD_AUTH_EN - if (!strcmp(ftp.username, ftpd_user)) - { - if (!strcmp(pass, ftpd_pass)) - { - - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in OK\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - return 1; - } - - } - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in ERROR\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "530 Login authentication failed\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_NOT_LOGIN; - return 0; -#else - //memset(sendbuf, 0, DATA_BUF_SIZE); - -#if defined(_FTP_DEBUG_) - PRINTF("%s logged in\r\n", ftp.username); -#endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - - return 1; -#endif -} - -int pport(char * arg) -{ - int i; - char* tok=0; - - for (i = 0; i < 4; i++) - { - if(i==0) tok = strtok(arg,",\r\n"); - else tok = strtok(NULL,","); - remote_ip.cVal[i] = (uint8_t)atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } - remote_port = 0; - for (i = 0; i < 2; i++) - { - tok = strtok(NULL,",\r\n"); - remote_port <<= 8; - remote_port += atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - - return 0; -} - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil) -{ -#if defined(_FTP_DEBUG_) - PRINTF("File System pointer : %08X\r\n", fil->fs); - PRINTF("File System mount ID : %d\r\n", fil->id); - PRINTF("File status flag : %08X\r\n", fil->flag); - PRINTF("File System pads : %08X\r\n", fil->err); - PRINTF("File read write pointer : %08X\r\n", fil->fptr); - PRINTF("File size : %08X\r\n", fil->fsize); - PRINTF("File start cluster : %08X\r\n", fil->sclust); - PRINTF("current cluster : %08X\r\n", fil->clust); - PRINTF("current data sector : %08X\r\n", fil->dsect); - PRINTF("dir entry sector : %08X\r\n", fil->dir_sect); - PRINTF("dir entry pointer : %08X\r\n", fil->dir_ptr); -#endif -} -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h deleted file mode 100644 index 8057eb9..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _FTPD_H_ -#define _FTPD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.h -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : Header file of FTP daemon. (AVR-GCC Compiler) -*/ - -#include - -#include "../../globals.h" //add AVR specific useful headers - -#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement. - -#if defined(F_FILESYSTEM) -#include "ff.h" -#endif - -#define F_APP_FTP -//#define _FTP_DEBUG_ - - -#define LINELEN 100 -//#define DATA_BUF_SIZE 100 -#if !defined(F_FILESYSTEM) -#define _MAX_SS 512 -#endif - -#define CTRL_SOCK 2 -#define DATA_SOCK 3 - -#define IPPORT_FTPD 20 /* FTP Data port */ -#define IPPORT_FTP 21 /* FTP Control port */ - -#define HOSTNAME "iinChip" -#define VERSION "1.0" - -#define FILENAME "a.txt" - -/* FTP commands */ -enum ftp_cmd { - USER_CMD, - ACCT_CMD, - PASS_CMD, - TYPE_CMD, - LIST_CMD, - CWD_CMD, - DELE_CMD, - NAME_CMD, - QUIT_CMD, - RETR_CMD, - STOR_CMD, - PORT_CMD, - NLST_CMD, - PWD_CMD, - XPWD_CMD, - MKD_CMD, - XMKD_CMD, - XRMD_CMD, - RMD_CMD, - STRU_CMD, - MODE_CMD, - SYST_CMD, - XMD5_CMD, - XCWD_CMD, - FEAT_CMD, - PASV_CMD, - SIZE_CMD, - MLSD_CMD, - APPE_CMD, - NO_CMD, -}; - -enum ftp_type { - ASCII_TYPE, - IMAGE_TYPE, - LOGICAL_TYPE -}; - -enum ftp_state { - FTPS_NOT_LOGIN, - FTPS_LOGIN -}; - -enum datasock_state{ - DATASOCK_IDLE, - DATASOCK_READY, - DATASOCK_START -}; - -enum datasock_mode{ - PASSIVE_MODE, - ACTIVE_MODE -}; - -struct ftpd { - uint8_t control; /* Control stream */ - uint8_t data; /* Data stream */ - - enum ftp_type type; /* Transfer type */ - enum ftp_state state; - - enum ftp_cmd current_cmd; - - enum datasock_state dsock_state; - enum datasock_mode dsock_mode; - - char username[LINELEN]; /* Arg to USER command */ - char workingdir[LINELEN]; - char filename[LINELEN]; - -#if defined(F_FILESYSTEM) - FIL fil; // FatFs File objects - FRESULT fr; // FatFs function common result code -#endif - -}; - -#ifndef un_I2cval -typedef union _un_l2cval { - uint32_t lVal; - uint8_t cVal[4]; -}un_l2cval; -#endif - -void ftpd_init(uint8_t * src_ip); -uint8_t ftpd_run(uint8_t * dbuf); -char proc_ftpd(char * buf); -char ftplogin(char * pass); -int pport(char * arg); - -int sendit(char * command); -int recvit(char * command); - -long sendfile(uint8_t s, char * command); -long recvfile(uint8_t s); - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil); -#endif - -#ifdef __cplusplus -} -#endif - -#endif // _FTPD_H_ diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h deleted file mode 100644 index 90c3a0d..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2002, Joerg Wunsch - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * Neither the name of the copyright holders nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - -//struct __file { -// char *buf; /* buffer pointer */ -// unsigned char unget; /* ungetc() buffer */ -// uint8_t flags; /* flags, see below */ -//#define __SRD 0x0001 /* OK to read */ -//#define __SWR 0x0002 /* OK to write */ -//#define __SSTR 0x0004 /* this is an sprintf/snprintf string */ -//#define __SPGM 0x0008 /* fmt string is in progmem */ -//#define __SERR 0x0010 /* found error */ -//#define __SEOF 0x0020 /* found EOF */ -//#define __SUNGET 0x040 /* ungetc() happened */ -//#if 0 -///* possible future extensions, will require uint16_t flags */ -//#define __SRW 0x0080 /* open for reading & writing */ -//#define __SLBF 0x0100 /* line buffered */ -//#define __SNBF 0x0200 /* unbuffered */ -//#define __SMBF 0x0400 /* buf is from malloc */ -//#endif -// int size; /* size of buffer */ -// int len; /* characters read or written so far */ -// int (*put)(char); /* function to write one char to device */ -// int (*get)(void); /* function to read one char from device */ -//}; - -/* values for PRINTF_LEVEL */ -#define PRINTF_MIN 1 -#define PRINTF_STD 2 -#define PRINTF_FLT 3 - -/* values for SCANF_LEVEL */ -#define SCANF_MIN 1 -#define SCANF_STD 2 -#define SCANF_FLT 3 - -#ifdef __cplusplus -} -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/diskio.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ffconf.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/integer.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.c deleted file mode 100644 index 6097df6..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//FTPD user-pass -#ifdef FTPD_AUTH_EN -const char ftpd_user[] = "user1234"; -const char ftpd_pass[] = "open_sesame"; -#endif diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.h b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.h deleted file mode 100644 index 2af0cd8..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -//#include "Internet/httpServer_avr/httpParser.h" -FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - -//Should not used here -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -//FTP Server IP (look at ) -//extern uint8_t FTP_SRV_destip[4]; - - -//#define _MAX_SS_FTP 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTP 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough - -//#define _MAX_SS_FTPD 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTPD 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough -#define _MAX_SS_FTPD _MAX_SS - -#define ETH_LOOPBACK_MAX_BUF_SIZE 512 - -//Enable BootLoader Running -#define BOOT_EN -//Disable BootLoader Running -//#undef BOOT_EN - -//Enable Bootloader debug message -#define BOOT_DEBUG -//Disable Bootloader debug message -//#undef BOOT_DEBUG - -//Enabled FTPD authorize -#define FTPD_AUTH_EN - -#ifdef FTPD_AUTH_EN -extern const char ftpd_user[]; -extern const char ftpd_pass[]; -#endif - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define SPRINTF(__S, FORMAT, args...) sprintf_P(__S, PSTR(FORMAT),##args) - -#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); -extern char uart0_receive(void); -extern void uart0_rx_flash(void); -extern void ls_dir(char* path); -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/FTPServer_avr/ftpd.h" - -uint8_t gFTPBUF[_MAX_SS_FTPD]; //512 bytes - -/* - * (18) Base template minimal for FTPD bootloaded application with TCP/IP loopback demo (m1284p) - * TODO: - * OK (v1.1) Add FTPD authorization abilities - * (17) Combine together (16) + abilities to enter BootLoader (reset with WDT), - * when occur event upload via FTPD to SD file with name <1284BOOT.BIN> (see STOR_CMD into ) - * TODO: - * OK (v1.2) - * OK (v1.2a) Some minor changes, added key - * OK (v1.2b) Some minor changes - * OK (v1.2d) Changed bootable image to 1284BOOT.BIN - * Notes. - * Works in pair with BootLoader project: - * Also see to set correct fuses - * - * (16) HTTPD + FTPD + FATFS SDCARD - trying combine together projects: - * <12_m1284p_WIZNET_HTTPServer_SDCARD_pages_v2.4d> + <15_m1284p_WIZNET_FTPD_FATFS_v1.4> - * TODO: - * OK (v1.0)1. Initial realize with some minor optimization - * OK (v1.1)2. Add additional 60sec timer - for and events - * - * (15) FTP Server +FATFS SDCARD (PC-side checked on Win7 / WIN7 (console client)) - * TODO: - * OK (v1.1) 1. doesn't work properly on WinSCP, but WIN7 ftp command OK. - Fix it (in first approach with fake data show first ~45 elements from root SD-CARD FTPD) - * Works with WinSCP put/get/delete/refresh - Marvelous! - * PS. Checked work with the next FTP clients (WIN7): - * WINSCP, - * ftp - native WIN7 (terminal-style), - * TotalCommander - need to add new type server with the next template: d ? SSSSSSSSS TTT DD YYYY nnnnnnnnnnnn - * - * OK (v1.1) 2. WIN7 ftp (i.e. downloading file from FTPD SDCARD-device to PC, see ) - works but after download file, progress line still filling ~ 3-5 sec. - Fix it. - * OK (v1.1) 3. WIN7 ftp (i.e. uploading file from PC to FTPD SDCARD-device, see ) - not work properly, device just reboot. - Fix it. - * OK (v1.2) 4. RAM usage optimize : - * OK (v1.1) A) printf(..) change to PRINTF(..) (i.e. printf_P(..)) - * OK (v1.2) B) sprintf(..) change to SPRINTF(..) (i.e. sprintf_P(..)) - Save ~ 900 bytes RAM - * 5. Optimize : - * OK (v1.3) A) To show ALL elements add inside -send(DATA_SOCK, dbuf, size); in portion by 10 elements - until All elements being sent - * OK (v1.3) B) Show real DATE(without TIME) of file from SD-CARD FTPD (Show only DATE without TIME (time showed with error, to show correct need to implement MLST and LMSD extension commands, defined in RFC 3659 )) - * OK (v1.3) C) Try decrease: gFTPBUF[_MAX_SS_FTPD]; //512 bytes - for save RAM resources (optional) - * OK (v1.4) Fix <_FTP_DEBUG_> in undefined state (at ftpd.c), further optimize (at ftpd.c) - * - * (14) FTP client (Active) +FATFS SDCARD (PC-side checked on Win7 ) - * Notes: tested only Active mode with ASCII type (Not sure that PASV mode works properly..). - * TODO: - * OK 1. Without exist FTP server (PC side), device reset always (decide not fix yet..) - * OK 2. <1> command (ls FTP server contents) received no more then _MAXX_SS(512) bytes - need to fix - * Full implement Done with _MAX_SS_FTP=512 checked on ~35 elements show OK (~2362 bytes received) - * !!Below is deprecated decision (read above)!! - * Change at ftpc: _MAX_SS (512 bytes) to _MAX_SS_FTP (2048 bytes - defined at ) - now show OK ~ 25-30 elements from FTPD directory - * (to full implement need fix at: -~355 line - if(gDataPutGetStart){ - switch(Command.Second){ - case s_dir: - PRINTF("dir waiting...\r\n"); - if((size = getSn_RX_RSR(DATA_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur. - PRINTF("ok\r\n"); - memset(dbuf, 0, _MAX_SS_FTP); - if(size > _MAX_SS_FTP) size = _MAX_SS_FTP - 1; - ret = recv(DATA_SOCK,dbuf,size); - * - * ) - * OK 3. <2> command (ls client side FATFS SDCARD contents)file name is empty (problem in scan_files()) - need to fix - * OK 4. Auto-login to anonymous(pass:1234) for test purposes (look at - Responses [R_220/R_331] ) - * OK 5. Add serial terminal session commands (look at ): - * . Test Message - * . Sta (uptime and freeram) - * . Reboot the board - * - * OK 6. Fix baud-rate issue on 115200bps 16Mhz - * OK 7. Add reaction on after not correct authorization - * (Add at - Responses R_530) - Reboot the board - * OK 8. Test and fix command: 5> Put File to Server (checked only active mode(passive not tested)) - * OK 9. Test and fix command: 6> Get File from Server - * OK 10. Add command: 8> Delete File from FTP server - * OK 11.Try add abilities to execute custom FTP server command. (Something like NOOP, HELP etc..) - * OK 12. Disable PASV mode (Tested - with bugs) - * - * - * (3) WIZNET loopback + FATFS (as template) - * + Added FATFS init (from <02_m1284p_FATFS_Chang_tst>), - * Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~12.2018..02.2019 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days -#ifdef BOOT_EN -volatile unsigned char sig_reset_board; // Flag to reset board -#endif -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.1 BootLoaded LOOPBACK and FTPD server && FATFS SDCARD WIZNET_5500 ETHERNET 15/02/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* UART0 Baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); - - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} - -//Blocking read UART RX (need for FTP Client) -char uart0_receive(void) -{ - unsigned int c; - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - //Suppress NEW LINE (It harm dialog with FTP server) - if((char)c != '\n') - { - uart_putc((char)c); - return (char)c ; - } - else - { - c = UART_NO_DATA; - } - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -#ifdef BOOT_EN -void fatfs_delete(const char * fn) -{ - FRESULT fr; - FILINFO fno; - - - fr = f_stat(fn, &fno); - switch (fr) { - - case FR_OK: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER: File <%s> is exist, so remove it.. ", fn); -#endif - fr = f_unlink(fn); -#ifdef BOOT_DEBUG - if(fr == FR_OK) - { - PRINTF(" OK\r\n"); - } - else - { - PRINTF(" ERROR\r\n"); - } -#endif - break; - - default: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER. File <%s> isn't exist..\r\n", fn); -#endif - break; - } -} -#endif - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -int main() -{ -#ifdef BOOT_EN - sig_reset_board = 0; // CLear flag to reset board -#endif - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - -#ifdef BOOT_EN - //Delete <1284BOOT.BIN> for BootLoader working properly - fatfs_delete("1284BOOT.BIN"); - //Test message - PRINTF("\r\n++Test message from new code #11\r\n"); -#endif - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//TODO: Add here FTP server initialize -#if defined(F_APP_FTP) - ftpd_init(netInfo.ip); -#endif -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - //Should not used here - //httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - //reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - //In this demo all www content saved onto SD-Card (you must copy all from folder to ROOT SD-Card) -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - //uint32_t timer_httpd_1sec = millis(); - uint32_t timer_uptime_60sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - //Should not used here - /* - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - } - */ - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - //TODO: Add here FTP server instance -#if defined(F_APP_FTP) - ftpd_run(gFTPBUF); -#endif - - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf1,PORT_UDPS); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - - } // End of user's code - - - if((millis()-timer_link_1sec)> 1000) - { - //Just for test bootloader works - led1_tgl(); - - //here every 1 sec - timer_link_1sec = millis(); - -#ifdef BOOT_EN - //Check signal to reset board (with additional pause 2-3 sec, to close ftp STOR transaction) - if(sig_reset_board) - { - - if(sig_reset_board++ > 3) - { - //If signal raised (3 sec) - reset the board (via WDT) to enter BootLoader - while(1) - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - _delay_ms(1000); - - } - } - else - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - } - } -#endif - //Check ETHERNET PHY link - //Shouldn't used here, LED1 handle via HTTPD - /* - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - /*/ - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - //PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - PRINTF("SW1 is pressed, Reboot the board..\r\n"); - while(1); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - } - - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/spi.c b/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.cproject b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.cproject deleted file mode 100644 index 098dce8..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.cproject +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.project b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.project deleted file mode 100644 index 34e7b54..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/644BOOT.BIN.bootloaded b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/644BOOT.BIN.bootloaded deleted file mode 100644 index 520ccda..0000000 Binary files a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/644BOOT.BIN.bootloaded and /dev/null differ diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/644BOOT.BIN.bootloaded.readme b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/644BOOT.BIN.bootloaded.readme deleted file mode 100644 index b10cf55..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/644BOOT.BIN.bootloaded.readme +++ /dev/null @@ -1,18 +0,0 @@ -Synopsis: -644BOOT.BIN.bootloaded - precompiled binary for use with bootloader zevero for m644p - -IP specs in this binary: -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration - -How to use: -Just copy 644BOOT.BIN.bootloaded to root SD-card (FAT32 FS) as 644BOOT.BIN, -then insert SD-card into m644p system (with bootloader zevero flashed before), -and reboot m644p system. - -maxxir -23.03.2019 10:34:30 diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h deleted file mode 100644 index 5a3a7d9..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../../globals.h" -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE ETH_LOOPBACK_MAX_BUF_SIZE -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c deleted file mode 100644 index 4d6490f..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c +++ /dev/null @@ -1,1304 +0,0 @@ -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.c -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : FTP daemon. (AVR-GCC Compiler) -*/ - -#include -#include -#include -#include -#include -//#include "stdio_private.h" -#include "socket.h" -#include "ftpd.h" - -/* Command table */ -static char *commands[] = { - "user", - "acct", - "pass", - "type", - "list", - "cwd", - "dele", - "name", - "quit", - "retr", - "stor", - "port", - "nlst", - "pwd", - "xpwd", - "mkd", - "xmkd", - "xrmd", - "rmd ", - "stru", - "mode", - "syst", - "xmd5", - "xcwd", - "feat", - "pasv", - "size", - "mlsd", - "appe", - NULL -}; - -#if 0 -/* Response messages */ -char banner[] = "220 %s FTP version %s ready.\r\n"; -char badcmd[] = "500 Unknown command '%s'\r\n"; -char binwarn[] = "100 Warning: type is ASCII and %s appears to be binary\r\n"; -char unsupp[] = "500 Unsupported command or option\r\n"; -char givepass[] = "331 Enter PASS command\r\n"; -char logged[] = "230 Logged in\r\n"; -char typeok[] = "200 Type %s OK\r\n"; -char only8[] = "501 Only logical bytesize 8 supported\r\n"; -char deleok[] = "250 File deleted\r\n"; -char mkdok[] = "200 MKD ok\r\n"; -char delefail[] = "550 Delete failed: %s\r\n"; -char pwdmsg[] = "257 \"%s\" is current directory\r\n"; -char badtype[] = "501 Unknown type \"%s\"\r\n"; -char badport[] = "501 Bad port syntax\r\n"; -char unimp[] = "502 Command does not implemented yet.\r\n"; -char bye[] = "221 Goodbye!\r\n"; -char nodir[] = "553 Can't read directory \"%s\": %s\r\n"; -char cantopen[] = "550 Can't read file \"%s\": %s\r\n"; -char sending[] = "150 Opening data connection for %s (%d.%d.%d.%d,%d)\r\n"; -char cantmake[] = "553 Can't create \"%s\": %s\r\n"; -char writerr[] = "552 Write error: %s\r\n"; -char portok[] = "200 PORT command successful.\r\n"; -char rxok[] = "226 Transfer complete.\r\n"; -char txok[] = "226 Transfer complete.\r\n"; -char noperm[] = "550 Permission denied\r\n"; -char noconn[] = "425 Data connection reset\r\n"; -char lowmem[] = "421 System overloaded, try again later\r\n"; -char notlog[] = "530 Please log in with USER and PASS\r\n"; -char userfirst[] = "503 Login with USER first.\r\n"; -char okay[] = "200 Ok\r\n"; -char syst[] = "215 %s Type: L%d Version: %s\r\n"; -char sizefail[] = "550 File not found\r\n"; -#endif - -un_l2cval remote_ip; -uint16_t remote_port; -un_l2cval local_ip; -uint16_t local_port; -uint8_t connect_state_control = 0; -uint8_t connect_state_data = 0; - -struct ftpd ftp; - -int current_year = 2014; -int current_month = 12; -int current_day = 31; -int current_hour = 10; -int current_min = 10; -int current_sec = 30; - -//int fsprintf(uint8_t s, const char *format, ...) -//{ -// int i; -///* -// char buf[LINELEN]; -// FILE f; -// va_list ap; -// -// f.flags = __SWR | __SSTR; -// f.buf = buf; -// f.size = INT_MAX; -// va_start(ap, format); -// i = vfprintf(&f, format, ap); -// va_end(ap); -// buf[f.len] = 0; -// -// send(s, (uint8_t *)buf, strlen(buf)); -//*/ -// return i; -//} - -void ftpd_init(uint8_t * src_ip) -{ - ftp.state = FTPS_NOT_LOGIN; - ftp.current_cmd = NO_CMD; - ftp.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - - strcpy(ftp.workingdir, "/"); - - socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0); -} - -/* - * From: FatFs - FAT file system module R0.10c - */ -int get_filesize(char* path, char *filename) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i, len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ -#if _USE_LFN - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - if(*path == 0x00) - res = f_opendir(&dir, "/"); - else - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - for(;;){ - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - if(!strcmp(fn, filename)) - { - if(fno.fattrib & AM_DIR){ - //printf("\r\n%s/%s is a directory\r\n", path, filename); - return 0; - } - return fno.fsize; - } - } - //printf("\r\n%s/%s was not found\r\n", path, filename); - //f_closedir(&dir); - } - return -1; -} - -/* - * Inserted from earlier realize FAT FS -> - * FAT file system module R0.10c (C)ChaN, 2014 - */ -/* - * Preferable structure of out see here: - * https://files.stairways.com/other/ftp-list-specs-info.txt - * - * something like: - -rw------- 1 peter 848 Dec 14 11:22 00README.txt -or - - whatever you feel like 848 Dec 14 11:22 00README.txt - - * also - * http://cr.yp.to/ftp/list/binls.html - * -/bin/ls format is a series of lines terminated by \015\012. Servers using /bin/ls format need to be prepared to generate lines in the following form: - - -rw-r--r-- 1 owner group 213 Aug 26 16:31 README - -The line contains - - - for a regular file or d for a directory; - the literal string rw-r--r-- 1 owner group for a regular file, or rwxr-xr-x 1 owner group for a directory; - the file size in decimal right-justified in a 13-byte field; - a three-letter month name, first letter capitalized; - a day number right-justified in a 3-byte field; - a space and a 2-digit hour number; - a colon and a 2-digit minute number; - a space and the abbreviated pathname of the file. - */ -FRESULT scan_files(char* path, char *buf, int * items_count) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i; - int len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ - char date_str[21]; - int date_str_ptr = 0; - int file_read_count = 0; - int file_read_count_10 = 0; - uint16_t size_dbuf = 0; -#if _USE_LFN == 1 - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - i = strlen(path); - //printf("strlen of path: %s %d \r\n", path, i); - for(;;){ - wdt_reset(); - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN == 1 - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; - - //Print out yet only first 30 files for full info - //if(file_read_count > 30) - //Print out yet only first 45 files for short info - /* - if(file_read_count > 45) - { - break; - } - */ - //!!Debug only - file_read_count++; -#if defined(_FTP_DEBUG_) - PRINTF("%02u:%9lu %s\r\n", (file_read_count+file_read_count_10), fno.fsize, fn); -#endif -#endif - //Encode date file like this (time show no correct, so remove): - //Aug 26 2018 - switch((fno.fdate >> 5) & 0x0f) - { - case 1: - len = SPRINTF(date_str, "JAN "); - break; - case 2: - len = SPRINTF(date_str, "FEB "); - break; - case 3: - len = SPRINTF(date_str, "MAR "); - break; - case 4: - len = SPRINTF(date_str, "APR "); - break; - case 5: - len = SPRINTF(date_str, "MAY "); - break; - case 6: - len = SPRINTF(date_str, "JUN "); - break; - case 7: - len = SPRINTF(date_str, "JUL "); - break; - case 8: - len = SPRINTF(date_str, "AUG "); - break; - case 9: - len = SPRINTF(date_str, "SEP "); - break; - case 10: - len = SPRINTF(date_str, "OCT "); - break; - case 11: - len = SPRINTF(date_str, "NOV "); - break; - case 12: - len = SPRINTF(date_str, "DEC "); - break; - } - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%2d ", (fno.fdate & 0x1f)); - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%d ", (((fno.fdate >> 9) & 0x7f) + 1980)); - //Time show not correct, so remove - /* - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%02u:%02u", (fno.ftime >> 11), (fno.ftime >> 5) & 63); - */ - date_str_ptr = 0; - - //printf("date str : %s \r\n", date_str); - - //Directory or file prefix - if(fno.fattrib & AM_DIR) - { - SPRINTF(buf + buf_ptr, "d"); - }else - { - SPRINTF(buf + buf_ptr, "-"); - } - buf_ptr++; - //Should not use here - /* - // drwxr-xr-x 1 ftp ftp 0 Apr 07 2014 $RECYCLE.BIN\r\n - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %u %s %s\r\n", fno.fsize, date_str, fn); - - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %s\r\n", fn); - - - //len = sprintf(buf + buf_ptr, " %6lu %s\r\n",fno.fsize, fn);// - Good minimum, but not seen on WinSCP - - - //len = sprintf(buf + buf_ptr, " %s\r\n", fn);// - Good minimum, but not seen on WinSCP - */ - - //Full with fake data - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) - - //Short without access rights and owner with fake data - /* - len = SPRINTF(buf + buf_ptr, " 1 %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) without access rights and owner - */ - - //Medium with real data file, without access rights and owner - len = SPRINTF(buf + buf_ptr, " 1 %9lu %s %s\r\n", fno.fsize, date_str, fn); //- Works on WinSCP with real data (OK) without access rights and owner - - buf_ptr += len; - - if(file_read_count > 9) - { - //Send out info about files in 10 items maximum - file_read_count = 0; - file_read_count_10 += 10; - //*buf_len = strlen(buf); - - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - - buf_ptr = 0; - - } - - //printf("fn: %s \r\n", fn); - - } - //Send out last packet with files numbers 1..9 - if(file_read_count) - { - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - } - - //*buf_len = strlen(buf); - *items_count = file_read_count + file_read_count_10; //Return number of sending file - //printf("%s", buf); - //printf("\r\nbuf_len : %d, sizeof(buf): %d\r\n", buf_len, sizeof(buf)); - f_closedir(&dir); - } - return res; -} - -uint8_t ftpd_run(uint8_t * dbuf) -{ - uint16_t size = 0, i; - long ret = 0; - uint32_t blocklen, send_byte, recv_byte; - uint32_t remain_filesize; - uint32_t remain_datasize; -#if defined(F_FILESYSTEM) - //FILINFO fno; -#endif - - //memset(dbuf, 0, sizeof(_MAX_SS_FTPD)); - - switch(getSn_SR(CTRL_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_control) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Connected\r\n", CTRL_SOCK); -#endif - //fsprintf(CTRL_SOCK, banner, HOSTNAME, VERSION); - strcpy(ftp.workingdir, "/"); - SPRINTF((char *)dbuf, "220 %s FTP version %s ready.\r\n", HOSTNAME, VERSION); - ret = send(CTRL_SOCK, (uint8_t *)dbuf, strlen((const char *)dbuf)); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - connect_state_control = 1; - } - -#if defined(_FTP_DEBUG_) - //printf("ftp socket %d\r\n", CTRL_SOCK); -#endif - - if((size = getSn_RX_RSR(CTRL_SOCK)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { -#if defined(_FTP_DEBUG_) - PRINTF("size: %d\r\n", size); -#endif - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(size > _MAX_SS_FTPD) size = _MAX_SS_FTPD - 1; - - ret = recv(CTRL_SOCK,dbuf,size); - dbuf[ret] = '\0'; - if(ret != size) - { - if(ret==SOCK_BUSY) return 0; - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("Rcvd Command: %s", dbuf); -#endif - proc_ftpd((char *)dbuf); - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",CTRL_SOCK); -#endif - if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",CTRL_SOCK); -#endif - break; - - case SOCK_CLOSED : -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPStart\r\n",CTRL_SOCK); -#endif - if((ret=socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0)) != CTRL_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", CTRL_SOCK, ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",CTRL_SOCK); -#endif - //strcpy(ftp.workingdir, "/"); - if( (ret = listen(CTRL_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",CTRL_SOCK); -#endif - return ret; - } - connect_state_control = 0; - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",CTRL_SOCK); -#endif - break; - - default : - break; - } - -#if 1 - switch(getSn_SR(DATA_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_data) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Data socket Connected\r\n", DATA_SOCK); -#endif - connect_state_data = 1; - } - - switch(ftp.current_cmd) - { - case LIST_CMD: - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("previous size: %u\r\n", size); -#endif -#if defined(F_FILESYSTEM) - scan_files(ftp.workingdir, dbuf, (int *)&size); -#endif -#if defined(_FTP_DEBUG_) - PRINTF("Items count: %u\r\n", size); - //PRINTF("%s\r\n", dbuf); -#endif -#if !defined(F_FILESYSTEM) - if (strncmp(ftp.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0) - size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n"); -#endif - /* - size = strlen(dbuf); - send(DATA_SOCK, dbuf, size); - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - */ - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - break; - - case RETR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to retrieve : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_READ); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ - remain_filesize = ftp.fil.fsize; -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - do{ -#if defined(_FTP_DEBUG_) - //printf("remained file size: %d\r\n", ftp.fil.fsize); -#endif - wdt_reset(); - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_filesize > _MAX_SS_FTPD) - send_byte = _MAX_SS_FTPD; - else - send_byte = remain_filesize; - - - uint16_t _blocklen; - ftp.fr = f_read(&(ftp.fil), dbuf, send_byte ,&_blocklen); - if(ftp.fr != FR_OK) - break; -#if defined(_FTP_DEBUG_) - PRINTF("#"); - //printf("----->fsize:%d recv:%d len:%d \r\n", remain_filesize, send_byte, blocklen); - //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - uint32_t send_size; - send_size = send(DATA_SOCK, dbuf, _blocklen); - //remain_filesize -= blocklen; - remain_filesize -= send_size; - }while(remain_filesize != 0); -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile read finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } -#else - remain_filesize = strlen(ftp.filename); - - do{ - memset(dbuf, 0, _MAX_SS_FTPD); - - blocklen = sprintf(dbuf, "%s", ftp.filename); - - printf("########## dbuf:%s\r\n", dbuf); - - send(DATA_SOCK, dbuf, blocklen); - remain_filesize -= blocklen; - }while(remain_filesize != 0); - -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case STOR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to store : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_CREATE_ALWAYS | FA_WRITE); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - while(1){ - wdt_reset(); - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf,(uint16_t) recv_byte); -#if defined(_FTP_DEBUG_) - //PRINTF("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - - uint16_t _blocklen; - ftp.fr = f_write(&(ftp.fil), dbuf, (UINT)ret, &_blocklen); -#if defined(_FTP_DEBUG_) - //PRINTF("----->dsize:%lu recv:%lu len:%u \r\n", remain_datasize, ret, _blocklen); -#endif - remain_datasize -= (uint32_t)_blocklen; - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - - if(remain_datasize <= 0) - break; - } - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - -#if defined(_FTP_DEBUG_) - PRINTF("#"); -#endif - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile write finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } - - //fno.fdate = (WORD)(((current_year - 1980) << 9) | (current_month << 5) | current_day); - //fno.ftime = (WORD)((current_hour << 11) | (current_min << 5) | (current_sec >> 1)); - //f_utime((const char *)ftp.filename, &fno); -#else - while(1){ - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf, recv_byte); - - printf("########## dbuf:%s\r\n", dbuf); - - remain_datasize -= ret; - - if(remain_datasize <= 0) - break; - } - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); -#ifdef BOOT_EN - if (strcasestr_P((const char *)ftp.filename, PSTR("644BOOT.BIN"))) - { - //Found event "644BOOT.BIN" upload to SD from FTPD, rise signal to running BootLoader (via WDT reset) -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>Catch <644BOOT.BIN> upload event, so run BOOTLOADER\r\n"); -#endif - sig_reset_board = 1; - } -#endif - break; - - case NO_CMD: - default: - break; - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",DATA_SOCK); -#endif - if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",DATA_SOCK); -#endif - break; - - case SOCK_CLOSED : - if(ftp.dsock_state == DATASOCK_READY) - { - if(ftp.dsock_mode == PASSIVE_MODE){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[PASSIV_MODE], port : %u\r\n",DATA_SOCK, local_port); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - - local_port++; - if(local_port > 50000) - local_port = 35000; - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[ACTIVE_MODE], port : %u\r\n",DATA_SOCK, IPPORT_FTPD); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, IPPORT_FTPD, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - } - - ftp.dsock_state = DATASOCK_START; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",DATA_SOCK); -#endif - if(ftp.dsock_mode == PASSIVE_MODE){ - if( (ret = listen(DATA_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",DATA_SOCK); -#endif - return ret; - } - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",DATA_SOCK); -#endif - }else{ - - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#1\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { -#if defined(_FTP_DEBUG_) - PRINTF("DATA_SOCK Connect#1 OK\r\n"); -#endif - } - //Try to FIX STOR command - } - connect_state_data = 0; - break; - - default : - break; - } -#endif - - return 0; -} - -char proc_ftpd(char * buf) -{ - char **cmdp, *cp, *arg, *tmpstr; - char sendbuf[200]; - int slen; - long ret; - - - /* Translate first word to lower case */ - for (cp = buf; *cp != ' ' && *cp != '\0'; cp++) - *cp = tolower(*cp); - - /* Find command in table; if not present, return syntax error */ - for (cmdp = commands; *cmdp != NULL; cmdp++) - if (strncmp(*cmdp, buf, strlen(*cmdp)) == 0) - break; - - if (*cmdp == NULL) - { - //fsprintf(CTRL_SOCK, badcmd, buf); - slen = SPRINTF(sendbuf, "500 Unknown command '%s'\r\n", buf); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - /* Allow only USER, PASS and QUIT before logging in */ - if (ftp.state == FTPS_NOT_LOGIN) - { - switch(cmdp - commands) - { - case USER_CMD: - case PASS_CMD: - case QUIT_CMD: - break; - default: - //fsprintf(CTRL_SOCK, notlog); - slen = SPRINTF(sendbuf, "530 Please log in with USER and PASS\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - } - - arg = &buf[strlen(*cmdp)]; - while(*arg == ' ') arg++; - - /* Execute specific command */ - switch (cmdp - commands) - { - case USER_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("USER_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - strcpy(ftp.username, arg); - //fsprintf(CTRL_SOCK, givepass); - slen = SPRINTF(sendbuf, "331 Enter PASS command\r\n"); - ret = send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case PASS_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("PASS_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - ftplogin(arg); - break; - - case TYPE_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - switch(arg[0]) - { - case 'A': - case 'a': /* Ascii */ - ftp.type = ASCII_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case 'B': - case 'b': /* Binary */ - case 'I': - case 'i': /* Image */ - ftp.type = IMAGE_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badtype, arg); - slen = SPRINTF(sendbuf, "501 Unknown type \"%s\"\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - break; - - case FEAT_CMD : - slen = SPRINTF(sendbuf, "211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST size*;type*;create*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 END\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case QUIT_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("QUIT_CMD\r\n"); -#endif - //fsprintf(CTRL_SOCK, bye); - slen = SPRINTF(sendbuf, "221 Goodbye!\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(CTRL_SOCK); - break; - - case RETR_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("RETR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = sprintf(sendbuf, "150 Opening data channel for file downloand from server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = RETR_CMD; - break; - - case APPE_CMD : - case STOR_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("STOR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "150 Opening data channel for file upload to server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = STOR_CMD; - /* - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#2\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { - //!!Debug only!! - PRINTF("DATA_SOCK Connect#2 OK\r\n"); - } - */ - //Try to FIX STOR command - connect_state_data = 0; - break; - - case PORT_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("PORT_CMD\r\n"); -#endif - if (pport(arg) == -1){ - //fsprintf(CTRL_SOCK, badport); - slen = SPRINTF(sendbuf, "501 Bad port syntax\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } else{ - //fsprintf(CTRL_SOCK, portok); - ftp.dsock_mode = ACTIVE_MODE; - ftp.dsock_state = DATASOCK_READY; - slen = SPRINTF(sendbuf, "200 PORT command successful.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } - break; - - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("MLSD_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = MLSD_CMD; - break; - - case LIST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("LIST_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = LIST_CMD; - break; - - case NLST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("NLST_CMD\r\n"); -#endif - break; - - case SYST_CMD: - slen = SPRINTF(sendbuf, "215 UNIX emulated by WIZnet\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PWD_CMD: - case XPWD_CMD: - slen = SPRINTF(sendbuf, "257 \"%s\" is current directory.\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PASV_CMD: - slen = SPRINTF(sendbuf, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", local_ip.cVal[0], local_ip.cVal[1], local_ip.cVal[2], local_ip.cVal[3], local_port >> 8, local_port & 0x00ff); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(DATA_SOCK); - ftp.dsock_mode = PASSIVE_MODE; - ftp.dsock_state = DATASOCK_READY; -#if defined(_FTP_DEBUG_) - PRINTF("PASV port: %u\r\n", local_port); -#endif - break; - - case SIZE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = _MAX_SS_FTPD; -#endif - if(slen > 0) - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - else - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - else - { - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case CWD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - arg[slen - 3] = 0x00; - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = 0; -#endif - *tmpstr = '/'; - if(slen == 0){ - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - else - { - slen = SPRINTF(sendbuf, "550 CWD failed. \"%s\"\r\n", arg); - } - } - else - { - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case MKD_CMD: - case XMKD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_mkdir(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Can't create directory. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "257 MKD command successful. \"%s\"\r\n", arg); - //strcpy(ftp.workingdir, arg); - } -#else - slen = SPRINTF(sendbuf, "550 Can't create directory. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case DELE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_unlink(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Could not delete. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "250 Deleted. \"%s\"\r\n", arg); - } -#else - slen = SPRINTF(sendbuf, "550 Could not delete. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case XCWD_CMD: - case ACCT_CMD: - case XRMD_CMD: - case RMD_CMD: - case STRU_CMD: - case MODE_CMD: - case XMD5_CMD: - //fsprintf(CTRL_SOCK, unimp); - slen = SPRINTF(sendbuf, "502 Command does not implemented yet.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badcmd, arg); - slen = SPRINTF(sendbuf, "500 Unknown command \'%s\'\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - - return 1; -} - - -char ftplogin(char * pass) -{ - char sendbuf[100]; - int slen = 0; -#ifdef FTPD_AUTH_EN - if (!strcmp(ftp.username, ftpd_user)) - { - if (!strcmp(pass, ftpd_pass)) - { - - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in OK\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - return 1; - } - - } - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in ERROR\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "530 Login authentication failed\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_NOT_LOGIN; - return 0; -#else - //memset(sendbuf, 0, DATA_BUF_SIZE); - -#if defined(_FTP_DEBUG_) - PRINTF("%s logged in\r\n", ftp.username); -#endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - - return 1; -#endif -} - -int pport(char * arg) -{ - int i; - char* tok=0; - - for (i = 0; i < 4; i++) - { - if(i==0) tok = strtok(arg,",\r\n"); - else tok = strtok(NULL,","); - remote_ip.cVal[i] = (uint8_t)atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } - remote_port = 0; - for (i = 0; i < 2; i++) - { - tok = strtok(NULL,",\r\n"); - remote_port <<= 8; - remote_port += atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - - return 0; -} - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil) -{ -#if defined(_FTP_DEBUG_) - PRINTF("File System pointer : %08X\r\n", fil->fs); - PRINTF("File System mount ID : %d\r\n", fil->id); - PRINTF("File status flag : %08X\r\n", fil->flag); - PRINTF("File System pads : %08X\r\n", fil->err); - PRINTF("File read write pointer : %08X\r\n", fil->fptr); - PRINTF("File size : %08X\r\n", fil->fsize); - PRINTF("File start cluster : %08X\r\n", fil->sclust); - PRINTF("current cluster : %08X\r\n", fil->clust); - PRINTF("current data sector : %08X\r\n", fil->dsect); - PRINTF("dir entry sector : %08X\r\n", fil->dir_sect); - PRINTF("dir entry pointer : %08X\r\n", fil->dir_ptr); -#endif -} -#endif diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h deleted file mode 100644 index 8057eb9..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _FTPD_H_ -#define _FTPD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.h -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : Header file of FTP daemon. (AVR-GCC Compiler) -*/ - -#include - -#include "../../globals.h" //add AVR specific useful headers - -#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement. - -#if defined(F_FILESYSTEM) -#include "ff.h" -#endif - -#define F_APP_FTP -//#define _FTP_DEBUG_ - - -#define LINELEN 100 -//#define DATA_BUF_SIZE 100 -#if !defined(F_FILESYSTEM) -#define _MAX_SS 512 -#endif - -#define CTRL_SOCK 2 -#define DATA_SOCK 3 - -#define IPPORT_FTPD 20 /* FTP Data port */ -#define IPPORT_FTP 21 /* FTP Control port */ - -#define HOSTNAME "iinChip" -#define VERSION "1.0" - -#define FILENAME "a.txt" - -/* FTP commands */ -enum ftp_cmd { - USER_CMD, - ACCT_CMD, - PASS_CMD, - TYPE_CMD, - LIST_CMD, - CWD_CMD, - DELE_CMD, - NAME_CMD, - QUIT_CMD, - RETR_CMD, - STOR_CMD, - PORT_CMD, - NLST_CMD, - PWD_CMD, - XPWD_CMD, - MKD_CMD, - XMKD_CMD, - XRMD_CMD, - RMD_CMD, - STRU_CMD, - MODE_CMD, - SYST_CMD, - XMD5_CMD, - XCWD_CMD, - FEAT_CMD, - PASV_CMD, - SIZE_CMD, - MLSD_CMD, - APPE_CMD, - NO_CMD, -}; - -enum ftp_type { - ASCII_TYPE, - IMAGE_TYPE, - LOGICAL_TYPE -}; - -enum ftp_state { - FTPS_NOT_LOGIN, - FTPS_LOGIN -}; - -enum datasock_state{ - DATASOCK_IDLE, - DATASOCK_READY, - DATASOCK_START -}; - -enum datasock_mode{ - PASSIVE_MODE, - ACTIVE_MODE -}; - -struct ftpd { - uint8_t control; /* Control stream */ - uint8_t data; /* Data stream */ - - enum ftp_type type; /* Transfer type */ - enum ftp_state state; - - enum ftp_cmd current_cmd; - - enum datasock_state dsock_state; - enum datasock_mode dsock_mode; - - char username[LINELEN]; /* Arg to USER command */ - char workingdir[LINELEN]; - char filename[LINELEN]; - -#if defined(F_FILESYSTEM) - FIL fil; // FatFs File objects - FRESULT fr; // FatFs function common result code -#endif - -}; - -#ifndef un_I2cval -typedef union _un_l2cval { - uint32_t lVal; - uint8_t cVal[4]; -}un_l2cval; -#endif - -void ftpd_init(uint8_t * src_ip); -uint8_t ftpd_run(uint8_t * dbuf); -char proc_ftpd(char * buf); -char ftplogin(char * pass); -int pport(char * arg); - -int sendit(char * command); -int recvit(char * command); - -long sendfile(uint8_t s, char * command); -long recvfile(uint8_t s); - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil); -#endif - -#ifdef __cplusplus -} -#endif - -#endif // _FTPD_H_ diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h deleted file mode 100644 index 90c3a0d..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2002, Joerg Wunsch - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * Neither the name of the copyright holders nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - -//struct __file { -// char *buf; /* buffer pointer */ -// unsigned char unget; /* ungetc() buffer */ -// uint8_t flags; /* flags, see below */ -//#define __SRD 0x0001 /* OK to read */ -//#define __SWR 0x0002 /* OK to write */ -//#define __SSTR 0x0004 /* this is an sprintf/snprintf string */ -//#define __SPGM 0x0008 /* fmt string is in progmem */ -//#define __SERR 0x0010 /* found error */ -//#define __SEOF 0x0020 /* found EOF */ -//#define __SUNGET 0x040 /* ungetc() happened */ -//#if 0 -///* possible future extensions, will require uint16_t flags */ -//#define __SRW 0x0080 /* open for reading & writing */ -//#define __SLBF 0x0100 /* line buffered */ -//#define __SNBF 0x0200 /* unbuffered */ -//#define __SMBF 0x0400 /* buf is from malloc */ -//#endif -// int size; /* size of buffer */ -// int len; /* characters read or written so far */ -// int (*put)(char); /* function to write one char to device */ -// int (*get)(void); /* function to read one char from device */ -//}; - -/* values for PRINTF_LEVEL */ -#define PRINTF_MIN 1 -#define PRINTF_STD 2 -#define PRINTF_FLT 3 - -/* values for SCANF_LEVEL */ -#define SCANF_MIN 1 -#define SCANF_STD 2 -#define SCANF_FLT 3 - -#ifdef __cplusplus -} -#endif diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/diskio.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ffconf.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/integer.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.c deleted file mode 100644 index e7d91ae..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//FTPD user-pass -#ifdef FTPD_AUTH_EN -const char ftpd_user[] = "user1234"; -const char ftpd_pass[] = "open_sesame"; -#endif - diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.h b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.h deleted file mode 100644 index 36347ba..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/globals.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -//#include "Internet/httpServer_avr/httpParser.h" -FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - -//Should not used here -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -//FTP Server IP (look at ) -//extern uint8_t FTP_SRV_destip[4]; - - -//#define _MAX_SS_FTP 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTP 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough - -//#define _MAX_SS_FTPD 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTPD 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough -#define _MAX_SS_FTPD _MAX_SS - -#define ETH_LOOPBACK_MAX_BUF_SIZE 512 - -//Enable BootLoader Running -#define BOOT_EN -//Disable BootLoader Running -//#undef BOOT_EN - -//Enable Bootloader debug message -#define BOOT_DEBUG -//Disable Bootloader debug message -//#undef BOOT_DEBUG - -//Enabled FTPD authorize -#define FTPD_AUTH_EN - -#ifdef FTPD_AUTH_EN -extern const char ftpd_user[]; -extern const char ftpd_pass[]; -#endif - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define SPRINTF(__S, FORMAT, args...) sprintf_P(__S, PSTR(FORMAT),##args) - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); -extern char uart0_receive(void); -extern void uart0_rx_flash(void); -extern void ls_dir(char* path); -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/FTPServer_avr/ftpd.h" - -uint8_t gFTPBUF[_MAX_SS_FTPD]; //512 bytes - -/* - * (18) Base template minimal for FTPD bootloaded application with TCP/IP loopback demo (m644p) - * TODO: - * OK (v1.1) Add FTPD authentication abilities - * (17) Combine together (16) + abilities to enter BootLoader (reset with WDT), - * when occur event upload via FTPD to SD file with name <1284BOOT.BIN> (see STOR_CMD into ) - * TODO: - * OK (v1.2) - * OK (v1.2a) Some minor changes, added key - * OK (v1.2b) Some minor changes - * OK (v1.2d) Changed bootable image to 1284BOOT.BIN - * Notes. - * Works in pair with BootLoader project: - * Also see to set correct fuses - * - * (16) HTTPD + FTPD + FATFS SDCARD - trying combine together projects: - * <12_m1284p_WIZNET_HTTPServer_SDCARD_pages_v2.4d> + <15_m1284p_WIZNET_FTPD_FATFS_v1.4> - * TODO: - * OK (v1.0)1. Initial realize with some minor optimization - * OK (v1.1)2. Add additional 60sec timer - for and events - * - * (15) FTP Server +FATFS SDCARD (PC-side checked on Win7 / WIN7 (console client)) - * TODO: - * OK (v1.1) 1. doesn't work properly on WinSCP, but WIN7 ftp command OK. - Fix it (in first approach with fake data show first ~45 elements from root SD-CARD FTPD) - * Works with WinSCP put/get/delete/refresh - Marvelous! - * PS. Checked work with the next FTP clients (WIN7): - * WINSCP, - * ftp - native WIN7 (terminal-style), - * TotalCommander - need to add new type server with the next template: d ? SSSSSSSSS TTT DD YYYY nnnnnnnnnnnn - * - * OK (v1.1) 2. WIN7 ftp (i.e. downloading file from FTPD SDCARD-device to PC, see ) - works but after download file, progress line still filling ~ 3-5 sec. - Fix it. - * OK (v1.1) 3. WIN7 ftp (i.e. uploading file from PC to FTPD SDCARD-device, see ) - not work properly, device just reboot. - Fix it. - * OK (v1.2) 4. RAM usage optimize : - * OK (v1.1) A) printf(..) change to PRINTF(..) (i.e. printf_P(..)) - * OK (v1.2) B) sprintf(..) change to SPRINTF(..) (i.e. sprintf_P(..)) - Save ~ 900 bytes RAM - * 5. Optimize : - * OK (v1.3) A) To show ALL elements add inside -send(DATA_SOCK, dbuf, size); in portion by 10 elements - until All elements being sent - * OK (v1.3) B) Show real DATE(without TIME) of file from SD-CARD FTPD (Show only DATE without TIME (time showed with error, to show correct need to implement MLST and LMSD extension commands, defined in RFC 3659 )) - * OK (v1.3) C) Try decrease: gFTPBUF[_MAX_SS_FTPD]; //512 bytes - for save RAM resources (optional) - * OK (v1.4) Fix <_FTP_DEBUG_> in undefined state (at ftpd.c), further optimize (at ftpd.c) - * - * (14) FTP client (Active) +FATFS SDCARD (PC-side checked on Win7 ) - * Notes: tested only Active mode with ASCII type (Not sure that PASV mode works properly..). - * TODO: - * OK 1. Without exist FTP server (PC side), device reset always (decide not fix yet..) - * OK 2. <1> command (ls FTP server contents) received no more then _MAXX_SS(512) bytes - need to fix - * Full implement Done with _MAX_SS_FTP=512 checked on ~35 elements show OK (~2362 bytes received) - * !!Below is deprecated decision (read above)!! - * Change at ftpc: _MAX_SS (512 bytes) to _MAX_SS_FTP (2048 bytes - defined at ) - now show OK ~ 25-30 elements from FTPD directory - * (to full implement need fix at: -~355 line - if(gDataPutGetStart){ - switch(Command.Second){ - case s_dir: - PRINTF("dir waiting...\r\n"); - if((size = getSn_RX_RSR(DATA_SOCK)) > 0){ // Don't need to check SOCKERR_BUSY because it doesn't not occur. - PRINTF("ok\r\n"); - memset(dbuf, 0, _MAX_SS_FTP); - if(size > _MAX_SS_FTP) size = _MAX_SS_FTP - 1; - ret = recv(DATA_SOCK,dbuf,size); - * - * ) - * OK 3. <2> command (ls client side FATFS SDCARD contents)file name is empty (problem in scan_files()) - need to fix - * OK 4. Auto-login to anonymous(pass:1234) for test purposes (look at - Responses [R_220/R_331] ) - * OK 5. Add serial terminal session commands (look at ): - * . Test Message - * . Sta (uptime and freeram) - * . Reboot the board - * - * OK 6. Fix baud-rate issue on 115200bps 16Mhz - * OK 7. Add reaction on after not correct authorization - * (Add at - Responses R_530) - Reboot the board - * OK 8. Test and fix command: 5> Put File to Server (checked only active mode(passive not tested)) - * OK 9. Test and fix command: 6> Get File from Server - * OK 10. Add command: 8> Delete File from FTP server - * OK 11.Try add abilities to execute custom FTP server command. (Something like NOOP, HELP etc..) - * OK 12. Disable PASV mode (Tested - with bugs) - * - * - * (3) WIZNET loopback + FATFS (as template) - * + Added FATFS init (from <02_m1284p_FATFS_Chang_tst>), - * Trying WIZNET5500 init with using official Wiznet ioLibrary_Driver - * working ping, assign static IP - * LED1 = ON when phy_link detected - * and loopback test on TCP-IP:5000 and UDP:3000 ports. - * use Hercules terminal utility to check network connection see: - * - * https://wizwiki.net/wiki/doku.php?id=osh:cookie:loopback_test - * https://www.hw-group.com/software/hercules-setup-utility - * - * Author of porting to AVR Mega: - * Ibragimov Maxim, Russia Togliatty ~12.2018..02.2019 - */ - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days -#ifdef BOOT_EN -volatile unsigned char sig_reset_board; // Flag to reset board -#endif -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega644p v1.1 BootLoaded LOOPBACK and FTPD server && FATFS SDCARD WIZNET_5500 ETHERNET 15/02/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* UART0 Baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); - - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} - -//Blocking read UART RX (need for FTP Client) -char uart0_receive(void) -{ - unsigned int c; - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - //Suppress NEW LINE (It harm dialog with FTP server) - if((char)c != '\n') - { - uart_putc((char)c); - return (char)c ; - } - else - { - c = UART_NO_DATA; - } - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -#ifdef BOOT_EN -void fatfs_delete(const char * fn) -{ - FRESULT fr; - FILINFO fno; - - - fr = f_stat(fn, &fno); - switch (fr) { - - case FR_OK: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER: File <%s> is exist, so remove it.. ", fn); -#endif - fr = f_unlink(fn); -#ifdef BOOT_DEBUG - if(fr == FR_OK) - { - PRINTF(" OK\r\n"); - } - else - { - PRINTF(" ERROR\r\n"); - } -#endif - break; - - default: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER. File <%s> isn't exist..\r\n", fn); -#endif - break; - } -} -#endif - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -int main() -{ -#ifdef BOOT_EN - sig_reset_board = 0; // CLear flag to reset board -#endif - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - -#ifdef BOOT_EN - //Delete <644BOOT.BIN> for BootLoader working properly - fatfs_delete("644BOOT.BIN"); - //Test message - PRINTF("\r\n++Test message from new code #12\r\n"); -#endif - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//TODO: Add here FTP server initialize -#if defined(F_APP_FTP) - ftpd_init(netInfo.ip); -#endif -//**************************************HTTPD init: BEGIN - /* HTTP Server Initialization */ - //Should not used here - //httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) / The number of W5500 chip H/W sockets in use - //reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: NXP MCU Reset - //reg_httpServer_cbfunc(NULL, NULL); // Callback: Still not used here ARV System reset, AVR WDT reset - //In this demo all www content saved onto SD-Card (you must copy all from folder to ROOT SD-Card) -//**************************************HTTPD init: END - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - //uint32_t timer_httpd_1sec = millis(); - uint32_t timer_uptime_60sec = millis(); - bool run_user_applications = true; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - /* HTTPD */ - /*HTTPD timer 1 sec interval tick*/ - //Should not used here - /* - if((millis()-timer_httpd_1sec)> 1000) - { - //here every 1 sec - timer_httpd_1sec = millis(); - //////////////////////////////////////////////////////// - // SHOULD BE Added HTTP Server Time Handler to your 1s tick timer - httpServer_time_handler(); // for HTTP server time counter - //////////////////////////////////////////////////////// - } - */ - - // TODO: insert user's code here - if(run_user_applications) - { - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - //TODO: Add here FTP server instance -#if defined(F_APP_FTP) - ftpd_run(gFTPBUF); -#endif - - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf1,PORT_UDPS); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - - } // End of user's code - - - if((millis()-timer_link_1sec)> 1000) - { - //Just for test bootloader works - led1_tgl(); - - //here every 1 sec - timer_link_1sec = millis(); - -#ifdef BOOT_EN - //Check signal to reset board (with additional pause 2-3 sec, to close ftp STOR transaction) - if(sig_reset_board) - { - - if(sig_reset_board++ > 3) - { - //If signal raised (3 sec) - reset the board (via WDT) to enter BootLoader - while(1) - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - _delay_ms(1000); - - } - } - else - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - } - } -#endif - //Check ETHERNET PHY link - //Shouldn't used here, LED1 handle via HTTPD - /* - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - /*/ - - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - //!! Debug only - //PRINTF("SW1 is pressed\r\nADC0/PA0 is: %u\r\n", adc_read(0)); - PRINTF("SW1 is pressed, Reboot the board..\r\n"); - while(1); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - } - - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/spi.c b/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/19_m1284p_WIZNET_blynk/.cproject b/19_m1284p_WIZNET_blynk/.cproject deleted file mode 100644 index 5201eba..0000000 --- a/19_m1284p_WIZNET_blynk/.cproject +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/19_m1284p_WIZNET_blynk/.project b/19_m1284p_WIZNET_blynk/.project deleted file mode 100644 index aaa0c2c..0000000 --- a/19_m1284p_WIZNET_blynk/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 19_m1284p_WIZNET_blynk - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/19_m1284p_WIZNET_blynk/Application/Blynk/blynk.c b/19_m1284p_WIZNET_blynk/Application/Blynk/blynk.c deleted file mode 100644 index 141a739..0000000 --- a/19_m1284p_WIZNET_blynk/Application/Blynk/blynk.c +++ /dev/null @@ -1,851 +0,0 @@ -/************************************************************** - * < Simple Blynk library for WIZnet products > - * - * WIZnet official website: http://www.wiznet.co.kr - * WIZnet Museum http://www.wiznetmuseum.com - * WIZnet Wiki http://wizwiki.net - * WIZnet Forum http://wizwiki.net/forum - * - * Downloads, docs, tutorials: http://www.blynk.cc - * Blynk community: http://community.blynk.cc - * Social groups: http://www.fb.com/blynkapp - * http://twitter.com/blynk_app - */ - -#include -#include -#include "socket.h" - -#include "blynk.h" -#include "blynkDependency.h" -#include "../globals.h" - -//#include "common.h" // When the project has no "common.h" file, this line have to commented out. -#ifndef BLYNK_DATA_BUF_SIZE - #define BLYNK_DATA_BUF_SIZE 2048 -#endif - -uint8_t blynk_connect(void); -void processInput(void); -void processCmd(uint8_t * buff, size_t len); -uint8_t readHeader(BlynkHeader * hdr); -void sendCmd(uint8_t cmd, uint16_t id, uint8_t * data, size_t length, uint8_t * data2, size_t length2); - -uint16_t getNextMsgId(void); -void BlynkAverageSample (uint32_t * avg, const uint32_t input, uint8_t n); -//uint32_t millis(void); -uint8_t blynk_custom_delay(uint32_t delayms); - -void blynkparam_init(BlynkParam p); -uint8_t * blynkparam_get(void); - -// Util functions -static uint16_t ATOI(uint8_t * str, uint8_t base); -static uint8_t C2D(uint8_t c); -static void replacetonull(uint8_t * str, uint8_t c); - -static void printBanner(); - -uint8_t * authkey; -uint32_t lastActivityIn; -uint32_t lastActivityOut; -uint32_t lastHeartbeat; -#ifdef BLYNK_MSG_LIMIT - uint32_t deltaCmd; -#endif -uint16_t currentMsgId; - -uint8_t blynk_connected = 0; -uint8_t blynk_connection_available = 0; -uint32_t ptime = 0; - -// Init variables -uint8_t blynk_socket, s; -uint8_t * server_ip; -uint16_t server_port; -uint8_t * msgbuf; - -// variables for parameter parsing -uint8_t * param_ptr; -uint8_t * param_end; - -volatile uint32_t blynk_time_1ms; -uint16_t blynkclient_port = BLYNK_DEFAULT_CLIENT_PORT; -uint8_t flag_blynkinit_complete = 0; - -void blynk_begin(uint8_t * auth, uint8_t * dest_ip, uint16_t dest_port, uint8_t * buf, uint8_t socket) -{ - s = socket; - - authkey = auth; - server_ip = dest_ip; - server_port = dest_port; - msgbuf = buf; - - flag_blynkinit_complete = 1; -} - -uint8_t blynk_connection_try = 0; - -void blynk_run(void) -{ - uint32_t t; - -#ifdef BLYNK_DEBUG - uint8_t destip[4]; - uint16_t destport; -#endif - - if(!flag_blynkinit_complete) return; - - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - -#ifdef BLYNK_DEBUG - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("Blynk[%d] : Connected - %d.%d.%d.%d:%d\r\n",s, destip[0], destip[1], destip[2], destip[3], destport); -#endif - } - - if(!blynk_connected) - { - if(!(blynk_connection_available = blynk_connect())) return; - else - { - blynk_connected = true; -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : Auth connection complete\r\n", s); -#endif - printBanner(); - } - - } - - if(blynk_connection_available > 0) processInput(); - - t = millis(); - - if (t - lastActivityIn > (1000UL * BLYNK_HEARTBEAT + BLYNK_TIMEOUT_MS*3)) { -#ifdef BLYNK_DEBUG - PRINTF("Heartbeat timeout (last in: %lu)\r\n", lastActivityIn); -#else - PRINTF("Heartbeat timeout\r\n"); -#endif - blynk_connected = false; - blynk_connection_available = false; - disconnect(s); - } - else if (( t - lastActivityIn > 1000UL * BLYNK_HEARTBEAT || - t - lastActivityOut > 1000UL * BLYNK_HEARTBEAT) && - t - lastHeartbeat > BLYNK_TIMEOUT_MS) - { - // Send ping if we didn't both send and receive something for BLYNK_HEARTBEAT seconds -#ifdef BLYNK_DEBUG - PRINTF("Heartbeat\r\n"); -#endif - sendCmd(BLYNK_CMD_PING, 0, NULL, 0, NULL, 0); - lastHeartbeat = t; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : ClOSE WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef BLYNK_DEBUG - //PRINTF("> Blynk[%d] : CLOSED\r\n", s); -#endif - blynk_connected = false; - blynk_connection_available = false; - - if(socket(s, Sn_MR_TCP, blynkclient_port++, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : SOCKET OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : Connecting to ", s); - PRINTF("%d.%d.%d.%d:%d\r\n", server_ip[0], server_ip[1], server_ip[2], server_ip[3], server_port); -#endif - connect(s, server_ip, server_port); - break; - - default : - break; - - } // end of switch -} - - -uint8_t blynk_connect(void) -{ - BlynkHeader hdr; - static uint16_t id = 0; - uint8_t i; - uint8_t hsize = 0; -//#ifdef BLYNK_DEBUG - uint32_t t = millis(); -//#endif - - // changed parts - ////////////////////////////////////////////////////////////////////////////////// - static uint8_t cmd_sent = false; - - if(blynk_custom_delay(0)) return false; - - if(!cmd_sent) - { - id = getNextMsgId(); - sendCmd(BLYNK_CMD_LOGIN, id, authkey, strlen((char *)authkey), NULL, 0); - cmd_sent = true; - ptime = millis(); // for check connection timeout - } - - if(millis() < (ptime + BLYNK_CONNECTION_TIMEOUT_MS)) // wait data received during 5sec before connection timeout occur - { - if(!readHeader(&hdr)) - { - return false; - } - else // Auth response received - { - cmd_sent = false; - } - } - else - { - hdr.length = BLYNK_TIMEOUT; - cmd_sent = false; - } - ////////////////////////////////////////////////////////////////////////////////// - if (BLYNK_CMD_RESPONSE != hdr.type || - id != hdr.msg_id || - //(BLYNK_SUCCESS != hdr.length && BLYNK_ALREADY_LOGGED_IN != hdr.length)) Deprecated on BLYNK_VERSION 0.6.0 - (BLYNK_SUCCESS != hdr.length && BLYNK_ILLEGAL_COMMAND_BODY != hdr.length)) - { - if (BLYNK_TIMEOUT == hdr.length) - { - PRINTF("Timeout\r\n"); - } - else if (BLYNK_INVALID_TOKEN == hdr.length) - { - PRINTF("Invalid auth token\r\n"); - } - else - { - PRINTF("Connect failed (code: %d)\r\n", hdr.length); - - // Send some invalid headers to server for disconnection - hdr.type = 255; - hdr.msg_id = 0; - hdr.length = 0; - - // problem fixed for header structure size - hsize = 0; - msgbuf[hsize++] = hdr.type; - msgbuf[hsize++] = hdr.msg_id; - msgbuf[hsize++] = hdr.msg_id; - msgbuf[hsize++] = hdr.length; - msgbuf[hsize++] = hdr.length; - for (i = 0; i < 10; i++) - { - send(s, msgbuf, hsize); - } - } - disconnect(s); - // old delay function removed - blynk_custom_delay(5000); - - return false; - } - - lastHeartbeat = lastActivityIn = lastActivityOut = millis(); -#ifdef BLYNK_MSG_LIMIT - deltaCmd = 1000; -#endif - - PRINTF("Ready!\r\n"); -#ifdef BLYNK_DEBUG - PRINTF("Roundtrip: %ldms\r\n", lastActivityIn-t); -#endif - - return true; -} - -void processInput(void) -{ - BlynkHeader hdr; -#ifdef BLYNK_DEBUG - uint16_t i; -#endif - - if (!readHeader(&hdr)) return; - - switch (hdr.type) - { - case BLYNK_CMD_RESPONSE: - { - if (BLYNK_NOT_AUTHENTICATED == hdr.length) - { - disconnect(s); - return; - } - // TODO: return code may indicate App presence - } break; - - case BLYNK_CMD_PING: - { - sendCmd(BLYNK_CMD_RESPONSE, hdr.msg_id, NULL, BLYNK_SUCCESS, NULL, 0); - } break; - - case BLYNK_CMD_HARDWARE: - case BLYNK_CMD_BRIDGE: - { - if (hdr.length > BLYNK_MAX_READBYTES) - { - PRINTF("Packet size (%u) > max allowed (%u)\r\n", hdr.length, BLYNK_MAX_READBYTES); - disconnect(s); - return; - } - - //PRINTF("hdr.length = %d\r\n", hdr.length); - if (hdr.length != recv(s, msgbuf, hdr.length)) - { - PRINTF("Can't read body\r\n"); - return; - } - msgbuf[hdr.length] = '\0'; // Add 1 to zero-terminate - -#ifdef BLYNK_DEBUG - PRINTF(">"); - for(i = 0; i < hdr.length; i++) - { - if(msgbuf[i] != '\0') PRINTF("%c", msgbuf[i]); - else PRINTF(" "); - } - PRINTF("\r\n"); -#endif - - currentMsgId = hdr.msg_id; - processCmd(msgbuf, hdr.length); - currentMsgId = 0; - } break; -//!! On BLYNK_VERSION 0.6.0 also present (look BlynkProtocol.h bool BlynkProtocol::processInput(void)): - /* - * - case BLYNK_CMD_LOGIN: {.. - - case BLYNK_CMD_REDIRECT: {.. - - case BLYNK_CMD_INTERNAL: {.. - - case BLYNK_CMD_DEBUG_PRINT: {.. - */ - default: - PRINTF("Invalid header type: %d\r\n", hdr.type); - disconnect(s); - return; - } - - lastActivityIn = millis(); -} - - -void blynkparam_init(BlynkParam p) -{ - param_ptr = p.buff; - param_end = param_ptr + p.len; -} - - -uint8_t * blynkparam_get(void) -{ - uint8_t size; - uint8_t * ret_ptr = param_ptr; - - if(param_ptr >= param_end) return NULL; - - size = strlen((char *)param_ptr); - param_ptr += (size+1); - - return ret_ptr; -} - -void processCmd(uint8_t * buff, size_t len) -{ - uint8_t * nexttok; - const char * cmd; - uint8_t pin; - uint8_t rsp_mem[16]; - uint16_t rsp_len; - uint16_t w_param; - - BlynkParam param; - param.buff = buff; - param.len = len; - - // for virtual read / write functions - //BlynkParam param2; - //uint8_t * start; - - memset(rsp_mem, 0, sizeof(rsp_mem)); - - blynkparam_init(param); - - nexttok = blynkparam_get(); - if(!nexttok) return; - - cmd = (char *)nexttok; - - if(!strcmp(cmd, "info")) - { - static uint8_t profile[] = - BLYNK_PARAM_KV("ver" , BLYNK_VERSION) - BLYNK_PARAM_KV("h-beat" , TOSTRING(BLYNK_HEARTBEAT)) - BLYNK_PARAM_KV("buff-in", TOSTRING(BLYNK_MAX_READBYTES)) -#ifdef BLYNK_INFO_DEVICE - BLYNK_PARAM_KV("dev" , BLYNK_INFO_DEVICE) -#endif -#ifdef BLYNK_INFO_CPU - BLYNK_PARAM_KV("cpu" , BLYNK_INFO_CPU) -#endif -#ifdef BLYNK_INFO_CONNECTION - BLYNK_PARAM_KV("con" , BLYNK_INFO_CONNECTION) -#endif -#ifdef BOARD_FIRMWARE_VERSION - BLYNK_PARAM_KV("fw" , BOARD_FIRMWARE_VERSION) -#endif - BLYNK_PARAM_KV("build" , __DATE__ " " __TIME__) - "\0" - ; - const size_t profile_len = sizeof(profile)-1; - - sendCmd(BLYNK_CMD_HARDWARE, 0, profile, profile_len, NULL, 0); - } - - nexttok = blynkparam_get(); - if(!nexttok) return; - - pin = (uint8_t)ATOI((uint8_t *)nexttok, 10); - - if(!strcmp(cmd, "dr")) // digital pin read - { - //This is bug on LPc13xx original sources, last space symbol is unnecessary - //rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d ", pin, digitalRead(pin)); - rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d", pin, digitalRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else if(!strcmp(cmd, "ar")) // analog pin read - { - //This is bug on LPc13xx original sources, last space symbol is unnecessary (as I think..) - //rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d ", pin, analogRead(pin)); - rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d", pin, analogRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else if(!strcmp(cmd, "vr")) // virtual pin read - { -#ifdef BLYNK_DEBUG - PRINTF("vr command: Not fully supported yet\r\n"); -#endif - rsp_len = SPRINTF((char *)rsp_mem, "vw %d %d", pin, virtualRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - - /* - WidgetReadHandler handler; - handler = GetReadHandler(pin); - if(handler) - { - BlynkReq req = { 0, BLYNK_SUCCESS, (uint8_t)pin }; - handler(req); - } - */ - } - else - { - if(!strcmp(cmd, "vw")) // virtual pin write - { -#ifdef BLYNK_DEBUG - PRINTF("vw command: Not fully supported yet\r\n"); -#endif - nexttok = blynkparam_get(); - w_param = ATOI((uint8_t *)nexttok, 10); - virtualWrite(pin, w_param); - - // update widget state - //rsp_len = SPRINTF((char *)rsp_mem, "vw %d %d ", pin, w_param); - //replacetonull(rsp_mem, ' '); - //sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - - /* - WidgetWriteHandler handler; - handler = GetWriteHandler(pin); - if(handler) - { - BlynkReq req = { 0, BLYNK_SUCCESS, (uint8_t)pin }; - - nexttok = blynkparam_get(); - start = nexttok; - - param2.buff = start; - param2.len = len - (start - buff); - handler(req, param2); - } - */ - } - - if(!strcmp(cmd, "pm")) // pin mode setting - { - while(nexttok) // end condition: nexttok == NULL - { - nexttok = blynkparam_get(); - - if (!strcmp((char *)nexttok, "in")) { - pinMode(pin, INPUT); - } else if (!strcmp((char *)nexttok, "out") || !strcmp((char *)nexttok, "pwm")) { - pinMode(pin, OUTPUT); - } else if (!strcmp((char *)nexttok, "pu")) { - pinMode(pin, INPUT_PULLUP); - } else { -#ifdef BLYNK_DEBUG - PRINTF("Invalid pinMode %u -> %s\r\n", pin, nexttok); -#endif - } - nexttok = blynkparam_get(); - if(!nexttok) {break;} - - pin = (uint8_t)ATOI((uint8_t *)nexttok, 10); // pin info update - } - } - - nexttok = blynkparam_get(); - if(!nexttok) return; - - // Should be 1 parameter (value) - if(!strcmp(cmd, "dw")) // digital pin write - { - w_param = (uint8_t)ATOI((uint8_t *)nexttok, 10); - - pinMode(pin, OUTPUT); - digitalWrite(pin, w_param ? HIGH : LOW); - - // update widget state - //rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d ", pin, digitalRead(pin)); - //replacetonull(rsp_mem, ' '); - //sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else if(!strcmp(cmd, "aw")) // analog pin write - { - w_param = (uint8_t)ATOI((uint8_t *)nexttok, 10); - - analogWrite(pin, w_param); - - // update widget state - //rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d ", pin, digitalRead(pin)); - //replacetonull(rsp_mem, ' '); - //sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else - { - PRINTF("Invalid HW cmd: %s\r\n", cmd); - } - } -} - -uint8_t readHeader(BlynkHeader * hdr) -{ - uint16_t len; - uint8_t hsize = 0; - - if((len = getSn_RX_RSR(s)) > 0) - { -#ifdef BLYNK_DEBUG - //PRINTF("recv header len = %d\r\n", len); -#endif - if(BLINK_HEADER_SIZE != recv(s, msgbuf, BLINK_HEADER_SIZE)) - { - return false; - } - - // problem fixed for header structure size - hdr->type = msgbuf[hsize++]; - hdr->msg_id = (uint16_t)msgbuf[hsize++]; - hdr->msg_id |= ((uint16_t)msgbuf[hsize++]) << 8; - hdr->length = (uint16_t)msgbuf[hsize++]; - hdr->length |= ((uint16_t)msgbuf[hsize++]) << 8; - - hdr->msg_id = ntohs(hdr->msg_id); - hdr->length = ntohs(hdr->length); -#ifdef BLYNK_DEBUG - PRINTF(">msg %d,%u,%u\r\n", hdr->type, hdr->msg_id, hdr->length); -#endif - return true; - } - - return false; -} - -void sendCmd(uint8_t cmd, uint16_t id, uint8_t * data, size_t length, uint8_t * data2, size_t length2) -{ - BlynkHeader hdr; - size_t wlen = 0; - uint32_t ts; - - uint8_t hsize = 0; - -#ifdef BLYNK_DEBUG - uint16_t i; -#endif - - if(getSn_SR(s) != SOCK_ESTABLISHED) - { -#ifdef BLYNK_DEBUG - PRINTF("Cmd not sent\r\n"); -#endif - return; - } - - if (0 == id) { - id = getNextMsgId(); - } - - hdr.type = cmd; - hdr.msg_id = htons(id); - hdr.length = htons(length+length2); - - // problem fixed for header structure size - msgbuf[hsize++] = hdr.type; - msgbuf[hsize++] = (uint8_t)(0x00ff & hdr.msg_id); - msgbuf[hsize++] = (uint8_t)((0xff00 & hdr.msg_id) >> 8); - msgbuf[hsize++] = (uint8_t)(0x00ff & hdr.length); - msgbuf[hsize++] = (uint8_t)((0xff00 & hdr.length) >> 8); - -#ifdef BLYNK_DEBUG - PRINTF(" 0) - { - if(!basetime) basetime = millis() + delayms; - } - else - { - if(millis() < basetime) - { - ret = true; // delaying - } - else - { - basetime = 0; - ret = false; // no delay - } - } - - return ret; -} - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -static uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - -static void replacetonull(uint8_t * str, uint8_t c) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == c) str[x] = NULL; -} - -uint8_t is_blynk_connection_available(void) -{ - return blynk_connection_available; -} - -//Requests Server to re-send current values for all widgets -void blynk_syncAll(void) -{ - sendCmd(BLYNK_CMD_HARDWARE_SYNC, 0, NULL, 0, NULL, 0); -} - -void blynk_push_pin(uint8_t pin) -{ - uint8_t rsp_mem[16]; - uint16_t rsp_len; - memset(rsp_mem, 0, sizeof(rsp_mem)); - rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d", pin, digitalRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); -} - -/* - * Sends integer value to a Virtual Pin - */ -void blynk_push_virtual_pin(uint8_t pin) -{ - uint8_t rsp_mem[16]; - uint16_t rsp_len; - memset(rsp_mem, 0, sizeof(rsp_mem)); - rsp_len = SPRINTF((char *)rsp_mem, "vw %d %d", pin, virtualRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); -} - -/* - * Sends buffer (string message for example) to a Virtual Pin - */ -void blynk_push_virtual_pin_msg(uint8_t pin, uint8_t * data) -{ - uint8_t rsp_mem[16]; - uint16_t rsp_len; - memset(rsp_mem, 0, sizeof(rsp_mem)); - rsp_len = SPRINTF((char *)rsp_mem, "vw %d", pin); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len+1, data, strlen(data)); -} - -void BLYNK_LOG_TIME() { - PRINTF(BLYNK_NEWLINE "[%lu] ", millis()); -} -#define BLYNK_LOG1(p1) { BLYNK_LOG_TIME(); PRINTF(p1); } - -static void printBanner() { -#if defined(BLYNK_NO_FANCY_LOGO) - BLYNK_LOG1(BLYNK_F("Blynk v" BLYNK_VERSION " on " BLYNK_INFO_DEVICE)); -#else - BLYNK_LOG1(BLYNK_NEWLINE - " ___ __ __" BLYNK_NEWLINE - " / _ )/ /_ _____ / /__" BLYNK_NEWLINE - " / _ / / // / _ \\/ '_/" BLYNK_NEWLINE - " /____/_/\\_, /_//_/_/\\_\\" BLYNK_NEWLINE - " /___/ v" BLYNK_VERSION " on " BLYNK_INFO_DEVICE BLYNK_NEWLINE - ); -#endif -} - diff --git a/19_m1284p_WIZNET_blynk/Application/Blynk/blynk.h b/19_m1284p_WIZNET_blynk/Application/Blynk/blynk.h deleted file mode 100644 index 40b7208..0000000 --- a/19_m1284p_WIZNET_blynk/Application/Blynk/blynk.h +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef _WIZNET_BLYNK_H_ -#define _WIZNET_BLYNK_H_ - -// Change these settings to match your need -#define BLYNK_DEFAULT_DOMAIN "blynk-cloud.com" -#define BLYNK_DEFAULT_PORT 80 -//SSL shouldn't used here -//#define BLYNK_DEFAULT_PORT_SSL 8441 - -//***************Professional settings: BEGIN -// Library version. -#define BLYNK_VERSION "0.6.0" - -// Heartbeat period in seconds. -#define BLYNK_HEARTBEAT 10 - -// Network timeout in milliseconds. -#define BLYNK_TIMEOUT_MS 3000UL - -// Limit the amount of outgoing commands per second. -//#define BLYNK_MSG_LIMIT 15 - -// Limit the incoming command length. -#define BLYNK_MAX_READBYTES 255 - -// Limit the outgoing command length. -#define BLYNK_MAX_SENDBYTES 128 - -//***************Professional settings: END - -//Print out BLYNK debug messages -#define BLYNK_DEBUG - -//Print out cool BLYNK ASCII LOGO -//#define BLYNK_NO_FANCY_LOGO -#undef BLYNK_NO_FANCY_LOGO - -#ifndef BLYNK_INFO_DEVICE - //#define BLYNK_INFO_DEVICE "Arduino" - //#define BLYNK_INFO_DEVICE "WIZWiki" - -#if defined (__AVR_ATmega644P__) - #define BLYNK_INFO_DEVICE "m644p_W5500" - #elif defined (__AVR_ATmega1284P__) - #define BLYNK_INFO_DEVICE "m1284p_W5500" - #else - #define BLYNK_INFO_DEVICE "Custom platform" - #endif - -#endif - -#ifndef BLYNK_INFO_CPU - //#define BLYNK_INFO_CPU "ATmega1284" - //#define BLYNK_INFO_CPU "ATmega2560" - //#define BLYNK_INFO_CPU "ATmega328P" - #if defined (__AVR_ATmega644P__) - #define BLYNK_INFO_CPU "ATmega644P" - #elif defined (__AVR_ATmega1284P__) - #define BLYNK_INFO_CPU "ATmega1284P" - #else - #define BLYNK_INFO_CPU "ATmega2560" - #endif -#endif - -#ifndef BLYNK_INFO_CONNECTION - #define BLYNK_INFO_CONNECTION "W5000" -#endif - -#define BLYNK_PARAM_KV(k, v) k "\0" v "\0" - -// General defines -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) - -// Custom defines -#define BLYNK_DEFAULT_CLIENT_PORT 1025 -#define BLYNK_CONNECTION_TIMEOUT_MS 5000 -#define BLINK_HEADER_SIZE 5 - -//#ifndef BlynkProtocolDefs_h -//#define BlynkProtocolDefs_h - -//BlynkCmd values compatible && synced with BLYNK_VERSION 0.6.0 -enum BlynkCmd -{ - BLYNK_CMD_RESPONSE = 0, - - //BLYNK_CMD_LOGIN = 2, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_CMD_LOGIN = 29, - BLYNK_CMD_PING = 6, - BLYNK_CMD_TWEET = 12, - BLYNK_CMD_EMAIL = 13, - //BLYNK_CMD_PUSH_NOTIFICATION = 14, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_CMD_NOTIFY = 14, - BLYNK_CMD_BRIDGE = 15, - BLYNK_CMD_HARDWARE_SYNC = 16, - BLYNK_CMD_INTERNAL = 17, - BLYNK_CMD_SMS = 18, - BLYNK_CMD_PROPERTY = 19, - BLYNK_CMD_HARDWARE = 20, - - //BLYNK_CMD_SAVE_PROF = 3, Deprecated on BLYNK_VERSION 0.6.0 - //BLYNK_CMD_LOAD_PROF = 4, Deprecated on BLYNK_VERSION 0.6.0 - //BLYNK_CMD_GET_TOKEN = 5, Deprecated on BLYNK_VERSION 0.6.0 - - BLYNK_CMD_REDIRECT = 41, - BLYNK_CMD_DEBUG_PRINT = 55, - BLYNK_CMD_EVENT_LOG = 64 - -}; - -//BlynkStatus values compatible && synced with BLYNK_VERSION 0.6.0 -enum BlynkStatus -{ - BLYNK_SUCCESS = 200, - //BLYNK_TIMEOUT = 1, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_QUOTA_LIMIT_EXCEPTION = 1, - //BLYNK_BAD_FORMAT = 2, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_ILLEGAL_COMMAND = 2, - BLYNK_NOT_REGISTERED = 3, - BLYNK_ALREADY_REGISTERED = 4, - //BLYNK_NO_LOGIN = 5, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_NOT_AUTHENTICATED = 5, - BLYNK_NOT_ALLOWED = 6, - //BLYNK_NO_CONNECTION = 7, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_DEVICE_NOT_IN_NETWORK = 7, - //BLYNK_NOT_SUPPORTED = 8, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_NO_ACTIVE_DASHBOARD = 8, - BLYNK_INVALID_TOKEN = 9, - //BLYNK_SERVER_ERROR = 10, Deprecated on BLYNK_VERSION 0.6.0 - //BLYNK_ALREADY_LOGGED_IN = 11, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_ILLEGAL_COMMAND_BODY = 11, - BLYNK_GET_GRAPH_DATA_EXCEPTION = 12, - BLYNK_NO_DATA_EXCEPTION = 17, - BLYNK_DEVICE_WENT_OFFLINE = 18, - BLYNK_SERVER_EXCEPTION = 19, - - BLYNK_NTF_INVALID_BODY = 13, - BLYNK_NTF_NOT_AUTHORIZED = 14, - BLYNK_NTF_ECXEPTION = 15, - - BLYNK_TIMEOUT = 16, - - BLYNK_NOT_SUPPORTED_VERSION = 20, - BLYNK_ENERGY_LIMIT = 21 - -}; - -typedef struct _BlynkHeader -{ - uint8_t type; - uint16_t msg_id; - uint16_t length; -} -BlynkHeader; - -typedef struct _BlynkParam -{ - uint8_t * buff; - uint16_t len; -} -BlynkParam; - -#if defined(__AVR_ATmega644P__) || defined (__AVR_ATmega1284P__) - #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) ) - #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ - ((x)<< 8 & 0x00FF0000UL) | \ - ((x)>> 8 & 0x0000FF00UL) | \ - ((x)>>24 & 0x000000FFUL) ) - #define ntohs(x) htons(x) - #define ntohl(x) htonl(x) - #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - #define htons(x) (x) - #define htonl(x) (x) - #define ntohs(x) (x) - #define ntohl(x) (x) - #else - #error byte order problem - #endif -#endif - -#define BLYNK_NEWLINE "\r\n" - -void blynk_begin(uint8_t * auth, uint8_t * dest_ip, uint16_t dest_port, uint8_t * buf, uint8_t socket); -void blynk_run(void); - -//void blynk_time_handler(void); -uint8_t is_blynk_connection_available(void); -/* -void sendCmd(uint8_t cmd, uint16_t id, uint8_t * data, size_t length, uint8_t * data2, size_t length2); -*/ -void blynk_syncAll(void); -void blynk_push_pin(uint8_t pin); -void blynk_push_virtual_pin(uint8_t pin); -void blynk_push_virtual_pin_msg(uint8_t pin, uint8_t * data); -#endif - diff --git a/19_m1284p_WIZNET_blynk/Application/Blynk/blynkDependency.c b/19_m1284p_WIZNET_blynk/Application/Blynk/blynkDependency.c deleted file mode 100644 index 0ad570c..0000000 --- a/19_m1284p_WIZNET_blynk/Application/Blynk/blynkDependency.c +++ /dev/null @@ -1,201 +0,0 @@ - -#include -#include "blynkDependency.h" -#include "../globals.h" - -#ifdef WIZNET_WIZ550WEB - #include "gpioHandler.h" - #include "userHandler.h" -#elif defined WIZNET_W5500_EVB - #include "board.h" - #include "adcHandler.h" -#endif - -uint8_t digitalRead(uint8_t pin) -{ - uint8_t val = pin; -#ifdef WIZNET_WIZ550WEB - val = get_IO_Status(pin); -#elif defined WIZNET_W5500_EVB - val = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -#else - PRINTF("digital pin %d read\r\n", pin); - if(pin == 21) - { - val = sw1_read()?0:!0; - PRINTF("SW1 is: %d %s\r\n", val, val?"HIGH":"LOW"); - } - else if(pin == 13) - { - val = led2_read()?1:0; - PRINTF("LED2 is: %d %s\r\n", val, val?"HIGH":"LOW"); - } - else - { - val = 1; - } -#endif - return val; -} - -void digitalWrite(uint8_t pin, uint8_t val) -{ -#ifdef WIZNET_WIZ550WEB - IOdata.ios[pin] = val; - if(val == HIGH) IO_On(pin); - else if(val == LOW) IO_Off(pin); - write_IOstorage(&IOdata, sizeof(IOdata)); -#elif defined WIZNET_W5500_EVB - if(val == HIGH) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High - else if(val == LOW) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -#else - PRINTF("digital pin %d write val %d\r\n", pin, val); - if(pin == 20) - { - if(val == 0) - { - led1_low(); - } - else - { - led1_high(); - } - //Rise flag to PUSH message to Virtual pin 20 - v20_changed = 1; - } -#endif -} - -uint16_t analogRead(uint8_t pin) -{ - uint16_t val = 0; -#ifdef WIZNET_WIZ550WEB - uint8_t analog_pin = 0; - if(pin > 14) analog_pin = pin - 14; - //PRINTF("analog_pin = %d\r\n", analog_pin); - val = get_ADC_val(analog_pin); -#elif defined WIZNET_W5500_EVB - uint8_t analog_pin = 0; - if(pin > 14) analog_pin = pin - 14; - PRINTF("analog_pin = %d\r\n", analog_pin); - if(analog_pin == A0) analog_pin = AIN; - PRINTF("changed analog_pin = %d\r\n", analog_pin); - val = get_ADC_val(analog_pin); -#else - if(pin == 6) - { - val = adc_read(6); - } - PRINTF("analog pin %d = %d\r\n", pin, val); -#endif - return val; -} - -void analogWrite(uint8_t pin, uint8_t val) -{ -#ifdef WIZNET_WIZ550WEB - PRINTF("Analog Write: Not supported yet. pin %d, val %d", pin, val); -#elif defined WIZNET_W5500_EVB - PRINTF("Analog Write: Not supported yet. pin %d, val %d", pin, val); -#else - PRINTF("analog pin %d write val %d\r\n", pin, val); -/* -* Handle PWM out PD7-PIN15: -* OCR2A = 0/127/255; Duty 0/50/100% -*/ - if(pin == 15) - { - OCR2A = val; - //Rise flag to PUSH message to Virtual pin 15 - v15_changed = 1; - } -#endif -} - -// Pin mode (dir) defines -// 0: Input -// 1: Output -// 2: Input Pull-up -void pinMode(uint8_t pin, pinmode_dir dir) -{ -// TODO: Add here example for AVR PULL-UP -#ifdef WIZNET_WIZ550WEB - if(dir == INPUT) IOdata.io[pin] = Input; - else if(dir == INPUT_PULLUP) IOdata.io[pin] = Input; - else if(dir == OUTPUT) IOdata.io[pin] = Output; // Output - IO_Init(pin); - write_IOstorage(&IOdata, sizeof(IOdata)); -#elif defined WIZNET_W5500_EVB - if(dir == INPUT) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input - else if(dir == INPUT_PULLUP) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input - else if(dir == OUTPUT) Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -#else - PRINTF("pinmode setting: pin %d dir %d\r\n", pin, dir); - if((pin == 20)&&(dir ==1)) - { - //m1284p LED1 pin to out - led1_conf(); - } - else if((pin == 21)&&(dir == 0)) - { - //m1284p SW1 pin to input - sw1_conf(); - } -#endif -} - -// Virtual Pin Read -uint16_t virtualRead(uint8_t pin) -{ - uint16_t val = 0; - PRINTF("virtual pin %d read\r\n", pin); - //Example virtual pin reading - //Override your own handlers here like: - if(pin == 13) - { - //Digital read example from Virtual Pin 13 - val = led2_read()?1:0; - //PRINTF("LED2 is: %d %s\r\n", val, val?"HIGH":"LOW"); - } - else if(pin == 6) - { - //Analog read example from Virtual Pin 6 - val = adc_read(6); - //PRINTF("analog pin %d = %d\r\n", pin, val); - } - else if(pin == 15) - { - //PWM Value PIN15/PD7 - val = (uint16_t)OCR2A; - } - else if(pin == 20) - { - //Digital OUT Value PIN20/PC4 - val = led1_read()?1:0; - } - return val; -} - -void virtualWrite(uint8_t pin, uint16_t val) -{ - PRINTF("virtual pin %d write val %d\r\n", pin, val); - //Example virtual pin writing - //Override your own handlers here like: - if(pin == 15) - { - //Analog write example to Virtual Pin 15 - OCR2A = (uint8_t)val; - } - else if(pin == 20) - { - //Digital write example to Virtual Pin 20 - if(val == 0) - { - led1_low(); - } - else - { - led1_high(); - } - } -} diff --git a/19_m1284p_WIZNET_blynk/Application/Blynk/blynkDependency.h b/19_m1284p_WIZNET_blynk/Application/Blynk/blynkDependency.h deleted file mode 100644 index 0a49789..0000000 --- a/19_m1284p_WIZNET_blynk/Application/Blynk/blynkDependency.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _WIZNET_BLYNK_DEPENDENCY_H_ -#define _WIZNET_BLYNK_DEPENDENCY_H_ - -#include -#include "blynk.h" - -//////////////////////////////////////////////////////////////// -typedef enum { // Pin mode; directions - INPUT, - OUTPUT, - INPUT_PULLUP -}pinmode_dir; - -typedef enum {false = 0, true = !false} Boolian; - -#define HIGH 1 -#define LOW 0 -//////////////////////////////////////////////////////////////// - -uint8_t digitalRead(uint8_t pin); -void digitalWrite(uint8_t pin, uint8_t val); - -uint16_t analogRead(uint8_t pin); -void analogWrite(uint8_t pin, uint8_t val); - -uint16_t virtualRead(uint8_t pin); -void virtualWrite(uint8_t pin, uint16_t val); - -void pinMode(uint8_t pin, pinmode_dir dir); - -#endif diff --git a/19_m1284p_WIZNET_blynk/Blynk_application/Check out m1284 + W5500 app I've made.txt b/19_m1284p_WIZNET_blynk/Blynk_application/Check out m1284 + W5500 app I've made.txt deleted file mode 100644 index 85bad8e..0000000 --- a/19_m1284p_WIZNET_blynk/Blynk_application/Check out m1284 + W5500 app I've made.txt +++ /dev/null @@ -1,8 +0,0 @@ -Hey, - -I've made m1284 + W5500 app. You are welcome to try it out! - -To start using it: -1. Download Blynk App: http://j.mp/blynk_Android or http://j.mp/blynk_iOS -2. Touch the QR-code icon and point the camera to the code below -3. Enjoy my app! diff --git a/19_m1284p_WIZNET_blynk/Blynk_application/Screenshot_2019-03-18-13-37-20-278_cc.blynk.png b/19_m1284p_WIZNET_blynk/Blynk_application/Screenshot_2019-03-18-13-37-20-278_cc.blynk.png deleted file mode 100644 index cbd18d1..0000000 Binary files a/19_m1284p_WIZNET_blynk/Blynk_application/Screenshot_2019-03-18-13-37-20-278_cc.blynk.png and /dev/null differ diff --git a/19_m1284p_WIZNET_blynk/Blynk_application/app1_m1284p_and_W5500_QR.png b/19_m1284p_WIZNET_blynk/Blynk_application/app1_m1284p_and_W5500_QR.png deleted file mode 100644 index d1a4369..0000000 Binary files a/19_m1284p_WIZNET_blynk/Blynk_application/app1_m1284p_and_W5500_QR.png and /dev/null differ diff --git a/19_m1284p_WIZNET_blynk/Blynk_application/app2_m1284p_and_W5500_QR.png b/19_m1284p_WIZNET_blynk/Blynk_application/app2_m1284p_and_W5500_QR.png deleted file mode 100644 index a45c06e..0000000 Binary files a/19_m1284p_WIZNET_blynk/Blynk_application/app2_m1284p_and_W5500_QR.png and /dev/null differ diff --git a/19_m1284p_WIZNET_blynk/Ethernet/W5500/w5500.c b/19_m1284p_WIZNET_blynk/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/19_m1284p_WIZNET_blynk/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/19_m1284p_WIZNET_blynk/Ethernet/W5500/w5500.h b/19_m1284p_WIZNET_blynk/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/19_m1284p_WIZNET_blynk/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/19_m1284p_WIZNET_blynk/Ethernet/socket.c b/19_m1284p_WIZNET_blynk/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/19_m1284p_WIZNET_blynk/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/19_m1284p_WIZNET_blynk/Ethernet/socket.h b/19_m1284p_WIZNET_blynk/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/19_m1284p_WIZNET_blynk/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/19_m1284p_WIZNET_blynk/Ethernet/wizchip_conf.c b/19_m1284p_WIZNET_blynk/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/19_m1284p_WIZNET_blynk/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/19_m1284p_WIZNET_blynk/Ethernet/wizchip_conf.h b/19_m1284p_WIZNET_blynk/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/19_m1284p_WIZNET_blynk/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/19_m1284p_WIZNET_blynk/Internet/DNS/dns.c b/19_m1284p_WIZNET_blynk/Internet/DNS/dns.c deleted file mode 100644 index 9f7107b..0000000 --- a/19_m1284p_WIZNET_blynk/Internet/DNS/dns.c +++ /dev/null @@ -1,566 +0,0 @@ -//***************************************************************************** -// -//! \file dns.c -//! \brief DNS APIs Implement file. -//! \details Send DNS query & Receive DNS reponse. \n -//! It depends on stdlib.h & string.h in ansi-c library -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Remove the unused define -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#include -#include - -#include "socket.h" -#include "dns.h" - -#ifdef _DNS_DEBUG_ - #include -#endif - -#define INITRTT 2000L /* Initial smoothed response time */ -#define MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */ - -#define TYPE_A 1 /* Host address */ -#define TYPE_NS 2 /* Name server */ -#define TYPE_MD 3 /* Mail destination (obsolete) */ -#define TYPE_MF 4 /* Mail forwarder (obsolete) */ -#define TYPE_CNAME 5 /* Canonical name */ -#define TYPE_SOA 6 /* Start of Authority */ -#define TYPE_MB 7 /* Mailbox name (experimental) */ -#define TYPE_MG 8 /* Mail group member (experimental) */ -#define TYPE_MR 9 /* Mail rename name (experimental) */ -#define TYPE_NULL 10 /* Null (experimental) */ -#define TYPE_WKS 11 /* Well-known sockets */ -#define TYPE_PTR 12 /* Pointer record */ -#define TYPE_HINFO 13 /* Host information */ -#define TYPE_MINFO 14 /* Mailbox information (experimental)*/ -#define TYPE_MX 15 /* Mail exchanger */ -#define TYPE_TXT 16 /* Text strings */ -#define TYPE_ANY 255 /* Matches any type */ - -#define CLASS_IN 1 /* The ARPA Internet */ - -/* Round trip timing parameters */ -#define AGAIN 8 /* Average RTT gain = 1/8 */ -#define LAGAIN 3 /* Log2(AGAIN) */ -#define DGAIN 4 /* Mean deviation gain = 1/4 */ -#define LDGAIN 2 /* log2(DGAIN) */ - -/* Header for all domain messages */ -struct dhdr -{ - uint16_t id; /* Identification */ - uint8_t qr; /* Query/Response */ -#define QUERY 0 -#define RESPONSE 1 - uint8_t opcode; -#define IQUERY 1 - uint8_t aa; /* Authoratative answer */ - uint8_t tc; /* Truncation */ - uint8_t rd; /* Recursion desired */ - uint8_t ra; /* Recursion available */ - uint8_t rcode; /* Response code */ -#define NO_ERROR 0 -#define FORMAT_ERROR 1 -#define SERVER_FAIL 2 -#define NAME_ERROR 3 -#define NOT_IMPL 4 -#define REFUSED 5 - uint16_t qdcount; /* Question count */ - uint16_t ancount; /* Answer count */ - uint16_t nscount; /* Authority (name server) count */ - uint16_t arcount; /* Additional record count */ -}; - - -uint8_t* pDNSMSG; // DNS message buffer -uint8_t DNS_SOCKET; // SOCKET number for DNS -uint16_t DNS_MSGID; // DNS message ID - -uint32_t dns_1s_tick; // for timout of DNS processing -static uint8_t retry_count; - -/* converts uint16_t from network buffer to a host byte order integer. */ -uint16_t get16(uint8_t * s) -{ - uint16_t i; - i = *s++ << 8; - i = i + *s; - return i; -} - -/* copies uint16_t to the network buffer with network byte order. */ -uint8_t * put16(uint8_t * s, uint16_t i) -{ - *s++ = i >> 8; - *s++ = i; - return s; -} - - -/* - * CONVERT A DOMAIN NAME TO THE HUMAN-READABLE FORM - * - * Description : This function converts a compressed domain name to the human-readable form - * Arguments : msg - is a pointer to the reply message - * compressed - is a pointer to the domain name in reply message. - * buf - is a pointer to the buffer for the human-readable form name. - * len - is the MAX. size of buffer. - * Returns : the length of compressed message - */ -int parse_name(uint8_t * msg, uint8_t * compressed, char * buf, int16_t len) -{ - uint16_t slen; /* Length of current segment */ - uint8_t * cp; - int clen = 0; /* Total length of compressed name */ - int indirect = 0; /* Set if indirection encountered */ - int nseg = 0; /* Total number of segments in name */ - - cp = compressed; - - for (;;) - { - slen = *cp++; /* Length of this segment */ - - if (!indirect) clen++; - - if ((slen & 0xc0) == 0xc0) - { - if (!indirect) - clen++; - indirect = 1; - /* Follow indirection */ - cp = &msg[((slen & 0x3f)<<8) + *cp]; - slen = *cp++; - } - - if (slen == 0) /* zero length == all done */ - break; - - len -= slen + 1; - - if (len < 0) return -1; - - if (!indirect) clen += slen; - - while (slen-- != 0) *buf++ = (char)*cp++; - *buf++ = '.'; - nseg++; - } - - if (nseg == 0) - { - /* Root name; represent as single dot */ - *buf++ = '.'; - len--; - } - - *buf++ = '\0'; - len--; - - return clen; /* Length of compressed message */ -} - -/* - * PARSE QUESTION SECTION - * - * Description : This function parses the qeustion record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the qeustion record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_question(uint8_t * msg, uint8_t * cp) -{ - int len; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - - if (len == -1) return 0; - - cp += len; - cp += 2; /* type */ - cp += 2; /* class */ - - return cp; -} - - -/* - * PARSE ANSER SECTION - * - * Description : This function parses the answer record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the answer record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_answer(uint8_t * msg, uint8_t * cp, uint8_t * ip_from_dns) -{ - int len, type; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - if (len == -1) return 0; - - cp += len; - type = get16(cp); - cp += 2; /* type */ - cp += 2; /* class */ - cp += 4; /* ttl */ - cp += 2; /* len */ - - - switch (type) - { - case TYPE_A: - /* Just read the address directly into the structure */ - ip_from_dns[0] = *cp++; - ip_from_dns[1] = *cp++; - ip_from_dns[2] = *cp++; - ip_from_dns[3] = *cp++; - break; - case TYPE_CNAME: - case TYPE_MB: - case TYPE_MG: - case TYPE_MR: - case TYPE_NS: - case TYPE_PTR: - /* These types all consist of a single domain name */ - /* convert it to ascii format */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_HINFO: - len = *cp++; - cp += len; - - len = *cp++; - cp += len; - break; - case TYPE_MX: - cp += 2; - /* Get domain name of exchanger */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_SOA: - /* Get domain name of name server */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - /* Get domain name of responsible person */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - cp += 4; - cp += 4; - cp += 4; - cp += 4; - cp += 4; - break; - case TYPE_TXT: - /* Just stash */ - break; - default: - /* Ignore */ - break; - } - - return cp; -} - -/* - * PARSE THE DNS REPLY - * - * Description : This function parses the reply message from DNS server. - * Arguments : dhdr - is a pointer to the header for DNS message - * buf - is a pointer to the reply message. - * len - is the size of reply message. - * Returns : -1 - Domain name lenght is too big - * 0 - Fail (Timout or parse error) - * 1 - Success, - */ -int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns) -{ - uint16_t tmp; - uint16_t i; - uint8_t * msg; - uint8_t * cp; - - msg = pbuf; - memset(pdhdr, 0, sizeof(*pdhdr)); - - pdhdr->id = get16(&msg[0]); - tmp = get16(&msg[2]); - if (tmp & 0x8000) pdhdr->qr = 1; - - pdhdr->opcode = (tmp >> 11) & 0xf; - - if (tmp & 0x0400) pdhdr->aa = 1; - if (tmp & 0x0200) pdhdr->tc = 1; - if (tmp & 0x0100) pdhdr->rd = 1; - if (tmp & 0x0080) pdhdr->ra = 1; - - pdhdr->rcode = tmp & 0xf; - pdhdr->qdcount = get16(&msg[4]); - pdhdr->ancount = get16(&msg[6]); - pdhdr->nscount = get16(&msg[8]); - pdhdr->arcount = get16(&msg[10]); - - - /* Now parse the variable length sections */ - cp = &msg[12]; - - /* Question section */ - for (i = 0; i < pdhdr->qdcount; i++) - { - cp = dns_question(msg, cp); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Answer section */ - for (i = 0; i < pdhdr->ancount; i++) - { - cp = dns_answer(msg, cp, ip_from_dns); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Name server (authority) section */ - for (i = 0; i < pdhdr->nscount; i++) - { - ; - } - - /* Additional section */ - for (i = 0; i < pdhdr->arcount; i++) - { - ; - } - - if(pdhdr->rcode == 0) return 1; // No error - else return 0; -} - - -/* - * MAKE DNS QUERY MESSAGE - * - * Description : This function makes DNS query message. - * Arguments : op - Recursion desired - * name - is a pointer to the domain name. - * buf - is a pointer to the buffer for DNS message. - * len - is the MAX. size of buffer. - * Returns : the pointer to the DNS message. - */ -int16_t dns_makequery(uint16_t op, char * name, uint8_t * buf, uint16_t len) -{ - uint8_t *cp; - char *cp1; - char sname[MAXCNAME]; - char *dname; - uint16_t p; - uint16_t dlen; - - cp = buf; - - DNS_MSGID++; - cp = put16(cp, DNS_MSGID); - p = (op << 11) | 0x0100; /* Recursion desired */ - cp = put16(cp, p); - cp = put16(cp, 1); - cp = put16(cp, 0); - cp = put16(cp, 0); - cp = put16(cp, 0); - - strcpy(sname, name); - dname = sname; - dlen = strlen(dname); - for (;;) - { - /* Look for next dot */ - cp1 = strchr(dname, '.'); - - if (cp1 != NULL) len = cp1 - dname; /* More to come */ - else len = dlen; /* Last component */ - - *cp++ = len; /* Write length of component */ - if (len == 0) break; - - /* Copy component up to (but not including) dot */ - strncpy((char *)cp, dname, len); - cp += len; - if (cp1 == NULL) - { - *cp++ = 0; /* Last one; write null and finish */ - break; - } - dname += len+1; - dlen -= len+1; - } - - cp = put16(cp, 0x0001); /* type */ - cp = put16(cp, 0x0001); /* class */ - - return ((int16_t)((uint32_t)(cp) - (uint32_t)(buf))); -} - -/* - * CHECK DNS TIMEOUT - * - * Description : This function check the DNS timeout - * Arguments : None. - * Returns : -1 - timeout occurred, 0 - timer over, but no timeout, 1 - no timer over, no timeout occur - * Note : timeout : retry count and timer both over. - */ - -int8_t check_DNS_timeout(void) -{ - - if(dns_1s_tick >= DNS_WAIT_TIME) - { - dns_1s_tick = 0; - if(retry_count >= MAX_DNS_RETRY) { - retry_count = 0; - return -1; // timeout occurred - } - retry_count++; - return 0; // timer over, but no timeout - } - - return 1; // no timer over, no timeout occur -} - - - -/* DNS CLIENT INIT */ -void DNS_init(uint8_t s, uint8_t * buf) -{ - DNS_SOCKET = s; // SOCK_DNS - pDNSMSG = buf; // User's shared buffer - DNS_MSGID = DNS_MSG_ID; -} - -/* DNS CLIENT RUN */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns) -{ - int8_t ret; - struct dhdr dhp; - uint8_t ip[4]; - uint16_t len, port; - int8_t ret_check_timeout; - - retry_count = 0; - dns_1s_tick = 0; - - // Socket open - socket(DNS_SOCKET, Sn_MR_UDP, 0, 0); - -#ifdef _DNS_DEBUG_ - printf("> DNS Query to DNS Server : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - - len = dns_makequery(0, (char *)name, pDNSMSG, MAX_DNS_BUF_SIZE); - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - - while (1) - { - if ((len = getSn_RX_RSR(DNS_SOCKET)) > 0) - { - if (len > MAX_DNS_BUF_SIZE) len = MAX_DNS_BUF_SIZE; - len = recvfrom(DNS_SOCKET, pDNSMSG, len, ip, &port); - #ifdef _DNS_DEBUG_ - printf("> Receive DNS message from %d.%d.%d.%d(%d). len = %d\r\n", ip[0], ip[1], ip[2], ip[3],port,len); - #endif - ret = parseDNSMSG(&dhp, pDNSMSG, ip_from_dns); - break; - } - // Check Timeout - ret_check_timeout = check_DNS_timeout(); - if (ret_check_timeout < 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Server is not responding : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - return 0; // timeout occurred - } - else if (ret_check_timeout == 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Timeout\r\n"); -#endif - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - } - } - close(DNS_SOCKET); - // Return value - // 0 > : failed / 1 - success - return ret; -} - - -/* DNS TIMER HANDLER */ -void DNS_time_handler(void) -{ - dns_1s_tick++; -} - - - diff --git a/19_m1284p_WIZNET_blynk/Internet/DNS/dns.h b/19_m1284p_WIZNET_blynk/Internet/DNS/dns.h deleted file mode 100644 index 6f6aa6b..0000000 --- a/19_m1284p_WIZNET_blynk/Internet/DNS/dns.h +++ /dev/null @@ -1,109 +0,0 @@ -//***************************************************************************** -// -//! \file dns.h -//! \brief DNS APIs Header file. -//! \details Send DNS query & Receive DNS reponse. -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Move the no reference define to dns.c -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#ifndef _DNS_H_ -#define _DNS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/* - * @brief Define it for Debug & Monitor DNS processing. - * @note If defined, it dependens on - */ -//#define _DNS_DEBUG_ - -#define MAX_DNS_BUF_SIZE 256 ///< maximum size of DNS buffer. */ -/* - * @brief Maxium length of your queried Domain name - * @todo SHOULD BE defined it equal as or greater than your Domain name lenght + null character(1) - * @note SHOULD BE careful to stack overflow because it is allocated 1.5 times as MAX_DOMAIN_NAME in stack. - */ -#define MAX_DOMAIN_NAME 16 // for example "www.google.com" - -#define MAX_DNS_RETRY 2 ///< Requery Count -#define DNS_WAIT_TIME 3 ///< Wait response time. unit 1s. - -#define IPPORT_DOMAIN 53 ///< DNS server port number - -#define DNS_MSG_ID 0x1122 ///< ID for DNS message. You can be modifyed it any number -/* - * @brief DNS process initialize - * @param s : Socket number for DNS - * @param buf : Buffer for DNS message - */ -void DNS_init(uint8_t s, uint8_t * buf); - -/* - * @brief DNS process - * @details Send DNS query and receive DNS response - * @param dns_ip : DNS server ip - * @param name : Domain name to be queryed - * @param ip_from_dns : IP address from DNS server - * @return -1 : failed. @ref MAX_DOMIN_NAME is too small \n - * 0 : failed (Timeout or Parse error)\n - * 1 : success - * @note This funtion blocks until success or fail. max time = @ref MAX_DNS_RETRY * @ref DNS_WAIT_TIME - */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns); - -/* - * @brief DNS 1s Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void DNS_time_handler(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _DNS_H_ */ diff --git a/19_m1284p_WIZNET_blynk/README.md b/19_m1284p_WIZNET_blynk/README.md deleted file mode 100644 index c1f85c6..0000000 --- a/19_m1284p_WIZNET_blynk/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# AtMega1284p+W5500 IOT Blynk application - -I’ve made porting from W5500_EVB(NXP LPC13xx + W5500) to AtMega1284p+W5500 custom board. - -This is NO Arduino. Used C language project with WIZNET native sockets API , only for experienced programmers. - -Building in Eclipse Kepler with AVR-Eclipse plugin and avr-gcc 4.9.2 toolchain. - -I made correction blynk.h/blynk.c to match BLYNK protocol 0.6.0, -because original W5500_EVB project based on BLYNK 0.2.1. - -Tested and worked: - -GPIO IN-OUT, Analog READ-WRITE, Virtual IN-OUT, PUSH values, PUSH messages, blynk_syncAll(). diff --git a/19_m1284p_WIZNET_blynk/git_goodies/git_usefull_commands.txt b/19_m1284p_WIZNET_blynk/git_goodies/git_usefull_commands.txt deleted file mode 100644 index cef7d1d..0000000 --- a/19_m1284p_WIZNET_blynk/git_goodies/git_usefull_commands.txt +++ /dev/null @@ -1,93 +0,0 @@ -7. Для AVR-Eclipse допустим загрузил проект, хочу поменять ключи в <00_m1284p_blink_make/Makefile>, но чтобы они не уходили назад -при PUSH'e на сервер (т.е. я работал со своей локальной копией): - -(Команду даем из консоли GIT из корня локального репозитария) -git update-index --assume-unchanged 00_m1284p_blink_make/Makefile - -Все далее спойкойно редактируем -При работе в другой локальной копии (на другой машине) эту команду надо давать снова. - -8. Для AVR-Eclipse (почти тоже что и (7)), после редактирования сделал Targets->Build->program -(Делаю прошивку программатором через Makefile). - -(Команду даем из консоли GIT из корня локального репозитария) -git update-index --assume-unchanged 00_m1284p_blink_make/.cproject - -Все далее спойкойно редактируем -При работе в другой локальной копии (на другой машине) эту команду надо давать снова. - -9. Это же нужно сделать с файлами globals.h, globals.c -git update-index --assume-unchanged globals.h -git update-index --assume-unchanged globals.c - -Возвращаем их обновление назад: -git update-index --no-assume-unchanged globals.h -git update-index --no-assume-unchanged globals.c - - -В общем виде: - - Ignoring versioned files - - Some files in a repository change often but are rarely committed. Usually, these are various local configuration files that are edited, but should never be committed upstream. Git lets you ignore those files by assuming they are unchanged. - - In Terminal, navigate to the location of your Git repository. - Run the following command in your terminal: - - git update-index --assume-unchanged path/to/file.txt - - Once you mark a file like this, Git completely ignores any changes on it. It will never show up when running git status or git diff, nor will it ever be committed. - - To make Git track the file again, simply run: - - git update-index --no-assume-unchanged path/to/file.txt. - -10. Чтобы видеть какие файлы в репозитарии "--assume-unchanged" (т.е. полагаются не изменяемыми, те. локальная копия не заносится в глобальный репозитарий при Commit, !! но наоборот обновляется из глобального при Pull !!): -git ls-files -v -При этом: те которые начинаются на h (строчную букву) и есть "--assume-unchanged" - -git ls-files -v - -Вывод: -H Internet/DNS/dns.c -H Internet/DNS/dns.h -H README.md -h globals.c << это "--assume-unchanged" -H main.c -H spi.c -H spi.h -H uart_extd.c -H uart_extd.h - - -Или (работает в GIT command console Win7, и Linux): - -git ls-files -v | grep -e "^[a-z]" - -Или (только для Win7 cmd используется Win cmd "findstr"): -git ls-files -v | findstr /B h - -Вывод: -#git ls-files -v | grep -e "^[a-z]" -h globals.c - -Отсюда: -https://stackoverflow.com/questions/2363197/can-i-get-a-list-of-files-marked-assume-unchanged - -11. Чтобы видеть какие файлы в репозитарии являются игнорируемыми "--ignored": -git status -s --ignored | grep "^!!" - -Вывод: - -!! Ethernet/Socket_APIs_V3.0.3.chm -!! Ethernet/W5100/ -!! Ethernet/W5100S/ -!! Ethernet/W5200/ -!! Ethernet/W5300/ -!! Release/ -!! ../bootloader_zevero_sd_m1284p_make/.settings/ -!! ../bootloader_zevero_sd_m644p_make/.settings/ - -Отсюда: -https://stackoverflow.com/questions/2363197/can-i-get-a-list-of-files-marked-assume-unchanged - diff --git a/19_m1284p_WIZNET_blynk/globals.c b/19_m1284p_WIZNET_blynk/globals.c deleted file mode 100644 index 25c70eb..0000000 --- a/19_m1284p_WIZNET_blynk/globals.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -uint8_t DNS_2nd[4] = {192, 168, 0, 1}; // Secondary DNS server IP -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -uint8_t DNS_2nd[4] = {192, 168, 1, 1}; // Secondary DNS server IP -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//My auth token for my android test application "m1284 + W5500": -uint8_t auth[] = "add_your_own_token_here"; // You should get your own Auth Token in the BLYNK App diff --git a/19_m1284p_WIZNET_blynk/globals.h b/19_m1284p_WIZNET_blynk/globals.h deleted file mode 100644 index e86d450..0000000 --- a/19_m1284p_WIZNET_blynk/globals.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" - -//Shouldn't use here -//******************************* Fat FS declare related: BEGIN -/* -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -#include "Internet/httpServer_avr/httpParser.h" -static FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -*/ -//******************************* Fat FS declare related: END - - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define SPRINTF(__S, FORMAT, args...) sprintf_P(__S, PSTR(FORMAT),##args) - -#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4/20 - m644p/m1284p maxxir brd -#define led1_conf() DDRC |= (1< - * OK (v1.1) Add LED_ON/LED_OFF handle on LED D13 BLYNK Android application - * GPIO OUT - works OK (look ./Application/Blynk/blynkDependency.c digitalWrite(..) && pinMode(..))! - * OK(v1.2) Add printout server metrics on start-up - * Need to try next: - * OK (v1.3)GPIO IN - fixed bug (remove redundant space symbol in ) - * OK Virtual IN/OUT - virtual pin push message see below (1.7) - * OK (v1.4)Analog Read/Write - * OK (v1.5)Restore pins state on board reboot - * OK (v1.6) Add push event (P13/PD.5 toggle every 10 sec && send state P13 to BLYNK server) - * OK (v1.7) Add push event to Virtual PIN1. Every 10sec push message: "Uptime: xxx sec", to BLYNK server (widget Terminal) - * OK (v1.8) Need compare local blynk.c code with modern library - (Too old version here - 0.2.1 (On git blynk March 2019 - 0.6.x) ) - * OK (v1.8) Made fix correction blynk.h/blynk.c 16.02.2019 to match BLYNK protocol 0.6.0 - * OK (v1.9) Two feedback examples from: - * D20/PC4(digitalWrite(20))->V20(virtualRead(20)) - * PWM D15/PD7(analogWrite(15))->V15(virtualRead(15)) - * using push events && on change state flags - * PS. - * Further correction, or advices about the code from BLYNK authors (Vladimir Shimansky, Dmitriy Dumanskiy ..) is highly desirable. - * Because I'm not the author of BLYNK libs. And I don't quite understand how this should work in the right manner. - * - * Author of unofficial porting to AVR Mega1284p/644p + W5500 Ethernet NIC (Wiznet sockets library using without Arduino): - * Ibragimov Maxim aka maxxir, Russia Togliatty ~xx.03.2019 - */ - -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/Blynk/blynk.h" -#include "Internet/DNS/dns.h" - -#define _MAIN_DEBUG_ - -//***********BLYNK related: BEGIN -#define SOCK_BLYNK_CLIENT 6 - -// Shouldn't used here, because used DNS resolving BLYNK server IP -// IP: 139.59.206.133 for via WIN7 nslookup - actually need to use DNS resolving -//Resolve here via DNS query see below Domain_IP[4] -//uint8_t blynk_server_ip[4] = {139, 59, 206, 133}; // Blynk cloud server IP (cloud.blynk.cc, 8422) -//uint8_t BLYNK_RX_BUF[DATA_BUF_SIZE]; - -uint8_t BLYNK_TX_BUF[BLYNK_DATA_BUF_SIZE]; - -//BLYNK Virtual pins state changed flags -uint8_t v15_changed; -uint8_t v20_changed; - -//***********BLYNK related: END - -//***************** DNS: BEGIN -////////////////////////////////////////////////// -// Socket & Port number definition for Examples // -////////////////////////////////////////////////// -#define SOCK_DNS 5 - -unsigned char gDATABUF_DNS[512]; -//#define IP_WORK - -//////////////// -// DNS client // -//////////////// -uint8_t Domain_name[] = BLYNK_DEFAULT_DOMAIN; // BLYNK server URI -uint8_t Domain_IP[4] = {0, }; // Translated IP address by DNS Server -//***************** DNS: END - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.9 Static IP BLYNK WIZNET_5500 ETHERNET 18/03/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -//static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -/* -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -*/ -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - - /* DNS client Initialization */ - PRINTF("> [BLYNK] Target Domain Name : %s\r\n", Domain_name); - DNS_init(SOCK_DNS, gDATABUF_DNS); - - /* DNS processing */ - int32_t ret; - if ((ret = DNS_run(netInfo.dns, Domain_name, Domain_IP)) > 0) // try to 1st DNS - { -#ifdef _MAIN_DEBUG_ - PRINTF("> 1st DNS Respond\r\n"); -#endif - } - else if ((ret != -1) && ((ret = DNS_run(DNS_2nd, Domain_name, Domain_IP))>0)) // retry to 2nd DNS - { -#ifdef _MAIN_DEBUG_ - PRINTF("> 2nd DNS Respond\r\n"); -#endif - } - else if(ret == -1) - { -#ifdef _MAIN_DEBUG_ - PRINTF("> MAX_DOMAIN_NAME is too small. Should be redefined it.\r\n"); -#endif - ; - } - else - { -#ifdef _MAIN_DEBUG_ - PRINTF("> DNS Failed\r\n"); -#endif - ; - } - - if(ret > 0) - { -#ifdef _MAIN_DEBUG_ - printf("> Translated %s to [%d.%d.%d.%d]\r\n\r\n",Domain_name,Domain_IP[0],Domain_IP[1],Domain_IP[2],Domain_IP[3]); -#endif - //IOT BLYK app init: - /* Blynk client Initialization */ - PRINTF("Try connect to BLYNK SERVER [%s]: %d.%d.%d.%d:%d..\n\r",Domain_name,Domain_IP[0],Domain_IP[1],Domain_IP[2],Domain_IP[3],BLYNK_DEFAULT_PORT); - blynk_begin(auth, Domain_IP, BLYNK_DEFAULT_PORT, BLYNK_TX_BUF, SOCK_BLYNK_CLIENT); - } - else - { - PRINTF("> [BLYNK] Target Domain Name : %s resolve ERROR\r\nReboot board..\r\n", Domain_name); - while(1); - } - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - - /* Loopback Test: TCP Server and UDP */ - // Test for Ethernet data transfer validation - uint32_t timer_tick_1sec = millis(); - uint8_t blynk_restore_connection = 1; - uint8_t timer_led2_push_10sec = 0; - static uint8_t _msg[64] = "\0"; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - // Blynk process handler - blynk_run(); - - //Here every 1sec event - if((millis()-timer_tick_1sec)> 1000) - { - //here every 1 sec - timer_tick_1sec = millis(); - //To restore GPIO state on start-up application - if(blynk_restore_connection) - { - if(is_blynk_connection_available()) - { - blynk_restore_connection = 0; - //Requests Server to re-send current values for all widgets - PRINTF("++blynk_syncAll event\r\n"); //Just for debug - blynk_syncAll(); - } - } - - //Virtual pins state change check here - if(v15_changed) - { - v15_changed = 0; //Drop flag - //Push message with changed V15 value (LED PWM PIN15/PD7 ) - blynk_push_virtual_pin(15); - - } - else if(v20_changed) - { - v20_changed = 0; //Drop flag - //Push message with changed V20 value (LED1 D20/PC4) - blynk_push_virtual_pin(20); - } - //Every 10sec event for LED2 PIN13, and uptime device - if(++timer_led2_push_10sec == 10) - { - timer_led2_push_10sec = 0; //Clear timer_led2.. - //Every 10sec toggle, and push LED2 PIN13/PD5 state to BLYNK server (widget Value Display) - led2_tgl(); - blynk_push_pin(13); - - //Every 10sec push message: "Uptime: xxx sec", to BLYNK server (widget Terminal) - SPRINTF(_msg, "Uptime: %lu sec\r\n", millis()/1000); - blynk_push_virtual_pin_msg(1, _msg); - } - } - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/.cproject b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/.cproject deleted file mode 100644 index bf504d8..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/.cproject +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/.project b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/.project deleted file mode 100644 index cab8dab..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded deleted file mode 100644 index 054f900..0000000 Binary files a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded and /dev/null differ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded.readme b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded.readme deleted file mode 100644 index 202c088..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/1284BOOT.BIN.bootloaded.readme +++ /dev/null @@ -1,18 +0,0 @@ -Synopsis: -1284BOOT.BIN.bootloaded - precompiled binary for use with bootloader zevero for m1284p - -IP specs in this binary: -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration - -How to use: -Just copy 1284BOOT.BIN.bootloaded to root SD-card (FAT32 FS) as 1284BOOT.BIN, -then insert SD-card into m1284p system (with bootloader zevero flashed before), -and reboot m1284p system. - -maxxir -23.03.2019 10:27:11 diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynk.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynk.c deleted file mode 100644 index 141a739..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynk.c +++ /dev/null @@ -1,851 +0,0 @@ -/************************************************************** - * < Simple Blynk library for WIZnet products > - * - * WIZnet official website: http://www.wiznet.co.kr - * WIZnet Museum http://www.wiznetmuseum.com - * WIZnet Wiki http://wizwiki.net - * WIZnet Forum http://wizwiki.net/forum - * - * Downloads, docs, tutorials: http://www.blynk.cc - * Blynk community: http://community.blynk.cc - * Social groups: http://www.fb.com/blynkapp - * http://twitter.com/blynk_app - */ - -#include -#include -#include "socket.h" - -#include "blynk.h" -#include "blynkDependency.h" -#include "../globals.h" - -//#include "common.h" // When the project has no "common.h" file, this line have to commented out. -#ifndef BLYNK_DATA_BUF_SIZE - #define BLYNK_DATA_BUF_SIZE 2048 -#endif - -uint8_t blynk_connect(void); -void processInput(void); -void processCmd(uint8_t * buff, size_t len); -uint8_t readHeader(BlynkHeader * hdr); -void sendCmd(uint8_t cmd, uint16_t id, uint8_t * data, size_t length, uint8_t * data2, size_t length2); - -uint16_t getNextMsgId(void); -void BlynkAverageSample (uint32_t * avg, const uint32_t input, uint8_t n); -//uint32_t millis(void); -uint8_t blynk_custom_delay(uint32_t delayms); - -void blynkparam_init(BlynkParam p); -uint8_t * blynkparam_get(void); - -// Util functions -static uint16_t ATOI(uint8_t * str, uint8_t base); -static uint8_t C2D(uint8_t c); -static void replacetonull(uint8_t * str, uint8_t c); - -static void printBanner(); - -uint8_t * authkey; -uint32_t lastActivityIn; -uint32_t lastActivityOut; -uint32_t lastHeartbeat; -#ifdef BLYNK_MSG_LIMIT - uint32_t deltaCmd; -#endif -uint16_t currentMsgId; - -uint8_t blynk_connected = 0; -uint8_t blynk_connection_available = 0; -uint32_t ptime = 0; - -// Init variables -uint8_t blynk_socket, s; -uint8_t * server_ip; -uint16_t server_port; -uint8_t * msgbuf; - -// variables for parameter parsing -uint8_t * param_ptr; -uint8_t * param_end; - -volatile uint32_t blynk_time_1ms; -uint16_t blynkclient_port = BLYNK_DEFAULT_CLIENT_PORT; -uint8_t flag_blynkinit_complete = 0; - -void blynk_begin(uint8_t * auth, uint8_t * dest_ip, uint16_t dest_port, uint8_t * buf, uint8_t socket) -{ - s = socket; - - authkey = auth; - server_ip = dest_ip; - server_port = dest_port; - msgbuf = buf; - - flag_blynkinit_complete = 1; -} - -uint8_t blynk_connection_try = 0; - -void blynk_run(void) -{ - uint32_t t; - -#ifdef BLYNK_DEBUG - uint8_t destip[4]; - uint16_t destport; -#endif - - if(!flag_blynkinit_complete) return; - - switch(getSn_SR(s)) - { - case SOCK_ESTABLISHED: - // Interrupt clear - if(getSn_IR(s) & Sn_IR_CON) - { - setSn_IR(s, Sn_IR_CON); - -#ifdef BLYNK_DEBUG - getSn_DIPR(s, destip); - destport = getSn_DPORT(s); - PRINTF("Blynk[%d] : Connected - %d.%d.%d.%d:%d\r\n",s, destip[0], destip[1], destip[2], destip[3], destport); -#endif - } - - if(!blynk_connected) - { - if(!(blynk_connection_available = blynk_connect())) return; - else - { - blynk_connected = true; -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : Auth connection complete\r\n", s); -#endif - printBanner(); - } - - } - - if(blynk_connection_available > 0) processInput(); - - t = millis(); - - if (t - lastActivityIn > (1000UL * BLYNK_HEARTBEAT + BLYNK_TIMEOUT_MS*3)) { -#ifdef BLYNK_DEBUG - PRINTF("Heartbeat timeout (last in: %lu)\r\n", lastActivityIn); -#else - PRINTF("Heartbeat timeout\r\n"); -#endif - blynk_connected = false; - blynk_connection_available = false; - disconnect(s); - } - else if (( t - lastActivityIn > 1000UL * BLYNK_HEARTBEAT || - t - lastActivityOut > 1000UL * BLYNK_HEARTBEAT) && - t - lastHeartbeat > BLYNK_TIMEOUT_MS) - { - // Send ping if we didn't both send and receive something for BLYNK_HEARTBEAT seconds -#ifdef BLYNK_DEBUG - PRINTF("Heartbeat\r\n"); -#endif - sendCmd(BLYNK_CMD_PING, 0, NULL, 0, NULL, 0); - lastHeartbeat = t; - } - break; - - case SOCK_CLOSE_WAIT: -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : ClOSE WAIT\r\n", s); // if a peer requests to close the current connection -#endif - disconnect(s); - break; - - case SOCK_CLOSED: -#ifdef BLYNK_DEBUG - //PRINTF("> Blynk[%d] : CLOSED\r\n", s); -#endif - blynk_connected = false; - blynk_connection_available = false; - - if(socket(s, Sn_MR_TCP, blynkclient_port++, 0x00) == s) /* Reinitialize the socket */ - { -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : SOCKET OPEN\r\n", s); -#endif - } - break; - - case SOCK_INIT: -#ifdef BLYNK_DEBUG - PRINTF("Blynk[%d] : Connecting to ", s); - PRINTF("%d.%d.%d.%d:%d\r\n", server_ip[0], server_ip[1], server_ip[2], server_ip[3], server_port); -#endif - connect(s, server_ip, server_port); - break; - - default : - break; - - } // end of switch -} - - -uint8_t blynk_connect(void) -{ - BlynkHeader hdr; - static uint16_t id = 0; - uint8_t i; - uint8_t hsize = 0; -//#ifdef BLYNK_DEBUG - uint32_t t = millis(); -//#endif - - // changed parts - ////////////////////////////////////////////////////////////////////////////////// - static uint8_t cmd_sent = false; - - if(blynk_custom_delay(0)) return false; - - if(!cmd_sent) - { - id = getNextMsgId(); - sendCmd(BLYNK_CMD_LOGIN, id, authkey, strlen((char *)authkey), NULL, 0); - cmd_sent = true; - ptime = millis(); // for check connection timeout - } - - if(millis() < (ptime + BLYNK_CONNECTION_TIMEOUT_MS)) // wait data received during 5sec before connection timeout occur - { - if(!readHeader(&hdr)) - { - return false; - } - else // Auth response received - { - cmd_sent = false; - } - } - else - { - hdr.length = BLYNK_TIMEOUT; - cmd_sent = false; - } - ////////////////////////////////////////////////////////////////////////////////// - if (BLYNK_CMD_RESPONSE != hdr.type || - id != hdr.msg_id || - //(BLYNK_SUCCESS != hdr.length && BLYNK_ALREADY_LOGGED_IN != hdr.length)) Deprecated on BLYNK_VERSION 0.6.0 - (BLYNK_SUCCESS != hdr.length && BLYNK_ILLEGAL_COMMAND_BODY != hdr.length)) - { - if (BLYNK_TIMEOUT == hdr.length) - { - PRINTF("Timeout\r\n"); - } - else if (BLYNK_INVALID_TOKEN == hdr.length) - { - PRINTF("Invalid auth token\r\n"); - } - else - { - PRINTF("Connect failed (code: %d)\r\n", hdr.length); - - // Send some invalid headers to server for disconnection - hdr.type = 255; - hdr.msg_id = 0; - hdr.length = 0; - - // problem fixed for header structure size - hsize = 0; - msgbuf[hsize++] = hdr.type; - msgbuf[hsize++] = hdr.msg_id; - msgbuf[hsize++] = hdr.msg_id; - msgbuf[hsize++] = hdr.length; - msgbuf[hsize++] = hdr.length; - for (i = 0; i < 10; i++) - { - send(s, msgbuf, hsize); - } - } - disconnect(s); - // old delay function removed - blynk_custom_delay(5000); - - return false; - } - - lastHeartbeat = lastActivityIn = lastActivityOut = millis(); -#ifdef BLYNK_MSG_LIMIT - deltaCmd = 1000; -#endif - - PRINTF("Ready!\r\n"); -#ifdef BLYNK_DEBUG - PRINTF("Roundtrip: %ldms\r\n", lastActivityIn-t); -#endif - - return true; -} - -void processInput(void) -{ - BlynkHeader hdr; -#ifdef BLYNK_DEBUG - uint16_t i; -#endif - - if (!readHeader(&hdr)) return; - - switch (hdr.type) - { - case BLYNK_CMD_RESPONSE: - { - if (BLYNK_NOT_AUTHENTICATED == hdr.length) - { - disconnect(s); - return; - } - // TODO: return code may indicate App presence - } break; - - case BLYNK_CMD_PING: - { - sendCmd(BLYNK_CMD_RESPONSE, hdr.msg_id, NULL, BLYNK_SUCCESS, NULL, 0); - } break; - - case BLYNK_CMD_HARDWARE: - case BLYNK_CMD_BRIDGE: - { - if (hdr.length > BLYNK_MAX_READBYTES) - { - PRINTF("Packet size (%u) > max allowed (%u)\r\n", hdr.length, BLYNK_MAX_READBYTES); - disconnect(s); - return; - } - - //PRINTF("hdr.length = %d\r\n", hdr.length); - if (hdr.length != recv(s, msgbuf, hdr.length)) - { - PRINTF("Can't read body\r\n"); - return; - } - msgbuf[hdr.length] = '\0'; // Add 1 to zero-terminate - -#ifdef BLYNK_DEBUG - PRINTF(">"); - for(i = 0; i < hdr.length; i++) - { - if(msgbuf[i] != '\0') PRINTF("%c", msgbuf[i]); - else PRINTF(" "); - } - PRINTF("\r\n"); -#endif - - currentMsgId = hdr.msg_id; - processCmd(msgbuf, hdr.length); - currentMsgId = 0; - } break; -//!! On BLYNK_VERSION 0.6.0 also present (look BlynkProtocol.h bool BlynkProtocol::processInput(void)): - /* - * - case BLYNK_CMD_LOGIN: {.. - - case BLYNK_CMD_REDIRECT: {.. - - case BLYNK_CMD_INTERNAL: {.. - - case BLYNK_CMD_DEBUG_PRINT: {.. - */ - default: - PRINTF("Invalid header type: %d\r\n", hdr.type); - disconnect(s); - return; - } - - lastActivityIn = millis(); -} - - -void blynkparam_init(BlynkParam p) -{ - param_ptr = p.buff; - param_end = param_ptr + p.len; -} - - -uint8_t * blynkparam_get(void) -{ - uint8_t size; - uint8_t * ret_ptr = param_ptr; - - if(param_ptr >= param_end) return NULL; - - size = strlen((char *)param_ptr); - param_ptr += (size+1); - - return ret_ptr; -} - -void processCmd(uint8_t * buff, size_t len) -{ - uint8_t * nexttok; - const char * cmd; - uint8_t pin; - uint8_t rsp_mem[16]; - uint16_t rsp_len; - uint16_t w_param; - - BlynkParam param; - param.buff = buff; - param.len = len; - - // for virtual read / write functions - //BlynkParam param2; - //uint8_t * start; - - memset(rsp_mem, 0, sizeof(rsp_mem)); - - blynkparam_init(param); - - nexttok = blynkparam_get(); - if(!nexttok) return; - - cmd = (char *)nexttok; - - if(!strcmp(cmd, "info")) - { - static uint8_t profile[] = - BLYNK_PARAM_KV("ver" , BLYNK_VERSION) - BLYNK_PARAM_KV("h-beat" , TOSTRING(BLYNK_HEARTBEAT)) - BLYNK_PARAM_KV("buff-in", TOSTRING(BLYNK_MAX_READBYTES)) -#ifdef BLYNK_INFO_DEVICE - BLYNK_PARAM_KV("dev" , BLYNK_INFO_DEVICE) -#endif -#ifdef BLYNK_INFO_CPU - BLYNK_PARAM_KV("cpu" , BLYNK_INFO_CPU) -#endif -#ifdef BLYNK_INFO_CONNECTION - BLYNK_PARAM_KV("con" , BLYNK_INFO_CONNECTION) -#endif -#ifdef BOARD_FIRMWARE_VERSION - BLYNK_PARAM_KV("fw" , BOARD_FIRMWARE_VERSION) -#endif - BLYNK_PARAM_KV("build" , __DATE__ " " __TIME__) - "\0" - ; - const size_t profile_len = sizeof(profile)-1; - - sendCmd(BLYNK_CMD_HARDWARE, 0, profile, profile_len, NULL, 0); - } - - nexttok = blynkparam_get(); - if(!nexttok) return; - - pin = (uint8_t)ATOI((uint8_t *)nexttok, 10); - - if(!strcmp(cmd, "dr")) // digital pin read - { - //This is bug on LPc13xx original sources, last space symbol is unnecessary - //rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d ", pin, digitalRead(pin)); - rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d", pin, digitalRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else if(!strcmp(cmd, "ar")) // analog pin read - { - //This is bug on LPc13xx original sources, last space symbol is unnecessary (as I think..) - //rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d ", pin, analogRead(pin)); - rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d", pin, analogRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else if(!strcmp(cmd, "vr")) // virtual pin read - { -#ifdef BLYNK_DEBUG - PRINTF("vr command: Not fully supported yet\r\n"); -#endif - rsp_len = SPRINTF((char *)rsp_mem, "vw %d %d", pin, virtualRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - - /* - WidgetReadHandler handler; - handler = GetReadHandler(pin); - if(handler) - { - BlynkReq req = { 0, BLYNK_SUCCESS, (uint8_t)pin }; - handler(req); - } - */ - } - else - { - if(!strcmp(cmd, "vw")) // virtual pin write - { -#ifdef BLYNK_DEBUG - PRINTF("vw command: Not fully supported yet\r\n"); -#endif - nexttok = blynkparam_get(); - w_param = ATOI((uint8_t *)nexttok, 10); - virtualWrite(pin, w_param); - - // update widget state - //rsp_len = SPRINTF((char *)rsp_mem, "vw %d %d ", pin, w_param); - //replacetonull(rsp_mem, ' '); - //sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - - /* - WidgetWriteHandler handler; - handler = GetWriteHandler(pin); - if(handler) - { - BlynkReq req = { 0, BLYNK_SUCCESS, (uint8_t)pin }; - - nexttok = blynkparam_get(); - start = nexttok; - - param2.buff = start; - param2.len = len - (start - buff); - handler(req, param2); - } - */ - } - - if(!strcmp(cmd, "pm")) // pin mode setting - { - while(nexttok) // end condition: nexttok == NULL - { - nexttok = blynkparam_get(); - - if (!strcmp((char *)nexttok, "in")) { - pinMode(pin, INPUT); - } else if (!strcmp((char *)nexttok, "out") || !strcmp((char *)nexttok, "pwm")) { - pinMode(pin, OUTPUT); - } else if (!strcmp((char *)nexttok, "pu")) { - pinMode(pin, INPUT_PULLUP); - } else { -#ifdef BLYNK_DEBUG - PRINTF("Invalid pinMode %u -> %s\r\n", pin, nexttok); -#endif - } - nexttok = blynkparam_get(); - if(!nexttok) {break;} - - pin = (uint8_t)ATOI((uint8_t *)nexttok, 10); // pin info update - } - } - - nexttok = blynkparam_get(); - if(!nexttok) return; - - // Should be 1 parameter (value) - if(!strcmp(cmd, "dw")) // digital pin write - { - w_param = (uint8_t)ATOI((uint8_t *)nexttok, 10); - - pinMode(pin, OUTPUT); - digitalWrite(pin, w_param ? HIGH : LOW); - - // update widget state - //rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d ", pin, digitalRead(pin)); - //replacetonull(rsp_mem, ' '); - //sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else if(!strcmp(cmd, "aw")) // analog pin write - { - w_param = (uint8_t)ATOI((uint8_t *)nexttok, 10); - - analogWrite(pin, w_param); - - // update widget state - //rsp_len = SPRINTF((char *)rsp_mem, "aw %d %d ", pin, digitalRead(pin)); - //replacetonull(rsp_mem, ' '); - //sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); - } - else - { - PRINTF("Invalid HW cmd: %s\r\n", cmd); - } - } -} - -uint8_t readHeader(BlynkHeader * hdr) -{ - uint16_t len; - uint8_t hsize = 0; - - if((len = getSn_RX_RSR(s)) > 0) - { -#ifdef BLYNK_DEBUG - //PRINTF("recv header len = %d\r\n", len); -#endif - if(BLINK_HEADER_SIZE != recv(s, msgbuf, BLINK_HEADER_SIZE)) - { - return false; - } - - // problem fixed for header structure size - hdr->type = msgbuf[hsize++]; - hdr->msg_id = (uint16_t)msgbuf[hsize++]; - hdr->msg_id |= ((uint16_t)msgbuf[hsize++]) << 8; - hdr->length = (uint16_t)msgbuf[hsize++]; - hdr->length |= ((uint16_t)msgbuf[hsize++]) << 8; - - hdr->msg_id = ntohs(hdr->msg_id); - hdr->length = ntohs(hdr->length); -#ifdef BLYNK_DEBUG - PRINTF(">msg %d,%u,%u\r\n", hdr->type, hdr->msg_id, hdr->length); -#endif - return true; - } - - return false; -} - -void sendCmd(uint8_t cmd, uint16_t id, uint8_t * data, size_t length, uint8_t * data2, size_t length2) -{ - BlynkHeader hdr; - size_t wlen = 0; - uint32_t ts; - - uint8_t hsize = 0; - -#ifdef BLYNK_DEBUG - uint16_t i; -#endif - - if(getSn_SR(s) != SOCK_ESTABLISHED) - { -#ifdef BLYNK_DEBUG - PRINTF("Cmd not sent\r\n"); -#endif - return; - } - - if (0 == id) { - id = getNextMsgId(); - } - - hdr.type = cmd; - hdr.msg_id = htons(id); - hdr.length = htons(length+length2); - - // problem fixed for header structure size - msgbuf[hsize++] = hdr.type; - msgbuf[hsize++] = (uint8_t)(0x00ff & hdr.msg_id); - msgbuf[hsize++] = (uint8_t)((0xff00 & hdr.msg_id) >> 8); - msgbuf[hsize++] = (uint8_t)(0x00ff & hdr.length); - msgbuf[hsize++] = (uint8_t)((0xff00 & hdr.length) >> 8); - -#ifdef BLYNK_DEBUG - PRINTF(" 0) - { - if(!basetime) basetime = millis() + delayms; - } - else - { - if(millis() < basetime) - { - ret = true; // delaying - } - else - { - basetime = 0; - ret = false; // no delay - } - } - - return ret; -} - -/** -@brief CONVERT STRING INTO INTEGER -@return a integer number -*/ -static uint16_t ATOI( - uint8_t * str, /**< is a pointer to convert */ - uint8_t base /**< is a base value (must be in the range 2 - 16) */ - ) -{ - unsigned int num = 0; - while ((*str !=0) && (*str != 0x20)) // not include the space(0x020) - num = num * base + C2D(*str++); - return num; -} - -static uint8_t C2D( - uint8_t c /**< is a character('0'-'F') to convert to HEX */ - ) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return 10 + c -'a'; - if (c >= 'A' && c <= 'F') - return 10 + c -'A'; - - return (char)c; -} - -static void replacetonull(uint8_t * str, uint8_t c) -{ - int x; - for (x = 0; str[x]; x++) - if (str[x] == c) str[x] = NULL; -} - -uint8_t is_blynk_connection_available(void) -{ - return blynk_connection_available; -} - -//Requests Server to re-send current values for all widgets -void blynk_syncAll(void) -{ - sendCmd(BLYNK_CMD_HARDWARE_SYNC, 0, NULL, 0, NULL, 0); -} - -void blynk_push_pin(uint8_t pin) -{ - uint8_t rsp_mem[16]; - uint16_t rsp_len; - memset(rsp_mem, 0, sizeof(rsp_mem)); - rsp_len = SPRINTF((char *)rsp_mem, "dw %d %d", pin, digitalRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); -} - -/* - * Sends integer value to a Virtual Pin - */ -void blynk_push_virtual_pin(uint8_t pin) -{ - uint8_t rsp_mem[16]; - uint16_t rsp_len; - memset(rsp_mem, 0, sizeof(rsp_mem)); - rsp_len = SPRINTF((char *)rsp_mem, "vw %d %d", pin, virtualRead(pin)); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len, NULL, 0); -} - -/* - * Sends buffer (string message for example) to a Virtual Pin - */ -void blynk_push_virtual_pin_msg(uint8_t pin, uint8_t * data) -{ - uint8_t rsp_mem[16]; - uint16_t rsp_len; - memset(rsp_mem, 0, sizeof(rsp_mem)); - rsp_len = SPRINTF((char *)rsp_mem, "vw %d", pin); - replacetonull(rsp_mem, ' '); - sendCmd(BLYNK_CMD_HARDWARE, 0, rsp_mem, rsp_len+1, data, strlen(data)); -} - -void BLYNK_LOG_TIME() { - PRINTF(BLYNK_NEWLINE "[%lu] ", millis()); -} -#define BLYNK_LOG1(p1) { BLYNK_LOG_TIME(); PRINTF(p1); } - -static void printBanner() { -#if defined(BLYNK_NO_FANCY_LOGO) - BLYNK_LOG1(BLYNK_F("Blynk v" BLYNK_VERSION " on " BLYNK_INFO_DEVICE)); -#else - BLYNK_LOG1(BLYNK_NEWLINE - " ___ __ __" BLYNK_NEWLINE - " / _ )/ /_ _____ / /__" BLYNK_NEWLINE - " / _ / / // / _ \\/ '_/" BLYNK_NEWLINE - " /____/_/\\_, /_//_/_/\\_\\" BLYNK_NEWLINE - " /___/ v" BLYNK_VERSION " on " BLYNK_INFO_DEVICE BLYNK_NEWLINE - ); -#endif -} - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynk.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynk.h deleted file mode 100644 index 40b7208..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynk.h +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef _WIZNET_BLYNK_H_ -#define _WIZNET_BLYNK_H_ - -// Change these settings to match your need -#define BLYNK_DEFAULT_DOMAIN "blynk-cloud.com" -#define BLYNK_DEFAULT_PORT 80 -//SSL shouldn't used here -//#define BLYNK_DEFAULT_PORT_SSL 8441 - -//***************Professional settings: BEGIN -// Library version. -#define BLYNK_VERSION "0.6.0" - -// Heartbeat period in seconds. -#define BLYNK_HEARTBEAT 10 - -// Network timeout in milliseconds. -#define BLYNK_TIMEOUT_MS 3000UL - -// Limit the amount of outgoing commands per second. -//#define BLYNK_MSG_LIMIT 15 - -// Limit the incoming command length. -#define BLYNK_MAX_READBYTES 255 - -// Limit the outgoing command length. -#define BLYNK_MAX_SENDBYTES 128 - -//***************Professional settings: END - -//Print out BLYNK debug messages -#define BLYNK_DEBUG - -//Print out cool BLYNK ASCII LOGO -//#define BLYNK_NO_FANCY_LOGO -#undef BLYNK_NO_FANCY_LOGO - -#ifndef BLYNK_INFO_DEVICE - //#define BLYNK_INFO_DEVICE "Arduino" - //#define BLYNK_INFO_DEVICE "WIZWiki" - -#if defined (__AVR_ATmega644P__) - #define BLYNK_INFO_DEVICE "m644p_W5500" - #elif defined (__AVR_ATmega1284P__) - #define BLYNK_INFO_DEVICE "m1284p_W5500" - #else - #define BLYNK_INFO_DEVICE "Custom platform" - #endif - -#endif - -#ifndef BLYNK_INFO_CPU - //#define BLYNK_INFO_CPU "ATmega1284" - //#define BLYNK_INFO_CPU "ATmega2560" - //#define BLYNK_INFO_CPU "ATmega328P" - #if defined (__AVR_ATmega644P__) - #define BLYNK_INFO_CPU "ATmega644P" - #elif defined (__AVR_ATmega1284P__) - #define BLYNK_INFO_CPU "ATmega1284P" - #else - #define BLYNK_INFO_CPU "ATmega2560" - #endif -#endif - -#ifndef BLYNK_INFO_CONNECTION - #define BLYNK_INFO_CONNECTION "W5000" -#endif - -#define BLYNK_PARAM_KV(k, v) k "\0" v "\0" - -// General defines -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) - -// Custom defines -#define BLYNK_DEFAULT_CLIENT_PORT 1025 -#define BLYNK_CONNECTION_TIMEOUT_MS 5000 -#define BLINK_HEADER_SIZE 5 - -//#ifndef BlynkProtocolDefs_h -//#define BlynkProtocolDefs_h - -//BlynkCmd values compatible && synced with BLYNK_VERSION 0.6.0 -enum BlynkCmd -{ - BLYNK_CMD_RESPONSE = 0, - - //BLYNK_CMD_LOGIN = 2, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_CMD_LOGIN = 29, - BLYNK_CMD_PING = 6, - BLYNK_CMD_TWEET = 12, - BLYNK_CMD_EMAIL = 13, - //BLYNK_CMD_PUSH_NOTIFICATION = 14, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_CMD_NOTIFY = 14, - BLYNK_CMD_BRIDGE = 15, - BLYNK_CMD_HARDWARE_SYNC = 16, - BLYNK_CMD_INTERNAL = 17, - BLYNK_CMD_SMS = 18, - BLYNK_CMD_PROPERTY = 19, - BLYNK_CMD_HARDWARE = 20, - - //BLYNK_CMD_SAVE_PROF = 3, Deprecated on BLYNK_VERSION 0.6.0 - //BLYNK_CMD_LOAD_PROF = 4, Deprecated on BLYNK_VERSION 0.6.0 - //BLYNK_CMD_GET_TOKEN = 5, Deprecated on BLYNK_VERSION 0.6.0 - - BLYNK_CMD_REDIRECT = 41, - BLYNK_CMD_DEBUG_PRINT = 55, - BLYNK_CMD_EVENT_LOG = 64 - -}; - -//BlynkStatus values compatible && synced with BLYNK_VERSION 0.6.0 -enum BlynkStatus -{ - BLYNK_SUCCESS = 200, - //BLYNK_TIMEOUT = 1, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_QUOTA_LIMIT_EXCEPTION = 1, - //BLYNK_BAD_FORMAT = 2, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_ILLEGAL_COMMAND = 2, - BLYNK_NOT_REGISTERED = 3, - BLYNK_ALREADY_REGISTERED = 4, - //BLYNK_NO_LOGIN = 5, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_NOT_AUTHENTICATED = 5, - BLYNK_NOT_ALLOWED = 6, - //BLYNK_NO_CONNECTION = 7, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_DEVICE_NOT_IN_NETWORK = 7, - //BLYNK_NOT_SUPPORTED = 8, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_NO_ACTIVE_DASHBOARD = 8, - BLYNK_INVALID_TOKEN = 9, - //BLYNK_SERVER_ERROR = 10, Deprecated on BLYNK_VERSION 0.6.0 - //BLYNK_ALREADY_LOGGED_IN = 11, Deprecated on BLYNK_VERSION 0.6.0 - BLYNK_ILLEGAL_COMMAND_BODY = 11, - BLYNK_GET_GRAPH_DATA_EXCEPTION = 12, - BLYNK_NO_DATA_EXCEPTION = 17, - BLYNK_DEVICE_WENT_OFFLINE = 18, - BLYNK_SERVER_EXCEPTION = 19, - - BLYNK_NTF_INVALID_BODY = 13, - BLYNK_NTF_NOT_AUTHORIZED = 14, - BLYNK_NTF_ECXEPTION = 15, - - BLYNK_TIMEOUT = 16, - - BLYNK_NOT_SUPPORTED_VERSION = 20, - BLYNK_ENERGY_LIMIT = 21 - -}; - -typedef struct _BlynkHeader -{ - uint8_t type; - uint16_t msg_id; - uint16_t length; -} -BlynkHeader; - -typedef struct _BlynkParam -{ - uint8_t * buff; - uint16_t len; -} -BlynkParam; - -#if defined(__AVR_ATmega644P__) || defined (__AVR_ATmega1284P__) - #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) ) - #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ - ((x)<< 8 & 0x00FF0000UL) | \ - ((x)>> 8 & 0x0000FF00UL) | \ - ((x)>>24 & 0x000000FFUL) ) - #define ntohs(x) htons(x) - #define ntohl(x) htonl(x) - #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - #define htons(x) (x) - #define htonl(x) (x) - #define ntohs(x) (x) - #define ntohl(x) (x) - #else - #error byte order problem - #endif -#endif - -#define BLYNK_NEWLINE "\r\n" - -void blynk_begin(uint8_t * auth, uint8_t * dest_ip, uint16_t dest_port, uint8_t * buf, uint8_t socket); -void blynk_run(void); - -//void blynk_time_handler(void); -uint8_t is_blynk_connection_available(void); -/* -void sendCmd(uint8_t cmd, uint16_t id, uint8_t * data, size_t length, uint8_t * data2, size_t length2); -*/ -void blynk_syncAll(void); -void blynk_push_pin(uint8_t pin); -void blynk_push_virtual_pin(uint8_t pin); -void blynk_push_virtual_pin_msg(uint8_t pin, uint8_t * data); -#endif - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynkDependency.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynkDependency.c deleted file mode 100644 index 0ad570c..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynkDependency.c +++ /dev/null @@ -1,201 +0,0 @@ - -#include -#include "blynkDependency.h" -#include "../globals.h" - -#ifdef WIZNET_WIZ550WEB - #include "gpioHandler.h" - #include "userHandler.h" -#elif defined WIZNET_W5500_EVB - #include "board.h" - #include "adcHandler.h" -#endif - -uint8_t digitalRead(uint8_t pin) -{ - uint8_t val = pin; -#ifdef WIZNET_WIZ550WEB - val = get_IO_Status(pin); -#elif defined WIZNET_W5500_EVB - val = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]); -#else - PRINTF("digital pin %d read\r\n", pin); - if(pin == 21) - { - val = sw1_read()?0:!0; - PRINTF("SW1 is: %d %s\r\n", val, val?"HIGH":"LOW"); - } - else if(pin == 13) - { - val = led2_read()?1:0; - PRINTF("LED2 is: %d %s\r\n", val, val?"HIGH":"LOW"); - } - else - { - val = 1; - } -#endif - return val; -} - -void digitalWrite(uint8_t pin, uint8_t val) -{ -#ifdef WIZNET_WIZ550WEB - IOdata.ios[pin] = val; - if(val == HIGH) IO_On(pin); - else if(val == LOW) IO_Off(pin); - write_IOstorage(&IOdata, sizeof(IOdata)); -#elif defined WIZNET_W5500_EVB - if(val == HIGH) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], true); // High - else if(val == LOW) Chip_GPIO_SetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin], false); // Low -#else - PRINTF("digital pin %d write val %d\r\n", pin, val); - if(pin == 20) - { - if(val == 0) - { - led1_low(); - } - else - { - led1_high(); - } - //Rise flag to PUSH message to Virtual pin 20 - v20_changed = 1; - } -#endif -} - -uint16_t analogRead(uint8_t pin) -{ - uint16_t val = 0; -#ifdef WIZNET_WIZ550WEB - uint8_t analog_pin = 0; - if(pin > 14) analog_pin = pin - 14; - //PRINTF("analog_pin = %d\r\n", analog_pin); - val = get_ADC_val(analog_pin); -#elif defined WIZNET_W5500_EVB - uint8_t analog_pin = 0; - if(pin > 14) analog_pin = pin - 14; - PRINTF("analog_pin = %d\r\n", analog_pin); - if(analog_pin == A0) analog_pin = AIN; - PRINTF("changed analog_pin = %d\r\n", analog_pin); - val = get_ADC_val(analog_pin); -#else - if(pin == 6) - { - val = adc_read(6); - } - PRINTF("analog pin %d = %d\r\n", pin, val); -#endif - return val; -} - -void analogWrite(uint8_t pin, uint8_t val) -{ -#ifdef WIZNET_WIZ550WEB - PRINTF("Analog Write: Not supported yet. pin %d, val %d", pin, val); -#elif defined WIZNET_W5500_EVB - PRINTF("Analog Write: Not supported yet. pin %d, val %d", pin, val); -#else - PRINTF("analog pin %d write val %d\r\n", pin, val); -/* -* Handle PWM out PD7-PIN15: -* OCR2A = 0/127/255; Duty 0/50/100% -*/ - if(pin == 15) - { - OCR2A = val; - //Rise flag to PUSH message to Virtual pin 15 - v15_changed = 1; - } -#endif -} - -// Pin mode (dir) defines -// 0: Input -// 1: Output -// 2: Input Pull-up -void pinMode(uint8_t pin, pinmode_dir dir) -{ -// TODO: Add here example for AVR PULL-UP -#ifdef WIZNET_WIZ550WEB - if(dir == INPUT) IOdata.io[pin] = Input; - else if(dir == INPUT_PULLUP) IOdata.io[pin] = Input; - else if(dir == OUTPUT) IOdata.io[pin] = Output; // Output - IO_Init(pin); - write_IOstorage(&IOdata, sizeof(IOdata)); -#elif defined WIZNET_W5500_EVB - if(dir == INPUT) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input - else if(dir == INPUT_PULLUP) Chip_GPIO_SetPinDIRInput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Input - else if(dir == OUTPUT) Chip_GPIO_SetPinDIROutput(LPC_GPIO, dio_ports[pin], dio_pins[pin]); // Output -#else - PRINTF("pinmode setting: pin %d dir %d\r\n", pin, dir); - if((pin == 20)&&(dir ==1)) - { - //m1284p LED1 pin to out - led1_conf(); - } - else if((pin == 21)&&(dir == 0)) - { - //m1284p SW1 pin to input - sw1_conf(); - } -#endif -} - -// Virtual Pin Read -uint16_t virtualRead(uint8_t pin) -{ - uint16_t val = 0; - PRINTF("virtual pin %d read\r\n", pin); - //Example virtual pin reading - //Override your own handlers here like: - if(pin == 13) - { - //Digital read example from Virtual Pin 13 - val = led2_read()?1:0; - //PRINTF("LED2 is: %d %s\r\n", val, val?"HIGH":"LOW"); - } - else if(pin == 6) - { - //Analog read example from Virtual Pin 6 - val = adc_read(6); - //PRINTF("analog pin %d = %d\r\n", pin, val); - } - else if(pin == 15) - { - //PWM Value PIN15/PD7 - val = (uint16_t)OCR2A; - } - else if(pin == 20) - { - //Digital OUT Value PIN20/PC4 - val = led1_read()?1:0; - } - return val; -} - -void virtualWrite(uint8_t pin, uint16_t val) -{ - PRINTF("virtual pin %d write val %d\r\n", pin, val); - //Example virtual pin writing - //Override your own handlers here like: - if(pin == 15) - { - //Analog write example to Virtual Pin 15 - OCR2A = (uint8_t)val; - } - else if(pin == 20) - { - //Digital write example to Virtual Pin 20 - if(val == 0) - { - led1_low(); - } - else - { - led1_high(); - } - } -} diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynkDependency.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynkDependency.h deleted file mode 100644 index 0a49789..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/Blynk/blynkDependency.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _WIZNET_BLYNK_DEPENDENCY_H_ -#define _WIZNET_BLYNK_DEPENDENCY_H_ - -#include -#include "blynk.h" - -//////////////////////////////////////////////////////////////// -typedef enum { // Pin mode; directions - INPUT, - OUTPUT, - INPUT_PULLUP -}pinmode_dir; - -typedef enum {false = 0, true = !false} Boolian; - -#define HIGH 1 -#define LOW 0 -//////////////////////////////////////////////////////////////// - -uint8_t digitalRead(uint8_t pin); -void digitalWrite(uint8_t pin, uint8_t val); - -uint16_t analogRead(uint8_t pin); -void analogWrite(uint8_t pin, uint8_t val); - -uint16_t virtualRead(uint8_t pin); -void virtualWrite(uint8_t pin, uint16_t val); - -void pinMode(uint8_t pin, pinmode_dir dir); - -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c deleted file mode 100644 index a921092..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - printf("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h deleted file mode 100644 index 5a3a7d9..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Application/loopback/loopback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../../globals.h" -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE ETH_LOOPBACK_MAX_BUF_SIZE -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/Check out m1284 + W5500 app I've made.txt b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/Check out m1284 + W5500 app I've made.txt deleted file mode 100644 index 85bad8e..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/Check out m1284 + W5500 app I've made.txt +++ /dev/null @@ -1,8 +0,0 @@ -Hey, - -I've made m1284 + W5500 app. You are welcome to try it out! - -To start using it: -1. Download Blynk App: http://j.mp/blynk_Android or http://j.mp/blynk_iOS -2. Touch the QR-code icon and point the camera to the code below -3. Enjoy my app! diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/Screenshot_2019-03-18-13-37-20-278_cc.blynk.png b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/Screenshot_2019-03-18-13-37-20-278_cc.blynk.png deleted file mode 100644 index cbd18d1..0000000 Binary files a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/Screenshot_2019-03-18-13-37-20-278_cc.blynk.png and /dev/null differ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/app1_m1284p_and_W5500_QR.png b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/app1_m1284p_and_W5500_QR.png deleted file mode 100644 index d1a4369..0000000 Binary files a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/app1_m1284p_and_W5500_QR.png and /dev/null differ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/app2_m1284p_and_W5500_QR.png b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/app2_m1284p_and_W5500_QR.png deleted file mode 100644 index a45c06e..0000000 Binary files a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Blynk_application/app2_m1284p_and_W5500_QR.png and /dev/null differ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/socket.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/socket.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/DNS/dns.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/DNS/dns.c deleted file mode 100644 index 9f7107b..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/DNS/dns.c +++ /dev/null @@ -1,566 +0,0 @@ -//***************************************************************************** -// -//! \file dns.c -//! \brief DNS APIs Implement file. -//! \details Send DNS query & Receive DNS reponse. \n -//! It depends on stdlib.h & string.h in ansi-c library -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Remove the unused define -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#include -#include - -#include "socket.h" -#include "dns.h" - -#ifdef _DNS_DEBUG_ - #include -#endif - -#define INITRTT 2000L /* Initial smoothed response time */ -#define MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */ - -#define TYPE_A 1 /* Host address */ -#define TYPE_NS 2 /* Name server */ -#define TYPE_MD 3 /* Mail destination (obsolete) */ -#define TYPE_MF 4 /* Mail forwarder (obsolete) */ -#define TYPE_CNAME 5 /* Canonical name */ -#define TYPE_SOA 6 /* Start of Authority */ -#define TYPE_MB 7 /* Mailbox name (experimental) */ -#define TYPE_MG 8 /* Mail group member (experimental) */ -#define TYPE_MR 9 /* Mail rename name (experimental) */ -#define TYPE_NULL 10 /* Null (experimental) */ -#define TYPE_WKS 11 /* Well-known sockets */ -#define TYPE_PTR 12 /* Pointer record */ -#define TYPE_HINFO 13 /* Host information */ -#define TYPE_MINFO 14 /* Mailbox information (experimental)*/ -#define TYPE_MX 15 /* Mail exchanger */ -#define TYPE_TXT 16 /* Text strings */ -#define TYPE_ANY 255 /* Matches any type */ - -#define CLASS_IN 1 /* The ARPA Internet */ - -/* Round trip timing parameters */ -#define AGAIN 8 /* Average RTT gain = 1/8 */ -#define LAGAIN 3 /* Log2(AGAIN) */ -#define DGAIN 4 /* Mean deviation gain = 1/4 */ -#define LDGAIN 2 /* log2(DGAIN) */ - -/* Header for all domain messages */ -struct dhdr -{ - uint16_t id; /* Identification */ - uint8_t qr; /* Query/Response */ -#define QUERY 0 -#define RESPONSE 1 - uint8_t opcode; -#define IQUERY 1 - uint8_t aa; /* Authoratative answer */ - uint8_t tc; /* Truncation */ - uint8_t rd; /* Recursion desired */ - uint8_t ra; /* Recursion available */ - uint8_t rcode; /* Response code */ -#define NO_ERROR 0 -#define FORMAT_ERROR 1 -#define SERVER_FAIL 2 -#define NAME_ERROR 3 -#define NOT_IMPL 4 -#define REFUSED 5 - uint16_t qdcount; /* Question count */ - uint16_t ancount; /* Answer count */ - uint16_t nscount; /* Authority (name server) count */ - uint16_t arcount; /* Additional record count */ -}; - - -uint8_t* pDNSMSG; // DNS message buffer -uint8_t DNS_SOCKET; // SOCKET number for DNS -uint16_t DNS_MSGID; // DNS message ID - -uint32_t dns_1s_tick; // for timout of DNS processing -static uint8_t retry_count; - -/* converts uint16_t from network buffer to a host byte order integer. */ -uint16_t get16(uint8_t * s) -{ - uint16_t i; - i = *s++ << 8; - i = i + *s; - return i; -} - -/* copies uint16_t to the network buffer with network byte order. */ -uint8_t * put16(uint8_t * s, uint16_t i) -{ - *s++ = i >> 8; - *s++ = i; - return s; -} - - -/* - * CONVERT A DOMAIN NAME TO THE HUMAN-READABLE FORM - * - * Description : This function converts a compressed domain name to the human-readable form - * Arguments : msg - is a pointer to the reply message - * compressed - is a pointer to the domain name in reply message. - * buf - is a pointer to the buffer for the human-readable form name. - * len - is the MAX. size of buffer. - * Returns : the length of compressed message - */ -int parse_name(uint8_t * msg, uint8_t * compressed, char * buf, int16_t len) -{ - uint16_t slen; /* Length of current segment */ - uint8_t * cp; - int clen = 0; /* Total length of compressed name */ - int indirect = 0; /* Set if indirection encountered */ - int nseg = 0; /* Total number of segments in name */ - - cp = compressed; - - for (;;) - { - slen = *cp++; /* Length of this segment */ - - if (!indirect) clen++; - - if ((slen & 0xc0) == 0xc0) - { - if (!indirect) - clen++; - indirect = 1; - /* Follow indirection */ - cp = &msg[((slen & 0x3f)<<8) + *cp]; - slen = *cp++; - } - - if (slen == 0) /* zero length == all done */ - break; - - len -= slen + 1; - - if (len < 0) return -1; - - if (!indirect) clen += slen; - - while (slen-- != 0) *buf++ = (char)*cp++; - *buf++ = '.'; - nseg++; - } - - if (nseg == 0) - { - /* Root name; represent as single dot */ - *buf++ = '.'; - len--; - } - - *buf++ = '\0'; - len--; - - return clen; /* Length of compressed message */ -} - -/* - * PARSE QUESTION SECTION - * - * Description : This function parses the qeustion record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the qeustion record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_question(uint8_t * msg, uint8_t * cp) -{ - int len; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - - if (len == -1) return 0; - - cp += len; - cp += 2; /* type */ - cp += 2; /* class */ - - return cp; -} - - -/* - * PARSE ANSER SECTION - * - * Description : This function parses the answer record of the reply message. - * Arguments : msg - is a pointer to the reply message - * cp - is a pointer to the answer record. - * Returns : a pointer the to next record. - */ -uint8_t * dns_answer(uint8_t * msg, uint8_t * cp, uint8_t * ip_from_dns) -{ - int len, type; - char name[MAXCNAME]; - - len = parse_name(msg, cp, name, MAXCNAME); - - if (len == -1) return 0; - - cp += len; - type = get16(cp); - cp += 2; /* type */ - cp += 2; /* class */ - cp += 4; /* ttl */ - cp += 2; /* len */ - - - switch (type) - { - case TYPE_A: - /* Just read the address directly into the structure */ - ip_from_dns[0] = *cp++; - ip_from_dns[1] = *cp++; - ip_from_dns[2] = *cp++; - ip_from_dns[3] = *cp++; - break; - case TYPE_CNAME: - case TYPE_MB: - case TYPE_MG: - case TYPE_MR: - case TYPE_NS: - case TYPE_PTR: - /* These types all consist of a single domain name */ - /* convert it to ascii format */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_HINFO: - len = *cp++; - cp += len; - - len = *cp++; - cp += len; - break; - case TYPE_MX: - cp += 2; - /* Get domain name of exchanger */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - break; - case TYPE_SOA: - /* Get domain name of name server */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - /* Get domain name of responsible person */ - len = parse_name(msg, cp, name, MAXCNAME); - if (len == -1) return 0; - - cp += len; - - cp += 4; - cp += 4; - cp += 4; - cp += 4; - cp += 4; - break; - case TYPE_TXT: - /* Just stash */ - break; - default: - /* Ignore */ - break; - } - - return cp; -} - -/* - * PARSE THE DNS REPLY - * - * Description : This function parses the reply message from DNS server. - * Arguments : dhdr - is a pointer to the header for DNS message - * buf - is a pointer to the reply message. - * len - is the size of reply message. - * Returns : -1 - Domain name lenght is too big - * 0 - Fail (Timout or parse error) - * 1 - Success, - */ -int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns) -{ - uint16_t tmp; - uint16_t i; - uint8_t * msg; - uint8_t * cp; - - msg = pbuf; - memset(pdhdr, 0, sizeof(*pdhdr)); - - pdhdr->id = get16(&msg[0]); - tmp = get16(&msg[2]); - if (tmp & 0x8000) pdhdr->qr = 1; - - pdhdr->opcode = (tmp >> 11) & 0xf; - - if (tmp & 0x0400) pdhdr->aa = 1; - if (tmp & 0x0200) pdhdr->tc = 1; - if (tmp & 0x0100) pdhdr->rd = 1; - if (tmp & 0x0080) pdhdr->ra = 1; - - pdhdr->rcode = tmp & 0xf; - pdhdr->qdcount = get16(&msg[4]); - pdhdr->ancount = get16(&msg[6]); - pdhdr->nscount = get16(&msg[8]); - pdhdr->arcount = get16(&msg[10]); - - - /* Now parse the variable length sections */ - cp = &msg[12]; - - /* Question section */ - for (i = 0; i < pdhdr->qdcount; i++) - { - cp = dns_question(msg, cp); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Answer section */ - for (i = 0; i < pdhdr->ancount; i++) - { - cp = dns_answer(msg, cp, ip_from_dns); - #ifdef _DNS_DEUBG_ - printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h" - #endif - if(!cp) return -1; - } - - /* Name server (authority) section */ - for (i = 0; i < pdhdr->nscount; i++) - { - ; - } - - /* Additional section */ - for (i = 0; i < pdhdr->arcount; i++) - { - ; - } - - if(pdhdr->rcode == 0) return 1; // No error - else return 0; -} - - -/* - * MAKE DNS QUERY MESSAGE - * - * Description : This function makes DNS query message. - * Arguments : op - Recursion desired - * name - is a pointer to the domain name. - * buf - is a pointer to the buffer for DNS message. - * len - is the MAX. size of buffer. - * Returns : the pointer to the DNS message. - */ -int16_t dns_makequery(uint16_t op, char * name, uint8_t * buf, uint16_t len) -{ - uint8_t *cp; - char *cp1; - char sname[MAXCNAME]; - char *dname; - uint16_t p; - uint16_t dlen; - - cp = buf; - - DNS_MSGID++; - cp = put16(cp, DNS_MSGID); - p = (op << 11) | 0x0100; /* Recursion desired */ - cp = put16(cp, p); - cp = put16(cp, 1); - cp = put16(cp, 0); - cp = put16(cp, 0); - cp = put16(cp, 0); - - strcpy(sname, name); - dname = sname; - dlen = strlen(dname); - for (;;) - { - /* Look for next dot */ - cp1 = strchr(dname, '.'); - - if (cp1 != NULL) len = cp1 - dname; /* More to come */ - else len = dlen; /* Last component */ - - *cp++ = len; /* Write length of component */ - if (len == 0) break; - - /* Copy component up to (but not including) dot */ - strncpy((char *)cp, dname, len); - cp += len; - if (cp1 == NULL) - { - *cp++ = 0; /* Last one; write null and finish */ - break; - } - dname += len+1; - dlen -= len+1; - } - - cp = put16(cp, 0x0001); /* type */ - cp = put16(cp, 0x0001); /* class */ - - return ((int16_t)((uint32_t)(cp) - (uint32_t)(buf))); -} - -/* - * CHECK DNS TIMEOUT - * - * Description : This function check the DNS timeout - * Arguments : None. - * Returns : -1 - timeout occurred, 0 - timer over, but no timeout, 1 - no timer over, no timeout occur - * Note : timeout : retry count and timer both over. - */ - -int8_t check_DNS_timeout(void) -{ - - if(dns_1s_tick >= DNS_WAIT_TIME) - { - dns_1s_tick = 0; - if(retry_count >= MAX_DNS_RETRY) { - retry_count = 0; - return -1; // timeout occurred - } - retry_count++; - return 0; // timer over, but no timeout - } - - return 1; // no timer over, no timeout occur -} - - - -/* DNS CLIENT INIT */ -void DNS_init(uint8_t s, uint8_t * buf) -{ - DNS_SOCKET = s; // SOCK_DNS - pDNSMSG = buf; // User's shared buffer - DNS_MSGID = DNS_MSG_ID; -} - -/* DNS CLIENT RUN */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns) -{ - int8_t ret; - struct dhdr dhp; - uint8_t ip[4]; - uint16_t len, port; - int8_t ret_check_timeout; - - retry_count = 0; - dns_1s_tick = 0; - - // Socket open - socket(DNS_SOCKET, Sn_MR_UDP, 0, 0); - -#ifdef _DNS_DEBUG_ - printf("> DNS Query to DNS Server : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - - len = dns_makequery(0, (char *)name, pDNSMSG, MAX_DNS_BUF_SIZE); - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - - while (1) - { - if ((len = getSn_RX_RSR(DNS_SOCKET)) > 0) - { - if (len > MAX_DNS_BUF_SIZE) len = MAX_DNS_BUF_SIZE; - len = recvfrom(DNS_SOCKET, pDNSMSG, len, ip, &port); - #ifdef _DNS_DEBUG_ - printf("> Receive DNS message from %d.%d.%d.%d(%d). len = %d\r\n", ip[0], ip[1], ip[2], ip[3],port,len); - #endif - ret = parseDNSMSG(&dhp, pDNSMSG, ip_from_dns); - break; - } - // Check Timeout - ret_check_timeout = check_DNS_timeout(); - if (ret_check_timeout < 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Server is not responding : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]); -#endif - return 0; // timeout occurred - } - else if (ret_check_timeout == 0) { - -#ifdef _DNS_DEBUG_ - printf("> DNS Timeout\r\n"); -#endif - sendto(DNS_SOCKET, pDNSMSG, len, dns_ip, IPPORT_DOMAIN); - } - } - close(DNS_SOCKET); - // Return value - // 0 > : failed / 1 - success - return ret; -} - - -/* DNS TIMER HANDLER */ -void DNS_time_handler(void) -{ - dns_1s_tick++; -} - - - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/DNS/dns.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/DNS/dns.h deleted file mode 100644 index 6f6aa6b..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/DNS/dns.h +++ /dev/null @@ -1,109 +0,0 @@ -//***************************************************************************** -// -//! \file dns.h -//! \brief DNS APIs Header file. -//! \details Send DNS query & Receive DNS reponse. -//! \version 1.1.0 -//! \date 2013/11/18 -//! \par Revision history -//! <2013/10/21> 1st Release -//! <2013/12/20> V1.1.0 -//! 1. Remove secondary DNS server in DNS_run -//! If 1st DNS_run failed, call DNS_run with 2nd DNS again -//! 2. DNS_timerHandler -> DNS_time_handler -//! 3. Move the no reference define to dns.c -//! 4. Integrated dns.h dns.c & dns_parse.h dns_parse.c into dns.h & dns.c -//! <2013/12/20> V1.1.0 -//! -//! \author Eric Jung & MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -#ifndef _DNS_H_ -#define _DNS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/* - * @brief Define it for Debug & Monitor DNS processing. - * @note If defined, it dependens on - */ -//#define _DNS_DEBUG_ - -#define MAX_DNS_BUF_SIZE 256 ///< maximum size of DNS buffer. */ -/* - * @brief Maxium length of your queried Domain name - * @todo SHOULD BE defined it equal as or greater than your Domain name lenght + null character(1) - * @note SHOULD BE careful to stack overflow because it is allocated 1.5 times as MAX_DOMAIN_NAME in stack. - */ -#define MAX_DOMAIN_NAME 16 // for example "www.google.com" - -#define MAX_DNS_RETRY 2 ///< Requery Count -#define DNS_WAIT_TIME 3 ///< Wait response time. unit 1s. - -#define IPPORT_DOMAIN 53 ///< DNS server port number - -#define DNS_MSG_ID 0x1122 ///< ID for DNS message. You can be modifyed it any number -/* - * @brief DNS process initialize - * @param s : Socket number for DNS - * @param buf : Buffer for DNS message - */ -void DNS_init(uint8_t s, uint8_t * buf); - -/* - * @brief DNS process - * @details Send DNS query and receive DNS response - * @param dns_ip : DNS server ip - * @param name : Domain name to be queryed - * @param ip_from_dns : IP address from DNS server - * @return -1 : failed. @ref MAX_DOMIN_NAME is too small \n - * 0 : failed (Timeout or Parse error)\n - * 1 : success - * @note This funtion blocks until success or fail. max time = @ref MAX_DNS_RETRY * @ref DNS_WAIT_TIME - */ -int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns); - -/* - * @brief DNS 1s Tick Timer handler - * @note SHOULD BE register to your system 1s Tick timer handler - */ -void DNS_time_handler(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _DNS_H_ */ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c deleted file mode 100644 index a1621d7..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.c +++ /dev/null @@ -1,1304 +0,0 @@ -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.c -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : FTP daemon. (AVR-GCC Compiler) -*/ - -#include -#include -#include -#include -#include -//#include "stdio_private.h" -#include "socket.h" -#include "ftpd.h" - -/* Command table */ -static char *commands[] = { - "user", - "acct", - "pass", - "type", - "list", - "cwd", - "dele", - "name", - "quit", - "retr", - "stor", - "port", - "nlst", - "pwd", - "xpwd", - "mkd", - "xmkd", - "xrmd", - "rmd ", - "stru", - "mode", - "syst", - "xmd5", - "xcwd", - "feat", - "pasv", - "size", - "mlsd", - "appe", - NULL -}; - -#if 0 -/* Response messages */ -char banner[] = "220 %s FTP version %s ready.\r\n"; -char badcmd[] = "500 Unknown command '%s'\r\n"; -char binwarn[] = "100 Warning: type is ASCII and %s appears to be binary\r\n"; -char unsupp[] = "500 Unsupported command or option\r\n"; -char givepass[] = "331 Enter PASS command\r\n"; -char logged[] = "230 Logged in\r\n"; -char typeok[] = "200 Type %s OK\r\n"; -char only8[] = "501 Only logical bytesize 8 supported\r\n"; -char deleok[] = "250 File deleted\r\n"; -char mkdok[] = "200 MKD ok\r\n"; -char delefail[] = "550 Delete failed: %s\r\n"; -char pwdmsg[] = "257 \"%s\" is current directory\r\n"; -char badtype[] = "501 Unknown type \"%s\"\r\n"; -char badport[] = "501 Bad port syntax\r\n"; -char unimp[] = "502 Command does not implemented yet.\r\n"; -char bye[] = "221 Goodbye!\r\n"; -char nodir[] = "553 Can't read directory \"%s\": %s\r\n"; -char cantopen[] = "550 Can't read file \"%s\": %s\r\n"; -char sending[] = "150 Opening data connection for %s (%d.%d.%d.%d,%d)\r\n"; -char cantmake[] = "553 Can't create \"%s\": %s\r\n"; -char writerr[] = "552 Write error: %s\r\n"; -char portok[] = "200 PORT command successful.\r\n"; -char rxok[] = "226 Transfer complete.\r\n"; -char txok[] = "226 Transfer complete.\r\n"; -char noperm[] = "550 Permission denied\r\n"; -char noconn[] = "425 Data connection reset\r\n"; -char lowmem[] = "421 System overloaded, try again later\r\n"; -char notlog[] = "530 Please log in with USER and PASS\r\n"; -char userfirst[] = "503 Login with USER first.\r\n"; -char okay[] = "200 Ok\r\n"; -char syst[] = "215 %s Type: L%d Version: %s\r\n"; -char sizefail[] = "550 File not found\r\n"; -#endif - -un_l2cval remote_ip; -uint16_t remote_port; -un_l2cval local_ip; -uint16_t local_port; -uint8_t connect_state_control = 0; -uint8_t connect_state_data = 0; - -struct ftpd ftp; - -int current_year = 2014; -int current_month = 12; -int current_day = 31; -int current_hour = 10; -int current_min = 10; -int current_sec = 30; - -//int fsprintf(uint8_t s, const char *format, ...) -//{ -// int i; -///* -// char buf[LINELEN]; -// FILE f; -// va_list ap; -// -// f.flags = __SWR | __SSTR; -// f.buf = buf; -// f.size = INT_MAX; -// va_start(ap, format); -// i = vfprintf(&f, format, ap); -// va_end(ap); -// buf[f.len] = 0; -// -// send(s, (uint8_t *)buf, strlen(buf)); -//*/ -// return i; -//} - -void ftpd_init(uint8_t * src_ip) -{ - ftp.state = FTPS_NOT_LOGIN; - ftp.current_cmd = NO_CMD; - ftp.dsock_mode = ACTIVE_MODE; - - local_ip.cVal[0] = src_ip[0]; - local_ip.cVal[1] = src_ip[1]; - local_ip.cVal[2] = src_ip[2]; - local_ip.cVal[3] = src_ip[3]; - local_port = 35000; - - strcpy(ftp.workingdir, "/"); - - socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0); -} - -/* - * From: FatFs - FAT file system module R0.10c - */ -int get_filesize(char* path, char *filename) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i, len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ -#if _USE_LFN - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - if(*path == 0x00) - res = f_opendir(&dir, "/"); - else - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - for(;;){ - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - if(!strcmp(fn, filename)) - { - if(fno.fattrib & AM_DIR){ - //printf("\r\n%s/%s is a directory\r\n", path, filename); - return 0; - } - return fno.fsize; - } - } - //printf("\r\n%s/%s was not found\r\n", path, filename); - //f_closedir(&dir); - } - return -1; -} - -/* - * Inserted from earlier realize FAT FS -> - * FAT file system module R0.10c (C)ChaN, 2014 - */ -/* - * Preferable structure of out see here: - * https://files.stairways.com/other/ftp-list-specs-info.txt - * - * something like: - -rw------- 1 peter 848 Dec 14 11:22 00README.txt -or - - whatever you feel like 848 Dec 14 11:22 00README.txt - - * also - * http://cr.yp.to/ftp/list/binls.html - * -/bin/ls format is a series of lines terminated by \015\012. Servers using /bin/ls format need to be prepared to generate lines in the following form: - - -rw-r--r-- 1 owner group 213 Aug 26 16:31 README - -The line contains - - - for a regular file or d for a directory; - the literal string rw-r--r-- 1 owner group for a regular file, or rwxr-xr-x 1 owner group for a directory; - the file size in decimal right-justified in a 13-byte field; - a three-letter month name, first letter capitalized; - a day number right-justified in a 3-byte field; - a space and a 2-digit hour number; - a colon and a 2-digit minute number; - a space and the abbreviated pathname of the file. - */ -FRESULT scan_files(char* path, char *buf, int * items_count) -{ - FRESULT res; - FILINFO fno; - DIR dir; - int i; - int len, buf_ptr = 0; - char *fn; /* This function is assuming no_Unicode cfg.*/ - char date_str[21]; - int date_str_ptr = 0; - int file_read_count = 0; - int file_read_count_10 = 0; - uint16_t size_dbuf = 0; -#if _USE_LFN == 1 - static char lfn[_MAX_LFN + 1]; - fno.lfname = lfn; - fno.lfsize = sizeof(lfn); -#endif - - res = f_opendir(&dir, path); - //printf("f_opendir res: %d\r\n", res); - if(res == FR_OK){ - i = strlen(path); - //printf("strlen of path: %s %d \r\n", path, i); - for(;;){ - wdt_reset(); - res = f_readdir(&dir, &fno); - if(res != FR_OK || fno.fname[0] == 0) break; - if(fno.fname[0] == '.') continue; -#if _USE_LFN == 1 - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; - - //Print out yet only first 30 files for full info - //if(file_read_count > 30) - //Print out yet only first 45 files for short info - /* - if(file_read_count > 45) - { - break; - } - */ - //!!Debug only - file_read_count++; -#if defined(_FTP_DEBUG_) - PRINTF("%02u:%9lu %s\r\n", (file_read_count+file_read_count_10), fno.fsize, fn); -#endif -#endif - //Encode date file like this (time show no correct, so remove): - //Aug 26 2018 - switch((fno.fdate >> 5) & 0x0f) - { - case 1: - len = SPRINTF(date_str, "JAN "); - break; - case 2: - len = SPRINTF(date_str, "FEB "); - break; - case 3: - len = SPRINTF(date_str, "MAR "); - break; - case 4: - len = SPRINTF(date_str, "APR "); - break; - case 5: - len = SPRINTF(date_str, "MAY "); - break; - case 6: - len = SPRINTF(date_str, "JUN "); - break; - case 7: - len = SPRINTF(date_str, "JUL "); - break; - case 8: - len = SPRINTF(date_str, "AUG "); - break; - case 9: - len = SPRINTF(date_str, "SEP "); - break; - case 10: - len = SPRINTF(date_str, "OCT "); - break; - case 11: - len = SPRINTF(date_str, "NOV "); - break; - case 12: - len = SPRINTF(date_str, "DEC "); - break; - } - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%2d ", (fno.fdate & 0x1f)); - date_str_ptr += len; - len = SPRINTF(date_str + date_str_ptr, "%d ", (((fno.fdate >> 9) & 0x7f) + 1980)); - //Time show not correct, so remove - /* - date_str_ptr += len; - len = sprintf(date_str + date_str_ptr, "%02u:%02u", (fno.ftime >> 11), (fno.ftime >> 5) & 63); - */ - date_str_ptr = 0; - - //printf("date str : %s \r\n", date_str); - - //Directory or file prefix - if(fno.fattrib & AM_DIR) - { - SPRINTF(buf + buf_ptr, "d"); - }else - { - SPRINTF(buf + buf_ptr, "-"); - } - buf_ptr++; - //Should not use here - /* - // drwxr-xr-x 1 ftp ftp 0 Apr 07 2014 $RECYCLE.BIN\r\n - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %d %s %s\r\n", fno.fsize, date_str, fn); - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %u %s %s\r\n", fno.fsize, date_str, fn); - - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp ftp %s\r\n", fn); - - - //len = sprintf(buf + buf_ptr, " %6lu %s\r\n",fno.fsize, fn);// - Good minimum, but not seen on WinSCP - - - //len = sprintf(buf + buf_ptr, " %s\r\n", fn);// - Good minimum, but not seen on WinSCP - */ - - //Full with fake data - //len = sprintf(buf + buf_ptr, "rwxr-xr-x 1 ftp %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) - - //Short without access rights and owner with fake data - /* - len = SPRINTF(buf + buf_ptr, " 1 %lu JAN 01 2000 %s\r\n", fno.fsize, fn); //- Works on WinSCP with fake data (OK) without access rights and owner - */ - - //Medium with real data file, without access rights and owner - len = SPRINTF(buf + buf_ptr, " 1 %9lu %s %s\r\n", fno.fsize, date_str, fn); //- Works on WinSCP with real data (OK) without access rights and owner - - buf_ptr += len; - - if(file_read_count > 9) - { - //Send out info about files in 10 items maximum - file_read_count = 0; - file_read_count_10 += 10; - //*buf_len = strlen(buf); - - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - - buf_ptr = 0; - - } - - //printf("fn: %s \r\n", fn); - - } - //Send out last packet with files numbers 1..9 - if(file_read_count) - { - size_dbuf = strlen(buf); - send(DATA_SOCK, buf, size_dbuf); - - //!!Debug only - //PRINTF("++Send packet: %u bytes\r\n", size_dbuf); - } - - //*buf_len = strlen(buf); - *items_count = file_read_count + file_read_count_10; //Return number of sending file - //printf("%s", buf); - //printf("\r\nbuf_len : %d, sizeof(buf): %d\r\n", buf_len, sizeof(buf)); - f_closedir(&dir); - } - return res; -} - -uint8_t ftpd_run(uint8_t * dbuf) -{ - uint16_t size = 0, i; - long ret = 0; - uint32_t blocklen, send_byte, recv_byte; - uint32_t remain_filesize; - uint32_t remain_datasize; -#if defined(F_FILESYSTEM) - //FILINFO fno; -#endif - - //memset(dbuf, 0, sizeof(_MAX_SS_FTPD)); - - switch(getSn_SR(CTRL_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_control) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Connected\r\n", CTRL_SOCK); -#endif - //fsprintf(CTRL_SOCK, banner, HOSTNAME, VERSION); - strcpy(ftp.workingdir, "/"); - SPRINTF((char *)dbuf, "220 %s FTP version %s ready.\r\n", HOSTNAME, VERSION); - ret = send(CTRL_SOCK, (uint8_t *)dbuf, strlen((const char *)dbuf)); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - connect_state_control = 1; - } - -#if defined(_FTP_DEBUG_) - //printf("ftp socket %d\r\n", CTRL_SOCK); -#endif - - if((size = getSn_RX_RSR(CTRL_SOCK)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { -#if defined(_FTP_DEBUG_) - PRINTF("size: %d\r\n", size); -#endif - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(size > _MAX_SS_FTPD) size = _MAX_SS_FTPD - 1; - - ret = recv(CTRL_SOCK,dbuf,size); - dbuf[ret] = '\0'; - if(ret != size) - { - if(ret==SOCK_BUSY) return 0; - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:recv() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("Rcvd Command: %s", dbuf); -#endif - proc_ftpd((char *)dbuf); - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",CTRL_SOCK); -#endif - if((ret=disconnect(CTRL_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",CTRL_SOCK); -#endif - break; - - case SOCK_CLOSED : -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPStart\r\n",CTRL_SOCK); -#endif - if((ret=socket(CTRL_SOCK, Sn_MR_TCP, IPPORT_FTP, 0x0)) != CTRL_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", CTRL_SOCK, ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",CTRL_SOCK); -#endif - //strcpy(ftp.workingdir, "/"); - if( (ret = listen(CTRL_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",CTRL_SOCK); -#endif - return ret; - } - connect_state_control = 0; - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",CTRL_SOCK); -#endif - break; - - default : - break; - } - -#if 1 - switch(getSn_SR(DATA_SOCK)) - { - case SOCK_ESTABLISHED : - if(!connect_state_data) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTP Data socket Connected\r\n", DATA_SOCK); -#endif - connect_state_data = 1; - } - - switch(ftp.current_cmd) - { - case LIST_CMD: - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("previous size: %u\r\n", size); -#endif -#if defined(F_FILESYSTEM) - scan_files(ftp.workingdir, dbuf, (int *)&size); -#endif -#if defined(_FTP_DEBUG_) - PRINTF("Items count: %u\r\n", size); - //PRINTF("%s\r\n", dbuf); -#endif -#if !defined(F_FILESYSTEM) - if (strncmp(ftp.workingdir, "/$Recycle.Bin", sizeof("/$Recycle.Bin")) != 0) - size = sprintf(dbuf, "drwxr-xr-x 1 ftp ftp 0 Dec 31 2014 $Recycle.Bin\r\n-rwxr-xr-x 1 ftp ftp 512 Dec 31 2014 test.txt\r\n"); -#endif - /* - size = strlen(dbuf); - send(DATA_SOCK, dbuf, size); - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - */ - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, dbuf, size); - break; - - case RETR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to retrieve : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_READ); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ - remain_filesize = ftp.fil.fsize; -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - do{ -#if defined(_FTP_DEBUG_) - //printf("remained file size: %d\r\n", ftp.fil.fsize); -#endif - wdt_reset(); - - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_filesize > _MAX_SS_FTPD) - send_byte = _MAX_SS_FTPD; - else - send_byte = remain_filesize; - - - uint16_t _blocklen; - ftp.fr = f_read(&(ftp.fil), dbuf, send_byte ,&_blocklen); - if(ftp.fr != FR_OK) - break; -#if defined(_FTP_DEBUG_) - PRINTF("#"); - //printf("----->fsize:%d recv:%d len:%d \r\n", remain_filesize, send_byte, blocklen); - //printf("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - uint32_t send_size; - send_size = send(DATA_SOCK, dbuf, _blocklen); - //remain_filesize -= blocklen; - remain_filesize -= send_size; - }while(remain_filesize != 0); -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile read finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } -#else - remain_filesize = strlen(ftp.filename); - - do{ - memset(dbuf, 0, _MAX_SS_FTPD); - - blocklen = sprintf(dbuf, "%s", ftp.filename); - - printf("########## dbuf:%s\r\n", dbuf); - - send(DATA_SOCK, dbuf, blocklen); - remain_filesize -= blocklen; - }while(remain_filesize != 0); - -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); - break; - - case STOR_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("filename to store : %s %d\r\n", ftp.filename, strlen(ftp.filename)); -#endif -#if defined(F_FILESYSTEM) - ftp.fr = f_open(&(ftp.fil), (const char *)ftp.filename, FA_CREATE_ALWAYS | FA_WRITE); - //print_filedsc(&(ftp.fil)); - if(ftp.fr == FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_open return FR_OK\r\n"); -#endif - while(1){ - wdt_reset(); - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - wdt_reset(); - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf,(uint16_t) recv_byte); -#if defined(_FTP_DEBUG_) - //PRINTF("----->fn:%s data:%s \r\n", ftp.filename, dbuf); -#endif - - uint16_t _blocklen; - ftp.fr = f_write(&(ftp.fil), dbuf, (UINT)ret, &_blocklen); -#if defined(_FTP_DEBUG_) - //PRINTF("----->dsize:%lu recv:%lu len:%u \r\n", remain_datasize, ret, _blocklen); -#endif - remain_datasize -= (uint32_t)_blocklen; - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - - if(remain_datasize <= 0) - break; - } - - if(ftp.fr != FR_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("f_write failed\r\n"); -#endif - break; - } - -#if defined(_FTP_DEBUG_) - PRINTF("#"); -#endif - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("\r\nFile write finished\r\n"); -#endif - ftp.fr = f_close(&(ftp.fil)); - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("File Open Error: %d\r\n", ftp.fr); -#endif - } - - //fno.fdate = (WORD)(((current_year - 1980) << 9) | (current_month << 5) | current_day); - //fno.ftime = (WORD)((current_hour << 11) | (current_min << 5) | (current_sec >> 1)); - //f_utime((const char *)ftp.filename, &fno); -#else - while(1){ - if((remain_datasize = getSn_RX_RSR(DATA_SOCK)) > 0){ - while(1){ - memset(dbuf, 0, _MAX_SS_FTPD); - - if(remain_datasize > _MAX_SS_FTPD) - recv_byte = _MAX_SS_FTPD; - else - recv_byte = remain_datasize; - - ret = recv(DATA_SOCK, dbuf, recv_byte); - - printf("########## dbuf:%s\r\n", dbuf); - - remain_datasize -= ret; - - if(remain_datasize <= 0) - break; - } - }else{ - if(getSn_SR(DATA_SOCK) != SOCK_ESTABLISHED) - break; - } - } -#endif - ftp.current_cmd = NO_CMD; - disconnect(DATA_SOCK); - size = SPRINTF(dbuf, "226 Successfully transferred \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, dbuf, size); -#ifdef BOOT_EN - if (strcasestr_P((const char *)ftp.filename, PSTR("1284BOOT.BIN"))) - { - //Found event "1284BOOT.BIN" upload to SD from FTPD, rise signal to running BootLoader (via WDT reset) -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>Catch <1284BOOT.BIN> upload event, so run BOOTLOADER\r\n"); -#endif - sig_reset_board = 1; - } -#endif - break; - - case NO_CMD: - default: - break; - } - break; - - case SOCK_CLOSE_WAIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:CloseWait\r\n",DATA_SOCK); -#endif - if((ret=disconnect(DATA_SOCK)) != SOCK_OK) return ret; -#if defined(_FTP_DEBUG_) - PRINTF("%d:Closed\r\n",DATA_SOCK); -#endif - break; - - case SOCK_CLOSED : - if(ftp.dsock_state == DATASOCK_READY) - { - if(ftp.dsock_mode == PASSIVE_MODE){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[PASSIV_MODE], port : %u\r\n",DATA_SOCK, local_port); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - - local_port++; - if(local_port > 50000) - local_port = 35000; - }else{ -#if defined(_FTP_DEBUG_) - PRINTF("%d:FTPDataStart[ACTIVE_MODE], port : %u\r\n",DATA_SOCK, IPPORT_FTPD); -#endif - if((ret=socket(DATA_SOCK, Sn_MR_TCP, IPPORT_FTPD, 0x0)) != DATA_SOCK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:socket() error:%ld\r\n", DATA_SOCK, ret); -#endif - close(DATA_SOCK); - return ret; - } - } - - ftp.dsock_state = DATASOCK_START; - } - break; - - case SOCK_INIT : -#if defined(_FTP_DEBUG_) - PRINTF("%d:Opened\r\n",DATA_SOCK); -#endif - if(ftp.dsock_mode == PASSIVE_MODE){ - if( (ret = listen(DATA_SOCK)) != SOCK_OK) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen error\r\n",DATA_SOCK); -#endif - return ret; - } - -#if defined(_FTP_DEBUG_) - PRINTF("%d:Listen ok\r\n",DATA_SOCK); -#endif - }else{ - - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#1\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { -#if defined(_FTP_DEBUG_) - PRINTF("DATA_SOCK Connect#1 OK\r\n"); -#endif - } - //Try to FIX STOR command - } - connect_state_data = 0; - break; - - default : - break; - } -#endif - - return 0; -} - -char proc_ftpd(char * buf) -{ - char **cmdp, *cp, *arg, *tmpstr; - char sendbuf[200]; - int slen; - long ret; - - - /* Translate first word to lower case */ - for (cp = buf; *cp != ' ' && *cp != '\0'; cp++) - *cp = tolower(*cp); - - /* Find command in table; if not present, return syntax error */ - for (cmdp = commands; *cmdp != NULL; cmdp++) - if (strncmp(*cmdp, buf, strlen(*cmdp)) == 0) - break; - - if (*cmdp == NULL) - { - //fsprintf(CTRL_SOCK, badcmd, buf); - slen = SPRINTF(sendbuf, "500 Unknown command '%s'\r\n", buf); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - /* Allow only USER, PASS and QUIT before logging in */ - if (ftp.state == FTPS_NOT_LOGIN) - { - switch(cmdp - commands) - { - case USER_CMD: - case PASS_CMD: - case QUIT_CMD: - break; - default: - //fsprintf(CTRL_SOCK, notlog); - slen = SPRINTF(sendbuf, "530 Please log in with USER and PASS\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - return 0; - } - } - - arg = &buf[strlen(*cmdp)]; - while(*arg == ' ') arg++; - - /* Execute specific command */ - switch (cmdp - commands) - { - case USER_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("USER_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - strcpy(ftp.username, arg); - //fsprintf(CTRL_SOCK, givepass); - slen = SPRINTF(sendbuf, "331 Enter PASS command\r\n"); - ret = send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - if(ret < 0) - { -#if defined(_FTP_DEBUG_) - PRINTF("%d:send() error:%ld\r\n",CTRL_SOCK,ret); -#endif - close(CTRL_SOCK); - return ret; - } - break; - - case PASS_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("PASS_CMD : %s", arg); -#endif - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - ftplogin(arg); - break; - - case TYPE_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - switch(arg[0]) - { - case 'A': - case 'a': /* Ascii */ - ftp.type = ASCII_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case 'B': - case 'b': /* Binary */ - case 'I': - case 'i': /* Image */ - ftp.type = IMAGE_TYPE; - //fsprintf(CTRL_SOCK, typeok, arg); - slen = SPRINTF(sendbuf, "200 Type set to %s\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badtype, arg); - slen = SPRINTF(sendbuf, "501 Unknown type \"%s\"\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - break; - - case FEAT_CMD : - slen = SPRINTF(sendbuf, "211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST size*;type*;create*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 END\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case QUIT_CMD : -#if defined(_FTP_DEBUG_) - PRINTF("QUIT_CMD\r\n"); -#endif - //fsprintf(CTRL_SOCK, bye); - slen = SPRINTF(sendbuf, "221 Goodbye!\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(CTRL_SOCK); - break; - - case RETR_CMD : - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("RETR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = sprintf(sendbuf, "150 Opening data channel for file downloand from server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = RETR_CMD; - break; - - case APPE_CMD : - case STOR_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(_FTP_DEBUG_) - PRINTF("STOR_CMD\r\n"); -#endif - if(strlen(ftp.workingdir) == 1) - SPRINTF(ftp.filename, "/%s", arg); - else - SPRINTF(ftp.filename, "%s/%s", ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "150 Opening data channel for file upload to server of \"%s\"\r\n", ftp.filename); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = STOR_CMD; - /* - if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){ -#if defined(_FTP_DEBUG_) - PRINTF("%d:Connect error#2\r\n", DATA_SOCK); - PRINTF("To ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - return ret; - } - else - { - //!!Debug only!! - PRINTF("DATA_SOCK Connect#2 OK\r\n"); - } - */ - //Try to FIX STOR command - connect_state_data = 0; - break; - - case PORT_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("PORT_CMD\r\n"); -#endif - if (pport(arg) == -1){ - //fsprintf(CTRL_SOCK, badport); - slen = SPRINTF(sendbuf, "501 Bad port syntax\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } else{ - //fsprintf(CTRL_SOCK, portok); - ftp.dsock_mode = ACTIVE_MODE; - ftp.dsock_state = DATASOCK_READY; - slen = SPRINTF(sendbuf, "200 PORT command successful.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - } - break; - - case MLSD_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("MLSD_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = MLSD_CMD; - break; - - case LIST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("LIST_CMD\r\n"); -#endif - slen = SPRINTF(sendbuf, "150 Opening data channel for directory listing of \"%s\"\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.current_cmd = LIST_CMD; - break; - - case NLST_CMD: -#if defined(_FTP_DEBUG_) - PRINTF("NLST_CMD\r\n"); -#endif - break; - - case SYST_CMD: - slen = SPRINTF(sendbuf, "215 UNIX emulated by WIZnet\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PWD_CMD: - case XPWD_CMD: - slen = SPRINTF(sendbuf, "257 \"%s\" is current directory.\r\n", ftp.workingdir); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case PASV_CMD: - slen = SPRINTF(sendbuf, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", local_ip.cVal[0], local_ip.cVal[1], local_ip.cVal[2], local_ip.cVal[3], local_port >> 8, local_port & 0x00ff); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - disconnect(DATA_SOCK); - ftp.dsock_mode = PASSIVE_MODE; - ftp.dsock_state = DATASOCK_READY; -#if defined(_FTP_DEBUG_) - PRINTF("PASV port: %u\r\n", local_port); -#endif - break; - - case SIZE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = _MAX_SS_FTPD; -#endif - if(slen > 0) - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - else - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - else - { - slen = SPRINTF(sendbuf, "550 File not Found\r\n"); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case CWD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; - if(slen > 3) - { - arg[slen - 3] = 0x00; - tmpstr = strrchr(arg, '/'); - *tmpstr = 0; -#if defined(F_FILESYSTEM) - slen = get_filesize(arg, tmpstr + 1); -#else - slen = 0; -#endif - *tmpstr = '/'; - if(slen == 0){ - slen = SPRINTF(sendbuf, "213 %d\r\n", slen); - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - else - { - slen = SPRINTF(sendbuf, "550 CWD failed. \"%s\"\r\n", arg); - } - } - else - { - strcpy(ftp.workingdir, arg); - slen = SPRINTF(sendbuf, "250 CWD successful. \"%s\" is current directory.\r\n", ftp.workingdir); - } - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case MKD_CMD: - case XMKD_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_mkdir(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Can't create directory. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "257 MKD command successful. \"%s\"\r\n", arg); - //strcpy(ftp.workingdir, arg); - } -#else - slen = SPRINTF(sendbuf, "550 Can't create directory. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case DELE_CMD: - slen = strlen(arg); - arg[slen - 1] = 0x00; - arg[slen - 2] = 0x00; -#if defined(F_FILESYSTEM) - if (f_unlink(arg) != 0) - { - slen = SPRINTF(sendbuf, "550 Could not delete. \"%s\"\r\n", arg); - } - else - { - slen = SPRINTF(sendbuf, "250 Deleted. \"%s\"\r\n", arg); - } -#else - slen = SPRINTF(sendbuf, "550 Could not delete. Permission denied\r\n"); -#endif - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - case XCWD_CMD: - case ACCT_CMD: - case XRMD_CMD: - case RMD_CMD: - case STRU_CMD: - case MODE_CMD: - case XMD5_CMD: - //fsprintf(CTRL_SOCK, unimp); - slen = SPRINTF(sendbuf, "502 Command does not implemented yet.\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - - default: /* Invalid */ - //fsprintf(CTRL_SOCK, badcmd, arg); - slen = SPRINTF(sendbuf, "500 Unknown command \'%s\'\r\n", arg); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - break; - } - - return 1; -} - - -char ftplogin(char * pass) -{ - char sendbuf[100]; - int slen = 0; -#ifdef FTPD_AUTH_EN - if (!strcmp(ftp.username, ftpd_user)) - { - if (!strcmp(pass, ftpd_pass)) - { - - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in OK\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - return 1; - } - - } - #if defined(_FTP_DEBUG_) - PRINTF("%s logged in ERROR\r\n", ftp.username); - #endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "530 Login authentication failed\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_NOT_LOGIN; - return 0; -#else - //memset(sendbuf, 0, DATA_BUF_SIZE); - -#if defined(_FTP_DEBUG_) - PRINTF("%s logged in\r\n", ftp.username); -#endif - //fsprintf(CTRL_SOCK, logged); - slen = SPRINTF(sendbuf, "230 Logged on\r\n"); - send(CTRL_SOCK, (uint8_t *)sendbuf, slen); - ftp.state = FTPS_LOGIN; - - return 1; -#endif -} - -int pport(char * arg) -{ - int i; - char* tok=0; - - for (i = 0; i < 4; i++) - { - if(i==0) tok = strtok(arg,",\r\n"); - else tok = strtok(NULL,","); - remote_ip.cVal[i] = (uint8_t)atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } - remote_port = 0; - for (i = 0; i < 2; i++) - { - tok = strtok(NULL,",\r\n"); - remote_port <<= 8; - remote_port += atoi(tok, 10); - if (!tok) - { -#if defined(_FTP_DEBUG_) - PRINTF("bad pport : %s\r\n", arg); -#endif - return -1; - } - } -#if defined(_FTP_DEBUG_) - PRINTF("ip : %d.%d.%d.%d, port : %u\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port); -#endif - - return 0; -} - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil) -{ -#if defined(_FTP_DEBUG_) - PRINTF("File System pointer : %08X\r\n", fil->fs); - PRINTF("File System mount ID : %d\r\n", fil->id); - PRINTF("File status flag : %08X\r\n", fil->flag); - PRINTF("File System pads : %08X\r\n", fil->err); - PRINTF("File read write pointer : %08X\r\n", fil->fptr); - PRINTF("File size : %08X\r\n", fil->fsize); - PRINTF("File start cluster : %08X\r\n", fil->sclust); - PRINTF("current cluster : %08X\r\n", fil->clust); - PRINTF("current data sector : %08X\r\n", fil->dsect); - PRINTF("dir entry sector : %08X\r\n", fil->dir_sect); - PRINTF("dir entry pointer : %08X\r\n", fil->dir_ptr); -#endif -} -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h deleted file mode 100644 index 8057eb9..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/ftpd.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _FTPD_H_ -#define _FTPD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -* Wiznet. -* (c) Copyright 2002, Wiznet. -* -* Filename : ftpd.h -* Version : 1.0 -* Programmer(s) : -* Created : 2003/01/28 -* Description : Header file of FTP daemon. (AVR-GCC Compiler) -*/ - -#include - -#include "../../globals.h" //add AVR specific useful headers - -#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement. - -#if defined(F_FILESYSTEM) -#include "ff.h" -#endif - -#define F_APP_FTP -//#define _FTP_DEBUG_ - - -#define LINELEN 100 -//#define DATA_BUF_SIZE 100 -#if !defined(F_FILESYSTEM) -#define _MAX_SS 512 -#endif - -#define CTRL_SOCK 2 -#define DATA_SOCK 3 - -#define IPPORT_FTPD 20 /* FTP Data port */ -#define IPPORT_FTP 21 /* FTP Control port */ - -#define HOSTNAME "iinChip" -#define VERSION "1.0" - -#define FILENAME "a.txt" - -/* FTP commands */ -enum ftp_cmd { - USER_CMD, - ACCT_CMD, - PASS_CMD, - TYPE_CMD, - LIST_CMD, - CWD_CMD, - DELE_CMD, - NAME_CMD, - QUIT_CMD, - RETR_CMD, - STOR_CMD, - PORT_CMD, - NLST_CMD, - PWD_CMD, - XPWD_CMD, - MKD_CMD, - XMKD_CMD, - XRMD_CMD, - RMD_CMD, - STRU_CMD, - MODE_CMD, - SYST_CMD, - XMD5_CMD, - XCWD_CMD, - FEAT_CMD, - PASV_CMD, - SIZE_CMD, - MLSD_CMD, - APPE_CMD, - NO_CMD, -}; - -enum ftp_type { - ASCII_TYPE, - IMAGE_TYPE, - LOGICAL_TYPE -}; - -enum ftp_state { - FTPS_NOT_LOGIN, - FTPS_LOGIN -}; - -enum datasock_state{ - DATASOCK_IDLE, - DATASOCK_READY, - DATASOCK_START -}; - -enum datasock_mode{ - PASSIVE_MODE, - ACTIVE_MODE -}; - -struct ftpd { - uint8_t control; /* Control stream */ - uint8_t data; /* Data stream */ - - enum ftp_type type; /* Transfer type */ - enum ftp_state state; - - enum ftp_cmd current_cmd; - - enum datasock_state dsock_state; - enum datasock_mode dsock_mode; - - char username[LINELEN]; /* Arg to USER command */ - char workingdir[LINELEN]; - char filename[LINELEN]; - -#if defined(F_FILESYSTEM) - FIL fil; // FatFs File objects - FRESULT fr; // FatFs function common result code -#endif - -}; - -#ifndef un_I2cval -typedef union _un_l2cval { - uint32_t lVal; - uint8_t cVal[4]; -}un_l2cval; -#endif - -void ftpd_init(uint8_t * src_ip); -uint8_t ftpd_run(uint8_t * dbuf); -char proc_ftpd(char * buf); -char ftplogin(char * pass); -int pport(char * arg); - -int sendit(char * command); -int recvit(char * command); - -long sendfile(uint8_t s, char * command); -long recvfile(uint8_t s); - -#if defined(F_FILESYSTEM) -void print_filedsc(FIL *fil); -#endif - -#ifdef __cplusplus -} -#endif - -#endif // _FTPD_H_ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h deleted file mode 100644 index 90c3a0d..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/Internet/FTPServer_avr/stdio_private.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2002, Joerg Wunsch - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * Neither the name of the copyright holders nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* $Id: stdio_private.h,v 1.6 2003/01/07 22:17:24 joerg_wunsch Exp $ */ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - -//struct __file { -// char *buf; /* buffer pointer */ -// unsigned char unget; /* ungetc() buffer */ -// uint8_t flags; /* flags, see below */ -//#define __SRD 0x0001 /* OK to read */ -//#define __SWR 0x0002 /* OK to write */ -//#define __SSTR 0x0004 /* this is an sprintf/snprintf string */ -//#define __SPGM 0x0008 /* fmt string is in progmem */ -//#define __SERR 0x0010 /* found error */ -//#define __SEOF 0x0020 /* found EOF */ -//#define __SUNGET 0x040 /* ungetc() happened */ -//#if 0 -///* possible future extensions, will require uint16_t flags */ -//#define __SRW 0x0080 /* open for reading & writing */ -//#define __SLBF 0x0100 /* line buffered */ -//#define __SNBF 0x0200 /* unbuffered */ -//#define __SMBF 0x0400 /* buf is from malloc */ -//#endif -// int size; /* size of buffer */ -// int len; /* characters read or written so far */ -// int (*put)(char); /* function to write one char to device */ -// int (*get)(void); /* function to read one char from device */ -//}; - -/* values for PRINTF_LEVEL */ -#define PRINTF_MIN 1 -#define PRINTF_STD 2 -#define PRINTF_FLT 3 - -/* values for SCANF_LEVEL */ -#define SCANF_MIN 1 -#define SCANF_STD 2 -#define SCANF_FLT 3 - -#ifdef __cplusplus -} -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/diskio.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ff.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ff.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ffconf.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/integer.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/globals.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/globals.c deleted file mode 100644 index 0fb6bf5..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/globals.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -uint8_t DNS_2nd[4] = {192, 168, 0, 1}; // Secondary DNS server IP -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#else -//NIC metrics for another PC (second IP configuration) -uint8_t DNS_2nd[4] = {192, 168, 1, 1}; // Secondary DNS server IP -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -#endif - -//FTPD user-pass -#ifdef FTPD_AUTH_EN -const char ftpd_user[] = "user1234"; -const char ftpd_pass[] = "open_sesame"; - - -#endif - -//My auth token for my android test application "m1284 + W5500": -uint8_t auth[] = "add_your_own_token_here"; // You should get your own Auth Token in the BLYNK App diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/globals.h b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/globals.h deleted file mode 100644 index 9db5675..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/globals.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -//#include "Internet/httpServer_avr/httpParser.h" -FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - -//Should not used here -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -//FTP Server IP (look at ) -//extern uint8_t FTP_SRV_destip[4]; - - -//#define _MAX_SS_FTP 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTP 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough - -//#define _MAX_SS_FTPD 1500 //FTP buffer 2048 bytes - For Mega1284p(16kb RAM)/Mega2560(8kb RAM) - actually wasteful RAM resources -//#define _MAX_SS_FTPD 512 //FTP buffer 512 bytes - For Mega644p(4kb RAM)/Mega128(4kb RAM) - this is enough -#define _MAX_SS_FTPD _MAX_SS - -#define ETH_LOOPBACK_MAX_BUF_SIZE 512 - -//Enable BootLoader Running -#define BOOT_EN -//Disable BootLoader Running -//#undef BOOT_EN - -//Enable Bootloader debug message -#define BOOT_DEBUG -//Disable Bootloader debug message -//#undef BOOT_DEBUG - -//Enabled FTPD authorize -#define FTPD_AUTH_EN - -#ifdef FTPD_AUTH_EN -extern const char ftpd_user[]; -extern const char ftpd_pass[]; -#endif - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -#define SPRINTF(__S, FORMAT, args...) sprintf_P(__S, PSTR(FORMAT),##args) - -#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); -extern char uart0_receive(void); -extern void uart0_rx_flash(void); -extern void ls_dir(char* path); -//M644P/M1284p Users LEDS: -//LED1/PORTC.4/20 - m644p/m1284p maxxir brd -#define led1_conf() DDRC |= (1< -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/FTPServer_avr/ftpd.h" -#include "Application/Blynk/blynk.h" -#include "Internet/DNS/dns.h" - -uint8_t gFTPBUF[_MAX_SS_FTPD]; //512 bytes - -#define _MAIN_DEBUG_ - -//***********BLYNK related: BEGIN -#define SOCK_BLYNK_CLIENT 6 - -// Shouldn't used here, because used DNS resolving BLYNK server IP -// IP: 139.59.206.133 for via WIN7 nslookup - actually need to use DNS resolving -//Resolve here via DNS query see below Domain_IP[4] -//uint8_t blynk_server_ip[4] = {139, 59, 206, 133}; // Blynk cloud server IP (cloud.blynk.cc, 8422) -//uint8_t BLYNK_RX_BUF[DATA_BUF_SIZE]; - -uint8_t BLYNK_TX_BUF[BLYNK_DATA_BUF_SIZE]; - -//BLYNK Virtual pins state changed flags -uint8_t v15_changed; -uint8_t v20_changed; - -//***********BLYNK related: END - -//***************** DNS: BEGIN -////////////////////////////////////////////////// -// Socket & Port number definition for Examples // -////////////////////////////////////////////////// -#define SOCK_DNS 5 - -unsigned char gDATABUF_DNS[512]; -//#define IP_WORK - -//////////////// -// DNS client // -//////////////// -uint8_t Domain_name[] = BLYNK_DEFAULT_DOMAIN; // BLYNK server URI -uint8_t Domain_IP[4] = {0, }; // Translated IP address by DNS Server -//***************** DNS: END - - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days -#ifdef BOOT_EN -volatile unsigned char sig_reset_board; // Flag to reset board -#endif -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.2 BootLoaded BLYNK + LOOPBACK and FTPD server && FATFS SDCARD WIZNET_5500 ETHERNET 23/03/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint8_t fatfs_10ms; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++fatfs_10ms > 9 ) - { - //Here every 10ms - fatfs_10ms = 0; - //Timer++; /* Performance counter for this module (for FatFS test) */ - disk_timerproc(); // FAT FS timing func - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* UART0 Baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); - - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} - -//Blocking read UART RX (need for FTP Client) -char uart0_receive(void) -{ - unsigned int c; - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - //Suppress NEW LINE (It harm dialog with FTP server) - if((char)c != '\n') - { - uart_putc((char)c); - return (char)c ; - } - else - { - c = UART_NO_DATA; - } - } - } - while(( c & UART_NO_DATA )); - return 0; -} - -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF ("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } -} - -#ifdef BOOT_EN -void fatfs_delete(const char * fn) -{ - FRESULT fr; - FILINFO fno; - - - fr = f_stat(fn, &fno); - switch (fr) { - - case FR_OK: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER: File <%s> is exist, so remove it.. ", fn); -#endif - fr = f_unlink(fn); -#ifdef BOOT_DEBUG - if(fr == FR_OK) - { - PRINTF(" OK\r\n"); - } - else - { - PRINTF(" ERROR\r\n"); - } -#endif - break; - - default: -#ifdef BOOT_DEBUG - PRINTF("\r\n\r\n>>BOOTLOADER. File <%s> isn't exist..\r\n", fn); -#endif - break; - } -} -#endif - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - -// Blocking (~3.5sec) receive one symbol from uart -/* -char uart0_receive(void) -{ - unsigned int c; - uint32_t wait_start = millis(); - do - { - wdt_reset(); - c = uart_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart_putc( (unsigned char)c ); - return (char)c ; - } - //After 3.5 sec waiting return with no symbol - if((millis()-wait_start) > 3500) - { - return 0; - } - } - while(( c & UART_NO_DATA )); - return 0; -} -*/ - - -//****************************FAT FS initialize: END - -int main() -{ -#ifdef BOOT_EN - sig_reset_board = 0; // CLear flag to reset board -#endif - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - - //Bullet proof: clear Virtual pins state change flags - v15_changed = 0; - v20_changed = 0; - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - - /* DNS client Initialization */ - PRINTF("> [BLYNK] Target Domain Name : %s\r\n", Domain_name); - DNS_init(SOCK_DNS, gDATABUF_DNS); - - /* DNS processing */ - int32_t ret; - if ((ret = DNS_run(netInfo.dns, Domain_name, Domain_IP)) > 0) // try to 1st DNS - { -#ifdef _MAIN_DEBUG_ - PRINTF("> 1st DNS Respond\r\n"); -#endif - } - else if ((ret != -1) && ((ret = DNS_run(DNS_2nd, Domain_name, Domain_IP))>0)) // retry to 2nd DNS - { -#ifdef _MAIN_DEBUG_ - PRINTF("> 2nd DNS Respond\r\n"); -#endif - } - else if(ret == -1) - { -#ifdef _MAIN_DEBUG_ - PRINTF("> MAX_DOMAIN_NAME is too small. Should be redefined it.\r\n"); -#endif - ; - } - else - { -#ifdef _MAIN_DEBUG_ - PRINTF("> DNS Failed\r\n"); -#endif - ; - } - - if(ret > 0) - { -#ifdef _MAIN_DEBUG_ - printf("> Translated %s to [%d.%d.%d.%d]\r\n\r\n",Domain_name,Domain_IP[0],Domain_IP[1],Domain_IP[2],Domain_IP[3]); -#endif - //IOT BLYK app init: - /* Blynk client Initialization */ - PRINTF("Try connect to BLYNK SERVER [%s]: %d.%d.%d.%d:%d..\n\r",Domain_name,Domain_IP[0],Domain_IP[1],Domain_IP[2],Domain_IP[3],BLYNK_DEFAULT_PORT); - blynk_begin(auth, Domain_IP, BLYNK_DEFAULT_PORT, BLYNK_TX_BUF, SOCK_BLYNK_CLIENT); - } - else - { - PRINTF("> [BLYNK] Target Domain Name : %s resolve ERROR\r\nReboot board..\r\n", Domain_name); - while(1); - } - - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - fatfs_head_file("index.htm"); - -#ifdef BOOT_EN - //Delete <1284BOOT.BIN> for BootLoader working properly - fatfs_delete("1284BOOT.BIN"); - //Test message - PRINTF("\r\n++Test message from new code #11\r\n"); -#endif - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - -//TODO: Add here FTP server initialize -#if defined(F_APP_FTP) - ftpd_init(netInfo.ip); -#endif - - uint32_t timer_link_1sec = millis(); - //uint32_t timer_httpd_1sec = millis(); - uint32_t timer_uptime_60sec = millis(); - bool run_user_applications = true; - uint8_t blynk_restore_connection = 1; - uint8_t timer_led2_push_10sec = 0; - static uint8_t _msg[64] = "\0"; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - // TODO: insert user's code here - if(run_user_applications) - { - // Blynk process handler - blynk_run(); - - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler - //for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run_avr(i); // HTTP Server handler avr optimized - - //loopback_tcps(SOCK_TCPS, RX_BUF, 5000); //not used here - - //TODO: Add here FTP server instance -#if defined(F_APP_FTP) - ftpd_run(gFTPBUF); -#endif - - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf1,PORT_UDPS); - - - //loopback_ret = loopback_tcpc(SOCK_TCPS, gDATABUF, destip, destport); - //if(loopback_ret < 0) printf("loopback ret: %ld\r\n", loopback_ret); // TCP Socket Error code - - - } // End of user's code - - - if((millis()-timer_link_1sec)> 1000) - { - //Just for test bootloader works - //led1_tgl(); - - //here every 1 sec - timer_link_1sec = millis(); - -#ifdef BOOT_EN - //Check signal to reset board (with additional pause 2-3 sec, to close ftp STOR transaction) - if(sig_reset_board) - { - - if(sig_reset_board++ > 3) - { - //If signal raised (3 sec) - reset the board (via WDT) to enter BootLoader - while(1) - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - _delay_ms(1000); - - } - } - else - { -#ifdef BOOT_DEBUG - PRINTF("."); -#endif - } - } -#endif - - - //!!Blynk every seconds tasks - //To restore GPIO state on start-up application - if(blynk_restore_connection) - { - if(is_blynk_connection_available()) - { - blynk_restore_connection = 0; - //Requests Server to re-send current values for all widgets - PRINTF("++blynk_syncAll event\r\n"); //Just for debug - blynk_syncAll(); - } - } - - //Virtual pins state change check here - if(v15_changed) - { - v15_changed = 0; //Drop flag - //Push message with changed V15 value (LED PWM PIN15/PD7 ) - blynk_push_virtual_pin(15); - - } - else if(v20_changed) - { - v20_changed = 0; //Drop flag - //Push message with changed V20 value (LED1 D20/PC4) - blynk_push_virtual_pin(20); - } - //Every 10sec event for LED2 PIN13, and uptime device - if(++timer_led2_push_10sec == 10) - { - timer_led2_push_10sec = 0; //Clear timer_led2.. - //Every 10sec toggle, and push LED2 PIN13/PD5 state to BLYNK server (widget Value Display) - led2_tgl(); - blynk_push_pin(13); - - //Every 10sec push message: "Uptime: xxx sec; Free RAM: xxxxx bytes", to BLYNK server (widget Terminal) - SPRINTF(_msg, "Uptime: %lu sec; Free RAM: %d bytes\r\n", millis()/1000, freeRam()); - blynk_push_virtual_pin_msg(1, _msg); - } - } - - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/spi.c b/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/.cproject b/21_m1284p_WIZNET_TFTP_client_FATFS/.cproject deleted file mode 100644 index fd362d2..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/.cproject +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/.project b/21_m1284p_WIZNET_TFTP_client_FATFS/.project deleted file mode 100644 index c22bc19..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - 21_m1284p_WIZNET_TFTP_client_FATFS - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Application/loopback/loopback.c b/21_m1284p_WIZNET_TFTP_client_FATFS/Application/loopback/loopback.c deleted file mode 100644 index b1143c0..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Application/loopback/loopback.c +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "loopback.h" -#include "socket.h" -#include "wizchip_conf.h" - -#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK - -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size = 0, sentsize=0; - -#ifdef _LOOPBACK_DEBUG_ - uint8_t destip[4]; - uint16_t destport; -#endif - - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) - { -#ifdef _LOOPBACK_DEBUG_ - getSn_DIPR(sn, destip); - destport = getSn_DPORT(sn); - - PRINTF("%d:Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn,Sn_IR_CON); - } - if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recv(sn, buf, size); - - if(ret <= 0) return ret; // check SOCKERR_BUSY & SOCKERR_XXX. For showing the occurrence of SOCKERR_BUSY. - size = (uint16_t) ret; - sentsize = 0; - - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); - if(ret < 0) - { - close(sn); - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret = disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Socket Closed\r\n", sn); -#endif - break; - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Listen, TCP server loopback, port [%u]\r\n", sn, port); -#endif - if( (ret = listen(sn)) != SOCK_OK) return ret; - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP server loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret; -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport) -{ - int32_t ret; // return value for SOCK_ERRORs - uint16_t size = 0, sentsize=0; - - // Destination (TCP Server) IP info (will be connected) - // >> loopback_tcpc() function parameter - // >> Ex) - // uint8_t destip[4] = {192, 168, 0, 214}; - // uint16_t destport = 5000; - - // Port number for TCP client (will be increased) - static uint16_t any_port = 50000; - - // Socket Status Transitions - // Check the W5500 Socket n status register (Sn_SR, The 'Sn_SR' controlled by Sn_CR command or Packet send/recv status) - switch(getSn_SR(sn)) - { - case SOCK_ESTABLISHED : - if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Connected to - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1' - } - - ////////////////////////////////////////////////////////////////////////////////////////////// - // Data Transaction Parts; Handle the [data receive and send] process - ////////////////////////////////////////////////////////////////////////////////////////////// - if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; // DATA_BUF_SIZE means user defined buffer size (array) - ret = recv(sn, buf, size); // Data Receive process (H/W Rx socket buffer -> User's buffer) - - if(ret <= 0) return ret; // If the received data length <= 0, receive failed and process end - size = (uint16_t) ret; - sentsize = 0; - - // Data sentsize control - while(size != sentsize) - { - ret = send(sn, buf+sentsize, size-sentsize); // Data send process (User's buffer -> Destination through H/W Tx socket buffer) - if(ret < 0) // Send Error occurred (sent data length < 0) - { - close(sn); // socket close - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - ////////////////////////////////////////////////////////////////////////////////////////////// - break; - - case SOCK_CLOSE_WAIT : -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:CloseWait\r\n",sn); -#endif - if((ret=disconnect(sn)) != SOCK_OK) return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Socket Closed\r\n", sn); -#endif - break; - - case SOCK_INIT : -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Try to connect to the %d.%d.%d.%d : %u\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport); -#endif - if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination) - break; - - case SOCK_CLOSED: - close(sn); - if((ret=socket(sn, Sn_MR_TCP, any_port++, 0x00)) != sn){ - if(any_port == 0xffff) any_port = 50000; - return ret; // TCP socket open with 'any_port' port number - } -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:TCP client loopback start\r\n",sn); - //printf("%d:Socket opened\r\n",sn); -#endif - break; - default: - break; - } - return 1; -} - - -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port) -{ - int32_t ret; - uint16_t size, sentsize; - uint8_t destip[4]; - uint16_t destport; - - switch(getSn_SR(sn)) - { - case SOCK_UDP : - if((size = getSn_RX_RSR(sn)) > 0) - { - if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE; - ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport); - if(ret <= 0) - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d: recvfrom error. %ld\r\n",sn,ret); -#endif - return ret; - } - size = (uint16_t) ret; - sentsize = 0; - while(sentsize != size) - { - ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport); - if(ret < 0) - { -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d: sendto error. %ld\r\n",sn,ret); -#endif - return ret; - } - sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero. - } - } - break; - case SOCK_CLOSED: -#ifdef _LOOPBACK_DEBUG_ - //printf("%d:UDP loopback start\r\n",sn); -#endif - if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn) - return ret; -#ifdef _LOOPBACK_DEBUG_ - PRINTF("%d:Opened, UDP loopback, port [%u]\r\n", sn, port); -#endif - break; - default : - break; - } - return 1; -} - -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Application/loopback/loopback.h b/21_m1284p_WIZNET_TFTP_client_FATFS/Application/loopback/loopback.h deleted file mode 100644 index be638f9..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Application/loopback/loopback.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _LOOPBACK_H_ -#define _LOOPBACK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "../../globals.h" - -/* Loopback test debug message printout enable */ -#define _LOOPBACK_DEBUG_ - -/* DATA_BUF_SIZE define for Loopback example */ -#ifndef DATA_BUF_SIZE - #define DATA_BUF_SIZE 2048 -#endif - -/************************/ -/* Select LOOPBACK_MODE */ -/************************/ -#define LOOPBACK_MAIN_NOBLOCK 0 -#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK - - -/* TCP server Loopback test example */ -int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port); - -/* TCP client Loopback test example */ -int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destport); - -/* UDP Loopback test example */ -int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/W5500/w5500.c b/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/W5500/w5500.c deleted file mode 100644 index 68d4cb8..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/W5500/w5500.c +++ /dev/null @@ -1,267 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.c -//! \brief W5500 HAL Interface. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2 -//! 1. Implicit type casting -> Explicit type casting. Refer to M20140501 -//! Fixed the problem on porting into under 32bit MCU -//! Issued by Mathias ClauBen, wizwiki forum ID Think01 and bobh -//! Thank for your interesting and serious advices. -//! <2013/12/20> V1.0.1 -//! 1. Remove warning -//! 2. WIZCHIP_READ_BUF WIZCHIP_WRITE_BUF in case _WIZCHIP_IO_MODE_SPI_FDM_ -//! for loop optimized(removed). refer to M20131220 -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -//#include -#include "w5500.h" - -#define _W5500_SPI_VDM_OP_ 0x00 -#define _W5500_SPI_FDM_OP_LEN1_ 0x01 -#define _W5500_SPI_FDM_OP_LEN2_ 0x02 -#define _W5500_SPI_FDM_OP_LEN4_ 0x03 - -#if (_WIZCHIP_ == 5500) -//////////////////////////////////////////////////// - -uint8_t WIZCHIP_READ(uint32_t AddrSel) -{ - uint8_t ret; - uint8_t spi_data[3]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - } - ret = WIZCHIP.IF.SPI._read_byte(); - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); - return ret; -} - -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ) -{ - uint8_t spi_data[4]; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - //if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - WIZCHIP.IF.SPI._write_byte(wb); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - spi_data[3] = wb; - WIZCHIP.IF.SPI._write_burst(spi_data, 4); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - pBuf[i] = WIZCHIP.IF.SPI._read_byte(); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._read_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len) -{ - uint8_t spi_data[3]; - uint16_t i; - - WIZCHIP_CRITICAL_ENTER(); - WIZCHIP.CS._select(); - - AddrSel |= (_W5500_SPI_WRITE_ | _W5500_SPI_VDM_OP_); - - if(!WIZCHIP.IF.SPI._write_burst) // byte operation - { - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); - WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); - for(i = 0; i < len; i++) - WIZCHIP.IF.SPI._write_byte(pBuf[i]); - } - else // burst operation - { - spi_data[0] = (AddrSel & 0x00FF0000) >> 16; - spi_data[1] = (AddrSel & 0x0000FF00) >> 8; - spi_data[2] = (AddrSel & 0x000000FF) >> 0; - WIZCHIP.IF.SPI._write_burst(spi_data, 3); - WIZCHIP.IF.SPI._write_burst(pBuf, len); - } - - WIZCHIP.CS._deselect(); - WIZCHIP_CRITICAL_EXIT(); -} - - -uint16_t getSn_TX_FSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_TX_FSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_TX_FSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_FSR(sn),1)); - } - }while (val != val1); - return val; -} - - -uint16_t getSn_RX_RSR(uint8_t sn) -{ - uint16_t val=0,val1=0; - - do - { - val1 = WIZCHIP_READ(Sn_RX_RSR(sn)); - val1 = (val1 << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - if (val1 != 0) - { - val = WIZCHIP_READ(Sn_RX_RSR(sn)); - val = (val << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RSR(sn),1)); - } - }while (val != val1); - return val; -} - -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_TX_WR(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3); - // - WIZCHIP_WRITE_BUF(addrsel,wizdata, len); - - ptr += len; - setSn_TX_WR(sn,ptr); -} - -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len) -{ - uint16_t ptr = 0; - uint32_t addrsel = 0; - - if(len == 0) return; - ptr = getSn_RX_RD(sn); - //M20140501 : implict type casting -> explict type casting - //addrsel = ((ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_RXBUF_BLOCK(sn) << 3); - // - WIZCHIP_READ_BUF(addrsel, wizdata, len); - ptr += len; - - setSn_RX_RD(sn,ptr); -} - - -void wiz_recv_ignore(uint8_t sn, uint16_t len) -{ - uint16_t ptr = 0; - - ptr = getSn_RX_RD(sn); - ptr += len; - setSn_RX_RD(sn,ptr); -} - -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/W5500/w5500.h b/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/W5500/w5500.h deleted file mode 100644 index 3afc16e..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/W5500/w5500.h +++ /dev/null @@ -1,2163 +0,0 @@ -//***************************************************************************** -// -//! \file w5500.h -//! \brief W5500 HAL Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -// - -#ifndef _W5500_H_ -#define _W5500_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "wizchip_conf.h" - -/// @cond DOXY_APPLY_CODE -#if (_WIZCHIP_ == 5500) -/// @endcond - -#define _W5500_IO_BASE_ 0x00000000 - -#define _W5500_SPI_READ_ (0x00 << 2) //< SPI interface Read operation in Control Phase -#define _W5500_SPI_WRITE_ (0x01 << 2) //< SPI interface Write operation in Control Phase - -#define WIZCHIP_CREG_BLOCK 0x00 //< Common register block -#define WIZCHIP_SREG_BLOCK(N) (1+4*N) //< Socket N register block -#define WIZCHIP_TXBUF_BLOCK(N) (2+4*N) //< Socket N Tx buffer address block -#define WIZCHIP_RXBUF_BLOCK(N) (3+4*N) //< Socket N Rx buffer address block - -#define WIZCHIP_OFFSET_INC(ADDR, N) (ADDR + (N<<8)) //< Increase offset address - - -/////////////////////////////////////// -// Definition For Legacy Chip Driver // -/////////////////////////////////////// -#define IINCHIP_READ(ADDR) WIZCHIP_READ(ADDR) ///< The defined for legacy chip driver -#define IINCHIP_WRITE(ADDR,VAL) WIZCHIP_WRITE(ADDR,VAL) ///< The defined for legacy chip driver -#define IINCHIP_READ_BUF(ADDR,BUF,LEN) WIZCHIP_READ_BUF(ADDR,BUF,LEN) ///< The defined for legacy chip driver -#define IINCHIP_WRITE_BUF(ADDR,BUF,LEN) WIZCHIP_WRITE(ADDR,BUF,LEN) ///< The defined for legacy chip driver - -////////////////////////////// -//-------------------------- defgroup --------------------------------- -/** - * @defgroup W5500 W5500 - * - * @brief WHIZCHIP register defines and I/O functions of @b W5500. - * - * - @ref WIZCHIP_register : @ref Common_register_group and @ref Socket_register_group - * - @ref WIZCHIP_IO_Functions : @ref Basic_IO_function, @ref Common_register_access_function and @ref Socket_register_access_function - */ - - -/** - * @defgroup WIZCHIP_register WIZCHIP register - * @ingroup W5500 - * - * @brief WHIZCHIP register defines register group of @b W5500. - * - * - @ref Common_register_group : Common register group - * - @ref Socket_register_group : \c SOCKET n register group - */ - - -/** - * @defgroup WIZCHIP_IO_Functions WIZCHIP I/O functions - * @ingroup W5500 - * - * @brief This supports the basic I/O functions for @ref WIZCHIP_register. - * - * - Basic I/O function \n - * WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() \n\n - * - * - @ref Common_register_group access functions \n - * -# @b Mode \n - * getMR(), setMR() - * -# @b Interrupt \n - * getIR(), setIR(), getIMR(), setIMR(), getSIR(), setSIR(), getSIMR(), setSIMR(), getINTLEVEL(), setINTLEVEL() - * -# Network Information \n - * getSHAR(), setSHAR(), getGAR(), setGAR(), getSUBR(), setSUBR(), getSIPR(), setSIPR() - * -# @b Retransmission \n - * getRCR(), setRCR(), getRTR(), setRTR() - * -# @b PPPoE \n - * getPTIMER(), setPTIMER(), getPMAGIC(), getPMAGIC(), getPSID(), setPSID(), getPHAR(), setPHAR(), getPMRU(), setPMRU() - * -# ICMP packet \n - * getUIPR(), getUPORTR() - * -# @b etc. \n - * getPHYCFGR(), setPHYCFGR(), getVERSIONR() \n\n - * - * - \ref Socket_register_group access functions \n - * -# SOCKET control \n - * getSn_MR(), setSn_MR(), getSn_CR(), setSn_CR(), getSn_IMR(), setSn_IMR(), getSn_IR(), setSn_IR() - * -# SOCKET information \n - * getSn_SR(), getSn_DHAR(), setSn_DHAR(), getSn_PORT(), setSn_PORT(), getSn_DIPR(), setSn_DIPR(), getSn_DPORT(), setSn_DPORT() - * getSn_MSSR(), setSn_MSSR() - * -# SOCKET communication \n - * getSn_RXBUF_SIZE(), setSn_RXBUF_SIZE(), getSn_TXBUF_SIZE(), setSn_TXBUF_SIZE() \n - * getSn_TX_RD(), getSn_TX_WR(), setSn_TX_WR() \n - * getSn_RX_RD(), setSn_RX_RD(), getSn_RX_WR() \n - * getSn_TX_FSR(), getSn_RX_RSR(), getSn_KPALVTR(), setSn_KPALVTR() - * -# IP header field \n - * getSn_FRAG(), setSn_FRAG(), getSn_TOS(), setSn_TOS() \n - * getSn_TTL(), setSn_TTL() - */ - - - -/** - * @defgroup Common_register_group Common register - * @ingroup WIZCHIP_register - * - * @brief Common register group\n - * It set the basic for the networking\n - * It set the configuration such as interrupt, network information, ICMP, etc. - * @details - * @sa MR : Mode register. - * @sa GAR, SUBR, SHAR, SIPR - * @sa INTLEVEL, IR, IMR, SIR, SIMR : Interrupt. - * @sa _RTR_, _RCR_ : Data retransmission. - * @sa PTIMER, PMAGIC, PHAR, PSID, PMRU : PPPoE. - * @sa UIPR, UPORTR : ICMP message. - * @sa PHYCFGR, VERSIONR : etc. - */ - - - -/** - * @defgroup Socket_register_group Socket register - * @ingroup WIZCHIP_register - * - * @brief Socket register group.\n - * Socket register configures and control SOCKETn which is necessary to data communication. - * @details - * @sa Sn_MR, Sn_CR, Sn_IR, Sn_IMR : SOCKETn Control - * @sa Sn_SR, Sn_PORT, Sn_DHAR, Sn_DIPR, Sn_DPORT : SOCKETn Information - * @sa Sn_MSSR, Sn_TOS, Sn_TTL, Sn_KPALVTR, Sn_FRAG : Internet protocol. - * @sa Sn_RXBUF_SIZE, Sn_TXBUF_SIZE, Sn_TX_FSR, Sn_TX_RD, Sn_TX_WR, Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR : Data communication - */ - - - - /** - * @defgroup Basic_IO_function Basic I/O function - * @ingroup WIZCHIP_IO_Functions - * @brief These are basic input/output functions to read values from register or write values to register. - */ - -/** - * @defgroup Common_register_access_function Common register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access common registers. - */ - -/** - * @defgroup Socket_register_access_function Socket register access functions - * @ingroup WIZCHIP_IO_Functions - * @brief These are functions to access socket registers. - */ - -//------------------------------- defgroup end -------------------------------------------- -//----------------------------- W5500 Common Registers IOMAP ----------------------------- -/** - * @ingroup Common_register_group - * @brief Mode Register address(R/W)\n - * @ref MR is used for S/W reset, ping block mode, PPPoE mode and etc. - * @details Each bit of @ref MR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
RST Reserved WOL PB PPPoE Reserved FARP Reserved
- * - \ref MR_RST : Reset - * - \ref MR_WOL : Wake on LAN - * - \ref MR_PB : Ping block - * - \ref MR_PPPOE : PPPoE mode - * - \ref MR_FARP : Force ARP mode - */ -#define MR (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Gateway IP Register address(R/W) - * @details @ref GAR configures the default gateway address. - */ -#define GAR (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Subnet mask Register address(R/W) - * @details @ref SUBR configures the subnet mask address. - */ -#define SUBR (_W5500_IO_BASE_ + (0x0005 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source MAC Register address(R/W) - * @details @ref SHAR configures the source hardware address. - */ -#define SHAR (_W5500_IO_BASE_ + (0x0009 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Source IP Register address(R/W) - * @details @ref SIPR configures the source IP address. - */ -#define SIPR (_W5500_IO_BASE_ + (0x000F << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Set Interrupt low level timer register address(R/W) - * @details @ref INTLEVEL configures the Interrupt Assert Time. - */ -#define INTLEVEL (_W5500_IO_BASE_ + (0x0013 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt Register(R/W) - * @details @ref IR indicates the interrupt status. Each bit of @ref IR will be still until the bit will be written to by the host. - * If @ref IR is not equal to x00 INTn PIN is asserted to low until it is x00\n\n - * Each bit of @ref IR defined as follows. - * - * - * - *
7 6 5 4 3 2 1 0
CONFLICT UNREACH PPPoE MP Reserved Reserved Reserved Reserved
- * - \ref IR_CONFLICT : IP conflict - * - \ref IR_UNREACH : Destination unreachable - * - \ref IR_PPPoE : PPPoE connection close - * - \ref IR_MP : Magic packet - */ -#define IR (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Interrupt mask register(R/W) - * @details @ref _IMR_ is used to mask interrupts. Each bit of @ref _IMR_ corresponds to each bit of @ref IR. - * When a bit of @ref _IMR_ is and the corresponding bit of @ref IR is an interrupt will be issued. In other words, - * if a bit of @ref _IMR_ is an interrupt will not be issued even if the corresponding bit of @ref IR is \n\n - * Each bit of @ref _IMR_ defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
IM_IR7 IM_IR6 IM_IR5 IM_IR4 Reserved Reserved Reserved Reserved
- * - \ref IM_IR7 : IP Conflict Interrupt Mask - * - \ref IM_IR6 : Destination unreachable Interrupt Mask - * - \ref IM_IR5 : PPPoE Close Interrupt Mask - * - \ref IM_IR4 : Magic Packet Interrupt Mask - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define IMR (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _IMR_ (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Register(R/W) - * @details @ref SIR indicates the interrupt status of Socket.\n - * Each bit of @ref SIR be still until @ref Sn_IR is cleared by the host.\n - * If @ref Sn_IR is not equal to x00 the n-th bit of @ref SIR is and INTn PIN is asserted until @ref SIR is x00 */ -#define SIR (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Socket Interrupt Mask Register(R/W) - * @details Each bit of @ref SIMR corresponds to each bit of @ref SIR. - * When a bit of @ref SIMR is and the corresponding bit of @ref SIR is Interrupt will be issued. - * In other words, if a bit of @ref SIMR is an interrupt will be not issued even if the corresponding bit of @ref SIR is - */ -#define SIMR (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Timeout register address( 1 is 100us )(R/W) - * @details @ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of @ref _RTR_ is x07D0. - * And so the default timeout period is 200ms(100us X 2000). During the time configured by @ref _RTR_, W5500 waits for the peer response - * to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command). - * If the peer does not respond within the @ref _RTR_ time, W5500 retransmits the packet or issues timeout. - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RTR (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RTR_ (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Retry count register(R/W) - * @details @ref _RCR_ configures the number of time of retransmission. - * When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (@ref Sn_IR_TIMEOUT = '1'). - */ -//M20150401 : Rename SYMBOE ( Re-define error in a compile) -//#define RCR (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) -#define _RCR_ (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Request Timer register in PPPoE mode(R/W) - * @details @ref PTIMER configures the time for sending LCP echo request. The unit of time is 25ms. - */ -#define PTIMER (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP LCP Magic number register in PPPoE mode(R/W) - * @details @ref PMAGIC configures the 4bytes magic number to be used in LCP negotiation. - */ -#define PMAGIC (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Destination MAC Register address(R/W) - * @details @ref PHAR configures the PPPoE server hardware address that is acquired during PPPoE connection process. - */ -#define PHAR (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Session Identification Register(R/W) - * @details @ref PSID configures the PPPoE sever session ID acquired during PPPoE connection process. - */ -#define PSID (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PPP Maximum Segment Size(MSS) register(R/W) - * @details @ref PMRU configures the maximum receive unit of PPPoE. - */ -#define PMRU (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable IP register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR indicates - * the destination IP address & port number respectively. - */ -#define UIPR (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief Unreachable Port register address in UDP mode(R) - * @details W5500 receives an ICMP packet(Destination port unreachable) when data is sent to a port number - * which socket is not open and @ref IR_UNREACH bit of @ref IR becomes and @ref UIPR & @ref UPORTR - * indicates the destination IP address & port number respectively. - */ -#define UPORTR (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief PHY Status Register(R/W) - * @details @ref PHYCFGR configures PHY operation mode and resets PHY. In addition, @ref PHYCFGR indicates the status of PHY such as duplex, Speed, Link. - */ -#define PHYCFGR (_W5500_IO_BASE_ + (0x002E << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0031 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0032 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0033 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0034 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0035 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0036 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0037 << 8) + (WIZCHIP_CREG_BLOCK << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0038 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - -/** - * @ingroup Common_register_group - * @brief chip version register address(R) - * @details @ref VERSIONR always indicates the W5500 version as @b 0x04. - */ -#define VERSIONR (_W5500_IO_BASE_ + (0x0039 << 8) + (WIZCHIP_CREG_BLOCK << 3)) - - -//----------------------------- W5500 Socket Registers IOMAP ----------------------------- -/** - * @ingroup Socket_register_group - * @brief socket Mode register(R/W) - * @details @ref Sn_MR configures the option or protocol type of Socket n.\n\n - * Each bit of @ref Sn_MR defined as the following. - * - * - * - *
7 6 5 4 3 2 1 0
MULTI/MFEN BCASTB ND/MC/MMB UCASTB/MIP6B Protocol[3] Protocol[2] Protocol[1] Protocol[0]
- * - @ref Sn_MR_MULTI : Support UDP Multicasting - * - @ref Sn_MR_BCASTB : Broadcast block in UDP Multicasting - * - @ref Sn_MR_ND : No Delayed Ack(TCP) flag - * - @ref Sn_MR_MC : IGMP version used in UDP mulitcasting - * - @ref Sn_MR_MMB : Multicast Blocking in @ref Sn_MR_MACRAW mode - * - @ref Sn_MR_UCASTB : Unicast Block in UDP Multicating - * - @ref Sn_MR_MIP6B : IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * - Protocol - * - * - * - * - * - * - *
Protocol[3] Protocol[2] Protocol[1] Protocol[0] @b Meaning
0 0 0 0 Closed
0 0 0 1 TCP
0 0 1 0 UDP
0 1 0 0 MACRAW
- * - @ref Sn_MR_MACRAW : MAC LAYER RAW SOCK \n - * - @ref Sn_MR_UDP : UDP - * - @ref Sn_MR_TCP : TCP - * - @ref Sn_MR_CLOSE : Unused socket - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR(N) (_W5500_IO_BASE_ + (0x0000 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket command register(R/W) - * @details This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND, and RECEIVE.\n - * After W5500 accepts the command, the @ref Sn_CR register is automatically cleared to 0x00. - * Even though @ref Sn_CR is cleared to 0x00, the command is still being processed.\n - * To check whether the command is completed or not, please check the @ref Sn_IR or @ref Sn_SR. - * - @ref Sn_CR_OPEN : Initialize or open socket. - * - @ref Sn_CR_LISTEN : Wait connection request in TCP mode(Server mode) - * - @ref Sn_CR_CONNECT : Send connection request in TCP mode(Client mode) - * - @ref Sn_CR_DISCON : Send closing request in TCP mode. - * - @ref Sn_CR_CLOSE : Close socket. - * - @ref Sn_CR_SEND : Update TX buffer pointer and send data. - * - @ref Sn_CR_SEND_MAC : Send data with MAC address, so without ARP process. - * - @ref Sn_CR_SEND_KEEP : Send keep alive message. - * - @ref Sn_CR_RECV : Update RX buffer pointer and receive data. - */ -#define Sn_CR(N) (_W5500_IO_BASE_ + (0x0001 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket interrupt register(R) - * @details @ref Sn_IR indicates the status of Socket Interrupt such as establishment, termination, receiving data, timeout).\n - * When an interrupt occurs and the corresponding bit of @ref Sn_IMR is the corresponding bit of @ref Sn_IR becomes \n - * In order to clear the @ref Sn_IR bit, the host should write the bit to \n - * - * - * - *
7 6 5 4 3 2 1 0
Reserved Reserved Reserved SEND_OK TIMEOUT RECV DISCON CON
- * - \ref Sn_IR_SENDOK : SEND_OK Interrupt - * - \ref Sn_IR_TIMEOUT : TIMEOUT Interrupt - * - \ref Sn_IR_RECV : RECV Interrupt - * - \ref Sn_IR_DISCON : DISCON Interrupt - * - \ref Sn_IR_CON : CON Interrupt - */ -#define Sn_IR(N) (_W5500_IO_BASE_ + (0x0002 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Socket status register(R) - * @details @ref Sn_SR indicates the status of Socket n.\n - * The status of Socket n is changed by @ref Sn_CR or some special control packet as SYN, FIN packet in TCP. - * @par Normal status - * - @ref SOCK_CLOSED : Closed - * - @ref SOCK_INIT : Initiate state - * - @ref SOCK_LISTEN : Listen state - * - @ref SOCK_ESTABLISHED : Success to connect - * - @ref SOCK_CLOSE_WAIT : Closing state - * - @ref SOCK_UDP : UDP socket - * - @ref SOCK_MACRAW : MAC raw mode socket - *@par Temporary status during changing the status of Socket n. - * - @ref SOCK_SYNSENT : This indicates Socket n sent the connect-request packet (SYN packet) to a peer. - * - @ref SOCK_SYNRECV : It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer. - * - @ref SOCK_FIN_WAIT : Connection state - * - @ref SOCK_CLOSING : Closing state - * - @ref SOCK_TIME_WAIT : Closing state - * - @ref SOCK_LAST_ACK : Closing state - */ -#define Sn_SR(N) (_W5500_IO_BASE_ + (0x0003 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief source port register(R/W) - * @details @ref Sn_PORT configures the source port number of Socket n. - * It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered. - */ -#define Sn_PORT(N) (_W5500_IO_BASE_ + (0x0004 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer MAC register address(R/W) - * @details @ref Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or - * it indicates that it is acquired in ARP-process by CONNECT/SEND command. - */ -#define Sn_DHAR(N) (_W5500_IO_BASE_ + (0x0006 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer IP register address(R/W) - * @details @ref Sn_DIPR configures or indicates the destination IP address of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP client mode, it configures an IP address of TCP serverbefore CONNECT command. - * In TCP server mode, it indicates an IP address of TCP clientafter successfully establishing connection. - * In UDP mode, it configures an IP address of peer to be received the UDP packet by SEND or SEND_MAC command. - */ -#define Sn_DIPR(N) (_W5500_IO_BASE_ + (0x000C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Peer port register address(R/W) - * @details @ref Sn_DPORT configures or indicates the destination port number of Socket n. It is valid when Socket n is used in TCP/UDP mode. - * In TCP clientmode, it configures the listen port number of TCP serverbefore CONNECT command. - * In TCP Servermode, it indicates the port number of TCP client after successfully establishing connection. - * In UDP mode, it configures the port number of peer to be transmitted the UDP packet by SEND/SEND_MAC command. - */ -#define Sn_DPORT(N) (_W5500_IO_BASE_ + (0x0010 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Maximum Segment Size(Sn_MSSR0) register address(R/W) - * @details @ref Sn_MSSR configures or indicates the MTU(Maximum Transfer Unit) of Socket n. - */ -#define Sn_MSSR(N) (_W5500_IO_BASE_ + (0x0012 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -// Reserved (_W5500_IO_BASE_ + (0x0014 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief IP Type of Service(TOS) Register(R/W) - * @details @ref Sn_TOS configures the TOS(Type Of Service field in IP Header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TOS(N) (_W5500_IO_BASE_ + (0x0015 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -/** - * @ingroup Socket_register_group - * @brief IP Time to live(TTL) Register(R/W) - * @details @ref Sn_TTL configures the TTL(Time To Live field in IP header) of Socket n. - * It is set before OPEN command. - */ -#define Sn_TTL(N) (_W5500_IO_BASE_ + (0x0016 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0017 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0018 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x0019 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001B << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) -// Reserved (_W5500_IO_BASE_ + (0x001D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Receive memory size register(R/W) - * @details @ref Sn_RXBUF_SIZE configures the RX buffer block size of Socket n. - * Socket n RX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data cannot be normally received from a peer. - * Although Socket n RX Buffer Block size is initially configured to 2Kbytes, - * user can re-configure its size using @ref Sn_RXBUF_SIZE. The total sum of @ref Sn_RXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data reception error is occurred. - */ -#define Sn_RXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001E << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory size register(R/W) - * @details @ref Sn_TXBUF_SIZE configures the TX buffer block size of Socket n. Socket n TX Buffer Block size can be configured with 1,2,4,8, and 16 Kbytes. - * If a different size is configured, the data can�t be normally transmitted to a peer. - * Although Socket n TX Buffer Block size is initially configured to 2Kbytes, - * user can be re-configure its size using @ref Sn_TXBUF_SIZE. The total sum of @ref Sn_TXBUF_SIZE can not be exceed 16Kbytes. - * When exceeded, the data transmission error is occurred. - */ -#define Sn_TXBUF_SIZE(N) (_W5500_IO_BASE_ + (0x001F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit free memory size register(R) - * @details @ref Sn_TX_FSR indicates the free size of Socket n TX Buffer Block. It is initialized to the configured size by @ref Sn_TXBUF_SIZE. - * Data bigger than @ref Sn_TX_FSR should not be saved in the Socket n TX Buffer because the bigger data overwrites the previous saved data not yet sent. - * Therefore, check before saving the data to the Socket n TX Buffer, and if data is equal or smaller than its checked size, - * transmit the data with SEND/SEND_MAC command after saving the data in Socket n TX buffer. But, if data is bigger than its checked size, - * transmit the data after dividing into the checked size and saving in the Socket n TX buffer. - */ -#define Sn_TX_FSR(N) (_W5500_IO_BASE_ + (0x0020 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory read pointer register address(R) - * @details @ref Sn_TX_RD is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP. - * After its initialization, it is auto-increased by SEND command. - * SEND command transmits the saved data from the current @ref Sn_TX_RD to the @ref Sn_TX_WR in the Socket n TX Buffer. - * After transmitting the saved data, the SEND command increases the @ref Sn_TX_RD as same as the @ref Sn_TX_WR. - * If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_TX_RD(N) (_W5500_IO_BASE_ + (0x0022 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Transmit memory write pointer register address(R/W) - * @details @ref Sn_TX_WR is initialized by OPEN command. However, if Sn_MR(P[3:0]) is TCP mode(001, it is re-initialized while connecting with TCP.\n - * It should be read or be updated like as follows.\n - * 1. Read the starting address for saving the transmitting data.\n - * 2. Save the transmitting data from the starting address of Socket n TX buffer.\n - * 3. After saving the transmitting data, update @ref Sn_TX_WR to the increased value as many as transmitting data size. - * If the increment value exceeds the maximum value 0xFFFF(greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value.\n - * 4. Transmit the saved data in Socket n TX Buffer by using SEND/SEND command - */ -#define Sn_TX_WR(N) (_W5500_IO_BASE_ + (0x0024 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Received data size register(R) - * @details @ref Sn_RX_RSR indicates the data size received and saved in Socket n RX Buffer. - * @ref Sn_RX_RSR does not exceed the @ref Sn_RXBUF_SIZE and is calculated as the difference between - * �Socket n RX Write Pointer (@ref Sn_RX_WR)and �Socket n RX Read Pointer (@ref Sn_RX_RD) - */ -#define Sn_RX_RSR(N) (_W5500_IO_BASE_ + (0x0026 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Read point of Receive memory(R/W) - * @details @ref Sn_RX_RD is initialized by OPEN command. Make sure to be read or updated as follows.\n - * 1. Read the starting save address of the received data.\n - * 2. Read data from the starting address of Socket n RX Buffer.\n - * 3. After reading the received data, Update @ref Sn_RX_RD to the increased value as many as the reading size. - * If the increment value exceeds the maximum value 0xFFFF, that is, is greater than 0x10000 and the carry bit occurs, - * update with the lower 16bits value ignored the carry bit.\n - * 4. Order RECV command is for notifying the updated @ref Sn_RX_RD to W5500. - */ -#define Sn_RX_RD(N) (_W5500_IO_BASE_ + (0x0028 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Write point of Receive memory(R) - * @details @ref Sn_RX_WR is initialized by OPEN command and it is auto-increased by the data reception. - * If the increased value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), - * then the carry bit is ignored and will automatically update with the lower 16bits value. - */ -#define Sn_RX_WR(N) (_W5500_IO_BASE_ + (0x002A << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief socket interrupt mask register(R) - * @details @ref Sn_IMR masks the interrupt of Socket n. - * Each bit corresponds to each bit of @ref Sn_IR. When a Socket n Interrupt is occurred and the corresponding bit of @ref Sn_IMR is - * the corresponding bit of @ref Sn_IR becomes When both the corresponding bit of @ref Sn_IMR and @ref Sn_IR are and the n-th bit of @ref IR is - * Host is interrupted by asserted INTn PIN to low. - */ -#define Sn_IMR(N) (_W5500_IO_BASE_ + (0x002C << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Fragment field value in IP header register(R/W) - * @details @ref Sn_FRAG configures the FRAG(Fragment field in IP header). - */ -#define Sn_FRAG(N) (_W5500_IO_BASE_ + (0x002D << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -/** - * @ingroup Socket_register_group - * @brief Keep Alive Timer register(R/W) - * @details @ref Sn_KPALVTR configures the transmitting timer of �KEEP ALIVE(KA)packet of SOCKETn. It is valid only in TCP mode, - * and ignored in other modes. The time unit is 5s. - * KA packet is transmittable after @ref Sn_SR is changed to SOCK_ESTABLISHED and after the data is transmitted or received to/from a peer at least once. - * In case of '@ref Sn_KPALVTR > 0', W5500 automatically transmits KA packet after time-period for checking the TCP connection (Auto-keepalive-process). - * In case of '@ref Sn_KPALVTR = 0', Auto-keep-alive-process will not operate, - * and KA packet can be transmitted by SEND_KEEP command by the host (Manual-keep-alive-process). - * Manual-keep-alive-process is ignored in case of '@ref Sn_KPALVTR > 0'. - */ -#define Sn_KPALVTR(N) (_W5500_IO_BASE_ + (0x002F << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - -//#define Sn_TSR(N) (_W5500_IO_BASE_ + (0x0030 << 8) + (WIZCHIP_SREG_BLOCK(N) << 3)) - - -//----------------------------- W5500 Register values ----------------------------- - -/* MODE register values */ -/** - * @brief Reset - * @details If this bit is All internal registers will be initialized. It will be automatically cleared as after S/W reset. - */ -#define MR_RST 0x80 - -/** - * @brief Wake on LAN - * @details 0 : Disable WOL mode\n - * 1 : Enable WOL mode\n - * If WOL mode is enabled and the received magic packet over UDP has been normally processed, the Interrupt PIN (INTn) asserts to low. - * When using WOL mode, the UDP Socket should be opened with any source port number. (Refer to Socket n Mode Register (@ref Sn_MR) for opening Socket.) - * @note The magic packet over UDP supported by W5500 consists of 6 bytes synchronization stream (xFFFFFFFFFFFF and - * 16 times Target MAC address stream in UDP payload. The options such like password are ignored. You can use any UDP source port number for WOL mode. - */ -#define MR_WOL 0x20 - -/** - * @brief Ping block - * @details 0 : Disable Ping block\n - * 1 : Enable Ping block\n - * If the bit is it blocks the response to a ping request. - */ -#define MR_PB 0x10 - -/** - * @brief Enable PPPoE - * @details 0 : DisablePPPoE mode\n - * 1 : EnablePPPoE mode\n - * If you use ADSL, this bit should be - */ -#define MR_PPPOE 0x08 - -/** - * @brief Enable UDP_FORCE_ARP CHECHK - * @details 0 : Disable Force ARP mode\n - * 1 : Enable Force ARP mode\n - * In Force ARP mode, It forces on sending ARP Request whenever data is sent. - */ -#define MR_FARP 0x02 - -/* IR register values */ -/** - * @brief Check IP conflict. - * @details Bit is set as when own source IP address is same with the sender IP address in the received ARP request. - */ -#define IR_CONFLICT 0x80 - -/** - * @brief Get the destination unreachable message in UDP sending. - * @details When receiving the ICMP (Destination port unreachable) packet, this bit is set as - * When this bit is Destination Information such as IP address and Port number may be checked with the corresponding @ref UIPR & @ref UPORTR. - */ -#define IR_UNREACH 0x40 - -/** - * @brief Get the PPPoE close message. - * @details When PPPoE is disconnected during PPPoE mode, this bit is set. - */ -#define IR_PPPoE 0x20 - -/** - * @brief Get the magic packet interrupt. - * @details When WOL mode is enabled and receives the magic packet over UDP, this bit is set. - */ -#define IR_MP 0x10 - - -/* PHYCFGR register value */ -#define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. -#define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value -#define PHYCFGR_OPMDC_ALLA (7<<3) -#define PHYCFGR_OPMDC_PDOWN (6<<3) -#define PHYCFGR_OPMDC_NA (5<<3) -#define PHYCFGR_OPMDC_100FA (4<<3) -#define PHYCFGR_OPMDC_100F (3<<3) -#define PHYCFGR_OPMDC_100H (2<<3) -#define PHYCFGR_OPMDC_10F (1<<3) -#define PHYCFGR_OPMDC_10H (0<<3) -#define PHYCFGR_DPX_FULL (1<<2) -#define PHYCFGR_DPX_HALF (0<<2) -#define PHYCFGR_SPD_100 (1<<1) -#define PHYCFGR_SPD_10 (0<<1) -#define PHYCFGR_LNK_ON (1<<0) -#define PHYCFGR_LNK_OFF (0<<0) - -/* IMR register values */ -/** - * @brief IP Conflict Interrupt Mask. - * @details 0: Disable IP Conflict Interrupt\n - * 1: Enable IP Conflict Interrupt - */ -#define IM_IR7 0x80 - -/** - * @brief Destination unreachable Interrupt Mask. - * @details 0: Disable Destination unreachable Interrupt\n - * 1: Enable Destination unreachable Interrupt - */ -#define IM_IR6 0x40 - -/** - * @brief PPPoE Close Interrupt Mask. - * @details 0: Disable PPPoE Close Interrupt\n - * 1: Enable PPPoE Close Interrupt - */ -#define IM_IR5 0x20 - -/** - * @brief Magic Packet Interrupt Mask. - * @details 0: Disable Magic Packet Interrupt\n - * 1: Enable Magic Packet Interrupt - */ -#define IM_IR4 0x10 - -/* Sn_MR Default values */ -/** - * @brief Support UDP Multicasting - * @details 0 : disable Multicasting\n - * 1 : enable Multicasting\n - * This bit is applied only during UDP mode(P[3:0] = 010.\n - * To use multicasting, @ref Sn_DIPR & @ref Sn_DPORT should be respectively configured with the multicast group IP address & port number - * before Socket n is opened by OPEN command of @ref Sn_CR. - */ -#define Sn_MR_MULTI 0x80 - -/** - * @brief Broadcast block in UDP Multicasting. - * @details 0 : disable Broadcast Blocking\n - * 1 : enable Broadcast Blocking\n - * This bit blocks to receive broadcasting packet during UDP mode(P[3:0] = 010.\m - * In addition, This bit does when MACRAW mode(P[3:0] = 100 - */ -#define Sn_MR_BCASTB 0x40 - -/** - * @brief No Delayed Ack(TCP), Multicast flag - * @details 0 : Disable No Delayed ACK option\n - * 1 : Enable No Delayed ACK option\n - * This bit is applied only during TCP mode (P[3:0] = 001.\n - * When this bit is It sends the ACK packet without delay as soon as a Data packet is received from a peer.\n - * When this bit is It sends the ACK packet after waiting for the timeout time configured by @ref _RTR_. - */ -#define Sn_MR_ND 0x20 - -/** - * @brief Unicast Block in UDP Multicasting - * @details 0 : disable Unicast Blocking\n - * 1 : enable Unicast Blocking\n - * This bit blocks receiving the unicast packet during UDP mode(P[3:0] = 010 and MULTI = - */ -#define Sn_MR_UCASTB 0x10 - -/** - * @brief MAC LAYER RAW SOCK - * @details This configures the protocol mode of Socket n. - * @note MACRAW mode should be only used in Socket 0. - */ -#define Sn_MR_MACRAW 0x04 - -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ - -/** - * @brief UDP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_UDP 0x02 - -/** - * @brief TCP - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_TCP 0x01 - -/** - * @brief Unused socket - * @details This configures the protocol mode of Socket n. - */ -#define Sn_MR_CLOSE 0x00 - -/* Sn_MR values used with Sn_MR_MACRAW */ -/** - * @brief MAC filter enable in @ref Sn_MR_MACRAW mode - * @details 0 : disable MAC Filtering\n - * 1 : enable MAC Filtering\n - * This bit is applied only during MACRAW mode(P[3:0] = 100.\n - * When set as W5500 can only receive broadcasting packet or packet sent to itself. - * When this bit is W5500 can receive all packets on Ethernet. - * If user wants to implement Hybrid TCP/IP stack, - * it is recommended that this bit is set as for reducing host overhead to process the all received packets. - */ -#define Sn_MR_MFEN Sn_MR_MULTI - -/** - * @brief Multicast Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : using IGMP version 2\n - * 1 : using IGMP version 1\n - * This bit is applied only during UDP mode(P[3:0] = 010 and MULTI = - * It configures the version for IGMP messages (Join/Leave/Report). - */ -#define Sn_MR_MMB Sn_MR_ND - -/** - * @brief IPv6 packet Blocking in @ref Sn_MR_MACRAW mode - * @details 0 : disable IPv6 Blocking\n - * 1 : enable IPv6 Blocking\n - * This bit is applied only during MACRAW mode (P[3:0] = 100. It blocks to receiving the IPv6 packet. - */ -#define Sn_MR_MIP6B Sn_MR_UCASTB - -/* Sn_MR value used with Sn_MR_UDP & Sn_MR_MULTI */ -/** - * @brief IGMP version used in UDP mulitcasting - * @details 0 : disable Multicast Blocking\n - * 1 : enable Multicast Blocking\n - * This bit is applied only when MACRAW mode(P[3:0] = 100. It blocks to receive the packet with multicast MAC address. - */ -#define Sn_MR_MC Sn_MR_ND - -/* Sn_MR alternate values */ -/** - * @brief For Berkeley Socket API - */ -#define SOCK_STREAM Sn_MR_TCP - -/** - * @brief For Berkeley Socket API - */ -#define SOCK_DGRAM Sn_MR_UDP - - -/* Sn_CR values */ -/** - * @brief Initialize or open socket - * @details Socket n is initialized and opened according to the protocol selected in Sn_MR(P3:P0). - * The table below shows the value of @ref Sn_SR corresponding to @ref Sn_MR.\n - * - * - * - * - * - * - *
\b Sn_MR (P[3:0]) \b Sn_SR
Sn_MR_CLOSE (000)
Sn_MR_TCP (001) SOCK_INIT (0x13)
Sn_MR_UDP (010) SOCK_UDP (0x22)
S0_MR_MACRAW (100) SOCK_MACRAW (0x02)
- */ -#define Sn_CR_OPEN 0x01 - -/** - * @brief Wait connection request in TCP mode(Server mode) - * @details This is valid only in TCP mode (\ref Sn_MR(P3:P0) = \ref Sn_MR_TCP). - * In this mode, Socket n operates as a TCP serverand waits for connection-request (SYN packet) from any TCP client - * The @ref Sn_SR changes the state from \ref SOCK_INIT to \ref SOCKET_LISTEN. - * When a TCP clientconnection request is successfully established, - * the @ref Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the @ref Sn_IR(0) becomes - * But when a TCP clientconnection request is failed, @ref Sn_IR(3) becomes and the status of @ref Sn_SR changes to SOCK_CLOSED. - */ -#define Sn_CR_LISTEN 0x02 - -/** - * @brief Send connection request in TCP mode(Client mode) - * @details To connect, a connect-request (SYN packet) is sent to TCP serverconfigured by @ref Sn_DIPR & Sn_DPORT(destination address & port). - * If the connect-request is successful, the @ref Sn_SR is changed to @ref SOCK_ESTABLISHED and the Sn_IR(0) becomes \n\n - * The connect-request fails in the following three cases.\n - * 1. When a @b ARPTO occurs (@ref Sn_IR[3] = ) because destination hardware address is not acquired through the ARP-process.\n - * 2. When a @b SYN/ACK packet is not received and @b TCPTO (Sn_IR(3) = )\n - * 3. When a @b RST packet is received instead of a @b SYN/ACK packet. In these cases, @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note This is valid only in TCP mode and operates when Socket n acts as TCP client - */ -#define Sn_CR_CONNECT 0x04 - -/** - * @brief Send closing request in TCP mode - * @details Regardless of TCP serveror TCP client the DISCON command processes the disconnect-process (b>Active closeor Passive close.\n - * @par Active close - * it transmits disconnect-request(FIN packet) to the connected peer\n - * @par Passive close - * When FIN packet is received from peer, a FIN packet is replied back to the peer.\n - * @details When the disconnect-process is successful (that is, FIN/ACK packet is received successfully), @ref Sn_SR is changed to @ref SOCK_CLOSED.\n - * Otherwise, TCPTO occurs (\ref Sn_IR(3)='1') and then @ref Sn_SR is changed to @ref SOCK_CLOSED. - * @note Valid only in TCP mode. - */ -#define Sn_CR_DISCON 0x08 - -/** - * @brief Close socket - * @details Sn_SR is changed to @ref SOCK_CLOSED. - */ -#define Sn_CR_CLOSE 0x10 - -/** - * @brief Update TX buffer pointer and send data - * @details SEND transmits all the data in the Socket n TX buffer.\n - * For more details, please refer to Socket n TX Free Size Register (@ref Sn_TX_FSR), Socket n, - * TX Write Pointer Register(@ref Sn_TX_WR), and Socket n TX Read Pointer Register(@ref Sn_TX_RD). - */ -#define Sn_CR_SEND 0x20 - -/** - * @brief Send data with MAC address, so without ARP process - * @details The basic operation is same as SEND.\n - * Normally SEND transmits data after destination hardware address is acquired by the automatic ARP-process(Address Resolution Protocol).\n - * But SEND_MAC transmits data without the automatic ARP-process.\n - * In this case, the destination hardware address is acquired from @ref Sn_DHAR configured by host, instead of APR-process. - * @note Valid only in UDP mode. - */ -#define Sn_CR_SEND_MAC 0x21 - -/** - * @brief Send keep alive message - * @details It checks the connection status by sending 1byte keep-alive packet.\n - * If the peer can not respond to the keep-alive packet during timeout time, the connection is terminated and the timeout interrupt will occur. - * @note Valid only in TCP mode. - */ -#define Sn_CR_SEND_KEEP 0x22 - -/** - * @brief Update RX buffer pointer and receive data - * @details RECV completes the processing of the received data in Socket n RX Buffer by using a RX read pointer register (@ref Sn_RX_RD).\n - * For more details, refer to Socket n RX Received Size Register (@ref Sn_RX_RSR), Socket n RX Write Pointer Register (@ref Sn_RX_WR), - * and Socket n RX Read Pointer Register (@ref Sn_RX_RD). - */ -#define Sn_CR_RECV 0x40 - -/* Sn_IR values */ -/** - * @brief SEND_OK Interrupt - * @details This is issued when SEND command is completed. - */ -#define Sn_IR_SENDOK 0x10 - -/** - * @brief TIMEOUT Interrupt - * @details This is issued when ARPTO or TCPTO occurs. - */ -#define Sn_IR_TIMEOUT 0x08 - -/** - * @brief RECV Interrupt - * @details This is issued whenever data is received from a peer. - */ -#define Sn_IR_RECV 0x04 - -/** - * @brief DISCON Interrupt - * @details This is issued when FIN or FIN/ACK packet is received from a peer. - */ -#define Sn_IR_DISCON 0x02 - -/** - * @brief CON Interrupt - * @details This is issued one time when the connection with peer is successful and then @ref Sn_SR is changed to @ref SOCK_ESTABLISHED. - */ -#define Sn_IR_CON 0x01 - -/* Sn_SR values */ -/** - * @brief Closed - * @details This indicates that Socket n is released.\n - * When DICON, CLOSE command is ordered, or when a timeout occurs, it is changed to @ref SOCK_CLOSED regardless of previous status. - */ -#define SOCK_CLOSED 0x00 - -/** - * @brief Initiate state - * @details This indicates Socket n is opened with TCP mode.\n - * It is changed to @ref SOCK_INIT when @ref Sn_MR(P[3:0]) = 001 and OPEN command is ordered.\n - * After @ref SOCK_INIT, user can use LISTEN /CONNECT command. - */ -#define SOCK_INIT 0x13 - -/** - * @brief Listen state - * @details This indicates Socket n is operating as TCP servermode and waiting for connection-request (SYN packet) from a peer TCP client.\n - * It will change to @ref SOCK_ESTALBLISHED when the connection-request is successfully accepted.\n - * Otherwise it will change to @ref SOCK_CLOSED after TCPTO @ref Sn_IR(TIMEOUT) = '1') is occurred. - */ -#define SOCK_LISTEN 0x14 - -/** - * @brief Connection state - * @details This indicates Socket n sent the connect-request packet (SYN packet) to a peer.\n - * It is temporarily shown when @ref Sn_SR is changed from @ref SOCK_INIT to @ref SOCK_ESTABLISHED by CONNECT command.\n - * If connect-accept(SYN/ACK packet) is received from the peer at SOCK_SYNSENT, it changes to @ref SOCK_ESTABLISHED.\n - * Otherwise, it changes to @ref SOCK_CLOSED after TCPTO (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNSENT 0x15 - -/** - * @brief Connection state - * @details It indicates Socket n successfully received the connect-request packet (SYN packet) from a peer.\n - * If socket n sends the response (SYN/ACK packet) to the peer successfully, it changes to @ref SOCK_ESTABLISHED. \n - * If not, it changes to @ref SOCK_CLOSED after timeout (@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_SYNRECV 0x16 - -/** - * @brief Success to connect - * @details This indicates the status of the connection of Socket n.\n - * It changes to @ref SOCK_ESTABLISHED when the TCP SERVERprocessed the SYN packet from the TCP CLIENTduring @ref SOCK_LISTEN, or - * when the CONNECT command is successful.\n - * During @ref SOCK_ESTABLISHED, DATA packet can be transferred using SEND or RECV command. - */ -#define SOCK_ESTABLISHED 0x17 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_FIN_WAIT 0x18 - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_CLOSING 0x1A - -/** - * @brief Closing state - * @details These indicate Socket n is closing.\n - * These are shown in disconnect-process such as active-close and passive-close.\n - * When Disconnect-process is successfully completed, or when timeout occurs, these change to @ref SOCK_CLOSED. - */ -#define SOCK_TIME_WAIT 0x1B - -/** - * @brief Closing state - * @details This indicates Socket n received the disconnect-request (FIN packet) from the connected peer.\n - * This is half-closing status, and data can be transferred.\n - * For full-closing, DISCON command is used. But For just-closing, CLOSE command is used. - */ -#define SOCK_CLOSE_WAIT 0x1C - -/** - * @brief Closing state - * @details This indicates Socket n is waiting for the response (FIN/ACK packet) to the disconnect-request (FIN packet) by passive-close.\n - * It changes to @ref SOCK_CLOSED when Socket n received the response successfully, or when timeout(@ref Sn_IR[TIMEOUT] = '1') is occurred. - */ -#define SOCK_LAST_ACK 0x1D - -/** - * @brief UDP socket - * @details This indicates Socket n is opened in UDP mode(@ref Sn_MR(P[3:0]) = '010').\n - * It changes to SOCK_UDP when @ref Sn_MR(P[3:0]) = '010' and @ref Sn_CR_OPEN command is ordered.\n - * Unlike TCP mode, data can be transfered without the connection-process. - */ -#define SOCK_UDP 0x22 - -#define SOCK_IPRAW 0x32 /**< IP raw mode socket */ - -/** - * @brief MAC raw mode socket - * @details This indicates Socket 0 is opened in MACRAW mode (S0_MR(P[3:0]) = 100and is valid only in Socket 0.\n - * It changes to SOCK_MACRAW when S0_MR(P[3:0] = 100and OPEN command is ordered.\n - * Like UDP mode socket, MACRAW mode Socket 0 can transfer a MAC packet (Ethernet frame) without the connection-process. - */ -#define SOCK_MACRAW 0x42 - -//#define SOCK_PPPOE 0x5F - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 //< Dummy for IP -#define IPPROTO_ICMP 1 //< Control message protocol -#define IPPROTO_IGMP 2 //< Internet group management protocol -#define IPPROTO_GGP 3 //< Gateway^2 (deprecated) -#define IPPROTO_TCP 6 //< TCP -#define IPPROTO_PUP 12 //< PUP -#define IPPROTO_UDP 17 //< UDP -#define IPPROTO_IDP 22 //< XNS idp -#define IPPROTO_ND 77 //< UNOFFICIAL net disk protocol -#define IPPROTO_RAW 255 //< Raw IP packet - - -/** - * @brief Enter a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n \n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt.\n - * In OS environment, You can replace it to critical section api supported by OS. - * - * \sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * \sa WIZCHIP_CRITICAL_EXIT() - */ -#define WIZCHIP_CRITICAL_ENTER() WIZCHIP.CRIS._enter() - -#ifdef _exit -#undef _exit -#endif - -/** - * @brief Exit a critical section - * - * @details It is provided to protect your shared code which are executed without distribution. \n\n - * - * In non-OS environment, It can be just implemented by disabling whole interrupt. \n - * In OS environment, You can replace it to critical section api supported by OS. - * - * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() - * @sa WIZCHIP_CRITICAL_ENTER() - */ -#define WIZCHIP_CRITICAL_EXIT() WIZCHIP.CRIS._exit() - - -//////////////////////// -// Basic I/O Function // -//////////////////////// - -/** - * @ingroup Basic_IO_function - * @brief It reads 1 byte value from a register. - * @param AddrSel Register address - * @return The value of register - */ -uint8_t WIZCHIP_READ (uint32_t AddrSel); - -/** - * @ingroup Basic_IO_function - * @brief It writes 1 byte value to a register. - * @param AddrSel Register address - * @param wb Write data - * @return void - */ -void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb ); - -/** - * @ingroup Basic_IO_function - * @brief It reads sequence data from registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to read data - * @param len Data length - */ -void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It writes sequence data to registers. - * @param AddrSel Register address - * @param pBuf Pointer buffer to write data - * @param len Data length - */ -void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len); - -///////////////////////////////// -// Common Register I/O function // -///////////////////////////////// -/** - * @ingroup Common_register_access_function - * @brief Set Mode Register - * @param (uint8_t)mr The value to be set. - * @sa getMR() - */ -#define setMR(mr) \ - WIZCHIP_WRITE(MR,mr) - - -/** - * @ingroup Common_register_access_function - * @brief Get Mode Register - * @return uint8_t. The value of Mode register. - * @sa setMR() - */ -#define getMR() \ - WIZCHIP_READ(MR) - -/** - * @ingroup Common_register_access_function - * @brief Set gateway IP address - * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. - * @sa getGAR() - */ -#define setGAR(gar) \ - WIZCHIP_WRITE_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Get gateway IP address - * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. - * @sa setGAR() - */ -#define getGAR(gar) \ - WIZCHIP_READ_BUF(GAR,gar,4) - -/** - * @ingroup Common_register_access_function - * @brief Set subnet mask address - * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. - * @sa getSUBR() - */ -#define setSUBR(subr) \ - WIZCHIP_WRITE_BUF(SUBR, subr,4) - - -/** - * @ingroup Common_register_access_function - * @brief Get subnet mask address - * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. - * @sa setSUBR() - */ -#define getSUBR(subr) \ - WIZCHIP_READ_BUF(SUBR, subr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set local MAC address - * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. - * @sa getSHAR() - */ -#define setSHAR(shar) \ - WIZCHIP_WRITE_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get local MAC address - * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. - * @sa setSHAR() - */ -#define getSHAR(shar) \ - WIZCHIP_READ_BUF(SHAR, shar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set local IP address - * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. - * @sa getSIPR() - */ -#define setSIPR(sipr) \ - WIZCHIP_WRITE_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Get local IP address - * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. - * @sa setSIPR() - */ -#define getSIPR(sipr) \ - WIZCHIP_READ_BUF(SIPR, sipr, 4) - -/** - * @ingroup Common_register_access_function - * @brief Set INTLEVEL register - * @param (uint16_t)intlevel Value to set @ref INTLEVEL register. - * @sa getINTLEVEL() - */ -#define setINTLEVEL(intlevel) {\ - WIZCHIP_WRITE(INTLEVEL, (uint8_t)(intlevel >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(INTLEVEL,1), (uint8_t) intlevel); \ - } - - -/** - * @ingroup Common_register_access_function - * @brief Get INTLEVEL register - * @return uint16_t. Value of @ref INTLEVEL register. - * @sa setINTLEVEL() - */ -//M20150401 : Type explict declaration -/* -#define getINTLEVEL() \ - ((WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) -*/ -#define getINTLEVEL() \ - (((uint16_t)WIZCHIP_READ(INTLEVEL) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(INTLEVEL,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref IR register - * @param (uint8_t)ir Value to set @ref IR register. - * @sa getIR() - */ -#define setIR(ir) \ - WIZCHIP_WRITE(IR, (ir & 0xF0)) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref IR register - * @return uint8_t. Value of @ref IR register. - * @sa setIR() - */ -#define getIR() \ - (WIZCHIP_READ(IR) & 0xF0) -/** - * @ingroup Common_register_access_function - * @brief Set @ref _IMR_ register - * @param (uint8_t)imr Value to set @ref _IMR_ register. - * @sa getIMR() - */ -#define setIMR(imr) \ - WIZCHIP_WRITE(_IMR_, imr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _IMR_ register - * @return uint8_t. Value of @ref _IMR_ register. - * @sa setIMR() - */ -#define getIMR() \ - WIZCHIP_READ(_IMR_) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIR register - * @param (uint8_t)sir Value to set @ref SIR register. - * @sa getSIR() - */ -#define setSIR(sir) \ - WIZCHIP_WRITE(SIR, sir) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIR register - * @return uint8_t. Value of @ref SIR register. - * @sa setSIR() - */ -#define getSIR() \ - WIZCHIP_READ(SIR) -/** - * @ingroup Common_register_access_function - * @brief Set @ref SIMR register - * @param (uint8_t)simr Value to set @ref SIMR register. - * @sa getSIMR() - */ -#define setSIMR(simr) \ - WIZCHIP_WRITE(SIMR, simr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref SIMR register - * @return uint8_t. Value of @ref SIMR register. - * @sa setSIMR() - */ -#define getSIMR() \ - WIZCHIP_READ(SIMR) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RTR_ register - * @param (uint16_t)rtr Value to set @ref _RTR_ register. - * @sa getRTR() - */ -#define setRTR(rtr) {\ - WIZCHIP_WRITE(_RTR_, (uint8_t)(rtr >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(_RTR_,1), (uint8_t) rtr); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RTR_ register - * @return uint16_t. Value of @ref _RTR_ register. - * @sa setRTR() - */ -//M20150401 : Type explict declaration -/* -#define getRTR() \ - ((WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) -*/ -#define getRTR() \ - (((uint16_t)WIZCHIP_READ(_RTR_) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(_RTR_,1))) - - -/** - * @ingroup Common_register_access_function - * @brief Set @ref _RCR_ register - * @param (uint8_t)rcr Value to set @ref _RCR_ register. - * @sa getRCR() - */ -#define setRCR(rcr) \ - WIZCHIP_WRITE(_RCR_, rcr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref _RCR_ register - * @return uint8_t. Value of @ref _RCR_ register. - * @sa setRCR() - */ -#define getRCR() \ - WIZCHIP_READ(_RCR_) - -//================================================== test done =========================================================== - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PTIMER register - * @param (uint8_t)ptimer Value to set @ref PTIMER register. - * @sa getPTIMER() - */ -#define setPTIMER(ptimer) \ - WIZCHIP_WRITE(PTIMER, ptimer) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PTIMER register - * @return uint8_t. Value of @ref PTIMER register. - * @sa setPTIMER() - */ -#define getPTIMER() \ - WIZCHIP_READ(PTIMER) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMAGIC register - * @param (uint8_t)pmagic Value to set @ref PMAGIC register. - * @sa getPMAGIC() - */ -#define setPMAGIC(pmagic) \ - WIZCHIP_WRITE(PMAGIC, pmagic) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMAGIC register - * @return uint8_t. Value of @ref PMAGIC register. - * @sa setPMAGIC() - */ -#define getPMAGIC() \ - WIZCHIP_READ(PMAGIC) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHAR address - * @param (uint8_t*)phar Pointer variable to set PPP destination MAC register address. It should be allocated 6 bytes. - * @sa getPHAR() - */ -#define setPHAR(phar) \ - WIZCHIP_WRITE_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHAR address - * @param (uint8_t*)phar Pointer variable to PPP destination MAC register address. It should be allocated 6 bytes. - * @sa setPHAR() - */ -#define getPHAR(phar) \ - WIZCHIP_READ_BUF(PHAR, phar, 6) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PSID register - * @param (uint16_t)psid Value to set @ref PSID register. - * @sa getPSID() - */ -#define setPSID(psid) {\ - WIZCHIP_WRITE(PSID, (uint8_t)(psid >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PSID,1), (uint8_t) psid); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PSID register - * @return uint16_t. Value of @ref PSID register. - * @sa setPSID() - */ -//uint16_t getPSID(void); -//M20150401 : Type explict declaration -/* -#define getPSID() \ - ((WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) -*/ -#define getPSID() \ - (((uint16_t)WIZCHIP_READ(PSID) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PSID,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PMRU register - * @param (uint16_t)pmru Value to set @ref PMRU register. - * @sa getPMRU() - */ -#define setPMRU(pmru) { \ - WIZCHIP_WRITE(PMRU, (uint8_t)(pmru>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(PMRU,1), (uint8_t) pmru); \ - } - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PMRU register - * @return uint16_t. Value of @ref PMRU register. - * @sa setPMRU() - */ -//M20150401 : Type explict declaration -/* -#define getPMRU() \ - ((WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) -*/ -#define getPMRU() \ - (((uint16_t)WIZCHIP_READ(PMRU) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(PMRU,1))) - -/** - * @ingroup Common_register_access_function - * @brief Get unreachable IP address - * @param (uint8_t*)uipr Pointer variable to get unreachable IP address. It should be allocated 4 bytes. - */ -//M20150401 : Size Error of UIPR (6 -> 4) -/* -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,6) -*/ -#define getUIPR(uipr) \ - WIZCHIP_READ_BUF(UIPR,uipr,4) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref UPORTR register - * @return uint16_t. Value of @ref UPORTR register. - */ -//M20150401 : Type explict declaration -/* -#define getUPORTR() \ - ((WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) -*/ -#define getUPORTR() \ - (((uint16_t)WIZCHIP_READ(UPORTR) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(UPORTR,1))) - -/** - * @ingroup Common_register_access_function - * @brief Set @ref PHYCFGR register - * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. - * @sa getPHYCFGR() - */ -#define setPHYCFGR(phycfgr) \ - WIZCHIP_WRITE(PHYCFGR, phycfgr) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref PHYCFGR register - * @return uint8_t. Value of @ref PHYCFGR register. - * @sa setPHYCFGR() - */ -#define getPHYCFGR() \ - WIZCHIP_READ(PHYCFGR) - -/** - * @ingroup Common_register_access_function - * @brief Get @ref VERSIONR register - * @return uint8_t. Value of @ref VERSIONR register. - */ -#define getVERSIONR() \ - WIZCHIP_READ(VERSIONR) - -///////////////////////////////////// - -/////////////////////////////////// -// Socket N register I/O function // -/////////////////////////////////// -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)mr Value to set @ref Sn_MR - * @sa getSn_MR() - */ -#define setSn_MR(sn, mr) \ - WIZCHIP_WRITE(Sn_MR(sn),mr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_MR. - * @sa setSn_MR() - */ -#define getSn_MR(sn) \ - WIZCHIP_READ(Sn_MR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)cr Value to set @ref Sn_CR - * @sa getSn_CR() - */ -#define setSn_CR(sn, cr) \ - WIZCHIP_WRITE(Sn_CR(sn), cr) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_CR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_CR. - * @sa setSn_CR() - */ -#define getSn_CR(sn) \ - WIZCHIP_READ(Sn_CR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ir Value to set @ref Sn_IR - * @sa getSn_IR() - */ -#define setSn_IR(sn, ir) \ - WIZCHIP_WRITE(Sn_IR(sn), (ir & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IR. - * @sa setSn_IR() - */ -#define getSn_IR(sn) \ - (WIZCHIP_READ(Sn_IR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)imr Value to set @ref Sn_IMR - * @sa getSn_IMR() - */ -#define setSn_IMR(sn, imr) \ - WIZCHIP_WRITE(Sn_IMR(sn), (imr & 0x1F)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_IMR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_IMR. - * @sa setSn_IMR() - */ -#define getSn_IMR(sn) \ - (WIZCHIP_READ(Sn_IMR(sn)) & 0x1F) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_SR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_SR. - */ -#define getSn_SR(sn) \ - WIZCHIP_READ(Sn_SR(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)port Value to set @ref Sn_PORT. - * @sa getSn_PORT() - */ -#define setSn_PORT(sn, port) { \ - WIZCHIP_WRITE(Sn_PORT(sn), (uint8_t)(port >> 8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1), (uint8_t) port); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_PORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_PORT. - * @sa setSn_PORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_PORT(sn) \ - ((WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) -*/ -#define getSn_PORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_PORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_PORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DHAR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. - * @sa getSn_DHAR() - */ -#define setSn_DHAR(sn, dhar) \ - WIZCHIP_WRITE_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. - * @sa setSn_DHAR() - */ -#define getSn_DHAR(sn, dhar) \ - WIZCHIP_READ_BUF(Sn_DHAR(sn), dhar, 6) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. - * @sa getSn_DIPR() - */ -#define setSn_DIPR(sn, dipr) \ - WIZCHIP_WRITE_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DIPR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. - * @sa setSn_DIPR() - */ -#define getSn_DIPR(sn, dipr) \ - WIZCHIP_READ_BUF(Sn_DIPR(sn), dipr, 4) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)dport Value to set @ref Sn_DPORT - * @sa getSn_DPORT() - */ -#define setSn_DPORT(sn, dport) { \ - WIZCHIP_WRITE(Sn_DPORT(sn), (uint8_t) (dport>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1), (uint8_t) dport); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_DPORT register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_DPORT. - * @sa setSn_DPORT() - */ -//M20150401 : Type explict declaration -/* -#define getSn_DPORT(sn) \ - ((WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) -*/ -#define getSn_DPORT(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_DPORT(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_DPORT(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)mss Value to set @ref Sn_MSSR - * @sa setSn_MSSR() - */ -#define setSn_MSSR(sn, mss) { \ - WIZCHIP_WRITE(Sn_MSSR(sn), (uint8_t)(mss>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1), (uint8_t) mss); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_MSSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_MSSR. - * @sa setSn_MSSR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_MSSR(sn) \ - ((WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) -*/ -#define getSn_MSSR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_MSSR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_MSSR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)tos Value to set @ref Sn_TOS - * @sa getSn_TOS() - */ -#define setSn_TOS(sn, tos) \ - WIZCHIP_WRITE(Sn_TOS(sn), tos) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TOS register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of Sn_TOS. - * @sa setSn_TOS() - */ -#define getSn_TOS(sn) \ - WIZCHIP_READ(Sn_TOS(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)ttl Value to set @ref Sn_TTL - * @sa getSn_TTL() - */ -#define setSn_TTL(sn, ttl) \ - WIZCHIP_WRITE(Sn_TTL(sn), ttl) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TTL register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TTL. - * @sa setSn_TTL() - */ -#define getSn_TTL(sn) \ - WIZCHIP_READ(Sn_TTL(sn)) - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE - * @sa getSn_RXBUF_SIZE() - */ -#define setSn_RXBUF_SIZE(sn, rxbufsize) \ - WIZCHIP_WRITE(Sn_RXBUF_SIZE(sn),rxbufsize) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. - * @sa setSn_RXBUF_SIZE() - */ -#define getSn_RXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_RXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE - * @sa getSn_TXBUF_SIZE() - */ -#define setSn_TXBUF_SIZE(sn, txbufsize) \ - WIZCHIP_WRITE(Sn_TXBUF_SIZE(sn), txbufsize) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TXBUF_SIZE register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. - * @sa setSn_TXBUF_SIZE() - */ -#define getSn_TXBUF_SIZE(sn) \ - WIZCHIP_READ(Sn_TXBUF_SIZE(sn)) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_FSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_FSR. - */ -uint16_t getSn_TX_FSR(uint8_t sn); - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_RD. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_RD(sn) \ - ((WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) -*/ -#define getSn_TX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)txwr Value to set @ref Sn_TX_WR - * @sa GetSn_TX_WR() - */ -#define setSn_TX_WR(sn, txwr) { \ - WIZCHIP_WRITE(Sn_TX_WR(sn), (uint8_t)(txwr>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1), (uint8_t) txwr); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_TX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_TX_WR. - * @sa setSn_TX_WR() - */ -//M20150401 : Type explict declaration -/* -#define getSn_TX_WR(sn) \ - ((WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) -*/ -#define getSn_TX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_TX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_TX_WR(sn),1))) - - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RSR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RSR. - */ -uint16_t getSn_RX_RSR(uint8_t sn); - - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD - * @sa getSn_RX_RD() - */ -#define setSn_RX_RD(sn, rxrd) { \ - WIZCHIP_WRITE(Sn_RX_RD(sn), (uint8_t)(rxrd>>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1), (uint8_t) rxrd); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_RD register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_RD. - * @sa setSn_RX_RD() - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_RD(sn) \ - ((WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) -*/ -#define getSn_RX_RD(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_RD(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_RD(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_RX_WR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_RX_WR. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RX_WR(sn) \ - ((WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) -*/ -#define getSn_RX_WR(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_RX_WR(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_RX_WR(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint16_t)frag Value to set @ref Sn_FRAG - * @sa getSn_FRAD() - */ -#define setSn_FRAG(sn, frag) { \ - WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \ - WIZCHIP_WRITE(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1), (uint8_t) frag); \ - } - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_FRAG register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of @ref Sn_FRAG. - * @sa setSn_FRAG() - */ -//M20150401 : Type explict declaration -/* -#define getSn_FRAG(sn) \ - ((WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) -*/ -#define getSn_FRAG(sn) \ - (((uint16_t)WIZCHIP_READ(Sn_FRAG(sn)) << 8) + WIZCHIP_READ(WIZCHIP_OFFSET_INC(Sn_FRAG(sn),1))) - -/** - * @ingroup Socket_register_access_function - * @brief Set @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param (uint8_t)kpalvt Value to set @ref Sn_KPALVTR - * @sa getSn_KPALVTR() - */ -#define setSn_KPALVTR(sn, kpalvt) \ - WIZCHIP_WRITE(Sn_KPALVTR(sn), kpalvt) - -/** - * @ingroup Socket_register_access_function - * @brief Get @ref Sn_KPALVTR register - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint8_t. Value of @ref Sn_KPALVTR. - * @sa setSn_KPALVTR() - */ -#define getSn_KPALVTR(sn) \ - WIZCHIP_READ(Sn_KPALVTR(sn)) - -////////////////////////////////////// - -///////////////////////////////////// -// Sn_TXBUF & Sn_RXBUF IO function // -///////////////////////////////////// -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameter. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n RX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_RxMAX(sn) \ - (getSn_RXBUF_SIZE(sn) << 10) -*/ -#define getSn_RxMAX(sn) \ - (((uint16_t)getSn_RXBUF_SIZE(sn)) << 10) - -/** - * @brief Socket_register_access_function - * @brief Gets the max buffer size of socket sn passed as parameters. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @return uint16_t. Value of Socket n TX max buffer size. - */ -//M20150401 : Type explict declaration -/* -#define getSn_TxMAX(sn) \ - (getSn_TXBUF_SIZE(sn) << 10) -*/ -#define getSn_TxMAX(sn) \ - (((uint16_t)getSn_TXBUF_SIZE(sn)) << 10) - -/** - * @ingroup Basic_IO_function - * @brief It copies data to internal TX memory - * - * @details This function reads the Tx write pointer register and after that, - * it copies the wizdata(pointer buffer) of the length of len(variable) bytes to internal TX memory - * and updates the Tx write pointer register. - * This function is being called by send() and sendto() function also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to write data - * @param len Data length - * @sa wiz_recv_data() - */ -void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It copies data to your buffer from internal RX memory - * - * @details This function read the Rx read pointer register and after that, - * it copies the received data from internal RX memory - * to wizdata(pointer variable) of the length of len(variable) bytes. - * This function is being called by recv() also. - * - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param wizdata Pointer buffer to read data - * @param len Data length - * @sa wiz_send_data() - */ -void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len); - -/** - * @ingroup Basic_IO_function - * @brief It discard the received data in RX memory. - * @details It discards the data of the length of len(variable) bytes in internal RX memory. - * @param (uint8_t)sn Socket number. It should be 0 ~ 7. - * @param len Data length - */ -void wiz_recv_ignore(uint8_t sn, uint16_t len); - -/// @cond DOXY_APPLY_CODE -#endif -/// @endcond - -#ifdef __cplusplus -} -#endif - -#endif // _W5500_H_ diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/socket.c b/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/socket.c deleted file mode 100644 index 961d9a4..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/socket.c +++ /dev/null @@ -1,930 +0,0 @@ -//***************************************************************************** -// -//! \file socket.c -//! \brief SOCKET APIs Implements file. -//! \details SOCKET APIs like as Berkeley Socket APIs. -//! \version 1.0.3 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.3. Refer to M20140501 -//! 1. Implicit type casting -> Explicit type casting. -//! 2. replace 0x01 with PACK_REMAINED in recvfrom() -//! 3. Validation a destination ip in connect() & sendto(): -//! It occurs a fatal error on converting unint32 address if uint8* addr parameter is not aligned by 4byte address. -//! Copy 4 byte addr value into temporary uint32 variable and then compares it. -//! <2013/12/20> V1.0.2 Refer to M20131220 -//! Remove Warning. -//! <2013/11/04> V1.0.1 2nd Release. Refer to "20131104". -//! In sendto(), Add to clear timeout interrupt status (Sn_IR_TIMEOUT) -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -#include "socket.h" - -//M20150401 : Typing Error -//#define SOCK_ANY_PORT_NUM 0xC000; -#define SOCK_ANY_PORT_NUM 0xC000 - -static uint16_t sock_any_port = SOCK_ANY_PORT_NUM; -static uint16_t sock_io_mode = 0; -static uint16_t sock_is_sending = 0; - -static uint16_t sock_remained_size[_WIZCHIP_SOCK_NUM_] = {0,0,}; - -//M20150601 : For extern decleation -//static uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -uint8_t sock_pack_info[_WIZCHIP_SOCK_NUM_] = {0,}; -// - -#if _WIZCHIP_ == 5200 - static uint16_t sock_next_rd[_WIZCHIP_SOCK_NUM_] ={0,}; -#endif - -//A20150601 : For integrating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t sock_remained_byte[_WIZCHIP_SOCK_NUM_] = {0,}; // set by wiz_recv_data() -#endif - - -#define CHECK_SOCKNUM() \ - do{ \ - if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ - }while(0); \ - -#define CHECK_SOCKMODE(mode) \ - do{ \ - if((getSn_MR(sn) & 0x0F) != mode) return SOCKERR_SOCKMODE; \ - }while(0); \ - -#define CHECK_SOCKINIT() \ - do{ \ - if((getSn_SR(sn) != SOCK_INIT)) return SOCKERR_SOCKINIT; \ - }while(0); \ - -#define CHECK_SOCKDATA() \ - do{ \ - if(len == 0) return SOCKERR_DATALEN; \ - }while(0); \ - - - -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag) -{ - CHECK_SOCKNUM(); - switch(protocol) - { - case Sn_MR_TCP : - { - //M20150601 : Fixed the warning - taddr will never be NULL - /* - uint8_t taddr[4]; - getSIPR(taddr); - */ - uint32_t taddr; - getSIPR((uint8_t*)&taddr); - if(taddr == 0) return SOCKERR_SOCKINIT; - } - case Sn_MR_UDP : - case Sn_MR_MACRAW : - case Sn_MR_IPRAW : - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE : - break; - #endif - default : - return SOCKERR_SOCKMODE; - } - //M20150601 : For SF_TCP_ALIGN & W5300 - //if((flag & 0x06) != 0) return SOCKERR_SOCKFLAG; - if((flag & 0x04) != 0) return SOCKERR_SOCKFLAG; -#if _WIZCHIP_ == 5200 - if(flag & 0x10) return SOCKERR_SOCKFLAG; -#endif - - if(flag != 0) - { - switch(protocol) - { - case Sn_MR_TCP: - //M20150601 : For SF_TCP_ALIGN & W5300 - #if _WIZCHIP_ == 5300 - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK|SF_TCP_ALIGN))==0) return SOCKERR_SOCKFLAG; - #else - if((flag & (SF_TCP_NODELAY|SF_IO_NONBLOCK))==0) return SOCKERR_SOCKFLAG; - #endif - - break; - case Sn_MR_UDP: - if(flag & SF_IGMP_VER2) - { - if((flag & SF_MULTI_ENABLE)==0) return SOCKERR_SOCKFLAG; - } - #if _WIZCHIP_ == 5500 - if(flag & SF_UNI_BLOCK) - { - if((flag & SF_MULTI_ENABLE) == 0) return SOCKERR_SOCKFLAG; - } - #endif - break; - default: - break; - } - } - close(sn); - //M20150601 - #if _WIZCHIP_ == 5300 - setSn_MR(sn, ((uint16_t)(protocol | (flag & 0xF0))) | (((uint16_t)(flag & 0x02)) << 7) ); - #else - setSn_MR(sn, (protocol | (flag & 0xF0))); - #endif - if(!port) - { - port = sock_any_port++; - if(sock_any_port == 0xFFF0) sock_any_port = SOCK_ANY_PORT_NUM; - } - setSn_PORT(sn,port); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn)); - //A20150401 : For release the previous sock_io_mode - sock_io_mode &= ~(1 < sn - //if( ((getSn_MR(s)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(s) != getSn_TxMAX(s)) ) - if( ((getSn_MR(sn)& 0x0F) == Sn_MR_TCP) && (getSn_TX_FSR(sn) != getSn_TxMAX(sn)) ) - { - uint8_t destip[4] = {0, 0, 0, 1}; - // TODO - // You can wait for completing to sending data; - // wait about 1 second; - // if you have completed to send data, skip the code of erratum 1 - // ex> wait_1s(); - // if (getSn_TX_FSR(s) == getSn_TxMAX(s)) continue; - // - //M20160503 : The socket() of close() calls close() itself again. It occures a infinite loop - close()->socket()->close()->socket()-> ~ - //socket(s,Sn_MR_UDP,0x3000,0); - //sendto(s,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - setSn_MR(sn,Sn_MR_UDP); - setSn_PORTR(sn, 0x3000); - setSn_CR(sn,Sn_CR_OPEN); - while(getSn_CR(sn) != 0); - while(getSn_SR(sn) != SOCK_UDP); - sendto(sn,destip,1,destip,0x3000); // send the dummy data to an unknown destination(0.0.0.1). - }; -#endif - setSn_CR(sn,Sn_CR_CLOSE); - /* wait to process the command... */ - while( getSn_CR(sn) ); - /* clear all interrupt of the socket. */ - setSn_IR(sn, 0xFF); - //A20150401 : Release the sock_io_mode of socket n. - sock_io_mode &= ~(1< freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - tmp = getSn_SR(sn); - if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - } - wiz_send_data(sn, buf, len); - #if _WIZCHIP_ == 5200 - sock_next_rd[sn] = getSn_TX_RD(sn) + len; - #endif - - #if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn,len); - #endif - - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - sock_is_sending |= (1 << sn); - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len) -{ - uint8_t tmp = 0; - uint16_t recvsize = 0; -//A20150601 : For integarating with W5300 -#if _WIZCHIP_ == 5300 - uint8_t head[2]; - uint16_t mr; -#endif -// - CHECK_SOCKNUM(); - CHECK_SOCKMODE(Sn_MR_TCP); - CHECK_SOCKDATA(); - - recvsize = getSn_RxMAX(sn); - if(recvsize < len) len = recvsize; - -//A20150601 : For Integrating with W5300 -#if _WIZCHIP_ == 5300 - //sock_pack_info[sn] = PACK_COMPLETED; // for clear - if(sock_remained_size[sn] == 0) - { -#endif -// - while(1) - { - recvsize = getSn_RX_RSR(sn); - tmp = getSn_SR(sn); - if (tmp != SOCK_ESTABLISHED) - { - if(tmp == SOCK_CLOSE_WAIT) - { - if(recvsize != 0) break; - else if(getSn_TX_FSR(sn) == getSn_TxMAX(sn)) - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - else - { - close(sn); - return SOCKERR_SOCKSTATUS; - } - } - if((sock_io_mode & (1< sock_remained_size[sn]) len = sock_remained_size[sn]; - recvsize = len; - if(sock_pack_info[sn] & PACK_FIFOBYTE) - { - *buf = sock_remained_byte[sn]; - buf++; - sock_pack_info[sn] &= ~(PACK_FIFOBYTE); - recvsize -= 1; - sock_remained_size[sn] -= 1; - } - if(recvsize != 0) - { - wiz_recv_data(sn, buf, recvsize); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - } - sock_remained_size[sn] -= recvsize; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - if(recvsize & 0x1) sock_pack_info[sn] |= PACK_FIFOBYTE; - } - else sock_pack_info[sn] = PACK_COMPLETED; - if(getSn_MR(sn) & Sn_MR_ALIGN) sock_remained_size[sn] = 0; - //len = recvsize; -#else - if(recvsize < len) len = recvsize; - wiz_recv_data(sn, buf, len); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); -#endif - - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port) -{ - uint8_t tmp = 0; - uint16_t freesize = 0; - uint32_t taddr; - - CHECK_SOCKNUM(); - switch(getSn_MR(sn) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_MACRAW: -// break; -// #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - break; -// #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - //M20140501 : For avoiding fatal error on memory align mismatched - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - //{ - //uint32_t taddr; - taddr = ((uint32_t)addr[0]) & 0x000000FF; - taddr = (taddr << 8) + ((uint32_t)addr[1] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[2] & 0x000000FF); - taddr = (taddr << 8) + ((uint32_t)addr[3] & 0x000000FF); - //} - // - //if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID; - if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID; - if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO; - tmp = getSn_SR(sn); -//#if ( _WIZCHIP_ < 5200 ) - if((tmp != SOCK_MACRAW) && (tmp != SOCK_UDP) && (tmp != SOCK_IPRAW)) return SOCKERR_SOCKSTATUS; -//#else -// if(tmp != SOCK_MACRAW && tmp != SOCK_UDP) return SOCKERR_SOCKSTATUS; -//#endif - - setSn_DIPR(sn,addr); - setSn_DPORT(sn,port); - freesize = getSn_TxMAX(sn); - if (len > freesize) len = freesize; // check size not to exceed MAX size. - while(1) - { - freesize = getSn_TX_FSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< freesize) ) return SOCK_BUSY; - if(len <= freesize) break; - }; - wiz_send_data(sn, buf, len); - - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - getSIPR((uint8_t*)&taddr); - if(taddr == 0) - { - getSUBR((uint8_t*)&taddr); - setSUBR((uint8_t*)"\x00\x00\x00\x00"); - } - else taddr = 0; - #endif - -//A20150601 : For W5300 -#if _WIZCHIP_ == 5300 - setSn_TX_WRSR(sn, len); -#endif -// - setSn_CR(sn,Sn_CR_SEND); - /* wait to process the command... */ - while(getSn_CR(sn)); - while(1) - { - tmp = getSn_IR(sn); - if(tmp & Sn_IR_SENDOK) - { - setSn_IR(sn, Sn_IR_SENDOK); - break; - } - //M:20131104 - //else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT; - else if(tmp & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - //M20150409 : Fixed the lost of sign bits by type casting. - //len = (uint16_t)SOCKERR_TIMEOUT; - //break; - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - return SOCKERR_TIMEOUT; - } - //////////// - } - #if _WIZCHIP_ < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata) - if(taddr) setSUBR((uint8_t*)&taddr); - #endif - //M20150409 : Explicit Type Casting - //return len; - return (int32_t)len; -} - - - -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port) -{ -//M20150601 : For W5300 -#if _WIZCHIP_ == 5300 - uint16_t mr; - uint16_t mr1; -#else - uint8_t mr; -#endif -// - uint8_t head[8]; - uint16_t pack_len=0; - - CHECK_SOCKNUM(); - //CHECK_SOCKMODE(Sn_MR_UDP); -//A20150601 -#if _WIZCHIP_ == 5300 - mr1 = getMR(); -#endif - - switch((mr=getSn_MR(sn)) & 0x0F) - { - case Sn_MR_UDP: - case Sn_MR_IPRAW: - case Sn_MR_MACRAW: - break; - #if ( _WIZCHIP_ < 5200 ) - case Sn_MR_PPPoE: - break; - #endif - default: - return SOCKERR_SOCKMODE; - } - CHECK_SOCKDATA(); - if(sock_remained_size[sn] == 0) - { - while(1) - { - pack_len = getSn_RX_RSR(sn); - if(getSn_SR(sn) == SOCK_CLOSED) return SOCKERR_SOCKCLOSED; - if( (sock_io_mode & (1< 1514) - { - close(sn); - return SOCKFATAL_PACKLEN; - } - sock_pack_info[sn] = PACK_FIRST; - } - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn,buf,pack_len); - break; - //#if ( _WIZCHIP_ < 5200 ) - case Sn_MR_IPRAW: - if(sock_remained_size[sn] == 0) - { - wiz_recv_data(sn, head, 6); - setSn_CR(sn,Sn_CR_RECV); - while(getSn_CR(sn)); - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - sock_remained_size[sn] = head[4]; - //M20150401 : For Typing Error - //sock_remaiend_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_remained_size[sn] = (sock_remained_size[sn] << 8) + head[5]; - sock_pack_info[sn] = PACK_FIRST; - } - // - // Need to packet length check - // - if(len < sock_remained_size[sn]) pack_len = len; - else pack_len = sock_remained_size[sn]; - wiz_recv_data(sn, buf, pack_len); // data copy. - break; - //#endif - default: - wiz_recv_ignore(sn, pack_len); // data copy. - sock_remained_size[sn] = pack_len; - break; - } - setSn_CR(sn,Sn_CR_RECV); - /* wait to process the command... */ - while(getSn_CR(sn)) ; - sock_remained_size[sn] -= pack_len; - //M20150601 : - //if(sock_remained_size[sn] != 0) sock_pack_info[sn] |= 0x01; - if(sock_remained_size[sn] != 0) - { - sock_pack_info[sn] |= PACK_REMAINED; - #if _WIZCHIP_ == 5300 - if(pack_len & 0x01) sock_pack_info[sn] |= PACK_FIFOBYTE; - #endif - } - else sock_pack_info[sn] = PACK_COMPLETED; -#if _WIZCHIP_ == 5300 - pack_len = len; -#endif - // - //M20150409 : Explicit Type Casting - //return pack_len; - return (int32_t)pack_len; -} - - -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg) -{ - uint8_t tmp = 0; - CHECK_SOCKNUM(); - switch(cstype) - { - case CS_SET_IOMODE: - tmp = *((uint8_t*)arg); - if(tmp == SOCK_IO_NONBLOCK) sock_io_mode |= (1< explict type casting - //*((uint8_t*)arg) = (sock_io_mode >> sn) & 0x0001; - *((uint8_t*)arg) = (uint8_t)((sock_io_mode >> sn) & 0x0001); - // - break; - case CS_GET_MAXTXBUF: - *((uint16_t*)arg) = getSn_TxMAX(sn); - break; - case CS_GET_MAXRXBUF: - *((uint16_t*)arg) = getSn_RxMAX(sn); - break; - case CS_CLR_INTERRUPT: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTERRUPT: - *((uint8_t*)arg) = getSn_IR(sn); - break; - #if _WIZCHIP_ != 5100 - case CS_SET_INTMASK: - if( (*(uint8_t*)arg) > SIK_ALL) return SOCKERR_ARG; - setSn_IMR(sn,*(uint8_t*)arg); - break; - case CS_GET_INTMASK: - *((uint8_t*)arg) = getSn_IMR(sn); - break; - #endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - // M20131220 : Remove warning - //uint8_t tmp; - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_TTL: - setSn_TTL(sn,*(uint8_t*)arg); - break; - case SO_TOS: - setSn_TOS(sn,*(uint8_t*)arg); - break; - case SO_MSS: - setSn_MSSR(sn,*(uint16_t*)arg); - break; - case SO_DESTIP: - setSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - setSn_DPORT(sn, *(uint16_t*)arg); - break; -#if _WIZCHIP_ != 5100 - case SO_KEEPALIVESEND: - CHECK_SOCKMODE(Sn_MR_TCP); - #if _WIZCHIP_ > 5200 - if(getSn_KPALVTR(sn) != 0) return SOCKERR_SOCKOPT; - #endif - setSn_CR(sn,Sn_CR_SEND_KEEP); - while(getSn_CR(sn) != 0) - { - // M20131220 - //if ((tmp = getSn_IR(sn)) & Sn_IR_TIMEOUT) - if (getSn_IR(sn) & Sn_IR_TIMEOUT) - { - setSn_IR(sn, Sn_IR_TIMEOUT); - return SOCKERR_TIMEOUT; - } - } - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - setSn_KPALVTR(sn,*(uint8_t*)arg); - break; - #endif -#endif - default: - return SOCKERR_ARG; - } - return SOCK_OK; -} - -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg) -{ - CHECK_SOCKNUM(); - switch(sotype) - { - case SO_FLAG: - *(uint8_t*)arg = getSn_MR(sn) & 0xF0; - break; - case SO_TTL: - *(uint8_t*) arg = getSn_TTL(sn); - break; - case SO_TOS: - *(uint8_t*) arg = getSn_TOS(sn); - break; - case SO_MSS: - *(uint16_t*) arg = getSn_MSSR(sn); - break; - case SO_DESTIP: - getSn_DIPR(sn, (uint8_t*)arg); - break; - case SO_DESTPORT: - *(uint16_t*) arg = getSn_DPORT(sn); - break; - #if _WIZCHIP_ > 5200 - case SO_KEEPALIVEAUTO: - CHECK_SOCKMODE(Sn_MR_TCP); - *(uint16_t*) arg = getSn_KPALVTR(sn); - break; - #endif - case SO_SENDBUF: - *(uint16_t*) arg = getSn_TX_FSR(sn); - break; - case SO_RECVBUF: - *(uint16_t*) arg = getSn_RX_RSR(sn); - break; - case SO_STATUS: - *(uint8_t*) arg = getSn_SR(sn); - break; - case SO_REMAINSIZE: - if(getSn_MR(sn) & Sn_MR_TCP) - *(uint16_t*)arg = getSn_RX_RSR(sn); - else - *(uint16_t*)arg = sock_remained_size[sn]; - break; - case SO_PACKINFO: - //CHECK_SOCKMODE(Sn_MR_TCP); -#if _WIZCHIP_ != 5300 - if((getSn_MR(sn) == Sn_MR_TCP)) - return SOCKERR_SOCKMODE; -#endif - *(uint8_t*)arg = sock_pack_info[sn]; - break; - default: - return SOCKERR_SOCKOPT; - } - return SOCK_OK; -} diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/socket.h b/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/socket.h deleted file mode 100644 index 7d703ba..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/socket.h +++ /dev/null @@ -1,489 +0,0 @@ -//***************************************************************************** -// -//! \file socket.h -//! \brief SOCKET APIs Header file. -//! \details SOCKET APIs like as berkeley socket api. -//! \version 1.0.2 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.2. Refer to M20140501 -//! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED -//! 2. Add the comment as zero byte udp data reception in getsockopt(). -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** -/** - * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs - * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. - * But there is a little bit of difference. - * @details - * Comparison between WIZnet and Berkeley SOCKET APIs - * - * - * - * - * - * - * - * - * - * - * - * - *
API WIZnet Berkeley
socket() O O
bind() X O
listen() O O
connect() O O
accept() X O
recv() O O
send() O O
recvfrom() O O
sendto() O O
closesocket() O
close() & disconnect()
O
- * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, - * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, - * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n - * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. - * When the listen SOCKET accepts a connection request from a client, it keeps listening. - * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n - * Following figure shows network flow diagram by Berkeley SOCKET API. - * @image html Berkeley_SOCKET.jpg "" - * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n - * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, - * it is changed in order to communicate with the client. - * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n - * If there're many listen SOCKET with same listen port number and a client requests a connection, - * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n - * Following figure shows network flow diagram by WIZnet SOCKET API. - * @image html WIZnet_SOCKET.jpg "" - */ -#ifndef _SOCKET_H_ -#define _SOCKET_H_ -#ifdef __cplusplus - extern "C" { -#endif - -#include "wizchip_conf.h" - -#define SOCKET uint8_t ///< SOCKET type define for legacy driver - -#define SOCK_OK 1 ///< Result is OK about socket process. -#define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. -#define SOCK_FATAL -1000 ///< Result is fatal error about socket process. - -#define SOCK_ERROR 0 -#define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number -#define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option -#define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP -#define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. -#define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. -#define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag -#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. -#define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. -#define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero -#define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address -#define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred -#define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. -#define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. - -#define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. - -/* - * SOCKET FLAG - */ -#define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet -#define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. -#define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. -#define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. - -#if _WIZCHIP_ == 5500 - #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 - #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 - #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 - #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 -#endif - -//A201505 : For W5300 -#if _WIZCHIP_ == 5300 - #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN -#endif - -#define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). - -/* - * UDP & MACRAW Packet Infomation - */ -#define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) -#define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) -#define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) -//A20150601 : For Integrating with W5300 -#define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. -// - -/** - * @ingroup WIZnet_socket_APIs - * @brief Open a socket. - * @details Initializes the socket with 'sn' passed as parameter and open. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. - * @param port Port number to be bined. - * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n - * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. - * @sa Sn_MR - * - * @return @b Success : The socket number @b 'sn' passed as parameter\n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n - * @ref SOCKERR_SOCKFLAG - Invaild socket flag. - */ -int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Close a socket. - * @details It closes the socket with @b'sn' passed as parameter. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number - */ -int8_t close(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Listen to a connection request from a client. - * @details It is listening to a connection request from a client. - * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n - * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. - */ -int8_t listen(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to connect a server. - * @details It requests connection to the server with destination IP address and port number passed as parameter.\n - * @note It is valid only in TCP client mode. - * In block io mode, it does not return until connection is completed. - * In Non-block io mode, it return @ref SOCK_BUSY immediately. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n - * @ref SOCKERR_SOCKMODE - Invalid socket mode\n - * @ref SOCKERR_SOCKINIT - Socket is not initialized\n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n - * @ref SOCK_BUSY - In non-block io mode, it returned immediately\n - */ -int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Try to disconnect a connection socket. - * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. - * @note It is valid only in TCP server or client mode. \n - * In block io mode, it does not return until disconnection is completed. \n - * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n - - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @return @b Success : @ref SOCK_OK \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int8_t disconnect(uint8_t sn); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Send data to the connected peer in TCP socket. - * @details It is used to send outgoing data to the connected socket. - * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n - * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer containing data to be sent. - * @param len The byte length of data in buf. - * @return @b Success : The sent data size \n - * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive data from the connected peer. - * @details It is used to read incoming data from the connected socket.\n - * It waits for data as much as the application wants to receive. - * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n - * In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer. \n - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. \n - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * @return @b Success : The real received data size \n - * @b Fail :\n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Sends datagram to the peer with destination IP address and port number passed as parameter. - * @details It sends datagram of UDP or MACRAW to the peer with destination IP address and port number passed as parameter.\n - * Even if the connectionless socket has been previously connected to a specific address, - * the address and port number parameters override the destination address for that particular datagram only. - * @note In block io mode, It doesn't return until data send is completed - socket buffer size is greater than len. - * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to send outgoing data. - * @param len The byte length of data in buf. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * @param port Destination port number. - * - * @return @b Success : The sent data size \n - * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n - * @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_IPINVALID - Wrong server IP address\n - * @ref SOCKERR_PORTZERO - Server port zero\n - * @ref SOCKERR_SOCKCLOSED - Socket unexpectedly closed \n - * @ref SOCKERR_TIMEOUT - Timeout occurred \n - * @ref SOCK_BUSY - Socket is busy. - */ -int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); - -/** - * @ingroup WIZnet_socket_APIs - * @brief Receive datagram of UDP or MACRAW - * @details This function is an application I/F function which is used to receive the data in other then TCP mode. \n - * This function is used to receive UDP and MAC_RAW mode, and handle the header as well. - * This function can divide to received the packet data. - * On the MACRAW SOCKET, the addr and port parameters are ignored. - * @note In block io mode, it doesn't return until data reception is completed - data is filled as len in socket buffer - * In non-block io mode, it return @ref SOCK_BUSY immediately when len is greater than data size in socket buffer. - * - * @param sn Socket number. It should be 0 ~ @ref \_WIZCHIP_SOCK_NUM_. - * @param buf Pointer buffer to read incoming data. - * @param len The max data length of data in buf. - * When the received packet size <= len, receives data as packet sized. - * When others, receives data as len. - * @param addr Pointer variable of destination IP address. It should be allocated 4 bytes. - * It is valid only when the first call recvfrom for receiving the packet. - * When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * @param port Pointer variable of destination port number. - * It is valid only when the first call recvform for receiving the packet. -* When it is valid, @ref packinfo[7] should be set as '1' after call @ref getsockopt(sn, SO_PACKINFO, &packinfo). - * - * @return @b Success : This function return real received data size for success.\n - * @b Fail : @ref SOCKERR_DATALEN - zero data length \n - * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n - * @ref SOCKERR_SOCKNUM - Invalid socket number \n - * @ref SOCKBUSY - Socket is busy. - */ -int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); - - -///////////////////////////// -// SOCKET CONTROL & OPTION // -///////////////////////////// -#define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). -#define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). - -/** - * @defgroup DATA_TYPE DATA TYPE - */ - -/** - * @ingroup DATA_TYPE - * @brief The kind of Socket Interrupt. - * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() - */ -typedef enum -{ - SIK_CONNECTED = (1 << 0), ///< connected - SIK_DISCONNECTED = (1 << 1), ///< disconnected - SIK_RECEIVED = (1 << 2), ///< data received - SIK_TIMEOUT = (1 << 3), ///< timeout occurred - SIK_SENT = (1 << 4), ///< send ok - //M20150410 : Remove the comma of last member - //SIK_ALL = 0x1F, ///< all interrupt - SIK_ALL = 0x1F ///< all interrupt -}sockint_kind; - -/** - * @ingroup DATA_TYPE - * @brief The type of @ref ctlsocket(). - */ -typedef enum -{ - CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK - CS_GET_IOMODE, ///< get socket IO mode - CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory - CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory - CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind - CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind -#if _WIZCHIP_ > 5100 - CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 - CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 -#endif -}ctlsock_type; - - -/** - * @ingroup DATA_TYPE - * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() - */ -typedef enum -{ - SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to flag in @ref socket(). - SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) - SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) - SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) - SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) - SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) -#if _WIZCHIP_ != 5100 - SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 - #if _WIZCHIP_ > 5200 - SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 - #endif -#endif - SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() - SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() - SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() - SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. - SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. -}sockopt_type; - -/** - * @ingroup WIZnet_socket_APIs - * @brief Control socket. - * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. - * Refer to @ref ctlsock_type. - * @param sn socket number - * @param cstype type of control socket. refer to @ref ctlsock_type. - * @param arg Data type and value is determined according to @ref ctlsock_type. \n - * - * - * - * - * - *
@b cstype @b data type@b value
@ref CS_SET_IOMODE \n @ref CS_GET_IOMODE uint8_t @ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK
@ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF uint16_t 0 ~ 16K
@ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK @ref sockint_kind @ref SIK_CONNECTED, etc.
- * @return @b Success @ref SOCK_OK \n - * @b fail @ref SOCKERR_ARG - Invalid argument\n - */ -int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief set socket options - * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. - * - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_TTL uint8_t 0 ~ 255
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t 0 ~ 65535
@ref SO_KEEPALIVESEND null null
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n - */ -int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -/** - * @ingroup WIZnet_socket_APIs - * @brief get socket options - * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type - * @param sn socket number - * @param sotype socket option type. refer to @ref sockopt_type - * @param arg Data type and value is determined according to sotype. \n - * - * - * - * - * - * - * - * - * - * - * - * - * - *
@b sotype @b data type@b value
@ref SO_FLAG uint8_t @ref SF_ETHER_OWN, etc...
@ref SO_TOS uint8_t 0 ~ 255
@ref SO_MSS uint16_t 0 ~ 65535
@ref SO_DESTIP uint8_t[4]
@ref SO_DESTPORT uint16_t
@ref SO_KEEPALIVEAUTO uint8_t 0 ~ 255
@ref SO_SENDBUF uint16_t 0 ~ 65535
@ref SO_RECVBUF uint16_t 0 ~ 65535
@ref SO_STATUS uint8_t @ref SOCK_ESTABLISHED, etc..
@ref SO_REMAINSIZE uint16_t 0~ 65535
@ref SO_PACKINFO uint8_t @ref PACK_FIRST, etc...
- * @return - * - @b Success : @ref SOCK_OK \n - * - @b Fail - * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n - * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n - * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n - * @note - * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n - * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, - * This means the zero byte UDP data(UDP Header only) received. - */ -int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); - -#ifdef __cplusplus - } -#endif - -#endif // _SOCKET_H_ diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/wizchip_conf.c b/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/wizchip_conf.c deleted file mode 100644 index 6592b0c..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/wizchip_conf.c +++ /dev/null @@ -1,903 +0,0 @@ -//****************************************************************************/ -//! -//! \file wizchip_conf.c -//! \brief WIZCHIP Config Header File. -//! \version 1.0.1 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2014/05/01> V1.0.1 Refer to M20140501 -//! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() -// Issued by Mathias ClauBen. -//! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* -//! For remove the warning when pointer type size is not 32bit. -//! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//*****************************************************************************/ -//A20140501 : for use the type - ptrdiff_t -#include -// - -#include "wizchip_conf.h" - -///////////// -//M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. -///////////// - -/** - * @brief Default function to enable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_enter(void) {}; -void wizchip_cris_enter(void) {} - -/** - * @brief Default function to disable interrupt. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cris_exit(void) {}; -void wizchip_cris_exit(void) {} - -/** - * @brief Default function to select chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_select(void) {}; -void wizchip_cs_select(void) {} - -/** - * @brief Default function to deselect chip. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_cs_deselect(void) {}; -void wizchip_cs_deselect(void) {} - -/** - * @brief Default function to read in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ - //M20150601 : Rename the function for integrating with W5300 -//uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } -iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } - -/** - * @brief Default function to write in direct or indirect interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//M20150601 : Rename the function for integrating with W5300 -//void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } -void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } - -/** - * @brief Default function to read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//uint8_t wizchip_spi_readbyte(void) {return 0;}; -uint8_t wizchip_spi_readbyte(void) {return 0;} - -/** - * @brief Default function to write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writebyte(uint8_t wb) {}; -void wizchip_spi_writebyte(uint8_t wb) {} - -/** - * @brief Default function to burst read in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @brief Default function to burst write in SPI interface. - * @note This function help not to access wrong address. If you do not describe this function or register any functions, - * null function is called. - */ -//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; -void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} - -/** - * @\ref _WIZCHIP instance - */ -// -//M20150401 : For a compiler didnot support a member of structure -// Replace the assignment of struct members with the assingment of array -// -/* -_WIZCHIP WIZCHIP = - { - .id = _WIZCHIP_ID_, - .if_mode = _WIZCHIP_IO_MODE_, - .CRIS._enter = wizchip_cris_enter, - .CRIS._exit = wizchip_cris_exit, - .CS._select = wizchip_cs_select, - .CS._deselect = wizchip_cs_deselect, - .IF.BUS._read_byte = wizchip_bus_readbyte, - .IF.BUS._write_byte = wizchip_bus_writebyte -// .IF.SPI._read_byte = wizchip_spi_readbyte, -// .IF.SPI._write_byte = wizchip_spi_writebyte - }; -*/ -_WIZCHIP WIZCHIP = -{ - _WIZCHIP_IO_MODE_, - _WIZCHIP_ID_ , - { - wizchip_cris_enter, - wizchip_cris_exit - }, - { - wizchip_cs_select, - wizchip_cs_deselect - }, - { - { - //M20150601 : Rename the function - //wizchip_bus_readbyte, - //wizchip_bus_writebyte - wizchip_bus_readdata, - wizchip_bus_writedata - }, - - } -}; - - -static uint8_t _DNS_[4]; // DNS server ip address -static dhcp_mode _DHCP_; // DHCP mode - -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) -{ - if(!cris_en || !cris_ex) - { - WIZCHIP.CRIS._enter = wizchip_cris_enter; - WIZCHIP.CRIS._exit = wizchip_cris_exit; - } - else - { - WIZCHIP.CRIS._enter = cris_en; - WIZCHIP.CRIS._exit = cris_ex; - } -} - -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) -{ - if(!cs_sel || !cs_desel) - { - WIZCHIP.CS._select = wizchip_cs_select; - WIZCHIP.CS._deselect = wizchip_cs_deselect; - } - else - { - WIZCHIP.CS._select = cs_sel; - WIZCHIP.CS._deselect = cs_desel; - } -} - -//M20150515 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) -void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); - //M20150601 : Rename call back function for integrating with W5300 - /* - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; - WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; - } - else - { - WIZCHIP.IF.BUS._read_byte = bus_rb; - WIZCHIP.IF.BUS._write_byte = bus_wb; - } - */ - if(!bus_rb || !bus_wb) - { - WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; - WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; - } - else - { - WIZCHIP.IF.BUS._read_data = bus_rb; - WIZCHIP.IF.BUS._write_data = bus_wb; - } -} - -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; - WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; - } - else - { - WIZCHIP.IF.SPI._read_byte = spi_rb; - WIZCHIP.IF.SPI._write_byte = spi_wb; - } -} - -// 20140626 Eric Added for SPI burst operations -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) -{ - while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); - - if(!spi_rb || !spi_wb) - { - WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; - WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; - } - else - { - WIZCHIP.IF.SPI._read_burst = spi_rb; - WIZCHIP.IF.SPI._write_burst = spi_wb; - } -} - -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) -{ -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - uint8_t tmp = 0; -#endif - uint8_t* ptmp[2] = {0,0}; - switch(cwtype) - { - case CW_RESET_WIZCHIP: - wizchip_sw_reset(); - break; - case CW_INIT_WIZCHIP: - if(arg != 0) - { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; - } - return wizchip_init(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - wizchip_clrinterrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = wizchip_getinterrupt(); - break; - case CW_SET_INTRMASK: - wizchip_setinterruptmask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = wizchip_getinterruptmask(); - break; - //M20150601 : This can be supported by W5200, W5500 - //#if _WIZCHIP_ > W5100 - #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) - case CW_SET_INTRTIME: - setINTLEVEL(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTLEVEL(); - break; - #endif - case CW_GET_ID: - ((uint8_t*)arg)[0] = WIZCHIP.id[0]; - ((uint8_t*)arg)[1] = WIZCHIP.id[1]; - ((uint8_t*)arg)[2] = WIZCHIP.id[2]; - ((uint8_t*)arg)[3] = WIZCHIP.id[3]; - ((uint8_t*)arg)[4] = WIZCHIP.id[4]; - ((uint8_t*)arg)[5] = 0; - break; - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - case CW_RESET_PHY: - wizphy_reset(); - break; - case CW_SET_PHYCONF: - wizphy_setphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYCONF: - wizphy_getphyconf((wiz_PhyConf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - return wizphy_setphypmode(*(uint8_t*)arg); - #endif - #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - case CW_GET_PHYPOWMODE: - tmp = wizphy_getphypmode(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = wizphy_getphylink(); - if((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - #endif - default: - return -1; - } - return 0; -} - - -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) -{ - - switch(cntype) - { - case CN_SET_NETINFO: - wizchip_setnetinfo((wiz_NetInfo*)arg); - break; - case CN_GET_NETINFO: - wizchip_getnetinfo((wiz_NetInfo*)arg); - break; - case CN_SET_NETMODE: - return wizchip_setnetmode(*(netmode_type*)arg); - case CN_GET_NETMODE: - *(netmode_type*)arg = wizchip_getnetmode(); - break; - case CN_SET_TIMEOUT: - wizchip_settimeout((wiz_NetTimeout*)arg); - break; - case CN_GET_TIMEOUT: - wizchip_gettimeout((wiz_NetTimeout*)arg); - break; - default: - return -1; - } - return 0; -} - -void wizchip_sw_reset(void) -{ - uint8_t gw[4], sn[4], sip[4]; - uint8_t mac[6]; -//A20150601 -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - uint16_t mr = (uint16_t)getMR(); - setMR(mr | MR_IND); -#endif -// - getSHAR(mac); - getGAR(gw); getSUBR(sn); getSIPR(sip); - setMR(MR_RST); - getMR(); // for delay -//A2015051 : For indirect bus mode -#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ - setMR(mr | MR_IND); -#endif -// - setSHAR(mac); - setGAR(gw); - setSUBR(sn); - setSIPR(sip); -} - -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) -{ - int8_t i; -#if _WIZCHIP_ < W5200 - int8_t j; -#endif - int8_t tmp = 0; - wizchip_sw_reset(); - if(txsize) - { - tmp = 0; - //M20150601 : For integrating with W5300 - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(txsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += txsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += txsize[i]; - - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 - j = 0; - while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_TXBUF_SIZE(i, j); - #else - setSn_TXBUF_SIZE(i, txsize[i]); - #endif - } - - #endif - } - - if(rxsize) - { - tmp = 0; - #if _WIZCHIP_ == W5300 - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - if(rxsize[i] >= 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation - tmp += rxsize[i]; - if(tmp > 128) return -1; - } - if(tmp % 8) return -1; - #else - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - tmp += rxsize[i]; - #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s - if(tmp > 8) return -1; - #else - if(tmp > 16) return -1; - #endif - } - - for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) - { - #if _WIZCHIP_ < W5200 // add condition for w5100 - j = 0; - while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} - setSn_RXBUF_SIZE(i, j); - #else - setSn_RXBUF_SIZE(i, rxsize[i]); - #endif - } - #endif - } - return 0; -} - -void wizchip_clrinterrupt(intr_kind intr) -{ - uint8_t ir = (uint8_t)intr; - uint8_t sir = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - ir |= (1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir |= (1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - sir &= 0x0F; -#endif - -#if _WIZCHIP_ <= W5100S - ir |= sir; - setIR(ir); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); -#else - setIR(ir); - setSIR(sir); -#endif -} - -intr_kind wizchip_getinterrupt(void) -{ - uint8_t ir = 0; - uint8_t sir = 0; - uint16_t ret = 0; -#if _WIZCHIP_ <= W5100S - ir = getIR(); - sir = ir & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIR(); - ir = (uint8_t)(ret >> 8); - sir = (uint8_t)ret; -#else - ir = getIR(); - sir = getSIR(); -#endif - -//M20150601 : For Integrating with W5300 -//#if _WIZCHIP_ < W5500 -#if _WIZCHIP_ < W5200 - ir &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - ir &= ~(1 << 6); -#endif - ret = sir; - ret = (ret << 8) + ir; - return (intr_kind)ret; -} - -void wizchip_setinterruptmask(intr_kind intr) -{ - uint8_t imr = (uint8_t)intr; - uint8_t simr = (uint8_t)((uint16_t)intr >> 8); -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); -#endif - -#if _WIZCHIP_ < W5200 - simr &= 0x0F; - imr |= simr; - setIMR(imr); -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); -#else - setIMR(imr); - setSIMR(simr); -#endif -} - -intr_kind wizchip_getinterruptmask(void) -{ - uint8_t imr = 0; - uint8_t simr = 0; - uint16_t ret = 0; -#if _WIZCHIP_ < W5200 - imr = getIMR(); - simr = imr & 0x0F; -//A20150601 : For integrating with W5300 -#elif _WIZCHIP_ == W5300 - ret = getIMR(); - imr = (uint8_t)(ret >> 8); - simr = (uint8_t)ret; -#else - imr = getIMR(); - simr = getSIMR(); -#endif - -#if _WIZCHIP_ < W5500 - imr &= ~(1<<4); // IK_WOL -#endif -#if _WIZCHIP_ == W5200 - imr &= ~(1 << 6); // IK_DEST_UNREACH -#endif - ret = simr; - ret = (ret << 8) + imr; - return (intr_kind)ret; -} - -int8_t wizphy_getphylink(void) -{ - int8_t tmp = PHY_LINK_OFF; -#if _WIZCHIP_ == W5100S - if(getPHYSR() & PHYSR_LNK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_LINK) - tmp = PHY_LINK_ON; -#elif _WIZCHIP_ == W5500 - if(getPHYCFGR() & PHYCFGR_LNK_ON) - tmp = PHY_LINK_ON; - -#else - tmp = -1; -#endif - return tmp; -} - -#if _WIZCHIP_ > W5100 - -int8_t wizphy_getphypmode(void) -{ - int8_t tmp = 0; - #if _WIZCHIP_ == W5200 - if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #elif _WIZCHIP_ == 5500 - if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) - tmp = PHY_POWER_DOWN; - else - tmp = PHY_POWER_NORM; - #else - tmp = -1; - #endif - return tmp; -} -#endif - -#if _WIZCHIP_ == W5100S -void wizphy_reset(void) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - tmp |= BMCR_RESET; - wiz_mdio_write(PHYMDIO_BMCR, tmp); - while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= BMCR_AUTONEGO; - else - { - tmp &= ~BMCR_AUTONEGO; - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - tmp |= BMCR_DUP; - } - else - { - tmp &= ~BMCR_DUP; - } - if(phyconf->speed == PHY_SPEED_100) - { - tmp |= BMCR_SPEED; - } - else - { - tmp &= ~BMCR_SPEED; - } - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - phyconf->by = PHY_CONFBY_SW; - if(tmp & BMCR_AUTONEGO) - { - phyconf->mode = PHY_MODE_AUTONEGO; - } - else - { - phyconf->mode = PHY_MODE_MANUAL; - if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; - else phyconf->duplex = PHY_DUPLEX_HALF; - if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; - else phyconf->speed = PHY_SPEED_10; - } -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint16_t tmp = 0; - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - tmp |= BMCR_PWDN; - } - else - { - tmp &= ~BMCR_PWDN; - } - wiz_mdio_write(PHYMDIO_BMCR, tmp); - tmp = wiz_mdio_read(PHYMDIO_BMCR); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & BMCR_PWDN) return 0; - } - else - { - if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; - } - return -1; -} - -#endif -#if _WIZCHIP_ == W5500 -void wizphy_reset(void) -{ - uint8_t tmp = getPHYCFGR(); - tmp &= PHYCFGR_RST; - setPHYCFGR(tmp); - tmp = getPHYCFGR(); - tmp |= ~PHYCFGR_RST; - setPHYCFGR(tmp); -} - -void wizphy_setphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - if(phyconf->by == PHY_CONFBY_SW) - tmp |= PHYCFGR_OPMD; - else - tmp &= ~PHYCFGR_OPMD; - if(phyconf->mode == PHY_MODE_AUTONEGO) - tmp |= PHYCFGR_OPMDC_ALLA; - else - { - if(phyconf->duplex == PHY_DUPLEX_FULL) - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100F; - else - tmp |= PHYCFGR_OPMDC_10F; - } - else - { - if(phyconf->speed == PHY_SPEED_100) - tmp |= PHYCFGR_OPMDC_100H; - else - tmp |= PHYCFGR_OPMDC_10H; - } - } - setPHYCFGR(tmp); - wizphy_reset(); -} - -void wizphy_getphyconf(wiz_PhyConf* phyconf) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_ALLA: - case PHYCFGR_OPMDC_100FA: - phyconf->mode = PHY_MODE_AUTONEGO; - break; - default: - phyconf->mode = PHY_MODE_MANUAL; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_100H: - phyconf->speed = PHY_SPEED_100; - break; - default: - phyconf->speed = PHY_SPEED_10; - break; - } - switch(tmp & PHYCFGR_OPMDC_ALLA) - { - case PHYCFGR_OPMDC_100FA: - case PHYCFGR_OPMDC_100F: - case PHYCFGR_OPMDC_10F: - phyconf->duplex = PHY_DUPLEX_FULL; - break; - default: - phyconf->duplex = PHY_DUPLEX_HALF; - break; - } -} - -void wizphy_getphystat(wiz_PhyConf* phyconf) -{ - uint8_t tmp = getPHYCFGR(); - phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; -} - -int8_t wizphy_setphypmode(uint8_t pmode) -{ - uint8_t tmp = 0; - tmp = getPHYCFGR(); - if((tmp & PHYCFGR_OPMD)== 0) return -1; - tmp &= ~PHYCFGR_OPMDC_ALLA; - if( pmode == PHY_POWER_DOWN) - tmp |= PHYCFGR_OPMDC_PDOWN; - else - tmp |= PHYCFGR_OPMDC_ALLA; - setPHYCFGR(tmp); - wizphy_reset(); - tmp = getPHYCFGR(); - if( pmode == PHY_POWER_DOWN) - { - if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; - } - else - { - if(tmp & PHYCFGR_OPMDC_ALLA) return 0; - } - return -1; -} -#endif - - -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) -{ - setSHAR(pnetinfo->mac); - setGAR(pnetinfo->gw); - setSUBR(pnetinfo->sn); - setSIPR(pnetinfo->ip); - _DNS_[0] = pnetinfo->dns[0]; - _DNS_[1] = pnetinfo->dns[1]; - _DNS_[2] = pnetinfo->dns[2]; - _DNS_[3] = pnetinfo->dns[3]; - _DHCP_ = pnetinfo->dhcp; -} - -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) -{ - getSHAR(pnetinfo->mac); - getGAR(pnetinfo->gw); - getSUBR(pnetinfo->sn); - getSIPR(pnetinfo->ip); - pnetinfo->dns[0]= _DNS_[0]; - pnetinfo->dns[1]= _DNS_[1]; - pnetinfo->dns[2]= _DNS_[2]; - pnetinfo->dns[3]= _DNS_[3]; - pnetinfo->dhcp = _DHCP_; -} - -int8_t wizchip_setnetmode(netmode_type netmode) -{ - uint8_t tmp = 0; -#if _WIZCHIP_ != W5500 - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; -#else - if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; -#endif - tmp = getMR(); - tmp |= (uint8_t)netmode; - setMR(tmp); - return 0; -} - -netmode_type wizchip_getnetmode(void) -{ - return (netmode_type) getMR(); -} - -void wizchip_settimeout(wiz_NetTimeout* nettime) -{ - setRCR(nettime->retry_cnt); - setRTR(nettime->time_100us); -} - -void wizchip_gettimeout(wiz_NetTimeout* nettime) -{ - nettime->retry_cnt = getRCR(); - nettime->time_100us = getRTR(); -} diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/wizchip_conf.h b/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/wizchip_conf.h deleted file mode 100644 index 5d6c1c1..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Ethernet/wizchip_conf.h +++ /dev/null @@ -1,660 +0,0 @@ -//***************************************************************************** -// -//! \file wizchip_conf.h -//! \brief WIZCHIP Config Header File. -//! \version 1.0.0 -//! \date 2013/10/21 -//! \par Revision history -//! <2015/02/05> Notice -//! The version history is not updated after this point. -//! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. -//! >> https://github.com/Wiznet/ioLibrary_Driver -//! <2013/10/21> 1st Release -//! \author MidnightCow -//! \copyright -//! -//! Copyright (c) 2013, WIZnet Co., LTD. -//! All rights reserved. -//! -//! Redistribution and use in source and binary forms, with or without -//! modification, are permitted provided that the following conditions -//! are met: -//! -//! * Redistributions of source code must retain the above copyright -//! notice, this list of conditions and the following disclaimer. -//! * 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. -//! * Neither the name of the nor the names of its -//! contributors may be used to endorse or promote products derived -//! from this software without specific prior written permission. -//! -//! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -// -//***************************************************************************** - -/** - * @defgroup extra_functions 2. WIZnet Extra Functions - * - * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. - * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n - * - */ - -#ifndef _WIZCHIP_CONF_H_ -#define _WIZCHIP_CONF_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -/** - * @brief Select WIZCHIP. - * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n - * ex> #define \_WIZCHIP_ W5500 - */ - -#define W5100 5100 -#define W5100S 5100+5 -#define W5200 5200 -#define W5300 5300 -#define W5500 5500 - -#ifndef _WIZCHIP_ -#define _WIZCHIP_ W5500 // W5100, W5100S, W5200, W5300, W5500 -#endif - -#define _WIZCHIP_IO_MODE_NONE_ 0x0000 -#define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ -#define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ -//#define _WIZCHIP_IO_MODE_IIC_ 0x0400 -//#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 -// Add to -// - -#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ -#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ - -#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ -#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ -#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ - -#if (_WIZCHIP_ == W5100) - #define _WIZCHIP_ID_ "W5100\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100/w5100.h" - -#elif (_WIZCHIP_ == W5100S) -#define _WIZCHIP_ID_ "W5100S\0" -/** -* @brief Define interface mode. -* @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ -*/ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ - -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; -//A20150401 : Indclude W5100.h file - #include "W5100S/w5100s.h" -#elif (_WIZCHIP_ == W5200) - #define _WIZCHIP_ID_ "W5200\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5200/w5200.h" -#elif (_WIZCHIP_ == W5500) - #define _WIZCHIP_ID_ "W5500\0" - -/** - * @brief Define interface mode. \n - * @todo Should select interface mode as chip. - * - @ref \_WIZCHIP_IO_MODE_SPI_ \n - * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n - * - @ref \_WIZCHIP_IO_MODE_BUS_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n - * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n - * - Others will be defined in future. \n\n - * ex> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ - * - */ -#ifndef _WIZCHIP_IO_MODE_ - //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ -#endif -//A20150601 : Define the unit of IO DATA. - typedef uint8_t iodata_t; - #include "W5500/w5500.h" -#elif ( _WIZCHIP_ == W5300) - #define _WIZCHIP_ID_ "W5300\0" -/** - * @brief Define interface mode. - * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ - */ -#ifndef _WIZCHIP_IO_MODE_ -// #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ - #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ -#endif - -//A20150601 : Define the unit and bus width of IO DATA. - /** - * @brief Select the data width 8 or 16 bits. - * @todo you should select the bus width. Select one of 8 or 16. - */ - #ifndef _WIZCHIP_IO_BUS_WIDTH_ - #define _WIZCHIP_IO_BUS_WIDTH_ 8 // 16 - #endif - #if _WIZCHIP_IO_BUS_WIDTH_ == 8 - typedef uint8_t iodata_t; - #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 - typedef uint16_t iodata_t; - #else - #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." - #endif -// - #include "W5300/w5300.h" -#else - #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!" -#endif - -#ifndef _WIZCHIP_IO_MODE_ - #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" -#endif - -/** - * @brief Define I/O base address when BUS IF mode. - * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, - * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n - * ex> #define \_WIZCHIP_IO_BASE_ 0x00008000 - */ -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND -#elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ - #define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI -#endif - -#ifndef _WIZCHIP_IO_BASE_ -#define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 -#endif - -//M20150401 : Typing Error -//#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS -#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ - #ifndef _WIZCHIP_IO_BASE_ - #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." - #endif -#endif - -#if _WIZCHIP_ >= W5200 - #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP -#else - #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP -#endif - - -/******************************************************** -* WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. -*********************************************************/ -/** - * @ingroup DATA_TYPE - * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 - */ -typedef struct __WIZCHIP -{ - uint16_t if_mode; ///< host interface mode - uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on. - /** - * The set of critical section callback func. - */ - struct _CRIS - { - void (*_enter) (void); ///< crtical section enter - void (*_exit) (void); ///< critial section exit - }CRIS; - /** - * The set of @ref \_WIZCHIP_ select control callback func. - */ - struct _CS - { - void (*_select) (void); ///< @ref \_WIZCHIP_ selected - void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected - }CS; - /** - * The set of interface IO callback func. - */ - union _IF - { - /** - * For BUS interface IO - */ - //M20156501 : Modify the function name for integrating with W5300 - //struct - //{ - // uint8_t (*_read_byte) (uint32_t AddrSel); - // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); - //}BUS; - struct - { - iodata_t (*_read_data) (uint32_t AddrSel); - void (*_write_data) (uint32_t AddrSel, iodata_t wb); - }BUS; - - /** - * For SPI interface IO - */ - struct - { - uint8_t (*_read_byte) (void); - void (*_write_byte) (uint8_t wb); - void (*_read_burst) (uint8_t* pBuf, uint16_t len); - void (*_write_burst) (uint8_t* pBuf, uint16_t len); - }SPI; - // To be added - // - }IF; -}_WIZCHIP; - -extern _WIZCHIP WIZCHIP; - -/** - * @ingroup DATA_TYPE - * WIZCHIP control type enumration used in @ref ctlwizchip(). - */ -typedef enum -{ - CW_RESET_WIZCHIP, ///< Resets WIZCHIP by softly - CW_INIT_WIZCHIP, ///< Initializes to WIZCHIP with SOCKET buffer size 2 or 1 dimension array typed uint8_t. - CW_GET_INTERRUPT, ///< Get Interrupt status of WIZCHIP - CW_CLR_INTERRUPT, ///< Clears interrupt - CW_SET_INTRMASK, ///< Masks interrupt - CW_GET_INTRMASK, ///< Get interrupt mask - CW_SET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_INTRTIME, ///< Set interval time between the current and next interrupt. - CW_GET_ID, ///< Gets WIZCHIP name. - -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5500 - CW_RESET_PHY, ///< Resets internal PHY. Valid Only W5500 - CW_SET_PHYCONF, ///< When PHY configured by internal register, PHY operation mode (Manual/Auto, 10/100, Half/Full). Valid Only W5000 - CW_GET_PHYCONF, ///< Get PHY operation mode in internal register. Valid Only W5500 - CW_GET_PHYSTATUS, ///< Get real PHY status on operating. Valid Only W5500 - CW_SET_PHYPOWMODE, ///< Set PHY power mode as normal and down when PHYSTATUS.OPMD == 1. Valid Only W5500 -//#endif -//D20150601 : For no modification your application code -//#if _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 - CW_GET_PHYPOWMODE, ///< Get PHY Power mode as down or normal, Valid Only W5100, W5200 - CW_GET_PHYLINK ///< Get PHY Link status, Valid Only W5100, W5200 -//#endif -}ctlwizchip_type; - -/** - * @ingroup DATA_TYPE - * Network control type enumration used in @ref ctlnetwork(). - */ -typedef enum -{ - CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo - CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo - CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode - CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. - CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. -}ctlnetwork_type; - -/** - * @ingroup DATA_TYPE - * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK - * and CW_GET_INTRMASK is used in @ref ctlnetwork(). - * It can be used with OR operation. - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. -#elif _WIZCHIP_ == W5300 - IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) -#endif - - IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected - -#if _WIZCHIP_ != W5200 - IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 -#endif - - IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred - - IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt - IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt - IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt - IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt -#if _WIZCHIP_ > W5100S - IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 - IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 - IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 - IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 -#endif - -#if _WIZCHIP_ > W5100S - IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt -#else - IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt -#endif -}intr_kind; - -#define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin -#define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register -#define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. -#define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation -#define PHY_SPEED_10 0 ///< Link Speed 10 -#define PHY_SPEED_100 1 ///< Link Speed 100 -#define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex -#define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex -#define PHY_LINK_OFF 0 ///< Link Off -#define PHY_LINK_ON 1 ///< Link On -#define PHY_POWER_NORM 0 ///< PHY power normal mode -#define PHY_POWER_DOWN 1 ///< PHY power down mode - - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 -/** - * @ingroup DATA_TYPE - * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, - * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n - * Valid only in W5500. - */ -typedef struct wiz_PhyConf_t -{ - uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW - uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO - uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 - uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL - //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN - //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF - }wiz_PhyConf; -#endif - -/** - * @ingroup DATA_TYPE - * It used in setting dhcp_mode of @ref wiz_NetInfo. - */ -typedef enum -{ - NETINFO_STATIC = 1, ///< Static IP configuration by manually. - NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever -}dhcp_mode; - -/** - * @ingroup DATA_TYPE - * Network Information for WIZCHIP - */ -typedef struct wiz_NetInfo_t -{ - uint8_t mac[6]; ///< Source Mac Address - uint8_t ip[4]; ///< Source IP Address - uint8_t sn[4]; ///< Subnet Mask - uint8_t gw[4]; ///< Gateway IP Address - uint8_t dns[4]; ///< DNS server IP Address - dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP -}wiz_NetInfo; - -/** - * @ingroup DATA_TYPE - * Network mode - */ -typedef enum -{ -#if _WIZCHIP_ == W5500 - NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 -#endif - NM_WAKEONLAN = (1<<5), ///< Wake On Lan - NM_PINGBLOCK = (1<<4), ///< Block ping-request - NM_PPPOE = (1<<3), ///< PPPoE mode -}netmode_type; - -/** - * @ingroup DATA_TYPE - * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. - */ -typedef struct wiz_NetTimeout_t -{ - uint8_t retry_cnt; ///< retry count - uint16_t time_100us; ///< time unit 100us -}wiz_NetTimeout; - -/** - *@brief Registers call back function for critical section of I/O functions such as - *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. - *@param cris_en : callback function for critical section enter. - *@param cris_ex : callback function for critical section exit. - *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. - *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. - */ -void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); - - -/** - *@brief Registers call back function for WIZCHIP select & deselect. - *@param cs_sel : callback function for WIZCHIP select - *@param cs_desel : callback fucntion for WIZCHIP deselect - *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); - -/** - *@brief Registers call back function for bus interface. - *@param bus_rb : callback function to read byte data using system bus - *@param bus_wb : callback function to write byte data using system bus - *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -//M20150601 : For integrating with W5300 -//void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); -void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to read byte using SPI - *@param spi_wb : callback function to write byte using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); - -/** - *@brief Registers call back function for SPI interface. - *@param spi_rb : callback function to burst read using SPI - *@param spi_wb : callback function to burst write using SPI - *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function - *or register your functions. - *@note If you do not describe or register, null function is called. - */ -void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); - -/** - * @ingroup extra_functions - * @brief Controls to the WIZCHIP. - * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), - * controls interrupt & mask and so on. - * @param cwtype : Decides to the control type - * @param arg : arg type is dependent on cwtype. - * @return 0 : Success \n - * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP - */ -int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); - -/** - * @ingroup extra_functions - * @brief Controls to network. - * @details Controls to network environment, mode, timeout and so on. - * @param cntype : Input. Decides to the control type - * @param arg : Inout. arg type is dependent on cntype. - * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n - * 0 : Success - */ -int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); - - -/* - * The following functions are implemented for internal use. - * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). - */ - -/** - * @ingroup extra_functions - * @brief Reset WIZCHIP by softly. - */ -void wizchip_sw_reset(void); - -/** - * @ingroup extra_functions - * @brief Initializes WIZCHIP with socket buffer size - * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. - * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. - * @return 0 : succcess \n - * -1 : fail. Invalid buffer size - */ -int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); - -/** - * @ingroup extra_functions - * @brief Clear Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_clrinterrupt(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt of WIZCHIP. - * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterrupt(void); - -/** - * @ingroup extra_functions - * @brief Mask or Unmask Interrupt of WIZCHIP. - * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. - */ -void wizchip_setinterruptmask(intr_kind intr); - -/** - * @ingroup extra_functions - * @brief Get Interrupt mask of WIZCHIP. - * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. - */ -intr_kind wizchip_getinterruptmask(void); - -//todo -#if _WIZCHIP_ > W5100 - int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 - int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 -#endif - -#if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 - void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 -/** - * @ingroup extra_functions - * @brief Set the phy information for WIZCHIP without power mode - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_setphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy configuration information. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphyconf(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief Get phy status. - * @param phyconf : @ref wiz_PhyConf - */ - void wizphy_getphystat(wiz_PhyConf* phyconf); - /** - * @ingroup extra_functions - * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 - * @param pmode Settig value of power down mode. - */ - int8_t wizphy_setphypmode(uint8_t pmode); -#endif - -/** -* @ingroup extra_functions - * @brief Set the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Get the network information for WIZCHIP - * @param pnetinfo : @ref wizNetInfo - */ -void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); - -/** - * @ingroup extra_functions - * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. - * @param pnetinfo Value of network mode. Refer to @ref netmode_type. - */ -int8_t wizchip_setnetmode(netmode_type netmode); - -/** - * @ingroup extra_functions - * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. - * @return Value of network mode. Refer to @ref netmode_type. - */ -netmode_type wizchip_getnetmode(void); - -/** - * @ingroup extra_functions - * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_settimeout(wiz_NetTimeout* nettime); - -/** - * @ingroup extra_functions - * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). - * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. - * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. - */ -void wizchip_gettimeout(wiz_NetTimeout* nettime); -#ifdef __cplusplus - } -#endif - -#endif // _WIZCHIP_CONF_H_ diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/netutil.c b/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/netutil.c deleted file mode 100644 index 77b0992..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/netutil.c +++ /dev/null @@ -1,158 +0,0 @@ -#include -#include -#include -#include "netutil.h" - -/** - * Convert a 32bit Address into a Dotted Decimal Format string. - * - * @param addr 32bit address. - * @return Dotted Decimal Format string. - */ -int8_t* inet_ntoa(uint32_t addr) -{ - static int8_t addr_str[16]; - memset(addr_str,0,16); - sprintf((char*)addr_str,"%d.%d.%d.%d",(int32_t)(addr>>24 & 0xFF),(int32_t)(addr>>16 & 0xFF),(int32_t)(addr>>8 & 0xFF),(int32_t)(addr & 0xFF)); - return addr_str; -} - -/** - * Convert a 32bit Address into a Dotted Decimal Format string. - * This is differ from inet_ntoa in fixed length. - * - * @param addr 32bit address. - * @return Dotted Decimal Format string. - */ -int8_t* inet_ntoa_pad(uint32_t addr) -{ - static int8_t addr_str[16]; - memset(addr_str,0,16); - sprintf((char*)addr_str,"%03d.%03d.%03d.%03d",(int32_t)(addr>>24 & 0xFF),(int32_t)(addr>>16 & 0xFF),(int32_t)(addr>>8 & 0xFF),(int32_t)(addr & 0xFF)); - return addr_str; -} - -/** - * Converts a string containing an (Ipv4) Internet Protocol decimal dotted address into a 32bit address. - * - * @param addr Dotted Decimal Format string. - * @return 32bit address. - */ -uint32_t inet_addr(uint8_t* addr) -{ - int8_t i; - uint32_t inetaddr = 0; - int8_t taddr[30]; - int8_t * nexttok; - int32_t num; - strcpy((char*)taddr,(char*)addr); - - nexttok = taddr; - for(i = 0; i < 4 ; i++) - { - nexttok = (int8_t*)strtok((char*)nexttok,"."); - if(nexttok[0] == '0' && nexttok[1] == 'x') num = strtol((char*)nexttok+2, NULL, 16); - else num = strtol((char*)nexttok, NULL, 10); - inetaddr = inetaddr << 8; - inetaddr |= (num & 0xFF); - nexttok = NULL; - } - return inetaddr; -} - -/** - * Swap the byte order of 16bit(short) wide variable. - * - * @param i 16bit value to swap - * @return Swapped value - */ -uint16_t swaps(uint16_t i) -{ - uint16_t ret=0; - ret = (i & 0xFF) << 8; - ret |= ((i >> 8)& 0xFF); - return ret; -} - -/** - * Swap the byte order of 32bit(long) wide variable. - * - * @param l 32bit value to convert - * @return Swapped value - */ -uint32_t swapl(uint32_t l) -{ - uint32_t ret=0; - ret = (l & 0xFF) << 24; - ret |= ((l >> 8) & 0xFF) << 16; - ret |= ((l >> 16) & 0xFF) << 8; - ret |= ((l >> 24) & 0xFF); - return ret; -} - -/** - * htons function converts a unsigned short from host to TCP/IP network byte order (which is big-endian). - * - * @param hostshort The value to convert. - * @return The value in TCP/IP network byte order. - */ -uint16_t htons(uint16_t hostshort) -{ -#ifdef SYSTEM_LITTLE_ENDIAN - return swaps(hostshort); -#else - return hostshort; -#endif -} - - -/** - * htonl function converts a unsigned long from host to TCP/IP network byte order (which is big-endian). - * - * @param hostlong The value to convert. - * @return The value in TCP/IP network byte order. - */ -uint32_t htonl(uint32_t hostlong) -{ -#ifdef SYSTEM_LITTLE_ENDIAN - return swapl(hostlong); -#else - return hostlong; -#endif -} - - -/** - * ntohs function converts a unsigned short from TCP/IP network byte order - * to host byte order (which is little-endian on Intel processors). - * - * @param netshort The value to convert. - * @return A 16-bit number in host byte order - */ -uint32_t ntohs(uint16_t netshort) -{ -#ifdef SYSTEM_LITTLE_ENDIAN - return htons(netshort); -#else - return netshort; -#endif -} - -/** - * converts a unsigned long from TCP/IP network byte order to host byte order - * (which is little-endian on Intel processors). - * - * @param netlong The value to convert. - * @return A 16-bit number in host byte order - */ -uint32_t ntohl(uint32_t netlong) -{ -#ifdef SYSTEM_LITTLE_ENDIAN - return swapl(netlong); -#else - return netlong; -#endif -} -/** - * @} - */ diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/netutil.h b/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/netutil.h deleted file mode 100644 index 08375a3..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/netutil.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef __NETUTIL_H__ -#define __NETUTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define SYSTEM_LITTLE_ENDIAN - -int8_t* inet_ntoa(uint32_t addr); -int8_t* inet_ntoa_pad(uint32_t addr); -uint32_t inet_addr(uint8_t* addr); -uint16_t swaps(uint16_t i); -uint32_t swapl(uint32_t l); -uint16_t htons(uint16_t hostshort); -uint32_t htonl(uint32_t hostlong); -uint32_t ntohs(uint16_t netshort); -uint32_t ntohl(uint32_t netlong); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/tftp.c b/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/tftp.c deleted file mode 100644 index ace1470..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/tftp.c +++ /dev/null @@ -1,762 +0,0 @@ -/** - * @file tftp.c - * @brief TFTP Source File. - * @version 0.1.0 - * @author Sang-sik Kim - */ - -/* Includes -----------------------------------------------------*/ -#include -#include "tftp.h" -#include "socket.h" -#include "netutil.h" - -/* define -------------------------------------------------------*/ - -/* typedef ------------------------------------------------------*/ - -/* Extern Variable ----------------------------------------------*/ - -/* Extern Functions ---------------------------------------------*/ -#ifdef F_STORAGE -extern uint8_t save_data(uint8_t *data, uint32_t data_len, uint16_t block_number); - -static uint32_t g_tftp_save_data = 0; - -uint32_t get_tftp_received_size(void) -{ - return g_tftp_save_data; -} - -void clear_tftp_received_size(void) -{ - g_tftp_save_data = 0; -} - -void close_tftp_file(void) -{ - if(tftp_fr == FR_OK) - { - tftp_fr = f_close(&tftp_fil); - if(tftp_fr != FR_OK){ - DBG_PRINT(INFO_DBG,"--f_close failed\r\n"); - } - } -} - -uint8_t save_data(uint8_t *data, uint32_t data_len, uint16_t block_number) -{ - uint8_t save_data_result = 0; -#ifdef TFTP_RCV_DBG - //Nothing to do with received data yet.. - //TODO: Add your own handler here - //Print out received data as string - uint8_t * str; - str = data; - str += data_len; - *str = 0x0; - DBG_PRINT(INFO_DBG,"\r\n++Data #%d-%lu:\r\n%s\r\n", block_number, data_len, data); -#endif - //Calculate received data size - g_tftp_save_data += data_len; - //Save TFTP block to file - if(tftp_fr == FR_OK) - { - uint16_t _blocklen; - tftp_fr = f_write(&tftp_fil, data, (UINT)data_len, &_blocklen); - if(tftp_fr != FR_OK){ - DBG_PRINT(INFO_DBG,"--f_write failed #2\r\n"); - save_data_result = 2; - } - else - { - f_sync(&tftp_fil); //Flush data to SDCARD from cache - } - } - else - { - DBG_PRINT(INFO_DBG,"--f_write failed #1\r\n"); - save_data_result = 1; - } - return save_data_result; -} -#endif - -/* Global Variable ----------------------------------------------*/ -static int g_tftp_socket = -1; - -static uint8_t g_filename[TFTP_FILE_NAME_SIZE]; - -static uint32_t g_server_ip = 0; -static uint16_t g_server_port = 0; -static uint16_t g_local_port = 0; - -static uint32_t g_tftp_state = STATE_NONE; -static uint16_t g_block_num = 0; - -static uint32_t g_timeout = 5; -static uint32_t g_resend_flag = 0; -static uint32_t tftp_time_cnt = 0; -static uint32_t tftp_retry_cnt = 0; - -static uint8_t *g_tftp_rcv_buf = NULL; - -static TFTP_OPTION default_tftp_opt = { - .code = (uint8_t *)"timeout", - .value = (uint8_t *)"5" -}; - -uint8_t g_progress_state = TFTP_PROGRESS; - -#ifdef __TFTP_DEBUG__ -int dbg_level = (INFO_DBG | ERROR_DBG | IPC_DBG | DEBUG_DBG); -#endif - -/* static function define ---------------------------------------*/ -static void set_filename(uint8_t *file, uint32_t file_size) -{ - memcpy(g_filename, file, file_size); -#if defined(F_STORAGE) - //Rewrite file onto SD-card - tftp_fr = f_open(&tftp_fil, (const char *)g_filename, FA_CREATE_ALWAYS | FA_WRITE); - if(tftp_fr != FR_OK){ - DBG_PRINT(INFO_DBG,"--f_open failed\r\n"); - } -#endif -} - -static inline void set_server_ip(uint32_t ipaddr) -{ - g_server_ip = ipaddr; -} - -static inline uint32_t get_server_ip() -{ - return g_server_ip; -} - -static inline void set_server_port(uint16_t port) -{ - g_server_port = port; -} - -static inline uint16_t get_server_port() -{ - return g_server_port; -} - -static inline void set_local_port(uint16_t port) -{ - g_local_port = port; -} - -static inline uint16_t get_local_port() -{ - return g_local_port; -} - -static inline uint16_t genernate_port() -{ - /* TODO */ - return 0; -} - -static inline void set_tftp_state(uint32_t state) -{ - g_tftp_state = state; -} - -static inline uint32_t get_tftp_state() -{ - return g_tftp_state; -} - -static inline void set_tftp_timeout(uint32_t timeout) -{ - g_timeout = timeout; -} - -static inline uint32_t get_tftp_timeout() -{ - return g_timeout; -} - -static inline void set_block_number(uint16_t block_number) -{ - g_block_num = block_number; -} - -static inline uint16_t get_block_number() -{ - return g_block_num; -} - -static int open_tftp_socket(uint8_t sock) -{ - uint8_t sd, sck_state; - - sd = socket(sock, Sn_MR_UDP, TFTP_LOCAL_PORT, SF_IO_NONBLOCK); - if(sd != sock) { - DBG_PRINT(ERROR_DBG, "[%s] socket error\r\n", __func__); - return -1; - } - - do { - getsockopt(sd , SO_STATUS, &sck_state); - } while(sck_state != SOCK_UDP); - - return (int)sd; -} - -static int send_udp_packet(int socket, uint8_t *packet, uint32_t len, uint32_t ip, uint16_t port) -{ - int snd_len; - - ip = htonl(ip); - - snd_len = sendto(socket, packet, len, (uint8_t *)&ip, port); - if(snd_len != len) { - //DBG_PRINT(ERROR_DBG, "[%s] sendto error\r\n", __func__); - return -1; - } - - return snd_len; -} - -static int recv_udp_packet(int socket, uint8_t *packet, uint32_t len, uint32_t *ip, uint16_t *port) -{ - int ret; - uint8_t sck_state; - uint16_t recv_len; - - /* Receive Packet Process */ - ret = getsockopt(socket, SO_STATUS, &sck_state); - if(ret != SOCK_OK) { - //DBG_PRINT(ERROR_DBG, "[%s] getsockopt SO_STATUS error\r\n", __func__); - return -1; - } - - if(sck_state == SOCK_UDP) { - ret = getsockopt(socket, SO_RECVBUF, &recv_len); - if(ret != SOCK_OK) { - //DBG_PRINT(ERROR_DBG, "[%s] getsockopt SO_RECVBUF error\r\n", __func__); - return -1; - } - - if(recv_len) { - recv_len = recvfrom(socket, packet, len, (uint8_t *)ip, port); - if(recv_len < 0) { - //DBG_PRINT(ERROR_DBG, "[%s] recvfrom error\r\n", __func__); - return -1; - } - - *ip = ntohl(*ip); - - return recv_len; - } - } - return -1; -} - -static void close_tftp_socket(int socket) -{ - close(socket); -} - - -static void init_tftp(void) -{ - g_filename[0] = 0; - - set_server_ip(0); - set_server_port(0); - set_local_port(0); - - set_tftp_state(STATE_NONE); - set_block_number(0); - - /* timeout flag */ - g_resend_flag = 0; - tftp_retry_cnt = tftp_time_cnt = 0; - - g_progress_state = TFTP_PROGRESS; -} - -static void tftp_cancel_timeout(void) -{ - if(g_resend_flag) { - g_resend_flag = 0; - tftp_retry_cnt = tftp_time_cnt = 0; - } -} - -static void tftp_reg_timeout() -{ - if(g_resend_flag == 0) { - g_resend_flag = 1; - tftp_retry_cnt = tftp_time_cnt = 0; - } -} - -static void process_tftp_option(uint8_t *msg, uint32_t msg_len) -{ - /* TODO Option Process */ -} - -static void send_tftp_rrq(uint8_t *filename, uint8_t *mode, TFTP_OPTION *opt, uint8_t opt_len) -{ - uint8_t snd_buf[MAX_MTU_SIZE]; - uint8_t *pkt = snd_buf; - uint32_t i, len; - - *((uint16_t *)pkt) = htons(TFTP_RRQ); - pkt += 2; - strcpy((char *)pkt, (const char *)filename); - pkt += strlen((char *)filename) + 1; - strcpy((char *)pkt, (const char *)mode); - pkt += strlen((char *)mode) + 1; - - for(i = 0 ; i < opt_len ; i++) { - strcpy((char *)pkt, (const char *)opt[i].code); - pkt += strlen((char *)opt[i].code) + 1; - strcpy((char *)pkt, (const char *)opt[i].value); - pkt += strlen((char *)opt[i].value) + 1; - } - - len = pkt - snd_buf; - - send_udp_packet(g_tftp_socket, snd_buf, len, get_server_ip(), TFTP_SERVER_PORT); - set_tftp_state(STATE_RRQ); - set_filename(filename, strlen((char *)filename) + 1); - tftp_reg_timeout(); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, ">> TFTP RRQ : FileName(%s), Mode(%s)\r\n", filename, mode); -#endif -} - -#if 0 // 2014.07.01 sskim -static void send_tftp_wrq(uint8_t *filename, uint8_t *mode, TFTP_OPTION *opt, uint8_t opt_len) -{ - uint8_t snd_buf[MAX_MTU_SIZE]; - uint8_t *pkt = snd_buf; - uint32_t i, len; - - *((uint16_t *)pkt) = htons((uint16_t)TFTP_WRQ); - pkt += 2; - strcpy((char *)pkt, (const char *)filename); - pkt += strlen((char *)filename) + 1; - strcpy((char *)pkt, (const char *)mode); - pkt += strlen((char *)mode) + 1; - - for(i = 0 ; i < opt_len ; i++) { - strcpy((char *)pkt, (const char *)opt[i].code); - pkt += strlen((char *)opt[i].code) + 1; - strcpy((char *)pkt, (const char *)opt[i].value); - pkt += strlen((char *)opt[i].value) + 1; - } - - len = pkt - snd_buf; - - send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), TFTP_SERVER_PORT); - set_tftp_state(STATE_WRQ); - set_filename(filename, strlen((char *)filename) + 1); - tftp_reg_timeout(); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, ">> TFTP WRQ : FileName(%s), Mode(%s)\r\n", filename, mode); -#endif -} -#endif - -#if 0 // 2014.07.01 sskim -static void send_tftp_data(uint16_t block_number, uint8_t *data, uint16_t data_len) -{ - uint8_t snd_buf[MAX_MTU_SIZE]; - uint8_t *pkt = snd_buf; - uint32_t len; - - *((uint16_t *)pkt) = htons((uint16_t)TFTP_DATA); - pkt += 2; - *((uint16_t *)pkt) = htons(block_number); - pkt += 2; - memcpy(pkt, data, data_len); - pkt += data_len; - - len = pkt - snd_buf; - - send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), get_server_port()); - tftp_reg_timeout(); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, ">> TFTP DATA : Block Number(%d), Data Length(%d)\r\n", block_number, data_len); -#endif -} -#endif - -static void send_tftp_ack(uint16_t block_number) -{ - uint8_t snd_buf[4]; - uint8_t *pkt = snd_buf; - - *((uint16_t *)pkt) = htons((uint16_t)TFTP_ACK); - pkt += 2; - *((uint16_t *)pkt) = htons(block_number); - pkt += 2; - - send_udp_packet(g_tftp_socket , snd_buf, 4, get_server_ip(), get_server_port()); - tftp_reg_timeout(); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, ">> TFTP ACK : Block Number(%d)\r\n", block_number); -#endif -} - -#if 0 // 2014.07.01 sskim -static void send_tftp_oack(TFTP_OPTION *opt, uint8_t opt_len) -{ - uint8_t snd_buf[MAX_MTU_SIZE]; - uint8_t *pkt = snd_buf; - uint32_t i, len; - - *((uint16_t *)pkt) = htons((uint16_t)TFTP_OACK); - pkt += 2; - - for(i = 0 ; i < opt_len ; i++) { - strcpy((char *)pkt, (const char *)opt[i].code); - pkt += strlen((char *)opt[i].code) + 1; - strcpy((char *)pkt, (const char *)opt[i].value); - pkt += strlen((char *)opt[i].value) + 1; - } - - len = pkt - snd_buf; - - send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), get_server_port()); - tftp_reg_timeout(); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, ">> TFTP OACK \r\n"); -#endif -} -#endif - -#if 0 // 2014.07.01 sskim -static void send_tftp_error(uint16_t error_number, uint8_t *error_message) -{ - uint8_t snd_buf[MAX_MTU_SIZE]; - uint8_t *pkt = snd_buf; - uint32_t len; - - *((uint16_t *)pkt) = htons((uint16_t)TFTP_ERROR); - pkt += 2; - *((uint16_t *)pkt) = htons(error_number); - pkt += 2; - strcpy((char *)pkt, (const char *)error_message); - pkt += strlen((char *)error_message) + 1; - - len = pkt - snd_buf; - - send_udp_packet(g_tftp_socket , snd_buf, len, get_server_ip(), get_server_port()); - tftp_reg_timeout(); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, ">> TFTP ERROR : Error Number(%d)\r\n", error_number); -#endif -} -#endif - -static void recv_tftp_rrq(uint8_t *msg, uint32_t msg_len) -{ - /* When TFTP Server Mode */ -} - -static void recv_tftp_wrq(uint8_t *msg, uint32_t msg_len) -{ - /* When TFTP Server Mode */ -} - -static void recv_tftp_data(uint8_t *msg, uint32_t msg_len) -{ - TFTP_DATA_T *data = (TFTP_DATA_T *)msg; - - data->opcode = ntohs(data->opcode); - data->block_num = ntohs(data->block_num); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, "<< TFTP_DATA : opcode(%d), block_num(%d)\r\n", data->opcode, data->block_num); -#endif - - switch(get_tftp_state()) - { - case STATE_RRQ : - case STATE_OACK : - if(data->block_num == 1) { - set_tftp_state(STATE_DATA); - set_block_number(data->block_num); -#ifdef F_STORAGE - if (save_data(data->data, msg_len - 4, data->block_num)) - { - g_progress_state = TFTP_FAIL; - } -#endif - tftp_cancel_timeout(); - } - send_tftp_ack(data->block_num); - - if((msg_len - 4) < TFTP_BLK_SIZE) { - init_tftp(); - g_progress_state = TFTP_SUCCESS; - } - - break; - - case STATE_DATA : - if(data->block_num == (get_block_number() + 1)) { - set_block_number(data->block_num); -#ifdef F_STORAGE - if(save_data(data->data, msg_len - 4, data->block_num)) - { - g_progress_state = TFTP_FAIL; - - } -#endif - tftp_cancel_timeout(); - } - send_tftp_ack(data->block_num); - - if((msg_len - 4) < TFTP_BLK_SIZE) { - init_tftp(); - g_progress_state = TFTP_SUCCESS; - } - - break; - - default : - /* invalid message */ - break; - } -} - -static void recv_tftp_ack(uint8_t *msg, uint32_t msg_len) -{ -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, "<< TFTP_ACK : \r\n"); -#endif - - switch(get_tftp_state()) - { - case STATE_WRQ : - break; - - case STATE_ACK : - break; - - default : - /* invalid message */ - break; - } -} - -static void recv_tftp_oack(uint8_t *msg, uint32_t msg_len) -{ -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, "<< TFTP_OACK : \r\n"); -#endif - - switch(get_tftp_state()) - { - case STATE_RRQ : - process_tftp_option(msg, msg_len); - set_tftp_state(STATE_OACK); - tftp_cancel_timeout(); - send_tftp_ack(0); - break; - - case STATE_WRQ : - process_tftp_option(msg, msg_len); - set_tftp_state(STATE_ACK); - tftp_cancel_timeout(); - - /* TODO DATA Transfer */ - //send_tftp_data(...); - break; - - default : - /* invalid message */ - break; - } -} - -static void recv_tftp_error(uint8_t *msg, uint32_t msg_len) -{ - TFTP_ERROR_T *data= (TFTP_ERROR_T *)msg; - - data->opcode = ntohs(data->opcode); - data->error_code = ntohs(data->error_code); - -#ifdef __TFTP_DEBUG__ - DBG_PRINT(IPC_DBG, "<< TFTP_ERROR : %d (%s)\r\n", data->error_code, data->error_msg); - DBG_PRINT(ERROR_DBG, "[%s] Error Code : %d (%s)\r\n", __func__, data->error_code, data->error_msg); -#endif - init_tftp(); - g_progress_state = TFTP_FAIL; -} - -static void recv_tftp_packet(uint8_t *packet, uint32_t packet_len, uint32_t from_ip, uint16_t from_port) -{ - uint16_t opcode; - - /* Verify Server IP */ - if(from_ip != get_server_ip()) { -#ifdef __TFTP_DEBUG__ - DBG_PRINT(ERROR_DBG, "[%s] Server IP faults\r\n", __func__); - DBG_PRINT(ERROR_DBG, "from IP : 0x%08lX, Server IP : 0x%08lX\r\n", from_ip, get_server_ip()); -#endif - return; - } - - opcode = ntohs(*((uint16_t *)packet)); - - /* Set Server Port */ - if((get_tftp_state() == STATE_WRQ) || (get_tftp_state() == STATE_RRQ)) { - set_server_port(from_port); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(INFO_DBG, "[%s] Set Server Port : %u\r\n", __func__, from_port); -#endif - } - - switch(opcode) - { - case TFTP_RRQ : /* When Server */ - recv_tftp_rrq(packet, packet_len); - break; - case TFTP_WRQ : /* When Server */ - recv_tftp_wrq(packet, packet_len); - break; - case TFTP_DATA : - recv_tftp_data(packet, packet_len); - break; - case TFTP_ACK : - recv_tftp_ack(packet, packet_len); - break; - case TFTP_OACK : - recv_tftp_oack(packet, packet_len); - break; - case TFTP_ERROR : - recv_tftp_error(packet, packet_len); - break; - - default : - // Unknown Message - break; - } -} - -/* Functions ----------------------------------------------------*/ -void TFTP_init(uint8_t socket, uint8_t *buf) -{ - init_tftp(); - - g_tftp_rcv_buf = buf; - g_tftp_socket = open_tftp_socket(socket); - if(g_tftp_socket == -1) - { - //Here when TFTP socket open OK - DBG_PRINT(ERROR_DBG, "--[%s] TFTP socket[%d] open error\r\nReboot the board..\r\n", __func__, socket); - while(1) - { - ; - } - } - else - { - DBG_PRINT(INFO_DBG, "++[%s] TFTP socket[%d]:%u open success\r\n", __func__, g_tftp_socket, TFTP_LOCAL_PORT); - } -} - -void TFTP_exit(void) -{ - init_tftp(); - - close_tftp_socket(g_tftp_socket); - g_tftp_socket = -1; - - g_tftp_rcv_buf = NULL; -} - -int TFTP_run(void) -{ - uint16_t len, from_port; - uint32_t from_ip; - - /* Timeout Process */ - if(g_resend_flag) { - if(tftp_time_cnt >= g_timeout) { - switch(get_tftp_state()) { - case STATE_WRQ: // 미구현 - break; - - case STATE_RRQ: - send_tftp_rrq(g_filename, (uint8_t *)TRANS_BINARY, &default_tftp_opt, 1); - break; - - case STATE_OACK: - case STATE_DATA: - send_tftp_ack(get_block_number()); - break; - - case STATE_ACK: // 미구현 - break; - - default: - break; - } - - tftp_time_cnt = 0; - tftp_retry_cnt++; - - if(tftp_retry_cnt >= 5) { - init_tftp(); - g_progress_state = TFTP_FAIL; - } - } - } - - /* Receive Packet Process */ - len = recv_udp_packet(g_tftp_socket, g_tftp_rcv_buf, MAX_MTU_SIZE, &from_ip, &from_port); - if(len < 0) { -#ifdef __TFTP_DEBUG__ - DBG_PRINT(ERROR_DBG, "[%s] recv_udp_packet error\r\n", __func__); -#endif -#ifdef F_STORAGE - if(g_progress_state != TFTP_PROGRESS) - { - //Close TFTP file if transfer complete - close_tftp_file(); - } -#endif - return g_progress_state; - } - - recv_tftp_packet(g_tftp_rcv_buf, len, from_ip, from_port); - -#ifdef F_STORAGE - if(g_progress_state != TFTP_PROGRESS) - { - //Close TFTP file if transfer complete - close_tftp_file(); - } -#endif - - return g_progress_state; -} - -void TFTP_read_request(uint32_t server_ip, uint8_t *filename) -{ - set_server_ip(server_ip); -#ifdef __TFTP_DEBUG__ - DBG_PRINT(INFO_DBG, "[%s] Set Tftp Server : 0x%lX\r\n", __func__, server_ip); -#endif - - g_progress_state = TFTP_PROGRESS; - send_tftp_rrq(filename, (uint8_t *)TRANS_BINARY, &default_tftp_opt, 1); -} - -void tftp_timeout_handler(void) -{ - if(g_resend_flag) - tftp_time_cnt++; -} diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/tftp.h b/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/tftp.h deleted file mode 100644 index 51b6ca8..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/Internet/TFTP/tftp.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file tftp.h - * @brief TFTP Header File. - * @version 0.1.0 - * @author Sang-sik Kim - */ -#ifndef __TFTP_H__ -#define __TFTP_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "../../globals.h" - -#define F_APP_TFTP -#define __TFTP_DEBUG__ -//define TFTP_RCV_DBG /* To print-out received TFTP packet as string data */ - -#define F_STORAGE // If your target support a storage, you have to activate this feature and implement. - -#if defined(F_STORAGE) -#include "../../ff/ff.h" -static FIL tftp_fil; // FatFs File objects -static FRESULT tftp_fr; // FatFs function common result code -#endif - - -#define SOCK_TFTP 2 - -#define INFO_DBG 0x01 -#define ERROR_DBG 0x02 -#define DEBUG_DBG 0x04 -#define IPC_DBG 0x08 - -#define DBG_PRINT(level, format, args...) { \ - if(dbg_level & level) \ - PRINTF(format, ##args); \ - } - -#define NORMAL_MODE 0 -#define TFTP_MODE 1 - -extern int dbg_level; - -/* tftp message */ -#define TFTP_RRQ 1 -#define TFTP_WRQ 2 -#define TFTP_DATA 3 -#define TFTP_ACK 4 -#define TFTP_ERROR 5 -#define TFTP_OACK 6 - -/* tftp state */ -#define STATE_NONE 0 -#define STATE_RRQ 1 -#define STATE_WRQ 2 -#define STATE_DATA 3 -#define STATE_ACK 4 -#define STATE_OACK 5 - -/* tftp transfer mode */ -#define TRANS_ASCII "netascii" -#define TRANS_BINARY "octet" - -/* tftp progress state */ -#define TFTP_PROGRESS 0 -#define TFTP_FAIL 1 -#define TFTP_SUCCESS 2 - -/* define */ -#define TFTP_SERVER_PORT 69 -#define TFTP_LOCAL_PORT 51000 -#define TFTP_BLK_SIZE 512 -#define MAX_MTU_SIZE 1514 -#define TFTP_FILE_NAME_SIZE 20 - -//#define __TFTP_DEBUG__ - -/* typedef */ -typedef struct tftp_data { - uint16_t opcode; - uint16_t block_num; - uint8_t data[0]; -} TFTP_DATA_T; - -typedef struct tftp_error { - uint16_t opcode; - uint16_t error_code; - uint8_t error_msg[0]; -} TFTP_ERROR_T; - -typedef struct tftp_option { - uint8_t *code; - uint8_t *value; -} TFTP_OPTION; - -/* Functions */ -void TFTP_init(uint8_t socket, uint8_t *buf); -void TFTP_exit(void); -int TFTP_run(void); -void TFTP_read_request(uint32_t server_ip, uint8_t *filename); -void tftp_timeout_handler(void); -uint32_t get_tftp_received_size(void); -void clear_tftp_received_size(void); - -#ifdef __cplusplus -} -#endif - -#endif /*__TFTP_H__ */ diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ccsbcs.c.unicode b/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ccsbcs.c.unicode deleted file mode 100644 index 42e8a57..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ccsbcs.c.unicode +++ /dev/null @@ -1,348 +0,0 @@ -/*------------------------------------------------------------------------*/ -/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */ -/* (SBCS code pages) */ -/*------------------------------------------------------------------------*/ -/* 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 -*/ - -#include "ff.h" - - -#if _CODE_PAGE == 437 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 720 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */ - 0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627, - 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, - 0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 737 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */ - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, - 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, - 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E, - 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 771 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 775 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */ - 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4, - 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D, - 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019, - 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 850 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 852 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106, - 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4, - 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 855 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */ - 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408, - 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A, - 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580, - 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116, - 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 857 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4, - 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580, - 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4, - 0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 860 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2, - 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 861 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 862 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */ - 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, - 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 863 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0, - 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192, - 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 864 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */ - 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518, - 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000, - 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5, - 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F, - 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9, - 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9, - 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1, - 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000 -}; - -#elif _CODE_PAGE == 865 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 866 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */ - 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, - 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, - 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0 -}; - -#elif _CODE_PAGE == 869 -#define _TBLDEF 1 -static -const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */ - 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389, - 0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF, - 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3, - 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384, - 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0 -}; - -#endif - - -#if !_TBLDEF || !_USE_LFN -#error This file is not needed at current configuration. Remove from the project. -#endif - - - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR chr, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEM code, 1: OEM code to Unicode */ -) -{ - WCHAR c; - - - if (chr < 0x80) { /* ASCII */ - c = chr; - - } else { - if (dir) { /* OEM code to Unicode */ - c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80]; - - } else { /* Unicode to OEM code */ - for (c = 0; c < 0x80; c++) { - if (chr == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - - - -WCHAR ff_wtoupper ( /* Returns upper converted character */ - WCHAR chr /* Unicode character to be upper converted */ -) -{ - static const WCHAR lower[] = { /* Lower case characters to be converted */ - /* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - /* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E, - /* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217, - /* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB, - /* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9, - /* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586, - /* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9, - /* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F, - /* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A - }; - static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178, - 0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D, - 0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216, - 0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA, - 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8, - 0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556, - 0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8, - 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F, - 0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A - }; - UINT i, n, hi, li; - - - if (chr < 0x80) { /* ASCII characters (acceleration) */ - if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20; - - } else { /* Non ASCII characters (table search) */ - n = 12; li = 0; hi = sizeof lower / sizeof lower[0]; - do { - i = li + (hi - li) / 2; - if (chr == lower[i]) break; - if (chr > lower[i]) li = i; else hi = i; - } while (--n); - if (n) chr = upper[i]; - } - - return chr; -} - diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/diskio.h b/21_m1284p_WIZNET_TFTP_client_FATFS/ff/diskio.h deleted file mode 100644 index e7164ea..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/diskio.h +++ /dev/null @@ -1,95 +0,0 @@ -/*----------------------------------------------------------------------- -/ Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -#if _USE_WRITE -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -#endif -#if _USE_IOCTL -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); -#endif -void disk_timerproc (void); - - -/* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ - -/* Generic command (Not used by FatFs) */ -#define CTRL_FORMAT 5 /* Create physical format on the media */ -#define CTRL_POWER_IDLE 6 /* Put the device idle state */ -#define CTRL_POWER_OFF 7 /* Put the device off state */ -#define CTRL_LOCK 8 /* Lock media removal */ -#define CTRL_UNLOCK 9 /* Unlock media removal */ -#define CTRL_EJECT 10 /* Eject media */ - -/* MMC/SDC specific command (Not used by FatFs) */ -#define MMC_GET_TYPE 50 /* Get card type */ -#define MMC_GET_CSD 51 /* Get CSD */ -#define MMC_GET_CID 52 /* Get CID */ -#define MMC_GET_OCR 53 /* Get OCR */ -#define MMC_GET_SDSTAT 54 /* Get SD status */ - -/* ATA/CF specific command (Not used by FatFs) */ -#define ATA_GET_REV 60 /* Get F/W revision */ -#define ATA_GET_MODEL 61 /* Get model name */ -#define ATA_GET_SN 62 /* Get serial number */ - - -/* MMC card type flags (MMC_GET_TYPE) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC (CT_SD1|CT_SD2) /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ff.c b/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ff.c deleted file mode 100644 index e4199c3..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ff.c +++ /dev/null @@ -1,4635 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.11 (C)ChaN, 2015 -/-----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/----------------------------------------------------------------------------*/ - - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 32020 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* Timestamp feature */ -#if _FS_NORTC == 1 -#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings -#endif -#define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) -#else -#define GET_FATTIME() get_fattime() -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only configuration -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NSFLAG 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */ -#define MIN_FAT16 4086U /* Minimum number of clusters as FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters as FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* x86 jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* Lower case flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Must be zero (0) */ -#define SZ_DIRE 32 /* Size of a directory entry */ -#define LLEF 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDEM 0xE5 /* Deleted directory entry mark at DIR_Name[0] */ -#define RDDEM 0x05 /* Replacement of the character collides with DDEM */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Remark: Uninitialized variables with static duration are -/ guaranteed zero/null at start-up. If not, either the linker -/ or start-up routine being used is out of ANSI-C standard. -*/ - -#if _VOLUMES < 1 || _VOLUMES > 9 -#error Wrong _VOLUMES setting -#endif -static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -static WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* Non LFN feature */ -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() -#else -#if _MAX_LFN < 12 || _MAX_LFN > 255 -#error Wrong _MAX_LFN setting -#endif -#if _USE_LFN == 1 /* LFN feature with static working buffer */ -static WCHAR LfnBuf[_MAX_LFN + 1]; -#define DEFINE_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) -#else -#error Wrong _USE_LFN setting -#endif -#endif - -#ifdef _EXCVT -static const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - FRESULT res = FR_OK; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1) != RES_OK) { - res = FR_DISK_ERR; - } else { - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - } - return res; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - FRESULT res = FR_OK; - - - if (sector != fs->winsect) { /* Window offset changed? */ -#if !_FS_READONLY - res = sync_window(fs); /* Write-back changes */ -#endif - if (res == FR_OK) { /* Fill sector window with new data */ - if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) { - sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */ - res = FR_DISK_ERR; - } - fs->winsect = sector; - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win + BS_55AA, 0xAA55); - ST_DWORD(fs->win + FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win + FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= fs->n_fatent - 2) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x0FFFFFFF:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* FAT index number (cluster number) to get the value */ -) -{ - UINT wc, bc; - BYTE *p; - DWORD val; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - val = 1; /* Internal error */ - - } else { - val = 0xFFFFFFFF; /* Default value falls on disk error */ - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc = fs->win[bc++ % SS(fs)]; - if (move_window(fs, fs->fatbase + (bc / SS(fs))) != FR_OK) break; - wc |= fs->win[bc % SS(fs)] << 8; - val = clst & 1 ? wc >> 4 : (wc & 0xFFF); - break; - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - val = LD_WORD(p); - break; - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val = LD_DWORD(p) & 0x0FFFFFFF; - break; - - default: - val = 1; /* Internal error */ - } - } - - return val; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -/* Hidden API for hacks and disk tools */ - -#if !_FS_READONLY -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* FAT index number (cluster number) to be changed */ - DWORD val /* New value to be set to the entry */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc++ % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - fs->wflag = 1; - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - fs->wflag = 1; - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - fs->wflag = 1; - break; - - default : - res = FR_INT_ERR; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_TRIM - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_TRIM - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_TRIM, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIRE * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; -#if !_FS_READONLY - UINT c; -#endif - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIRE))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIRE)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDEM || dp->dir[0] == 0) { /* Is it a free entry? */ - if (++n == nent) break; /* A block of contiguous free entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir + DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir + DIR_FstClusLO, cl); - ST_WORD(dir + DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLEF) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir + LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - WCHAR wc; - DWORD sr; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - sr = seq; - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLEF) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLEF; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NSFLAG] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NSFLAG] = sn[NSFLAG]; dp->lfn = lfn; - } - - if (sn[NSFLAG] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIRE); /* Clear and mark the entry "deleted" */ - *dp->dir = DDEM; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - BYTE *dir; -#if _USE_LFN - WCHAR w, *lfn; -#endif - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - dir = dp->dir; - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir + DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir + DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir + DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pattern matching */ -/*-----------------------------------------------------------------------*/ -#if _USE_FIND && _FS_MINIMIZE <= 1 -static -WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ - const TCHAR** ptr /* Pointer to pointer to the SBCS/DBCS/Unicode string */ -) -{ - WCHAR chr; - -#if !_LFN_UNICODE - chr = (BYTE)*(*ptr)++; /* Get a byte */ - if (IsLower(chr)) chr -= 0x20; /* To upper ASCII char */ - if (IsDBCS1(chr) && IsDBCS2(**ptr)) /* Get DBC 2nd byte if needed */ - chr = chr << 8 | (BYTE)*(*ptr)++; -#ifdef _EXCVT - if (chr >= 0x80) chr = ExCvt[chr - 0x80]; /* To upper SBCS extended char */ -#endif -#else - chr = ff_wtoupper(*(*ptr)++); /* Get a word and to upper */ -#endif - return chr; -} - - -static -int pattern_matching ( /* Return value: 0:mismatched, 1:matched */ - const TCHAR* pat, /* Matching pattern */ - const TCHAR* nam, /* String to be tested */ - int skip, /* Number of pre-skip chars (number of ?s) */ - int inf /* Infinite search (* specified) */ -) -{ - const TCHAR *pp, *np; - WCHAR pc, nc; - int nm, nx; - - - while (skip--) { /* Pre-skip name chars */ - if (!get_achar(&nam)) return 0; /* Branch mismatched if less name chars */ - } - if (!*pat && inf) return 1; /* (short circuit) */ - - do { - pp = pat; np = nam; /* Top of pattern and name to match */ - for (;;) { - if (*pp == '?' || *pp == '*') { /* Wildcard? */ - nm = nx = 0; - do { /* Analyze the wildcard chars */ - if (*pp++ == '?') nm++; else nx = 1; - } while (*pp == '?' || *pp == '*'); - if (pattern_matching(pp, np, nm, nx)) return 1; /* Test new branch (recurs upto number of wildcard blocks in the pattern) */ - nc = *np; break; /* Branch mismatched */ - } - pc = get_achar(&pp); /* Get a pattern char */ - nc = get_achar(&np); /* Get a name char */ - if (pc != nc) break; /* Branch mismatched? */ - if (!pc) return 1; /* Branch matched? (matched at end of both strings) */ - } - get_achar(&nam); /* nam++ */ - } while (inf && nc); /* Retry until end of name if infinite search is specified */ - - return 0; -} -#endif /* _USE_FIND && _FS_MINIMIZE <= 1 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - w = (w << 8) + b; /* Create a DBC */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di - 1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* DBC (always false at SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* SBC */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM; /* If the first character collides with deleted mark, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NSFLAG] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NSFLAG] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* SBC */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDEM) sfn[0] = RDDEM; /* When first character collides with DDEM, replace it with RDDEM */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NSFLAG] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NSFLAG]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; -#endif - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } -#if _STR_VOLUME_ID - else { /* No numeric drive number, find string drive id */ - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } - } -#endif - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt, *pt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4]; - WORD nrsv; - FATFS *fs; - UINT i; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - for (i = 0; i < 4; i++) { /* Get partition offset */ - pt = fs->win + MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win + BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win + BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win + BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIRE)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win + BPB_TotSec32); - - nrsv = LD_WORD(fs->win + BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win + BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than the size needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win + BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win + BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win + FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; -#if !_FS_READONLY - DWORD dw, cl; -#endif - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = GET_FATTIME(); /* Created time */ - ST_DWORD(dir + DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir + DIR_FileSize, 0);/* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir + DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir + DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = GET_FATTIME(); /* Update updated time */ - ST_DWORD(dir + DIR_WrtTime, tm); - ST_WORD(dir + DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEFINE_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - DWORD clst, bcs, nsect, ifptr; -#if _USE_FASTSEEK - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; -#endif - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEFINE_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEFINE_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _USE_FIND -/*-----------------------------------------------------------------------*/ -/* Find next file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findnext ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ -) -{ - FRESULT res; - - - for (;;) { - res = f_readdir(dp, fno); /* Get a directory item */ - if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ -#if _USE_LFN - if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ -#endif - if (pattern_matching(dp->pat, fno->fname, 0, 0)) break; /* Test for SFN */ - } - return res; - -} - - - -/*-----------------------------------------------------------------------*/ -/* Find first file */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_findfirst ( - DIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ - const TCHAR* path, /* Pointer to the directory to open */ - const TCHAR* pattern /* Pointer to the matching pattern */ -) -{ - FRESULT res; - - - dp->pat = pattern; /* Save pointer to pattern string */ - res = f_opendir(dp, path); /* Open the target directory */ - if (res == FR_OK) - res = f_findnext(dp, fno); /* Find the first item */ - return res; -} - -#endif /* _USE_FIND */ - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst = 0; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the origin directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - if (res == FR_OK) { - dclst = ld_clust(dj.fs, dir); - if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ -#if _FS_RPATH - if (dclst == dj.fs->cdir) { /* Is it the current directory? */ - res = FR_DENIED; - } else -#endif - { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Open the sub-directory */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item (excluding dot entries) */ - if (res == FR_OK) res = FR_DENIED; /* Not empty? (cannot remove) */ - if (res == FR_NO_FILE) res = FR_OK; /* Empty? (can remove) */ - } - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK && dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = GET_FATTIME(); - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir + DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); /* Create ".." entry */ - dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir + SZ_DIRE, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir + DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE attr, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEFINE_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* It is a valid path and no name collision */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { -/* Start of critical section where any interruption can cause a cross-link */ - dir = djn.dir; /* Copy information about object except name */ - mem_cpy(dir + 13, buf + 2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) { /* Update .. entry in the sub-directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win + SZ_DIRE * 1; /* Ptr to .. entry */ - if (res == FR_OK && dir[1] == '.') { - st_clust(dir, djn.sclust); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } -/* End of critical section */ - } - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEFINE_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir + DIR_WrtTime, fno->ftime); - ST_WORD(dir + DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; -#if _USE_LFN && _LFN_UNICODE - WCHAR w; -#endif - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl - 1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; /* Fill remaining name field */ - if (vn[0] == DDEM) LEAVE_FF(dj.fs, FR_INVALID_NAME); /* Reject illegal name (heading DDEM) */ - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - } else { - dj.dir[0] = DDEM; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIRE); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = GET_FATTIME(); - ST_DWORD(dj.dir + DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect) != FR_OK) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create file system on the logical drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FATs (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Size of allocation unit in unit of byte or sector */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; -#if _USE_TRIM - DWORD eb[2]; -#endif - - - /* Check mounted drive and clear work area */ - if (sfd > 1) return FR_INVALID_PARAMETER; - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; - if (LD_WORD(fs->win + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl + 8); /* Volume start sector */ - n_vol = LD_DWORD(tbl + 12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (au & (au - 1)) au = 0; - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ - if (!au) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIRE / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win + MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl + 8, 63); /* Partition start in LBA */ - ST_DWORD(tbl + 12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win + BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl + BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl + BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl + BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl + BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl + BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */ - n = GET_FATTIME(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + BS_VolID32, n); /* VSN */ - ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */ - ST_WORD(tbl + BPB_BkBootSec, 6); /* Backup boot record offset (VBR + 6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl + BS_VolID, n); /* VSN */ - ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR + 6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl + 0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl + 4, 0xFFFFFFFF); - ST_DWORD(tbl + 8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) - return FR_DISK_ERR; - } while (--i); - -#if _USE_TRIM /* Erase data area if needed */ - { - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_TRIM, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl + FSI_LeadSig, 0x41615252); - ST_DWORD(tbl + FSI_StrucSig, 0x61417272); - ST_DWORD(tbl + FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl + FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl + BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR + 1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR + 7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Create partition table on the physical drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) != RES_OK || disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ff.h b/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ff.h deleted file mode 100644 index 28537b6..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ff.h +++ /dev/null @@ -1,350 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include R0.11 (C)ChaN, 2015 -/----------------------------------------------------------------------------/ -/ FatFs module is a free software that opened under license policy of -/ following conditions. -/ -/ Copyright (C) 2015, ChaN, all right reserved. -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/---------------------------------------------------------------------------*/ - - -#ifndef _FATFS -#define _FATFS 32020 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ -#if _FATFS != _FFCONF -#error Wrong configuration file (ffconf.h). -#endif - - - -/* Definitions of volume management */ - -#if _MULTI_PARTITION /* Multiple partition configuration */ -typedef struct { - BYTE pd; /* Physical drive number */ - BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ -} PARTITION; -extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ - -#else /* Single partition configuration */ -#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ -#define LD2PT(vol) 0 /* Find first valid partition or in SFD */ - -#endif - - - -/* Type of path name strings on FatFs API */ - -#if _LFN_UNICODE /* Unicode string */ -#if !_USE_LFN -#error _LFN_UNICODE must be 0 at non-LFN cfg. -#endif -#ifndef _INC_TCHAR -typedef WCHAR TCHAR; -#define _T(x) L ## x -#define _TEXT(x) L ## x -#endif - -#else /* ANSI/OEM string */ -#ifndef _INC_TCHAR -typedef char TCHAR; -#define _T(x) x -#define _TEXT(x) x -#endif - -#endif - - - -/* File system object structure (FATFS) */ - -typedef struct { - BYTE fs_type; /* FAT sub-type (0:Not mounted) */ - BYTE drv; /* Physical drive number */ - BYTE csize; /* Sectors per cluster (1,2,4...128) */ - BYTE n_fats; /* Number of FAT copies (1 or 2) */ - BYTE wflag; /* win[] flag (b0:dirty) */ - BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ - WORD id; /* File system mount ID */ - WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ -#if _MAX_SS != _MIN_SS - WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ -#endif -#if _FS_REENTRANT - _SYNC_t sobj; /* Identifier of sync object */ -#endif -#if !_FS_READONLY - DWORD last_clust; /* Last allocated cluster */ - DWORD free_clust; /* Number of free clusters */ -#endif -#if _FS_RPATH - DWORD cdir; /* Current directory start cluster (0:root) */ -#endif - DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ - DWORD fsize; /* Sectors per FAT */ - DWORD volbase; /* Volume start sector */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ - DWORD database; /* Data start sector */ - DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ -} FATFS; - - - -/* File object structure (FIL) */ - -typedef struct { - FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - BYTE flag; /* Status flags */ - BYTE err; /* Abort flag (error code) */ - DWORD fptr; /* File read/write pointer (Zeroed on file open) */ - DWORD fsize; /* File size */ - DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ - DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ - DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ -#if !_FS_READONLY - DWORD dir_sect; /* Sector number containing the directory entry */ - BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ -#endif -#if _USE_FASTSEEK - DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ -#endif -#if _FS_LOCK - UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ -#endif -#if !_FS_TINY - BYTE buf[_MAX_SS]; /* File private data read/write window */ -#endif -} FIL; - - - -/* Directory object structure (DIR) */ - -typedef struct { - FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ - WORD id; /* Owner file system mount ID (**do not change order**) */ - WORD index; /* Current read/write index number */ - DWORD sclust; /* Table start cluster (0:Root dir) */ - DWORD clust; /* Current cluster */ - DWORD sect; /* Current sector */ - BYTE* dir; /* Pointer to the current SFN entry in the win[] */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ -#if _FS_LOCK - UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ -#endif -#if _USE_LFN - WCHAR* lfn; /* Pointer to the LFN working buffer */ - WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ -#endif -#if _USE_FIND - const TCHAR* pat; /* Pointer to the name matching pattern */ -#endif -} DIR; - - - -/* File information structure (FILINFO) */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - TCHAR fname[13]; /* Short file name (8.3 format) */ -#if _USE_LFN - TCHAR* lfname; /* Pointer to the LFN buffer */ - UINT lfsize; /* Size of LFN buffer in TCHAR */ -#endif -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* (0) Succeeded */ - FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - FR_INT_ERR, /* (2) Assertion failed */ - FR_NOT_READY, /* (3) The physical drive cannot work */ - FR_NO_FILE, /* (4) Could not find the file */ - FR_NO_PATH, /* (5) Could not find the path */ - FR_INVALID_NAME, /* (6) The path name format is invalid */ - FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ - FR_EXIST, /* (8) Access denied due to prohibited access */ - FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ - FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ - FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* FatFs module application interface */ - -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ -FRESULT f_truncate (FIL* fp); /* Truncate file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ -FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (DIR* dp); /* Close an open directory */ -FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ -FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ -FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ -FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ -FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ -FRESULT f_chdir (const TCHAR* path); /* Change current directory */ -FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ -FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ -FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ -FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ -FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ - -#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) -#define f_error(fp) ((fp)->err) -#define f_tell(fp) ((fp)->fptr) -#define f_size(fp) ((fp)->fsize) -#define f_rewind(fp) f_lseek((fp), 0) -#define f_rewinddir(dp) f_readdir((dp), 0) - -#ifndef EOF -#define EOF (-1) -#endif - - - - -/*--------------------------------------------------------------*/ -/* Additional user defined functions */ - -/* RTC function */ -#if !_FS_READONLY && !_FS_NORTC -DWORD get_fattime (void); -#endif - -/* Unicode support functions */ -#if _USE_LFN /* Unicode - OEM code conversion */ -WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ -WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ -#if _USE_LFN == 3 /* Memory functions */ -void* ff_memalloc (UINT msize); /* Allocate memory block */ -void ff_memfree (void* mblock); /* Free memory block */ -#endif -#endif - -/* Sync functions */ -#if _FS_REENTRANT -int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ -int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ -void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ -int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ -#endif - - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File access control and file status flags (FIL.flag) */ - -#define FA_READ 0x01 -#define FA_OPEN_EXISTING 0x00 - -#if !_FS_READONLY -#define FA_WRITE 0x02 -#define FA_CREATE_NEW 0x04 -#define FA_CREATE_ALWAYS 0x08 -#define FA_OPEN_ALWAYS 0x10 -#define FA__WRITTEN 0x20 -#define FA__DIRTY 0x40 -#endif - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/* Fast seek feature */ -#define CREATE_LINKMAP 0xFFFFFFFF - - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _FATFS */ diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ffconf.h b/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ffconf.h deleted file mode 100644 index e9f71d2..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/ffconf.h +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015 -/---------------------------------------------------------------------------*/ - -#define _FFCONF 32020 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Functions and Buffer Configurations -/---------------------------------------------------------------------------*/ - -#define _FS_TINY 1 -/* 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_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 0 -/* 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 0 -/* 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 1 -/* 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 437 -/* 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 -/ 775 - Baltic -/ 850 - Multilingual Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 858 - Multilingual Latin 1 + Euro -/ 862 - Hebrew -/ 866 - Russian -/ 874 - Thai -/ 932 - Japanese Shift_JIS (DBCS) -/ 936 - Simplified Chinese GBK (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese Big5 (DBCS) -*/ - - -#define _USE_LFN 0 -#define _MAX_LFN 128 -/* 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 2 -/* 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 1 -/* Number of volumes (logical drives) to be used. */ - - -#define _STR_VOLUME_ID 0 -#define _VOLUME_STRS "CF","SD" -/* _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_NORTC 1 -#define _NORTC_MON 2 -#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.. */ - - -#define _WORD_ACCESS 1 -/* 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 processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 x86 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 8051 0/1 -*/ - diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/integer.h b/21_m1284p_WIZNET_TFTP_client_FATFS/ff/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/ff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/globals.c b/21_m1284p_WIZNET_TFTP_client_FATFS/globals.c deleted file mode 100644 index 39fa652..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/globals.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * globals.c - * - * Created on: 07 февр. 2019 г. - * Author: maxx - */ -#include "globals.h" - -#ifdef IP_WORK -//NIC metrics for WORK PC -uint8_t DNS_2nd[4] = {192, 168, 0, 1}; // Secondary DNS server IP -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 0, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 0, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -//PC TFTP server IP -uint8_t tftp_destip[4] = {192, 168, 0, 100}; -#else -//NIC metrics for another PC (second IP configuration) -uint8_t DNS_2nd[4] = {192, 168, 1, 1}; // Secondary DNS server IP -wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address - .ip = {192, 168, 1, 199}, // IP address - .sn = {255, 255, 255, 0}, // Subnet mask - .dns = {8,8,8,8}, // DNS address (google dns) - .gw = {192, 168, 1, 1}, // Gateway address - .dhcp = NETINFO_STATIC}; //Static IP configuration -//PC TFTP server IP -uint8_t tftp_destip[4] = {192, 168, 1, 81}; -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/globals.h b/21_m1284p_WIZNET_TFTP_client_FATFS/globals.h deleted file mode 100644 index ac75aba..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/globals.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * globals.h - * - * Created on: 29 нояб. 2018 г. - * Author: maxx - */ - -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#include -#include -#include -#include "avr/wdt.h" // WatchDog - -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" - -//******************************* Fat FS declare related: BEGIN - -#include "string.h" -#include "ff.h" -#include "diskio.h" -#include "integer.h" -//#include "Internet/httpServer_avr/httpParser.h" -static FATFS Fatfs; //File system object for each logical drive. >= 2 -//static FIL File; //File object. there are _FS_LOCK file objects available, >= 2 -//******************************* Fat FS declare related: END - - -//Should not use here -//#define HTTPD_MAX_BUF_SIZE 2048 //For Mega1284p(16kb RAM)/Mega2560(8kb RAM) -//#define HTTPD_MAX_BUF_SIZE MAX_URI_SIZE+10 //For Mega644p(4kb RAM)/Mega128(4kb RAM) (ie. 512+10=522 bytes look at httpParser.h <_st_http_request> definition) - -#define PRINTF_EN 1 -#if PRINTF_EN -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#else -#define PRINTF(...) -#endif - -//#define IP_WORK - -//SPI CLOCK 4 or 8Mhz -#define SPI_4_MHZ -//#define SPI_8_MHZ - -extern unsigned long millis(void); -extern int freeRam (void); - -//M644P/M1284p Users LEDS: -//LED1/PORTC.4- m644p/m1284p maxxir -#define led1_conf() DDRC |= (1< 512 bytes). - * OK(v1.3) 3. Write-in data to SD-card file "test.txt" and another patterns. - * OK(v1.4) 4. Print out "test.txt" contents head (from SD-Card ) in a serial terminal. - * OK(v1.5) 5. Add handlers for CHK_RAM_LEAKAGE && CHK_UPTIME. - * OK(v1.7) 6. Add FSM for TFTP client in main loop - * OK(v1.6) 7. All my debug code in tftp.c replace PRINTF(..) to DBG_PRINT(INFO_DBG, ..) - * OK(v1.7) 8. Add and check standard WIZNET TCP/UDP loopback - * - * Remark: - * Checked with PC tftp-server (WIN7) - tftpd64.exe - * - * Author of unofficial porting to AVR Mega1284p/644p + W5500 Ethernet NIC (Wiznet sockets library using without Arduino): - * Ibragimov Maxim aka maxxir, Russia Togliatty 31.03.2019 - */ - -#include -#include -#include -#include -#include //sbi, cbi etc.. -#include "avr/wdt.h" // WatchDog -#include // printf etc.. -#include "uart_extd.h" -#include "spi.h" - -#include "globals.h" //Global definitions for project - -#include "stdbool.h" -#include "Ethernet/socket.h" -#include "Ethernet/wizchip_conf.h" -#include "Application/loopback/loopback.h" -#include "Internet/TFTP/tftp.h" - -#define _MAIN_DEBUG_ - - -//***********Prologue for fast WDT disable & and save reason of reset/power-up: BEGIN -uint8_t mcucsr_mirror __attribute__ ((section (".noinit"))); - -// This is for fast WDT disable & and save reason of reset/power-up -void get_mcusr(void) \ - __attribute__((naked)) \ - __attribute__((section(".init3"))); -void get_mcusr(void) -{ - mcucsr_mirror = MCUSR; - MCUSR = 0; - wdt_disable(); -} -//***********Prologue for fast WDT disable & and save reason of reset/power-up: END - -//*********Global vars -#define TICK_PER_SEC 1000UL -volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days - -//*********Program metrics -const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции -const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции -const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.7 Static IP TFTP Client && FATFS SDCARD WIZNET_5500 ETHERNET 31/03/2019\r\n"; // Program name - -#if defined(__AVR_ATmega128__) -const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128 -#elif defined (__AVR_ATmega2560__) -const char PROGMEM str_mcu[] = "ATmega2560"; //CPU is m2560 -#elif defined (__AVR_ATmega2561__) -const char PROGMEM str_mcu[] = "ATmega2561"; //CPU is m2561 -#elif defined (__AVR_ATmega328P__) -const char PROGMEM str_mcu[] = "ATmega328P"; //CPU is m328p -#elif defined (__AVR_ATmega32U4__) -const char PROGMEM str_mcu[] = "ATmega32u4"; //CPU is m32u4 -#elif defined (__AVR_ATmega644P__) -const char PROGMEM str_mcu[] = "ATmega644p"; //CPU is m644p -#elif defined (__AVR_ATmega1284P__) -const char PROGMEM str_mcu[] = "ATmega1284p"; //CPU is m1284p -#else -const char PROGMEM str_mcu[] = "Unknown CPU"; //CPU is unknown -#endif - - -//FUNC headers -static void avr_init(void); -void timer0_init(void); - - -//Wiznet FUNC headers -void print_network_information(void); - -// RAM Memory usage test -int freeRam (void) -{ - extern int __heap_start, *__brkval; - int v; - int _res = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); - return _res; -} - - -//******************* MILLIS ENGINE: BEGIN -//ISR (TIMER0_COMP_vect ) -ISR (TIMER0_COMPA_vect) -{ - static uint16_t tftp_1sec; - // Compare match Timer0 - // Here every 1ms - _millis++; // INC millis tick - // Тест мигаем при в ходе в прерывание - // 500Hz FREQ OUT - // LED_TGL; - if(++tftp_1sec > 999) - { - //Here every 1 sec - tftp_1sec = 0; - //TFTP time handler - tftp_timeout_handler(); - } -} - -unsigned long millis(void) -{ - unsigned long i; - cli(); - // Atomic tick reading - i = _millis; - sei(); - return i; -} -//******************* MILLIS ENGINE: END - -//***************** UART0: BEGIN -// Assign I/O stream to UART -/* define CPU frequency in Mhz here if not defined in Makefile */ -//#ifndef F_CPU -//#define F_CPU 16000000UL -//#endif - -/* 19200 baud */ -//#define UART_BAUD_RATE 19200 -//#define UART_BAUD_RATE 38400 -#define UART_BAUD_RATE 115200 - -static int uart0_putchar(char ch,FILE *stream); -static void uart0_rx_flash(void); - -static FILE uart0_stdout = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); -//PS. stdin не переназначаю, т.к. удобнее с ним работать через uart.h - api: - -/* - * Т.е. например так - c = uart1_getc(); - if (( c & UART_NO_DATA ) == 0) - { - uart1_putc( (unsigned char)c ); - } - При этом чекаем что буфер приема не пуст и опрос идет неблокирующий (+ работаем через UART RX RINGBUFFER), - а если работаем в стиле stdin->getchar() там опрос блокируется пока символ не будет принят (поллинг) - через UART1_RX, т.е. неудобно. - */ - -// STDOUT UART0 TX handler -static int uart0_putchar(char ch,FILE *stream) -{ - uart_putc(ch); - return 0; -} - -// Очищаем буфер приема UART1 RX (иногда нужно) -static void uart0_rx_flash(void) -{ - // Считываем все из ring-buffer UART1 RX - unsigned int c; - do - { - c = uart_getc(); - } while (( c & UART_NO_DATA ) == 0); // Check RX1 none-empty - -} -//***************** UART0: END - -//***************** ADC: BEGIN - -#ifndef ADC_DIV -//12.5MHz or over use this ADC reference clock -#define ADC_DIV (1<> 9) + 1980, (_Finfo.fdate >> 5) & 15, _Finfo.fdate & 31, - (_Finfo.ftime >> 11), (_Finfo.ftime >> 5) & 63, - _Finfo.fsize, &(_Finfo.fname[0])); -#if _USE_LFN - for (p2 = strlen(_Finfo.fname); p2 < 14; p2++) - xputc(' '); - xprintf(PSTR("%s\r\n"), Lfname); -#else - PRINTF("\r\n"); -#endif - } - f_closedir(&Dir); -} - -void fatfs_head_file(const char * fn) -{ - FRESULT f_err_code; - FIL fil_obj; - //trying to open and read file.. - f_chdir("/"); - f_err_code=f_open(&fil_obj, fn,FA_READ); //Open *fn - for reading - if(f_err_code==0) - { - DWORD file_len = fil_obj.fsize; - UINT br; - uint8_t _buf[128] = {0, }; - PRINTF("++Content <%s> = %lu bytes found on SDCARD\r\n", fn, file_len); - PRINTF("++Trying to read head file..\r\n"); - f_err_code = f_read(&fil_obj,&_buf[0], 128, &br); - if(f_err_code == 0) - { - if(br < 128) - _buf[br] = 0x0; - else - _buf[127] = 0x0; - PRINTF("OK\r\n"); - PRINTF("text contents reading %u bytes:\r\n", br); - PRINTF("%s", _buf); - } - else - { - PRINTF ("ERROR "); - put_rc(f_err_code); - PRINTF("But anyway text contents:\r\n"); - PRINTF("%s", _buf); - } - f_close(&fil_obj); - } - else - { - PRINTF ("ERROR opening file <%s> ", fn); - put_rc(f_err_code); - } - PRINTF("\r\n"); -} - -void fatfs_init(void) -{ - if( disk_status (0) == STA_NOINIT ) // Initialise the SD Card here, before we do anything else. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, try again. - { - if( disk_initialize (0) ) // If it didn't initialise, or the card is write protected, then call it out. - { - PRINTF("\r\nSDCard initialization failed..!\r\nPlease power cycle the SDCard.\r\nCheck write protect.\r\n"); - PRINTF("\r\nReboot the Board"); - while(1) - { - _delay_ms(1000); - PRINTF("."); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - } - else - { - PRINTF("\r\nSDCard initialization OK\r\n"); - } - PRINTF(">>FS MOUNT "); - put_rc(f_mount(&Fatfs, (const TCHAR *)"", 1)); - PRINTF(">>GO ROOT DIRECTORY "); - put_rc(f_chdir((const TCHAR *)"/") ); - - PRINTF ("\r\n\r\nSD-Card root file list:\r\n"); - PRINTF ("===============================================\r\n"); - ls_dir("/"); - PRINTF ("===============================================\r\n\r\n"); - - } -} - - -//****************************FAT FS initialize: END - -int main() -{ - uint8_t prev_sw1 = 1; // VAR for sw1 pressing detect - - // INIT MCU - avr_init(); - spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5) - //spi_speed_tst(); / Here on SPI pins: MOSI 400Khz freq out, on SCLK 3.2MhzOUT (Witk SPI CLK 4Mhz) - - - // Print program metrics - PRINTF("%S", str_prog_name);// Название программы - PRINTF("Compiled at: %S %S\r\n", compile_time, compile_date);// Время Дата компиляции - PRINTF(">> MCU is: %S; CLK is: %luHz\r\n", str_mcu, F_CPU);// MCU Name && FREQ - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); - - - - //Short Blink LED 3 times on startup - unsigned char i = 3; - while(i--) - { - led1_high(); - _delay_ms(100); - led1_low(); - _delay_ms(400); - wdt_reset(); - } - - //FAT_FS init and quick test(root directory list && print out head index.htm) - fatfs_init(); - //fatfs_head_file("index.htm"); - - //Wizchip WIZ5500 Ethernet initialize - IO_LIBRARY_Init(); //After that ping must working - print_network_information(); - - //TFTP init - TFTP_init(SOCK_TFTP, g_tftp_socket_rcv_buf); - - - // Test for Ethernet data transfer validation - uint32_t timer_link_1sec = millis(); - uint32_t timer_sw1_1sec = millis(); - uint32_t timer_uptime_60sec = millis(); - uint8_t _ret = 0; - while(1) - { - //Here at least every 1sec - wdt_reset(); // WDT reset at least every sec - - //Use Hercules Terminal to check loopback tcp:5000 and udp:3000 - /* - * https://www.hw-group.com/software/hercules-setup-utility - * */ - loopback_tcps(SOCK_TCPS,ethBuf0,PORT_TCPS); - loopback_udps(SOCK_UDPS,ethBuf0,PORT_UDPS); - - //TFTPC FSM state - switch(tftpc_state) - { - case TFTPC_STOPPED: - //Wait here (unblocking) SW1 pressing - if((millis()-timer_sw1_1sec)> 1000) - { - //here every 1 sec - timer_sw1_1sec = millis(); - //!! SW1 pressing action - if(!sw1_read())// Check for SW1 pressed every second - { - // SW1 is pressed - //led1_high(); //LED1 ON - if(prev_sw1) - { - //!! Здесь по факту нажатия кнопки (1->0 SW1) - - PRINTF("\r\n########## SW1 was pressed.\r\n"); - tftpc_state = TFTPC_RUNNING; - - //!! Debug only - //PRINTF("SW1 is pressed\r\n"); - }//if(prev_sw1) - prev_sw1 = 0; // Store SW1 state for next iteration - }//if(!sw1_read()) - else - { - // SW1 is unpressed - //led1_low(); // LED1 OFF - prev_sw1 = 1;// Store SW1 state for next iteration - }//if(!sw1_read())else.. - } - break; - case TFTPC_RUNNING: - - memset(tftp_filename, 0x0, TFTP_FILE_NAME_SIZE); - //!!Don't forget about 8.3 file name rule!! - strncpy(tftp_filename, "test.txt", TFTP_FILE_NAME_SIZE); //pattern#1 test - //strncpy(tftp_filename, "README.md", TFTP_FILE_NAME_SIZE);//pattern#2 test - //strncpy(tftp_filename, "tftpd32.ini", TFTP_FILE_NAME_SIZE);//pattern#3 test - //strncpy(tftp_filename, "ff_lfn.txt", TFTP_FILE_NAME_SIZE);//pattern#4 test - //strncpy(tftp_filename, "dir.txt", TFTP_FILE_NAME_SIZE);//pattern#5 test - - tftp_server = ((uint32_t)tftp_destip[0] << 24) | ((uint32_t)tftp_destip[1] << 16) | ((uint32_t)tftp_destip[2] << 8) | ((uint32_t)tftp_destip[3]); - - PRINTF("TFTP IP address : %d.%d.%d.%d\r\n",tftp_destip[0],tftp_destip[1],tftp_destip[2],tftp_destip[3]); - PRINTF("TFTP IP address (32 bit) : 0x%lX\r\n",tftp_server); - - - - TFTP_read_request(tftp_server, tftp_filename); - clear_tftp_received_size(); - - tftpc_state = TFTPC_DATA_TRANSFER; - break; - case TFTPC_DATA_TRANSFER: - wdt_reset(); - _ret = TFTP_run(); //Proceed TFTPC transfer data - if(_ret != TFTP_PROGRESS) - { - //Print-out result TFTP complete - if(_ret == TFTP_SUCCESS) - { - PRINTF("\r\n++TFTP transfer complete:[%u] SUCCESS, received %lu bytes\r\n", _ret, get_tftp_received_size()); - - //Print-out head received file - fatfs_head_file(tftp_filename); - - } - else if(_ret == TFTP_FAIL) - { - PRINTF("\r\n--TFTP transfer complete:[%u] FAIL, received %lu bytes\r\n", _ret, get_tftp_received_size()); - } - else - { - PRINTF("\r\n??TFTP transfer complete:[%u] UNKNOWN, received %lu bytes\r\n\r\n", _ret, get_tftp_received_size()); - } - tftpc_state = TFTPC_STOPPED; - timer_sw1_1sec = millis(); - } - else - { - tftpc_state = TFTPC_DATA_TRANSFER; //bulletproof - } - break; - default: - tftpc_state = TFTPC_STOPPED; - break; - }//switch(tftpc_state) - - - if((millis()-timer_link_1sec)> 1000) - { - //here every 1 sec - timer_link_1sec = millis(); - - //Check ETHERNET PHY link - if(wizphy_getphylink() == PHY_LINK_ON) - { - led1_high(); - } - else - { - led1_low(); - } - - } - - if((millis()-timer_uptime_60sec)> 60000) - { - //here every 60 sec - timer_uptime_60sec = millis(); -#ifdef CHK_RAM_LEAKAGE - //Printout RAM usage every 1 minute - PRINTF(">> Free RAM is: %d bytes\r\n", freeRam()); -#endif - -#ifdef CHK_UPTIME - //Printout RAM usage every 1 minute - PRINTF(">> Uptime %lu sec\r\n", millis()/1000); -#endif - } - - - } - return 0; -} - -// Timer0 -// 1ms IRQ -// Used for millis() timing -void timer0_init(void) -{ - /* - * - * For M128 - TCCR0 = (1<250kHz:250-=>1kHz) - TIMSK |= 1<250kHz:250-=>1kHz) - TIMSK0 |= 1< - */ -/*-----------------------------------------------------------------------*/ -/* MMCv3/SDv1/SDv2 (in SPI mode) control module */ -/*-----------------------------------------------------------------------*/ -/* -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * This software 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. -/ -/-------------------------------------------------------------------------*/ - -#include -#include "diskio.h" -#include "globals.h" - -/* Port controls (Platform dependent) */ - -//!! M128 -//#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */ -//#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */ -//#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */ -//#define CSN 0 /*SPI - SS*/ -//#define SD_CS 6 /* PB.6 Output as CS*/ - -//!! ATMEGA644/1284 -#define SCK 7 /* - Output: SPI Serial Clock (SCLK) - ATMEGA644/1284 PORTB, PIN7 */ -#define MOSI 5 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA644/1284 PORTB, PIN5 */ -#define MISO 6 /* - Input: SPI Master in - slave out (MISO) - ATMEGA644/1284 PORTB, PIN6 */ -#define CSN 4 /*SPI - SS*/ -//#define SD_CS 2 /* PB.2 Output as CS*/ -#define SD_CS 0 /* PB.0 Output as CS*/ - - -#define CS_LOW() PORTB &= ~(1< is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card and wait for ready except to stop multiple block read */ - if (cmd != CMD12) { - deselect(); - if (!select()) return 0xFF; - } - - /* Send command packet */ - xchg_spi(0x40 | cmd); /* Start + Command index */ - xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xchg_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) + Stop */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) Stop */ - xchg_spi(n); - - /* Receive command response */ - if (cmd == CMD12) xchg_spi(0xFF); /* Skip a stuff byte when stop reading */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do - res = xchg_spi(0xFF); - while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - BYTE n, cmd, ty, ocr[4]; - - - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - power_off(); /* Turn off the socket power to reset the card */ - if (Stat & STA_NODISK) return Stat; /* No card in the socket */ - power_on(); /* Turn on the socket power */ - FCLK_SLOW(); - for (n = 10; n; n--) xchg_spi(0xFF); /* 80 dummy clocks */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - Timer1 = 100; /* Initialization timeout of 1000 msec */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - while (Timer1 && send_cmd(ACMD41, 1UL << 30)); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - while (Timer1 && send_cmd(cmd, 0)); /* Wait for leaving idle state */ - if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - if (ty) { /* Initialization succeded */ - Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ - FCLK_FAST(); - } else { /* Initialization failed */ - power_off(); - } - - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Get Disk Status */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0) */ -) -{ - if (pdrv) return STA_NOINIT; /* Supports only single drive */ - return Stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Sector(s) */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE *buff, /* Pointer to the data buffer to store read data */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - BYTE cmd; - - - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */ - if (send_cmd(cmd, sector) == 0) { - do { - if (!rcvr_datablock(buff, 512)) break; - buff += 512; - } while (--count); - if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Sector(s) */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0) */ - const BYTE *buff, /* Pointer to the data to be written */ - DWORD sector, /* Start sector number (LBA) */ - UINT count /* Sector count (1..128) */ -) -{ - if (pdrv || !count) return RES_PARERR; - if (Stat & STA_NOINIT) return RES_NOTRDY; - if (Stat & STA_PROTECT) return RES_WRPRT; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - if (count == 1) { /* Single block write */ - if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */ - && xmit_datablock(buff, 0xFE)) - count = 0; - } - else { /* Multiple block write */ - if (CardType & CT_SDC) send_cmd(ACMD23, count); - if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */ - do { - if (!xmit_datablock(buff, 0xFC)) break; - buff += 512; - } while (--count); - if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */ - count = 1; - } - } - deselect(); - - return count ? RES_ERROR : RES_OK; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ -/*-----------------------------------------------------------------------*/ - -#if _USE_IOCTL -DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive nmuber (0) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - DRESULT res; - BYTE n, csd[16], *ptr = buff; - DWORD csize; - - - if (pdrv) return RES_PARERR; - - res = RES_ERROR; - - if (Stat & STA_NOINIT) return RES_NOTRDY; - - switch (cmd) { - case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */ - if (select()) res = RES_OK; - break; - - case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { - if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */ - csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1; - *(DWORD*)buff = csize << 10; - } else { /* SDC ver 1.XX or MMC*/ - n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; - csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; - *(DWORD*)buff = csize << (n - 9); - } - res = RES_OK; - } - break; - - case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */ - if (CardType & CT_SD2) { /* SDv2? */ - if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */ - xchg_spi(0xFF); - if (rcvr_datablock(csd, 16)) { /* Read partial block */ - for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */ - *(DWORD*)buff = 16UL << (csd[10] >> 4); - res = RES_OK; - } - } - } else { /* SDv1 or MMCv3 */ - if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */ - if (CardType & CT_SD1) { /* SDv1 */ - *(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1); - } else { /* MMCv3 */ - *(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1); - } - res = RES_OK; - } - } - break; - - /* Following commands are never used by FatFs module */ - - case MMC_GET_TYPE : /* Get card type flags (1 byte) */ - *ptr = CardType; - res = RES_OK; - break; - - case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */ - if (send_cmd(CMD9, 0) == 0 /* READ_CSD */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */ - if (send_cmd(CMD10, 0) == 0 /* READ_CID */ - && rcvr_datablock(ptr, 16)) - res = RES_OK; - break; - - case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */ - if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */ - for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF); - res = RES_OK; - } - break; - - case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */ - if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */ - xchg_spi(0xFF); - if (rcvr_datablock(ptr, 64)) - res = RES_OK; - } - break; - - case CTRL_POWER_OFF : /* Power off */ - power_off(); - Stat |= STA_NOINIT; - res = RES_OK; - break; - - default: - res = RES_PARERR; - } - - deselect(); - - return res; -} -#endif - - -/*-----------------------------------------------------------------------*/ -/* Device Timer Interrupt Procedure */ -/*-----------------------------------------------------------------------*/ -/* This function must be called in period of 10ms */ - -void disk_timerproc (void) -{ - BYTE n, s; - - - n = Timer1; /* 100Hz decrement timer */ - if (n) Timer1 = --n; - n = Timer2; - if (n) Timer2 = --n; - - s = Stat; - - if (MMC_WP) /* Write protected */ - s |= STA_PROTECT; - else /* Write enabled */ - s &= ~STA_PROTECT; - - if (MMC_CD) /* Card inserted */ - s &= ~STA_NODISK; - else /* Socket empty */ - s |= (STA_NODISK | STA_NOINIT); - - Stat = s; /* Update MMC status */ -} diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/spi.c b/21_m1284p_WIZNET_TFTP_client_FATFS/spi.c deleted file mode 100644 index 47d9c33..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/spi.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "spi.h" -#include "globals.h" - -/* - * Initialize SPI bus. - */ - -//~ // From working SPI ENC28J60 driver -//~ #define ENC28J60_CONTROL_PORT PORTB -//~ #define ENC28J60_CONTROL_DDR DDRB -//~ -//~ #define ENC28J60_CONTROL_CS PORTB6 -//~ #define ENC28J60_CONTROL_SO PORTB3 -//~ #define ENC28J60_CONTROL_SI PORTB2 -//~ #define ENC28J60_CONTROL_SCK PORTB1 -//~ #define ENC28J60_CONTROL_SS PORTB0 -//~ -//~ // set CS to 0 = active -//~ #define CSACTIVE ENC28J60_CONTROL_PORT&=~(1< -#include "FatFs/ffconf.h" -#include "FatFs/ff.h" - -#if (_USE_LFN == 2) - -static -const unsigned short Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, - 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, - 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, - 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, - 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, - 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, - 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, - 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, - 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 -}; - - -WCHAR ff_convert ( /* Converted character, Returns zero on error */ - WCHAR src, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */ -) -{ - WCHAR c; - - - if (src < 0x80) { /* ASCII */ - c = src; - - } else { - if (dir) { /* OEMCP to Unicode */ - c = (src >= 0x100) ? 0 : Tbl[src - 0x80]; - - } else { /* Unicode to OEMCP */ - for (c = 0; c < 0x80; c++) { - if (src == Tbl[c]) break; - } - c = (c + 0x80) & 0xFF; - } - } - - return c; -} - - -WCHAR ff_wtoupper(WCHAR chr) -{ - if(chr >= 'a' && chr <= 'z') - return (chr - 32); - else - return chr; -} - -#elif (_USE_LFN == 1) || (_USE_LFN == 3) - -#define _TINY_TABLE 1 - -static -const WCHAR uni2sjis[] = { -/* Unicode - Sjis, Unicode - Sjis, Unicode - Sjis, Unicode - Sjis, */ - 0x00A7, 0x8198, 0x00A8, 0x814E, 0x00B0, 0x818B, 0x00B1, 0x817D, - 0x00B4, 0x814C, 0x00B6, 0x81F7, 0x00D7, 0x817E, 0x00F7, 0x8180, - 0x0391, 0x839F, 0x0392, 0x83A0, 0x0393, 0x83A1, 0x0394, 0x83A2, - 0x0395, 0x83A3, 0x0396, 0x83A4, 0x0397, 0x83A5, 0x0398, 0x83A6, - 0x0399, 0x83A7, 0x039A, 0x83A8, 0x039B, 0x83A9, 0x039C, 0x83AA, - 0x039D, 0x83AB, 0x039E, 0x83AC, 0x039F, 0x83AD, 0x03A0, 0x83AE, - 0x03A1, 0x83AF, 0x03A3, 0x83B0, 0x03A4, 0x83B1, 0x03A5, 0x83B2, - 0x03A6, 0x83B3, 0x03A7, 0x83B4, 0x03A8, 0x83B5, 0x03A9, 0x83B6, - 0x03B1, 0x83BF, 0x03B2, 0x83C0, 0x03B3, 0x83C1, 0x03B4, 0x83C2, - 0x03B5, 0x83C3, 0x03B6, 0x83C4, 0x03B7, 0x83C5, 0x03B8, 0x83C6, - 0x03B9, 0x83C7, 0x03BA, 0x83C8, 0x03BB, 0x83C9, 0x03BC, 0x83CA, - 0x03BD, 0x83CB, 0x03BE, 0x83CC, 0x03BF, 0x83CD, 0x03C0, 0x83CE, - 0x03C1, 0x83CF, 0x03C3, 0x83D0, 0x03C4, 0x83D1, 0x03C5, 0x83D2, - 0x03C6, 0x83D3, 0x03C7, 0x83D4, 0x03C8, 0x83D5, 0x03C9, 0x83D6, - 0x0401, 0x8446, 0x0410, 0x8440, 0x0411, 0x8441, 0x0412, 0x8442, - 0x0413, 0x8443, 0x0414, 0x8444, 0x0415, 0x8445, 0x0416, 0x8447, - 0x0417, 0x8448, 0x0418, 0x8449, 0x0419, 0x844A, 0x041A, 0x844B, - 0x041B, 0x844C, 0x041C, 0x844D, 0x041D, 0x844E, 0x041E, 0x844F, - 0x041F, 0x8450, 0x0420, 0x8451, 0x0421, 0x8452, 0x0422, 0x8453, - 0x0423, 0x8454, 0x0424, 0x8455, 0x0425, 0x8456, 0x0426, 0x8457, - 0x0427, 0x8458, 0x0428, 0x8459, 0x0429, 0x845A, 0x042A, 0x845B, - 0x042B, 0x845C, 0x042C, 0x845D, 0x042D, 0x845E, 0x042E, 0x845F, - 0x042F, 0x8460, 0x0430, 0x8470, 0x0431, 0x8471, 0x0432, 0x8472, - 0x0433, 0x8473, 0x0434, 0x8474, 0x0435, 0x8475, 0x0436, 0x8477, - 0x0437, 0x8478, 0x0438, 0x8479, 0x0439, 0x847A, 0x043A, 0x847B, - 0x043B, 0x847C, 0x043C, 0x847D, 0x043D, 0x847E, 0x043E, 0x8480, - 0x043F, 0x8481, 0x0440, 0x8482, 0x0441, 0x8483, 0x0442, 0x8484, - 0x0443, 0x8485, 0x0444, 0x8486, 0x0445, 0x8487, 0x0446, 0x8488, - 0x0447, 0x8489, 0x0448, 0x848A, 0x0449, 0x848B, 0x044A, 0x848C, - 0x044B, 0x848D, 0x044C, 0x848E, 0x044D, 0x848F, 0x044E, 0x8490, - 0x044F, 0x8491, 0x0451, 0x8476, 0x2010, 0x815D, 0x2015, 0x815C, - 0x2018, 0x8165, 0x2019, 0x8166, 0x201C, 0x8167, 0x201D, 0x8168, - 0x2020, 0x81F5, 0x2021, 0x81F6, 0x2025, 0x8164, 0x2026, 0x8163, - 0x2030, 0x81F1, 0x2032, 0x818C, 0x2033, 0x818D, 0x203B, 0x81A6, - 0x2103, 0x818E, 0x2116, 0x8782, 0x2121, 0x8784, 0x212B, 0x81F0, - 0x2160, 0x8754, 0x2161, 0x8755, 0x2162, 0x8756, 0x2163, 0x8757, - 0x2164, 0x8758, 0x2165, 0x8759, 0x2166, 0x875A, 0x2167, 0x875B, - 0x2168, 0x875C, 0x2169, 0x875D, 0x2170, 0xFA40, 0x2171, 0xFA41, - 0x2172, 0xFA42, 0x2173, 0xFA43, 0x2174, 0xFA44, 0x2175, 0xFA45, - 0x2176, 0xFA46, 0x2177, 0xFA47, 0x2178, 0xFA48, 0x2179, 0xFA49, - 0x2190, 0x81A9, 0x2191, 0x81AA, 0x2192, 0x81A8, 0x2193, 0x81AB, - 0x21D2, 0x81CB, 0x21D4, 0x81CC, 0x2200, 0x81CD, 0x2202, 0x81DD, - 0x2203, 0x81CE, 0x2207, 0x81DE, 0x2208, 0x81B8, 0x220B, 0x81B9, - 0x2211, 0x8794, 0x221A, 0x81E3, 0x221D, 0x81E5, 0x221E, 0x8187, - 0x221F, 0x8798, 0x2220, 0x81DA, 0x2225, 0x8161, 0x2227, 0x81C8, - 0x2228, 0x81C9, 0x2229, 0x81BF, 0x222A, 0x81BE, 0x222B, 0x81E7, - 0x222C, 0x81E8, 0x222E, 0x8793, 0x2234, 0x8188, 0x2235, 0x81E6, - 0x223D, 0x81E4, 0x2252, 0x81E0, 0x2260, 0x8182, 0x2261, 0x81DF, - 0x2266, 0x8185, 0x2267, 0x8186, 0x226A, 0x81E1, 0x226B, 0x81E2, - 0x2282, 0x81BC, 0x2283, 0x81BD, 0x2286, 0x81BA, 0x2287, 0x81BB, - 0x22A5, 0x81DB, 0x22BF, 0x8799, 0x2312, 0x81DC, 0x2460, 0x8740, - 0x2461, 0x8741, 0x2462, 0x8742, 0x2463, 0x8743, 0x2464, 0x8744, - 0x2465, 0x8745, 0x2466, 0x8746, 0x2467, 0x8747, 0x2468, 0x8748, - 0x2469, 0x8749, 0x246A, 0x874A, 0x246B, 0x874B, 0x246C, 0x874C, - 0x246D, 0x874D, 0x246E, 0x874E, 0x246F, 0x874F, 0x2470, 0x8750, - 0x2471, 0x8751, 0x2472, 0x8752, 0x2473, 0x8753, 0x2500, 0x849F, - 0x2501, 0x84AA, 0x2502, 0x84A0, 0x2503, 0x84AB, 0x250C, 0x84A1, - 0x250F, 0x84AC, 0x2510, 0x84A2, 0x2513, 0x84AD, 0x2514, 0x84A4, - 0x2517, 0x84AF, 0x2518, 0x84A3, 0x251B, 0x84AE, 0x251C, 0x84A5, - 0x251D, 0x84BA, 0x2520, 0x84B5, 0x2523, 0x84B0, 0x2524, 0x84A7, - 0x2525, 0x84BC, 0x2528, 0x84B7, 0x252B, 0x84B2, 0x252C, 0x84A6, - 0x252F, 0x84B6, 0x2530, 0x84BB, 0x2533, 0x84B1, 0x2534, 0x84A8, - 0x2537, 0x84B8, 0x2538, 0x84BD, 0x253B, 0x84B3, 0x253C, 0x84A9, - 0x253F, 0x84B9, 0x2542, 0x84BE, 0x254B, 0x84B4, 0x25A0, 0x81A1, - 0x25A1, 0x81A0, 0x25B2, 0x81A3, 0x25B3, 0x81A2, 0x25BC, 0x81A5, - 0x25BD, 0x81A4, 0x25C6, 0x819F, 0x25C7, 0x819E, 0x25CB, 0x819B, - 0x25CE, 0x819D, 0x25CF, 0x819C, 0x25EF, 0x81FC, 0x2605, 0x819A, - 0x2606, 0x8199, 0x2640, 0x818A, 0x2642, 0x8189, 0x266A, 0x81F4, - 0x266D, 0x81F3, 0x266F, 0x81F2, 0x3000, 0x8140, 0x3001, 0x8141, - 0x3002, 0x8142, 0x3003, 0x8156, 0x3005, 0x8158, 0x3006, 0x8159, - 0x3007, 0x815A, 0x3008, 0x8171, 0x3009, 0x8172, 0x300A, 0x8173, - 0x300B, 0x8174, 0x300C, 0x8175, 0x300D, 0x8176, 0x300E, 0x8177, - 0x300F, 0x8178, 0x3010, 0x8179, 0x3011, 0x817A, 0x3012, 0x81A7, - 0x3013, 0x81AC, 0x3014, 0x816B, 0x3015, 0x816C, 0x301D, 0x8780, - 0x301F, 0x8781, 0x3041, 0x829F, 0x3042, 0x82A0, 0x3043, 0x82A1, - 0x3044, 0x82A2, 0x3045, 0x82A3, 0x3046, 0x82A4, 0x3047, 0x82A5, - 0x3048, 0x82A6, 0x3049, 0x82A7, 0x304A, 0x82A8, 0x304B, 0x82A9, - 0x304C, 0x82AA, 0x304D, 0x82AB, 0x304E, 0x82AC, 0x304F, 0x82AD, - 0x3050, 0x82AE, 0x3051, 0x82AF, 0x3052, 0x82B0, 0x3053, 0x82B1, - 0x3054, 0x82B2, 0x3055, 0x82B3, 0x3056, 0x82B4, 0x3057, 0x82B5, - 0x3058, 0x82B6, 0x3059, 0x82B7, 0x305A, 0x82B8, 0x305B, 0x82B9, - 0x305C, 0x82BA, 0x305D, 0x82BB, 0x305E, 0x82BC, 0x305F, 0x82BD, - 0x3060, 0x82BE, 0x3061, 0x82BF, 0x3062, 0x82C0, 0x3063, 0x82C1, - 0x3064, 0x82C2, 0x3065, 0x82C3, 0x3066, 0x82C4, 0x3067, 0x82C5, - 0x3068, 0x82C6, 0x3069, 0x82C7, 0x306A, 0x82C8, 0x306B, 0x82C9, - 0x306C, 0x82CA, 0x306D, 0x82CB, 0x306E, 0x82CC, 0x306F, 0x82CD, - 0x3070, 0x82CE, 0x3071, 0x82CF, 0x3072, 0x82D0, 0x3073, 0x82D1, - 0x3074, 0x82D2, 0x3075, 0x82D3, 0x3076, 0x82D4, 0x3077, 0x82D5, - 0x3078, 0x82D6, 0x3079, 0x82D7, 0x307A, 0x82D8, 0x307B, 0x82D9, - 0x307C, 0x82DA, 0x307D, 0x82DB, 0x307E, 0x82DC, 0x307F, 0x82DD, - 0x3080, 0x82DE, 0x3081, 0x82DF, 0x3082, 0x82E0, 0x3083, 0x82E1, - 0x3084, 0x82E2, 0x3085, 0x82E3, 0x3086, 0x82E4, 0x3087, 0x82E5, - 0x3088, 0x82E6, 0x3089, 0x82E7, 0x308A, 0x82E8, 0x308B, 0x82E9, - 0x308C, 0x82EA, 0x308D, 0x82EB, 0x308E, 0x82EC, 0x308F, 0x82ED, - 0x3090, 0x82EE, 0x3091, 0x82EF, 0x3092, 0x82F0, 0x3093, 0x82F1, - 0x309B, 0x814A, 0x309C, 0x814B, 0x309D, 0x8154, - 0x309E, 0x8155, 0x30A1, 0x8340, 0x30A2, 0x8341, 0x30A3, 0x8342, - 0x30A4, 0x8343, 0x30A5, 0x8344, 0x30A6, 0x8345, 0x30A7, 0x8346, - 0x30A8, 0x8347, 0x30A9, 0x8348, 0x30AA, 0x8349, 0x30AB, 0x834A, - 0x30AC, 0x834B, 0x30AD, 0x834C, 0x30AE, 0x834D, 0x30AF, 0x834E, - 0x30B0, 0x834F, 0x30B1, 0x8350, 0x30B2, 0x8351, 0x30B3, 0x8352, - 0x30B4, 0x8353, 0x30B5, 0x8354, 0x30B6, 0x8355, 0x30B7, 0x8356, - 0x30B8, 0x8357, 0x30B9, 0x8358, 0x30BA, 0x8359, 0x30BB, 0x835A, - 0x30BC, 0x835B, 0x30BD, 0x835C, 0x30BE, 0x835D, 0x30BF, 0x835E, - 0x30C0, 0x835F, 0x30C1, 0x8360, 0x30C2, 0x8361, 0x30C3, 0x8362, - 0x30C4, 0x8363, 0x30C5, 0x8364, 0x30C6, 0x8365, 0x30C7, 0x8366, - 0x30C8, 0x8367, 0x30C9, 0x8368, 0x30CA, 0x8369, 0x30CB, 0x836A, - 0x30CC, 0x836B, 0x30CD, 0x836C, 0x30CE, 0x836D, 0x30CF, 0x836E, - 0x30D0, 0x836F, 0x30D1, 0x8370, 0x30D2, 0x8371, 0x30D3, 0x8372, - 0x30D4, 0x8373, 0x30D5, 0x8374, 0x30D6, 0x8375, 0x30D7, 0x8376, - 0x30D8, 0x8377, 0x30D9, 0x8378, 0x30DA, 0x8379, 0x30DB, 0x837A, - 0x30DC, 0x837B, 0x30DD, 0x837C, 0x30DE, 0x837D, 0x30DF, 0x837E, - 0x30E0, 0x8380, 0x30E1, 0x8381, 0x30E2, 0x8382, 0x30E3, 0x8383, - 0x30E4, 0x8384, 0x30E5, 0x8385, 0x30E6, 0x8386, 0x30E7, 0x8387, - 0x30E8, 0x8388, 0x30E9, 0x8389, 0x30EA, 0x838A, 0x30EB, 0x838B, - 0x30EC, 0x838C, 0x30ED, 0x838D, 0x30EE, 0x838E, 0x30EF, 0x838F, - 0x30F0, 0x8390, 0x30F1, 0x8391, 0x30F2, 0x8392, 0x30F3, 0x8393, - 0x30F4, 0x8394, 0x30F5, 0x8395, 0x30F6, 0x8396, 0x30FB, 0x8145, - 0x30FC, 0x815B, 0x30FD, 0x8152, 0x30FE, 0x8153, 0x3231, 0x878A, - 0x3232, 0x878B, 0x3239, 0x878C, 0x32A4, 0x8785, 0x32A5, 0x8786, - 0x32A6, 0x8787, 0x32A7, 0x8788, 0x32A8, 0x8789, 0x3303, 0x8765, - 0x330D, 0x8769, 0x3314, 0x8760, 0x3318, 0x8763, 0x3322, 0x8761, - 0x3323, 0x876B, 0x3326, 0x876A, 0x3327, 0x8764, 0x332B, 0x876C, - 0x3336, 0x8766, 0x333B, 0x876E, 0x3349, 0x875F, 0x334A, 0x876D, - 0x334D, 0x8762, 0x3351, 0x8767, 0x3357, 0x8768, 0x337B, 0x877E, - 0x337C, 0x878F, 0x337D, 0x878E, 0x337E, 0x878D, 0x338E, 0x8772, - 0x338F, 0x8773, 0x339C, 0x876F, 0x339D, 0x8770, 0x339E, 0x8771, - 0x33A1, 0x8775, 0x33C4, 0x8774, 0x33CD, 0x8783, 0x4E00, 0x88EA, - 0x4E01, 0x929A, 0x4E03, 0x8EB5, 0x4E07, 0x969C, 0x4E08, 0x8FE4, - 0x4E09, 0x8E4F, 0x4E0A, 0x8FE3, 0x4E0B, 0x89BA, 0x4E0D, 0x9573, - 0x4E0E, 0x975E, 0x4E10, 0x98A0, 0x4E11, 0x894E, 0x4E14, 0x8A8E, - 0x4E15, 0x98A1, 0x4E16, 0x90A2, 0x4E17, 0x99C0, 0x4E18, 0x8B75, - 0x4E19, 0x95B8, 0x4E1E, 0x8FE5, 0x4E21, 0x97BC, 0x4E26, 0x95C0, - 0x4E28, 0xFA68, 0x4E2A, 0x98A2, 0x4E2D, 0x9286, 0x4E31, 0x98A3, - 0x4E32, 0x8BF8, 0x4E36, 0x98A4, 0x4E38, 0x8ADB, 0x4E39, 0x924F, - 0x4E3B, 0x8EE5, 0x4E3C, 0x98A5, 0x4E3F, 0x98A6, 0x4E42, 0x98A7, - 0x4E43, 0x9454, 0x4E45, 0x8B76, 0x4E4B, 0x9456, 0x4E4D, 0x93E1, - 0x4E4E, 0x8CC1, 0x4E4F, 0x9652, 0x4E55, 0xE568, 0x4E56, 0x98A8, - 0x4E57, 0x8FE6, 0x4E58, 0x98A9, 0x4E59, 0x89B3, 0x4E5D, 0x8BE3, - 0x4E5E, 0x8CEE, 0x4E5F, 0x96E7, 0x4E62, 0x9BA4, 0x4E71, 0x9790, - 0x4E73, 0x93FB, 0x4E7E, 0x8AA3, 0x4E80, 0x8B54, 0x4E82, 0x98AA, - 0x4E85, 0x98AB, 0x4E86, 0x97B9, 0x4E88, 0x975C, 0x4E89, 0x9188, - 0x4E8A, 0x98AD, 0x4E8B, 0x8E96, 0x4E8C, 0x93F1, 0x4E8E, 0x98B0, - 0x4E91, 0x895D, 0x4E92, 0x8CDD, 0x4E94, 0x8CDC, 0x4E95, 0x88E4, - 0x4E98, 0x986A, 0x4E99, 0x9869, 0x4E9B, 0x8DB1, 0x4E9C, 0x889F, - 0x4E9E, 0x98B1, 0x4E9F, 0x98B2, 0x4EA0, 0x98B3, 0x4EA1, 0x9653, - 0x4EA2, 0x98B4, 0x4EA4, 0x8CF0, 0x4EA5, 0x88E5, 0x4EA6, 0x9692, - 0x4EA8, 0x8B9C, 0x4EAB, 0x8B9D, 0x4EAC, 0x8B9E, 0x4EAD, 0x92E0, - 0x4EAE, 0x97BA, 0x4EB0, 0x98B5, 0x4EB3, 0x98B6, 0x4EB6, 0x98B7, - 0x4EBA, 0x906C, 0x4EC0, 0x8F59, 0x4EC1, 0x906D, 0x4EC2, 0x98BC, - 0x4EC4, 0x98BA, 0x4EC6, 0x98BB, 0x4EC7, 0x8B77, 0x4ECA, 0x8DA1, - 0x4ECB, 0x89EE, 0x4ECD, 0x98B9, 0x4ECE, 0x98B8, 0x4ECF, 0x95A7, - 0x4ED4, 0x8E65, 0x4ED5, 0x8E64, 0x4ED6, 0x91BC, 0x4ED7, 0x98BD, - 0x4ED8, 0x9574, 0x4ED9, 0x90E5, 0x4EDD, 0x8157, 0x4EDE, 0x98BE, - 0x4EDF, 0x98C0, 0x4EE1, 0xFA69, 0x4EE3, 0x91E3, 0x4EE4, 0x97DF, - 0x4EE5, 0x88C8, 0x4EED, 0x98BF, 0x4EEE, 0x89BC, 0x4EF0, 0x8BC2, - 0x4EF2, 0x9287, 0x4EF6, 0x8C8F, 0x4EF7, 0x98C1, 0x4EFB, 0x9443, - 0x4EFC, 0xFA6A, 0x4F00, 0xFA6B, 0x4F01, 0x8AE9, 0x4F03, 0xFA6C, - 0x4F09, 0x98C2, 0x4F0A, 0x88C9, 0x4F0D, 0x8CDE, 0x4F0E, 0x8AEA, - 0x4F0F, 0x959A, 0x4F10, 0x94B0, 0x4F11, 0x8B78, 0x4F1A, 0x89EF, - 0x4F1C, 0x98E5, 0x4F1D, 0x9360, 0x4F2F, 0x948C, 0x4F30, 0x98C4, - 0x4F34, 0x94BA, 0x4F36, 0x97E0, 0x4F38, 0x904C, 0x4F39, 0xFA6D, - 0x4F3A, 0x8E66, 0x4F3C, 0x8E97, 0x4F3D, 0x89BE, 0x4F43, 0x92CF, - 0x4F46, 0x9241, 0x4F47, 0x98C8, 0x4F4D, 0x88CA, 0x4F4E, 0x92E1, - 0x4F4F, 0x8F5A, 0x4F50, 0x8DB2, 0x4F51, 0x9743, 0x4F53, 0x91CC, - 0x4F55, 0x89BD, 0x4F56, 0xFA6E, 0x4F57, 0x98C7, 0x4F59, 0x975D, - 0x4F5A, 0x98C3, 0x4F5B, 0x98C5, 0x4F5C, 0x8DEC, 0x4F5D, 0x98C6, - 0x4F5E, 0x9B43, 0x4F69, 0x98CE, 0x4F6F, 0x98D1, 0x4F70, 0x98CF, - 0x4F73, 0x89C0, 0x4F75, 0x95B9, 0x4F76, 0x98C9, 0x4F7B, 0x98CD, - 0x4F7C, 0x8CF1, 0x4F7F, 0x8E67, 0x4F83, 0x8AA4, 0x4F86, 0x98D2, - 0x4F88, 0x98CA, 0x4F8A, 0xFA70, 0x4F8B, 0x97E1, 0x4F8D, 0x8E98, - 0x4F8F, 0x98CB, 0x4F91, 0x98D0, 0x4F92, 0xFA6F, 0x4F94, 0xFA72, - 0x4F96, 0x98D3, 0x4F98, 0x98CC, 0x4F9A, 0xFA71, 0x4F9B, 0x8B9F, - 0x4F9D, 0x88CB, 0x4FA0, 0x8BA0, 0x4FA1, 0x89BF, 0x4FAB, 0x9B44, - 0x4FAD, 0x9699, 0x4FAE, 0x958E, 0x4FAF, 0x8CF2, 0x4FB5, 0x904E, - 0x4FB6, 0x97B5, 0x4FBF, 0x95D6, 0x4FC2, 0x8C57, 0x4FC3, 0x91A3, - 0x4FC4, 0x89E2, 0x4FC9, 0xFA61, 0x4FCA, 0x8F72, 0x4FCD, 0xFA73, - 0x4FCE, 0x98D7, 0x4FD0, 0x98DC, 0x4FD1, 0x98DA, 0x4FD4, 0x98D5, - 0x4FD7, 0x91AD, 0x4FD8, 0x98D8, 0x4FDA, 0x98DB, 0x4FDB, 0x98D9, - 0x4FDD, 0x95DB, 0x4FDF, 0x98D6, 0x4FE1, 0x904D, 0x4FE3, 0x9693, - 0x4FE4, 0x98DD, 0x4FE5, 0x98DE, 0x4FEE, 0x8F43, 0x4FEF, 0x98EB, - 0x4FF3, 0x946F, 0x4FF5, 0x9555, 0x4FF6, 0x98E6, 0x4FF8, 0x95EE, - 0x4FFA, 0x89B4, 0x4FFE, 0x98EA, 0x4FFF, 0xFA76, 0x5005, 0x98E4, - 0x5006, 0x98ED, 0x5009, 0x9171, 0x500B, 0x8CC2, 0x500D, 0x947B, - 0x500F, 0xE0C5, 0x5011, 0x98EC, 0x5012, 0x937C, 0x5014, 0x98E1, - 0x5016, 0x8CF4, 0x5019, 0x8CF3, 0x501A, 0x98DF, 0x501E, 0xFA77, - 0x501F, 0x8ED8, 0x5021, 0x98E7, 0x5022, 0xFA75, 0x5023, 0x95ED, - 0x5024, 0x926C, 0x5025, 0x98E3, 0x5026, 0x8C91, 0x5028, 0x98E0, - 0x5029, 0x98E8, 0x502A, 0x98E2, 0x502B, 0x97CF, 0x502C, 0x98E9, - 0x502D, 0x9860, 0x5036, 0x8BE4, 0x5039, 0x8C90, 0x5040, 0xFA74, - 0x5042, 0xFA7A, 0x5043, 0x98EE, 0x5046, 0xFA78, 0x5047, 0x98EF, - 0x5048, 0x98F3, 0x5049, 0x88CC, 0x504F, 0x95CE, 0x5050, 0x98F2, - 0x5055, 0x98F1, 0x5056, 0x98F5, 0x505A, 0x98F4, 0x505C, 0x92E2, - 0x5065, 0x8C92, 0x506C, 0x98F6, 0x5070, 0xFA79, 0x5072, 0x8EC3, - 0x5074, 0x91A4, 0x5075, 0x92E3, 0x5076, 0x8BF4, 0x5078, 0x98F7, - 0x507D, 0x8B55, 0x5080, 0x98F8, 0x5085, 0x98FA, 0x508D, 0x9654, - 0x5091, 0x8C86, 0x5094, 0xFA7B, 0x5098, 0x8E50, 0x5099, 0x94F5, - 0x509A, 0x98F9, 0x50AC, 0x8DC3, 0x50AD, 0x9762, 0x50B2, 0x98FC, - 0x50B3, 0x9942, 0x50B4, 0x98FB, 0x50B5, 0x8DC2, 0x50B7, 0x8F9D, - 0x50BE, 0x8C58, 0x50C2, 0x9943, 0x50C5, 0x8BCD, 0x50C9, 0x9940, - 0x50CA, 0x9941, 0x50CD, 0x93AD, 0x50CF, 0x919C, 0x50D1, 0x8BA1, - 0x50D5, 0x966C, 0x50D6, 0x9944, 0x50D8, 0xFA7D, 0x50DA, 0x97BB, - 0x50DE, 0x9945, 0x50E3, 0x9948, 0x50E5, 0x9946, 0x50E7, 0x916D, - 0x50ED, 0x9947, 0x50EE, 0x9949, 0x50F4, 0xFA7C, 0x50F5, 0x994B, - 0x50F9, 0x994A, 0x50FB, 0x95C6, 0x5100, 0x8B56, 0x5101, 0x994D, - 0x5102, 0x994E, 0x5104, 0x89AD, 0x5109, 0x994C, 0x5112, 0x8EF2, - 0x5114, 0x9951, 0x5115, 0x9950, 0x5116, 0x994F, 0x5118, 0x98D4, - 0x511A, 0x9952, 0x511F, 0x8F9E, 0x5121, 0x9953, 0x512A, 0x9744, - 0x5132, 0x96D7, 0x5137, 0x9955, 0x513A, 0x9954, 0x513B, 0x9957, - 0x513C, 0x9956, 0x513F, 0x9958, 0x5140, 0x9959, 0x5141, 0x88F2, - 0x5143, 0x8CB3, 0x5144, 0x8C5A, 0x5145, 0x8F5B, 0x5146, 0x929B, - 0x5147, 0x8BA2, 0x5148, 0x90E6, 0x5149, 0x8CF5, 0x514A, 0xFA7E, - 0x514B, 0x8D8E, 0x514C, 0x995B, 0x514D, 0x96C6, 0x514E, 0x9365, - 0x5150, 0x8E99, 0x5152, 0x995A, 0x5154, 0x995C, 0x515A, 0x937D, - 0x515C, 0x8A95, 0x5162, 0x995D, 0x5164, 0xFA80, 0x5165, 0x93FC, - 0x5168, 0x9153, 0x5169, 0x995F, 0x516A, 0x9960, 0x516B, 0x94AA, - 0x516C, 0x8CF6, 0x516D, 0x985A, 0x516E, 0x9961, 0x5171, 0x8BA4, - 0x5175, 0x95BA, 0x5176, 0x91B4, 0x5177, 0x8BEF, 0x5178, 0x9354, - 0x517C, 0x8C93, 0x5180, 0x9962, 0x5182, 0x9963, 0x5185, 0x93E0, - 0x5186, 0x897E, 0x5189, 0x9966, 0x518A, 0x8DFB, 0x518C, 0x9965, - 0x518D, 0x8DC4, 0x518F, 0x9967, 0x5190, 0xE3EC, 0x5191, 0x9968, - 0x5192, 0x9660, 0x5193, 0x9969, 0x5195, 0x996A, 0x5196, 0x996B, - 0x5197, 0x8FE7, 0x5199, 0x8ECA, 0x519D, 0xFA81, 0x51A0, 0x8AA5, - 0x51A2, 0x996E, 0x51A4, 0x996C, 0x51A5, 0x96BB, 0x51A6, 0x996D, - 0x51A8, 0x9579, 0x51A9, 0x996F, 0x51AA, 0x9970, 0x51AB, 0x9971, - 0x51AC, 0x937E, 0x51B0, 0x9975, 0x51B1, 0x9973, 0x51B2, 0x9974, - 0x51B3, 0x9972, 0x51B4, 0x8DE1, 0x51B5, 0x9976, 0x51B6, 0x96E8, - 0x51B7, 0x97E2, 0x51BD, 0x9977, 0x51BE, 0xFA82, 0x51C4, 0x90A6, - 0x51C5, 0x9978, 0x51C6, 0x8F79, 0x51C9, 0x9979, 0x51CB, 0x929C, - 0x51CC, 0x97BD, 0x51CD, 0x9380, 0x51D6, 0x99C3, 0x51DB, 0x997A, - 0x51DC, 0xEAA3, 0x51DD, 0x8BC3, 0x51E0, 0x997B, 0x51E1, 0x967D, - 0x51E6, 0x8F88, 0x51E7, 0x91FA, 0x51E9, 0x997D, 0x51EA, 0x93E2, - 0x51EC, 0xFA83, 0x51ED, 0x997E, 0x51F0, 0x9980, 0x51F1, 0x8A4D, - 0x51F5, 0x9981, 0x51F6, 0x8BA5, 0x51F8, 0x93CA, 0x51F9, 0x899A, - 0x51FA, 0x8F6F, 0x51FD, 0x949F, 0x51FE, 0x9982, 0x5200, 0x9381, - 0x5203, 0x906E, 0x5204, 0x9983, 0x5206, 0x95AA, 0x5207, 0x90D8, - 0x5208, 0x8AA0, 0x520A, 0x8AA7, 0x520B, 0x9984, 0x520E, 0x9986, - 0x5211, 0x8C59, 0x5214, 0x9985, 0x5215, 0xFA84, 0x5217, 0x97F1, - 0x521D, 0x8F89, 0x5224, 0x94BB, 0x5225, 0x95CA, 0x5227, 0x9987, - 0x5229, 0x9798, 0x522A, 0x9988, 0x522E, 0x9989, 0x5230, 0x939E, - 0x5233, 0x998A, 0x5236, 0x90A7, 0x5237, 0x8DFC, 0x5238, 0x8C94, - 0x5239, 0x998B, 0x523A, 0x8E68, 0x523B, 0x8D8F, 0x5243, 0x92E4, - 0x5244, 0x998D, 0x5247, 0x91A5, 0x524A, 0x8DED, 0x524B, 0x998E, - 0x524C, 0x998F, 0x524D, 0x914F, 0x524F, 0x998C, 0x5254, 0x9991, - 0x5256, 0x9655, 0x525B, 0x8D84, 0x525E, 0x9990, 0x5263, 0x8C95, - 0x5264, 0x8DDC, 0x5265, 0x948D, 0x5269, 0x9994, 0x526A, 0x9992, - 0x526F, 0x959B, 0x5270, 0x8FE8, 0x5271, 0x999B, 0x5272, 0x8A84, - 0x5273, 0x9995, 0x5274, 0x9993, 0x5275, 0x916E, 0x527D, 0x9997, - 0x527F, 0x9996, 0x5283, 0x8A63, 0x5287, 0x8C80, 0x5288, 0x999C, - 0x5289, 0x97AB, 0x528D, 0x9998, 0x5291, 0x999D, 0x5292, 0x999A, - 0x5294, 0x9999, 0x529B, 0x97CD, 0x529C, 0xFA85, 0x529F, 0x8CF7, - 0x52A0, 0x89C1, 0x52A3, 0x97F2, 0x52A6, 0xFA86, 0x52A9, 0x8F95, - 0x52AA, 0x9377, 0x52AB, 0x8D85, 0x52AC, 0x99A0, 0x52AD, 0x99A1, - 0x52AF, 0xFB77, 0x52B1, 0x97E3, 0x52B4, 0x984A, 0x52B5, 0x99A3, - 0x52B9, 0x8CF8, 0x52BC, 0x99A2, 0x52BE, 0x8A4E, 0x52C0, 0xFA87, - 0x52C1, 0x99A4, 0x52C3, 0x9675, 0x52C5, 0x92BA, 0x52C7, 0x9745, - 0x52C9, 0x95D7, 0x52CD, 0x99A5, 0x52D2, 0xE8D3, 0x52D5, 0x93AE, - 0x52D7, 0x99A6, 0x52D8, 0x8AA8, 0x52D9, 0x96B1, 0x52DB, 0xFA88, - 0x52DD, 0x8F9F, 0x52DE, 0x99A7, 0x52DF, 0x95E5, 0x52E0, 0x99AB, - 0x52E2, 0x90A8, 0x52E3, 0x99A8, 0x52E4, 0x8BCE, 0x52E6, 0x99A9, - 0x52E7, 0x8AA9, 0x52F2, 0x8C4D, 0x52F3, 0x99AC, 0x52F5, 0x99AD, - 0x52F8, 0x99AE, 0x52F9, 0x99AF, 0x52FA, 0x8ED9, 0x52FE, 0x8CF9, - 0x52FF, 0x96DC, 0x5300, 0xFA89, 0x5301, 0x96E6, 0x5302, 0x93F5, - 0x5305, 0x95EF, 0x5306, 0x99B0, 0x5307, 0xFA8A, 0x5308, 0x99B1, - 0x530D, 0x99B3, 0x530F, 0x99B5, 0x5310, 0x99B4, 0x5315, 0x99B6, - 0x5316, 0x89BB, 0x5317, 0x966B, 0x5319, 0x8DFA, 0x531A, 0x99B7, - 0x531D, 0x9178, 0x5320, 0x8FA0, 0x5321, 0x8BA7, 0x5323, 0x99B8, - 0x5324, 0xFA8B, 0x532A, 0x94D9, 0x532F, 0x99B9, 0x5331, 0x99BA, - 0x5333, 0x99BB, 0x5338, 0x99BC, 0x5339, 0x9543, 0x533A, 0x8BE6, - 0x533B, 0x88E3, 0x533F, 0x93BD, 0x5340, 0x99BD, 0x5341, 0x8F5C, - 0x5343, 0x90E7, 0x5345, 0x99BF, 0x5346, 0x99BE, 0x5347, 0x8FA1, - 0x5348, 0x8CDF, 0x5349, 0x99C1, 0x534A, 0x94BC, 0x534D, 0x99C2, - 0x5351, 0x94DA, 0x5352, 0x91B2, 0x5353, 0x91EC, 0x5354, 0x8BA6, - 0x5357, 0x93EC, 0x5358, 0x9250, 0x535A, 0x948E, 0x535C, 0x966D, - 0x535E, 0x99C4, 0x5360, 0x90E8, 0x5366, 0x8C54, 0x5369, 0x99C5, - 0x536E, 0x99C6, 0x536F, 0x894B, 0x5370, 0x88F3, 0x5371, 0x8AEB, - 0x5372, 0xFA8C, 0x5373, 0x91A6, 0x5374, 0x8B70, 0x5375, 0x9791, - 0x5377, 0x99C9, 0x5378, 0x89B5, 0x537B, 0x99C8, 0x537F, 0x8BA8, - 0x5382, 0x99CA, 0x5384, 0x96EF, 0x5393, 0xFA8D, 0x5396, 0x99CB, - 0x5398, 0x97D0, 0x539A, 0x8CFA, 0x539F, 0x8CB4, 0x53A0, 0x99CC, - 0x53A5, 0x99CE, 0x53A6, 0x99CD, 0x53A8, 0x907E, 0x53A9, 0x8958, - 0x53AD, 0x897D, 0x53AE, 0x99CF, 0x53B0, 0x99D0, 0x53B2, 0xFA8E, - 0x53B3, 0x8CB5, 0x53B6, 0x99D1, 0x53BB, 0x8B8E, 0x53C2, 0x8E51, - 0x53C3, 0x99D2, 0x53C8, 0x9694, 0x53C9, 0x8DB3, 0x53CA, 0x8B79, - 0x53CB, 0x9746, 0x53CC, 0x916F, 0x53CD, 0x94BD, 0x53CE, 0x8EFB, - 0x53D4, 0x8F66, 0x53D6, 0x8EE6, 0x53D7, 0x8EF3, 0x53D9, 0x8F96, - 0x53DB, 0x94BE, 0x53DD, 0xFA8F, 0x53DF, 0x99D5, 0x53E1, 0x8962, - 0x53E2, 0x9170, 0x53E3, 0x8CFB, 0x53E4, 0x8CC3, 0x53E5, 0x8BE5, - 0x53E8, 0x99D9, 0x53E9, 0x9240, 0x53EA, 0x91FC, 0x53EB, 0x8BA9, - 0x53EC, 0x8FA2, 0x53ED, 0x99DA, 0x53EE, 0x99D8, 0x53EF, 0x89C2, - 0x53F0, 0x91E4, 0x53F1, 0x8EB6, 0x53F2, 0x8E6A, 0x53F3, 0x8945, - 0x53F6, 0x8A90, 0x53F7, 0x8D86, 0x53F8, 0x8E69, 0x53FA, 0x99DB, - 0x5401, 0x99DC, 0x5403, 0x8B68, 0x5404, 0x8A65, 0x5408, 0x8D87, - 0x5409, 0x8B67, 0x540A, 0x92DD, 0x540B, 0x8944, 0x540C, 0x93AF, - 0x540D, 0x96BC, 0x540E, 0x8D40, 0x540F, 0x9799, 0x5410, 0x9366, - 0x5411, 0x8CFC, 0x541B, 0x8C4E, 0x541D, 0x99E5, 0x541F, 0x8BE1, - 0x5420, 0x9669, 0x5426, 0x94DB, 0x5429, 0x99E4, 0x542B, 0x8ADC, - 0x542C, 0x99DF, 0x542D, 0x99E0, 0x542E, 0x99E2, 0x5436, 0x99E3, - 0x5438, 0x8B7A, 0x5439, 0x9081, 0x543B, 0x95AB, 0x543C, 0x99E1, - 0x543D, 0x99DD, 0x543E, 0x8CE1, 0x5440, 0x99DE, 0x5442, 0x9843, - 0x5446, 0x95F0, 0x5448, 0x92E6, 0x5449, 0x8CE0, 0x544A, 0x8D90, - 0x544E, 0x99E6, 0x5451, 0x93DB, 0x545F, 0x99EA, 0x5468, 0x8EFC, - 0x546A, 0x8EF4, 0x5470, 0x99ED, 0x5471, 0x99EB, 0x5473, 0x96A1, - 0x5475, 0x99E8, 0x5476, 0x99F1, 0x5477, 0x99EC, 0x547B, 0x99EF, - 0x547C, 0x8CC4, 0x547D, 0x96BD, 0x5480, 0x99F0, 0x5484, 0x99F2, - 0x5486, 0x99F4, 0x548A, 0xFA92, 0x548B, 0x8DEE, 0x548C, 0x9861, - 0x548E, 0x99E9, 0x548F, 0x99E7, 0x5490, 0x99F3, 0x5492, 0x99EE, - 0x549C, 0xFA91, 0x54A2, 0x99F6, 0x54A4, 0x9A42, 0x54A5, 0x99F8, - 0x54A8, 0x99FC, 0x54A9, 0xFA93, 0x54AB, 0x9A40, 0x54AC, 0x99F9, - 0x54AF, 0x9A5D, 0x54B2, 0x8DE7, 0x54B3, 0x8A50, 0x54B8, 0x99F7, - 0x54BC, 0x9A44, 0x54BD, 0x88F4, 0x54BE, 0x9A43, 0x54C0, 0x88A3, - 0x54C1, 0x9569, 0x54C2, 0x9A41, 0x54C4, 0x99FA, 0x54C7, 0x99F5, - 0x54C8, 0x99FB, 0x54C9, 0x8DC6, 0x54D8, 0x9A45, 0x54E1, 0x88F5, - 0x54E2, 0x9A4E, 0x54E5, 0x9A46, 0x54E6, 0x9A47, 0x54E8, 0x8FA3, - 0x54E9, 0x9689, 0x54ED, 0x9A4C, 0x54EE, 0x9A4B, 0x54F2, 0x934E, - 0x54FA, 0x9A4D, 0x54FD, 0x9A4A, 0x54FF, 0xFA94, 0x5504, 0x8953, - 0x5506, 0x8DB4, 0x5507, 0x904F, 0x550F, 0x9A48, 0x5510, 0x9382, - 0x5514, 0x9A49, 0x5516, 0x88A0, 0x552E, 0x9A53, 0x552F, 0x9742, - 0x5531, 0x8FA5, 0x5533, 0x9A59, 0x5538, 0x9A58, 0x5539, 0x9A4F, - 0x553E, 0x91C1, 0x5540, 0x9A50, 0x5544, 0x91ED, 0x5545, 0x9A55, - 0x5546, 0x8FA4, 0x554C, 0x9A52, 0x554F, 0x96E2, 0x5553, 0x8C5B, - 0x5556, 0x9A56, 0x5557, 0x9A57, 0x555C, 0x9A54, 0x555D, 0x9A5A, - 0x5563, 0x9A51, 0x557B, 0x9A60, 0x557C, 0x9A65, 0x557E, 0x9A61, - 0x5580, 0x9A5C, 0x5583, 0x9A66, 0x5584, 0x9150, 0x5586, 0xFA95, - 0x5587, 0x9A68, 0x5589, 0x8D41, 0x558A, 0x9A5E, 0x558B, 0x929D, - 0x5598, 0x9A62, 0x5599, 0x9A5B, 0x559A, 0x8AAB, 0x559C, 0x8AEC, - 0x559D, 0x8A85, 0x559E, 0x9A63, 0x559F, 0x9A5F, 0x55A7, 0x8C96, - 0x55A8, 0x9A69, 0x55A9, 0x9A67, 0x55AA, 0x9172, 0x55AB, 0x8B69, - 0x55AC, 0x8BAA, 0x55AE, 0x9A64, 0x55B0, 0x8BF2, 0x55B6, 0x8963, - 0x55C4, 0x9A6D, 0x55C5, 0x9A6B, 0x55C7, 0x9AA5, 0x55D4, 0x9A70, - 0x55DA, 0x9A6A, 0x55DC, 0x9A6E, 0x55DF, 0x9A6C, 0x55E3, 0x8E6B, - 0x55E4, 0x9A6F, 0x55F7, 0x9A72, 0x55F9, 0x9A77, 0x55FD, 0x9A75, - 0x55FE, 0x9A74, 0x5606, 0x9251, 0x5609, 0x89C3, 0x5614, 0x9A71, - 0x5616, 0x9A73, 0x5617, 0x8FA6, 0x5618, 0x8952, 0x561B, 0x9A76, - 0x5629, 0x89DC, 0x562F, 0x9A82, 0x5631, 0x8FFA, 0x5632, 0x9A7D, - 0x5634, 0x9A7B, 0x5636, 0x9A7C, 0x5638, 0x9A7E, 0x5642, 0x895C, - 0x564C, 0x9158, 0x564E, 0x9A78, 0x5650, 0x9A79, 0x565B, 0x8A9A, - 0x5664, 0x9A81, 0x5668, 0x8AED, 0x566A, 0x9A84, 0x566B, 0x9A80, - 0x566C, 0x9A83, 0x5674, 0x95AC, 0x5678, 0x93D3, 0x567A, 0x94B6, - 0x5680, 0x9A86, 0x5686, 0x9A85, 0x5687, 0x8A64, 0x568A, 0x9A87, - 0x568F, 0x9A8A, 0x5694, 0x9A89, 0x56A0, 0x9A88, 0x56A2, 0x9458, - 0x56A5, 0x9A8B, 0x56AE, 0x9A8C, 0x56B4, 0x9A8E, 0x56B6, 0x9A8D, - 0x56BC, 0x9A90, 0x56C0, 0x9A93, 0x56C1, 0x9A91, 0x56C2, 0x9A8F, - 0x56C3, 0x9A92, 0x56C8, 0x9A94, 0x56CE, 0x9A95, 0x56D1, 0x9A96, - 0x56D3, 0x9A97, 0x56D7, 0x9A98, 0x56D8, 0x9964, 0x56DA, 0x8EFA, - 0x56DB, 0x8E6C, 0x56DE, 0x89F1, 0x56E0, 0x88F6, 0x56E3, 0x9263, - 0x56EE, 0x9A99, 0x56F0, 0x8DA2, 0x56F2, 0x88CD, 0x56F3, 0x907D, - 0x56F9, 0x9A9A, 0x56FA, 0x8CC5, 0x56FD, 0x8D91, 0x56FF, 0x9A9C, - 0x5700, 0x9A9B, 0x5703, 0x95DE, 0x5704, 0x9A9D, 0x5708, 0x9A9F, - 0x5709, 0x9A9E, 0x570B, 0x9AA0, 0x570D, 0x9AA1, 0x570F, 0x8C97, - 0x5712, 0x8980, 0x5713, 0x9AA2, 0x5716, 0x9AA4, 0x5718, 0x9AA3, - 0x571C, 0x9AA6, 0x571F, 0x9379, 0x5726, 0x9AA7, 0x5727, 0x88B3, - 0x5728, 0x8DDD, 0x572D, 0x8C5C, 0x5730, 0x926E, 0x5737, 0x9AA8, - 0x5738, 0x9AA9, 0x573B, 0x9AAB, 0x5740, 0x9AAC, 0x5742, 0x8DE2, - 0x5747, 0x8BCF, 0x574A, 0x9656, 0x574E, 0x9AAA, 0x574F, 0x9AAD, - 0x5750, 0x8DBF, 0x5751, 0x8D42, 0x5759, 0xFA96, 0x5761, 0x9AB1, - 0x5764, 0x8DA3, 0x5765, 0xFA97, 0x5766, 0x9252, 0x5769, 0x9AAE, - 0x576A, 0x92D8, 0x577F, 0x9AB2, 0x5782, 0x9082, 0x5788, 0x9AB0, - 0x5789, 0x9AB3, 0x578B, 0x8C5E, 0x5793, 0x9AB4, 0x57A0, 0x9AB5, - 0x57A2, 0x8D43, 0x57A3, 0x8A5F, 0x57A4, 0x9AB7, 0x57AA, 0x9AB8, - 0x57AC, 0xFA98, 0x57B0, 0x9AB9, 0x57B3, 0x9AB6, 0x57C0, 0x9AAF, - 0x57C3, 0x9ABA, 0x57C6, 0x9ABB, 0x57C7, 0xFA9A, 0x57C8, 0xFA99, - 0x57CB, 0x9684, 0x57CE, 0x8FE9, 0x57D2, 0x9ABD, 0x57D3, 0x9ABE, - 0x57D4, 0x9ABC, 0x57D6, 0x9AC0, 0x57DC, 0x9457, 0x57DF, 0x88E6, - 0x57E0, 0x9575, 0x57E3, 0x9AC1, 0x57F4, 0x8FFB, 0x57F7, 0x8EB7, - 0x57F9, 0x947C, 0x57FA, 0x8AEE, 0x57FC, 0x8DE9, 0x5800, 0x9678, - 0x5802, 0x93B0, 0x5805, 0x8C98, 0x5806, 0x91CD, 0x580A, 0x9ABF, - 0x580B, 0x9AC2, 0x5815, 0x91C2, 0x5819, 0x9AC3, 0x581D, 0x9AC4, - 0x5821, 0x9AC6, 0x5824, 0x92E7, 0x582A, 0x8AAC, 0x582F, 0xEA9F, - 0x5830, 0x8981, 0x5831, 0x95F1, 0x5834, 0x8FEA, 0x5835, 0x9367, - 0x583A, 0x8DE4, 0x583D, 0x9ACC, 0x5840, 0x95BB, 0x5841, 0x97DB, - 0x584A, 0x89F2, 0x584B, 0x9AC8, 0x5851, 0x9159, 0x5852, 0x9ACB, - 0x5854, 0x9383, 0x5857, 0x9368, 0x5858, 0x9384, 0x5859, 0x94B7, - 0x585A, 0x92CB, 0x585E, 0x8DC7, 0x5862, 0x9AC7, 0x5869, 0x8996, - 0x586B, 0x9355, 0x5870, 0x9AC9, 0x5872, 0x9AC5, 0x5875, 0x906F, - 0x5879, 0x9ACD, 0x587E, 0x8F6D, 0x5883, 0x8BAB, 0x5885, 0x9ACE, - 0x5893, 0x95E6, 0x5897, 0x919D, 0x589C, 0x92C4, 0x589E, 0xFA9D, - 0x589F, 0x9AD0, 0x58A8, 0x966E, 0x58AB, 0x9AD1, 0x58AE, 0x9AD6, - 0x58B2, 0xFA9E, 0x58B3, 0x95AD, 0x58B8, 0x9AD5, 0x58B9, 0x9ACF, - 0x58BA, 0x9AD2, 0x58BB, 0x9AD4, 0x58BE, 0x8DA4, 0x58C1, 0x95C7, - 0x58C5, 0x9AD7, 0x58C7, 0x9264, 0x58CA, 0x89F3, 0x58CC, 0x8FEB, - 0x58D1, 0x9AD9, 0x58D3, 0x9AD8, 0x58D5, 0x8D88, 0x58D7, 0x9ADA, - 0x58D8, 0x9ADC, 0x58D9, 0x9ADB, 0x58DC, 0x9ADE, 0x58DE, 0x9AD3, - 0x58DF, 0x9AE0, 0x58E4, 0x9ADF, 0x58E5, 0x9ADD, 0x58EB, 0x8E6D, - 0x58EC, 0x9070, 0x58EE, 0x9173, 0x58EF, 0x9AE1, 0x58F0, 0x90BA, - 0x58F1, 0x88EB, 0x58F2, 0x9484, 0x58F7, 0x92D9, 0x58F9, 0x9AE3, - 0x58FA, 0x9AE2, 0x58FB, 0x9AE4, 0x58FC, 0x9AE5, 0x58FD, 0x9AE6, - 0x5902, 0x9AE7, 0x5909, 0x95CF, 0x590A, 0x9AE8, 0x590B, 0xFA9F, - 0x590F, 0x89C4, 0x5910, 0x9AE9, 0x5915, 0x975B, 0x5916, 0x8A4F, - 0x5918, 0x99C7, 0x5919, 0x8F67, 0x591A, 0x91BD, 0x591B, 0x9AEA, - 0x591C, 0x96E9, 0x5922, 0x96B2, 0x5925, 0x9AEC, 0x5927, 0x91E5, - 0x5929, 0x9356, 0x592A, 0x91BE, 0x592B, 0x9576, 0x592C, 0x9AED, - 0x592D, 0x9AEE, 0x592E, 0x899B, 0x5931, 0x8EB8, 0x5932, 0x9AEF, - 0x5937, 0x88CE, 0x5938, 0x9AF0, 0x593E, 0x9AF1, 0x5944, 0x8982, - 0x5947, 0x8AEF, 0x5948, 0x93DE, 0x5949, 0x95F2, 0x594E, 0x9AF5, - 0x594F, 0x9174, 0x5950, 0x9AF4, 0x5951, 0x8C5F, 0x5953, 0xFAA0, - 0x5954, 0x967A, 0x5955, 0x9AF3, 0x5957, 0x9385, 0x5958, 0x9AF7, - 0x595A, 0x9AF6, 0x595B, 0xFAA1, 0x595D, 0xFAA2, 0x5960, 0x9AF9, - 0x5962, 0x9AF8, 0x5963, 0xFAA3, 0x5965, 0x899C, 0x5967, 0x9AFA, - 0x5968, 0x8FA7, 0x5969, 0x9AFC, 0x596A, 0x9244, 0x596C, 0x9AFB, - 0x596E, 0x95B1, 0x5973, 0x8F97, 0x5974, 0x937A, 0x5978, 0x9B40, - 0x597D, 0x8D44, 0x5981, 0x9B41, 0x5982, 0x9440, 0x5983, 0x94DC, - 0x5984, 0x96CF, 0x598A, 0x9444, 0x598D, 0x9B4A, 0x5993, 0x8B57, - 0x5996, 0x9764, 0x5999, 0x96AD, 0x599B, 0x9BAA, 0x599D, 0x9B42, - 0x59A3, 0x9B45, 0x59A4, 0xFAA4, 0x59A5, 0x91C3, 0x59A8, 0x9657, - 0x59AC, 0x9369, 0x59B2, 0x9B46, 0x59B9, 0x9685, 0x59BA, 0xFAA5, - 0x59BB, 0x8DC8, 0x59BE, 0x8FA8, 0x59C6, 0x9B47, 0x59C9, 0x8E6F, - 0x59CB, 0x8E6E, 0x59D0, 0x88B7, 0x59D1, 0x8CC6, 0x59D3, 0x90A9, - 0x59D4, 0x88CF, 0x59D9, 0x9B4B, 0x59DA, 0x9B4C, 0x59DC, 0x9B49, - 0x59E5, 0x8957, 0x59E6, 0x8AAD, 0x59E8, 0x9B48, 0x59EA, 0x96C3, - 0x59EB, 0x9550, 0x59F6, 0x88A6, 0x59FB, 0x88F7, 0x59FF, 0x8E70, - 0x5A01, 0x88D0, 0x5A03, 0x88A1, 0x5A09, 0x9B51, 0x5A11, 0x9B4F, - 0x5A18, 0x96BA, 0x5A1A, 0x9B52, 0x5A1C, 0x9B50, 0x5A1F, 0x9B4E, - 0x5A20, 0x9050, 0x5A25, 0x9B4D, 0x5A29, 0x95D8, 0x5A2F, 0x8CE2, - 0x5A35, 0x9B56, 0x5A36, 0x9B57, 0x5A3C, 0x8FA9, 0x5A40, 0x9B53, - 0x5A41, 0x984B, 0x5A46, 0x946B, 0x5A49, 0x9B55, 0x5A5A, 0x8DA5, - 0x5A62, 0x9B58, 0x5A66, 0x9577, 0x5A6A, 0x9B59, 0x5A6C, 0x9B54, - 0x5A7F, 0x96B9, 0x5A92, 0x947D, 0x5A9A, 0x9B5A, 0x5A9B, 0x9551, - 0x5ABC, 0x9B5B, 0x5ABD, 0x9B5F, 0x5ABE, 0x9B5C, 0x5AC1, 0x89C5, - 0x5AC2, 0x9B5E, 0x5AC9, 0x8EB9, 0x5ACB, 0x9B5D, 0x5ACC, 0x8C99, - 0x5AD0, 0x9B6B, 0x5AD6, 0x9B64, 0x5AD7, 0x9B61, 0x5AE1, 0x9284, - 0x5AE3, 0x9B60, 0x5AE6, 0x9B62, 0x5AE9, 0x9B63, 0x5AFA, 0x9B65, - 0x5AFB, 0x9B66, 0x5B09, 0x8AF0, 0x5B0B, 0x9B68, 0x5B0C, 0x9B67, - 0x5B16, 0x9B69, 0x5B22, 0x8FEC, 0x5B2A, 0x9B6C, 0x5B2C, 0x92DA, - 0x5B30, 0x8964, 0x5B32, 0x9B6A, 0x5B36, 0x9B6D, 0x5B3E, 0x9B6E, - 0x5B40, 0x9B71, 0x5B43, 0x9B6F, 0x5B45, 0x9B70, 0x5B50, 0x8E71, - 0x5B51, 0x9B72, 0x5B54, 0x8D45, 0x5B55, 0x9B73, 0x5B56, 0xFAA6, - 0x5B57, 0x8E9A, 0x5B58, 0x91B6, 0x5B5A, 0x9B74, 0x5B5B, 0x9B75, - 0x5B5C, 0x8E79, 0x5B5D, 0x8D46, 0x5B5F, 0x96D0, 0x5B63, 0x8B47, - 0x5B64, 0x8CC7, 0x5B65, 0x9B76, 0x5B66, 0x8A77, 0x5B69, 0x9B77, - 0x5B6B, 0x91B7, 0x5B70, 0x9B78, 0x5B71, 0x9BA1, 0x5B73, 0x9B79, - 0x5B75, 0x9B7A, 0x5B78, 0x9B7B, 0x5B7A, 0x9B7D, 0x5B80, 0x9B7E, - 0x5B83, 0x9B80, 0x5B85, 0x91EE, 0x5B87, 0x8946, 0x5B88, 0x8EE7, - 0x5B89, 0x88C0, 0x5B8B, 0x9176, 0x5B8C, 0x8AAE, 0x5B8D, 0x8EB3, - 0x5B8F, 0x8D47, 0x5B95, 0x9386, 0x5B97, 0x8F40, 0x5B98, 0x8AAF, - 0x5B99, 0x9288, 0x5B9A, 0x92E8, 0x5B9B, 0x88B6, 0x5B9C, 0x8B58, - 0x5B9D, 0x95F3, 0x5B9F, 0x8EC0, 0x5BA2, 0x8B71, 0x5BA3, 0x90E9, - 0x5BA4, 0x8EBA, 0x5BA5, 0x9747, 0x5BA6, 0x9B81, 0x5BAE, 0x8B7B, - 0x5BB0, 0x8DC9, 0x5BB3, 0x8A51, 0x5BB4, 0x8983, 0x5BB5, 0x8FAA, - 0x5BB6, 0x89C6, 0x5BB8, 0x9B82, 0x5BB9, 0x9765, 0x5BBF, 0x8F68, - 0x5BC0, 0xFAA7, 0x5BC2, 0x8EE2, 0x5BC3, 0x9B83, 0x5BC4, 0x8AF1, - 0x5BC5, 0x93D0, 0x5BC6, 0x96A7, 0x5BC7, 0x9B84, 0x5BC9, 0x9B85, - 0x5BCC, 0x9578, 0x5BD0, 0x9B87, 0x5BD2, 0x8AA6, 0x5BD3, 0x8BF5, - 0x5BD4, 0x9B86, 0x5BD8, 0xFAA9, 0x5BDB, 0x8AB0, 0x5BDD, 0x9051, - 0x5BDE, 0x9B8B, 0x5BDF, 0x8E40, 0x5BE1, 0x89C7, 0x5BE2, 0x9B8A, - 0x5BE4, 0x9B88, 0x5BE5, 0x9B8C, 0x5BE6, 0x9B89, 0x5BE7, 0x944A, - 0x5BE8, 0x9ECB, 0x5BE9, 0x9052, 0x5BEB, 0x9B8D, 0x5BEC, 0xFAAA, - 0x5BEE, 0x97BE, 0x5BF0, 0x9B8E, 0x5BF3, 0x9B90, 0x5BF5, 0x929E, - 0x5BF6, 0x9B8F, 0x5BF8, 0x90A1, 0x5BFA, 0x8E9B, 0x5BFE, 0x91CE, - 0x5BFF, 0x8EF5, 0x5C01, 0x9595, 0x5C02, 0x90EA, 0x5C04, 0x8ECB, - 0x5C05, 0x9B91, 0x5C06, 0x8FAB, 0x5C07, 0x9B92, 0x5C08, 0x9B93, - 0x5C09, 0x88D1, 0x5C0A, 0x91B8, 0x5C0B, 0x9071, 0x5C0D, 0x9B94, - 0x5C0E, 0x93B1, 0x5C0F, 0x8FAC, 0x5C11, 0x8FAD, 0x5C13, 0x9B95, - 0x5C16, 0x90EB, 0x5C1A, 0x8FAE, 0x5C1E, 0xFAAB, 0x5C20, 0x9B96, - 0x5C22, 0x9B97, 0x5C24, 0x96DE, 0x5C28, 0x9B98, 0x5C2D, 0x8BC4, - 0x5C31, 0x8F41, 0x5C38, 0x9B99, 0x5C39, 0x9B9A, 0x5C3A, 0x8EDA, - 0x5C3B, 0x904B, 0x5C3C, 0x93F2, 0x5C3D, 0x9073, 0x5C3E, 0x94F6, - 0x5C3F, 0x9441, 0x5C40, 0x8BC7, 0x5C41, 0x9B9B, 0x5C45, 0x8B8F, - 0x5C46, 0x9B9C, 0x5C48, 0x8BFC, 0x5C4A, 0x93CD, 0x5C4B, 0x89AE, - 0x5C4D, 0x8E72, 0x5C4E, 0x9B9D, 0x5C4F, 0x9BA0, 0x5C50, 0x9B9F, - 0x5C51, 0x8BFB, 0x5C53, 0x9B9E, 0x5C55, 0x9357, 0x5C5E, 0x91AE, - 0x5C60, 0x936A, 0x5C61, 0x8EC6, 0x5C64, 0x9177, 0x5C65, 0x979A, - 0x5C6C, 0x9BA2, 0x5C6E, 0x9BA3, 0x5C6F, 0x93D4, 0x5C71, 0x8E52, - 0x5C76, 0x9BA5, 0x5C79, 0x9BA6, 0x5C8C, 0x9BA7, 0x5C90, 0x8AF2, - 0x5C91, 0x9BA8, 0x5C94, 0x9BA9, 0x5CA1, 0x89AA, 0x5CA6, 0xFAAC, - 0x5CA8, 0x915A, 0x5CA9, 0x8AE2, 0x5CAB, 0x9BAB, 0x5CAC, 0x96A6, - 0x5CB1, 0x91D0, 0x5CB3, 0x8A78, 0x5CB6, 0x9BAD, 0x5CB7, 0x9BAF, - 0x5CB8, 0x8ADD, 0x5CBA, 0xFAAD, 0x5CBB, 0x9BAC, 0x5CBC, 0x9BAE, - 0x5CBE, 0x9BB1, 0x5CC5, 0x9BB0, 0x5CC7, 0x9BB2, 0x5CD9, 0x9BB3, - 0x5CE0, 0x93BB, 0x5CE1, 0x8BAC, 0x5CE8, 0x89E3, 0x5CE9, 0x9BB4, - 0x5CEA, 0x9BB9, 0x5CED, 0x9BB7, 0x5CEF, 0x95F5, 0x5CF0, 0x95F4, - 0x5CF5, 0xFAAE, 0x5CF6, 0x9387, 0x5CFA, 0x9BB6, 0x5CFB, 0x8F73, - 0x5CFD, 0x9BB5, 0x5D07, 0x9092, 0x5D0B, 0x9BBA, 0x5D0E, 0x8DE8, - 0x5D11, 0x9BC0, 0x5D14, 0x9BC1, 0x5D15, 0x9BBB, 0x5D16, 0x8A52, - 0x5D17, 0x9BBC, 0x5D18, 0x9BC5, 0x5D19, 0x9BC4, 0x5D1A, 0x9BC3, - 0x5D1B, 0x9BBF, 0x5D1F, 0x9BBE, 0x5D22, 0x9BC2, 0x5D27, 0xFAAF, - 0x5D29, 0x95F6, 0x5D42, 0xFAB2, 0x5D4B, 0x9BC9, 0x5D4C, 0x9BC6, - 0x5D4E, 0x9BC8, 0x5D50, 0x9792, 0x5D52, 0x9BC7, 0x5D53, 0xFAB0, - 0x5D5C, 0x9BBD, 0x5D69, 0x9093, 0x5D6C, 0x9BCA, 0x5D6D, 0xFAB3, - 0x5D6F, 0x8DB5, 0x5D73, 0x9BCB, 0x5D76, 0x9BCC, 0x5D82, 0x9BCF, - 0x5D84, 0x9BCE, 0x5D87, 0x9BCD, 0x5D8B, 0x9388, 0x5D8C, 0x9BB8, - 0x5D90, 0x9BD5, 0x5D9D, 0x9BD1, 0x5DA2, 0x9BD0, 0x5DAC, 0x9BD2, - 0x5DAE, 0x9BD3, 0x5DB7, 0x9BD6, 0x5DB8, 0xFAB4, 0x5DB9, 0xFAB5, - 0x5DBA, 0x97E4, 0x5DBC, 0x9BD7, 0x5DBD, 0x9BD4, 0x5DC9, 0x9BD8, - 0x5DCC, 0x8ADE, 0x5DCD, 0x9BD9, 0x5DD0, 0xFAB6, 0x5DD2, 0x9BDB, - 0x5DD3, 0x9BDA, 0x5DD6, 0x9BDC, 0x5DDB, 0x9BDD, 0x5DDD, 0x90EC, - 0x5DDE, 0x8F42, 0x5DE1, 0x8F84, 0x5DE3, 0x9183, 0x5DE5, 0x8D48, - 0x5DE6, 0x8DB6, 0x5DE7, 0x8D49, 0x5DE8, 0x8B90, 0x5DEB, 0x9BDE, - 0x5DEE, 0x8DB7, 0x5DF1, 0x8CC8, 0x5DF2, 0x9BDF, 0x5DF3, 0x96A4, - 0x5DF4, 0x9462, 0x5DF5, 0x9BE0, 0x5DF7, 0x8D4A, 0x5DFB, 0x8AAA, - 0x5DFD, 0x9246, 0x5DFE, 0x8BD0, 0x5E02, 0x8E73, 0x5E03, 0x957A, - 0x5E06, 0x94BF, 0x5E0B, 0x9BE1, 0x5E0C, 0x8AF3, 0x5E11, 0x9BE4, - 0x5E16, 0x929F, 0x5E19, 0x9BE3, 0x5E1A, 0x9BE2, 0x5E1B, 0x9BE5, - 0x5E1D, 0x92E9, 0x5E25, 0x9083, 0x5E2B, 0x8E74, 0x5E2D, 0x90C8, - 0x5E2F, 0x91D1, 0x5E30, 0x8B41, 0x5E33, 0x92A0, 0x5E36, 0x9BE6, - 0x5E37, 0x9BE7, 0x5E38, 0x8FED, 0x5E3D, 0x9658, 0x5E40, 0x9BEA, - 0x5E43, 0x9BE9, 0x5E44, 0x9BE8, 0x5E45, 0x959D, 0x5E47, 0x9BF1, - 0x5E4C, 0x9679, 0x5E4E, 0x9BEB, 0x5E54, 0x9BED, 0x5E55, 0x968B, - 0x5E57, 0x9BEC, 0x5E5F, 0x9BEE, 0x5E61, 0x94A6, 0x5E62, 0x9BEF, - 0x5E63, 0x95BC, 0x5E64, 0x9BF0, 0x5E72, 0x8AB1, 0x5E73, 0x95BD, - 0x5E74, 0x944E, 0x5E75, 0x9BF2, 0x5E76, 0x9BF3, 0x5E78, 0x8D4B, - 0x5E79, 0x8AB2, 0x5E7A, 0x9BF4, 0x5E7B, 0x8CB6, 0x5E7C, 0x9763, - 0x5E7D, 0x9748, 0x5E7E, 0x8AF4, 0x5E7F, 0x9BF6, 0x5E81, 0x92A1, - 0x5E83, 0x8D4C, 0x5E84, 0x8FAF, 0x5E87, 0x94DD, 0x5E8A, 0x8FB0, - 0x5E8F, 0x8F98, 0x5E95, 0x92EA, 0x5E96, 0x95F7, 0x5E97, 0x9358, - 0x5E9A, 0x8D4D, 0x5E9C, 0x957B, 0x5EA0, 0x9BF7, 0x5EA6, 0x9378, - 0x5EA7, 0x8DC0, 0x5EAB, 0x8CC9, 0x5EAD, 0x92EB, 0x5EB5, 0x88C1, - 0x5EB6, 0x8F8E, 0x5EB7, 0x8D4E, 0x5EB8, 0x9766, 0x5EC1, 0x9BF8, - 0x5EC2, 0x9BF9, 0x5EC3, 0x9470, 0x5EC8, 0x9BFA, 0x5EC9, 0x97F5, - 0x5ECA, 0x984C, 0x5ECF, 0x9BFC, 0x5ED0, 0x9BFB, 0x5ED3, 0x8A66, - 0x5ED6, 0x9C40, 0x5EDA, 0x9C43, 0x5EDB, 0x9C44, 0x5EDD, 0x9C42, - 0x5EDF, 0x955F, 0x5EE0, 0x8FB1, 0x5EE1, 0x9C46, 0x5EE2, 0x9C45, - 0x5EE3, 0x9C41, 0x5EE8, 0x9C47, 0x5EE9, 0x9C48, 0x5EEC, 0x9C49, - 0x5EF0, 0x9C4C, 0x5EF1, 0x9C4A, 0x5EF3, 0x9C4B, 0x5EF4, 0x9C4D, - 0x5EF6, 0x8984, 0x5EF7, 0x92EC, 0x5EF8, 0x9C4E, 0x5EFA, 0x8C9A, - 0x5EFB, 0x89F4, 0x5EFC, 0x9455, 0x5EFE, 0x9C4F, 0x5EFF, 0x93F9, - 0x5F01, 0x95D9, 0x5F03, 0x9C50, 0x5F04, 0x984D, 0x5F09, 0x9C51, - 0x5F0A, 0x95BE, 0x5F0B, 0x9C54, 0x5F0C, 0x989F, 0x5F0D, 0x98AF, - 0x5F0F, 0x8EAE, 0x5F10, 0x93F3, 0x5F11, 0x9C55, 0x5F13, 0x8B7C, - 0x5F14, 0x92A2, 0x5F15, 0x88F8, 0x5F16, 0x9C56, 0x5F17, 0x95A4, - 0x5F18, 0x8D4F, 0x5F1B, 0x926F, 0x5F1F, 0x92ED, 0x5F21, 0xFAB7, - 0x5F25, 0x96ED, 0x5F26, 0x8CB7, 0x5F27, 0x8CCA, 0x5F29, 0x9C57, - 0x5F2D, 0x9C58, 0x5F2F, 0x9C5E, 0x5F31, 0x8EE3, 0x5F34, 0xFAB8, - 0x5F35, 0x92A3, 0x5F37, 0x8BAD, 0x5F38, 0x9C59, 0x5F3C, 0x954A, - 0x5F3E, 0x9265, 0x5F41, 0x9C5A, 0x5F45, 0xFA67, 0x5F48, 0x9C5B, - 0x5F4A, 0x8BAE, 0x5F4C, 0x9C5C, 0x5F4E, 0x9C5D, 0x5F51, 0x9C5F, - 0x5F53, 0x9396, 0x5F56, 0x9C60, 0x5F57, 0x9C61, 0x5F59, 0x9C62, - 0x5F5C, 0x9C53, 0x5F5D, 0x9C52, 0x5F61, 0x9C63, 0x5F62, 0x8C60, - 0x5F66, 0x9546, 0x5F67, 0xFAB9, 0x5F69, 0x8DCA, 0x5F6A, 0x9556, - 0x5F6B, 0x92A4, 0x5F6C, 0x956A, 0x5F6D, 0x9C64, 0x5F70, 0x8FB2, - 0x5F71, 0x8965, 0x5F73, 0x9C65, 0x5F77, 0x9C66, 0x5F79, 0x96F0, - 0x5F7C, 0x94DE, 0x5F7F, 0x9C69, 0x5F80, 0x899D, 0x5F81, 0x90AA, - 0x5F82, 0x9C68, 0x5F83, 0x9C67, 0x5F84, 0x8C61, 0x5F85, 0x91D2, - 0x5F87, 0x9C6D, 0x5F88, 0x9C6B, 0x5F8A, 0x9C6A, 0x5F8B, 0x97A5, - 0x5F8C, 0x8CE3, 0x5F90, 0x8F99, 0x5F91, 0x9C6C, 0x5F92, 0x936B, - 0x5F93, 0x8F5D, 0x5F97, 0x93BE, 0x5F98, 0x9C70, 0x5F99, 0x9C6F, - 0x5F9E, 0x9C6E, 0x5FA0, 0x9C71, 0x5FA1, 0x8CE4, 0x5FA8, 0x9C72, - 0x5FA9, 0x959C, 0x5FAA, 0x8F7A, 0x5FAD, 0x9C73, 0x5FAE, 0x94F7, - 0x5FB3, 0x93BF, 0x5FB4, 0x92A5, 0x5FB7, 0xFABA, 0x5FB9, 0x934F, - 0x5FBC, 0x9C74, 0x5FBD, 0x8B4A, 0x5FC3, 0x9053, 0x5FC5, 0x954B, - 0x5FCC, 0x8AF5, 0x5FCD, 0x9445, 0x5FD6, 0x9C75, 0x5FD7, 0x8E75, - 0x5FD8, 0x9659, 0x5FD9, 0x965A, 0x5FDC, 0x899E, 0x5FDD, 0x9C7A, - 0x5FDE, 0xFABB, 0x5FE0, 0x9289, 0x5FE4, 0x9C77, 0x5FEB, 0x89F5, - 0x5FF0, 0x9CAB, 0x5FF1, 0x9C79, 0x5FF5, 0x944F, 0x5FF8, 0x9C78, - 0x5FFB, 0x9C76, 0x5FFD, 0x8D9A, 0x5FFF, 0x9C7C, 0x600E, 0x9C83, - 0x600F, 0x9C89, 0x6010, 0x9C81, 0x6012, 0x937B, 0x6015, 0x9C86, - 0x6016, 0x957C, 0x6019, 0x9C80, 0x601B, 0x9C85, 0x601C, 0x97E5, - 0x601D, 0x8E76, 0x6020, 0x91D3, 0x6021, 0x9C7D, 0x6025, 0x8B7D, - 0x6026, 0x9C88, 0x6027, 0x90AB, 0x6028, 0x8985, 0x6029, 0x9C82, - 0x602A, 0x89F6, 0x602B, 0x9C87, 0x602F, 0x8BAF, 0x6031, 0x9C84, - 0x603A, 0x9C8A, 0x6041, 0x9C8C, 0x6042, 0x9C96, 0x6043, 0x9C94, - 0x6046, 0x9C91, 0x604A, 0x9C90, 0x604B, 0x97F6, 0x604D, 0x9C92, - 0x6050, 0x8BB0, 0x6052, 0x8D50, 0x6055, 0x8F9A, 0x6059, 0x9C99, - 0x605A, 0x9C8B, 0x605D, 0xFABC, 0x605F, 0x9C8F, 0x6060, 0x9C7E, - 0x6062, 0x89F8, 0x6063, 0x9C93, 0x6064, 0x9C95, 0x6065, 0x9270, - 0x6068, 0x8DA6, 0x6069, 0x89B6, 0x606A, 0x9C8D, 0x606B, 0x9C98, - 0x606C, 0x9C97, 0x606D, 0x8BB1, 0x606F, 0x91A7, 0x6070, 0x8A86, - 0x6075, 0x8C62, 0x6077, 0x9C8E, 0x6081, 0x9C9A, 0x6083, 0x9C9D, - 0x6084, 0x9C9F, 0x6085, 0xFABD, 0x6089, 0x8EBB, 0x608A, 0xFABE, - 0x608B, 0x9CA5, 0x608C, 0x92EE, 0x608D, 0x9C9B, 0x6092, 0x9CA3, - 0x6094, 0x89F7, 0x6096, 0x9CA1, 0x6097, 0x9CA2, 0x609A, 0x9C9E, - 0x609B, 0x9CA0, 0x609F, 0x8CE5, 0x60A0, 0x9749, 0x60A3, 0x8AB3, - 0x60A6, 0x8978, 0x60A7, 0x9CA4, 0x60A9, 0x9459, 0x60AA, 0x88AB, - 0x60B2, 0x94DF, 0x60B3, 0x9C7B, 0x60B4, 0x9CAA, 0x60B5, 0x9CAE, - 0x60B6, 0x96E3, 0x60B8, 0x9CA7, 0x60BC, 0x9389, 0x60BD, 0x9CAC, - 0x60C5, 0x8FEE, 0x60C6, 0x9CAD, 0x60C7, 0x93D5, 0x60D1, 0x9866, - 0x60D3, 0x9CA9, 0x60D5, 0xFAC0, 0x60D8, 0x9CAF, 0x60DA, 0x8D9B, - 0x60DC, 0x90C9, 0x60DE, 0xFABF, 0x60DF, 0x88D2, 0x60E0, 0x9CA8, - 0x60E1, 0x9CA6, 0x60E3, 0x9179, 0x60E7, 0x9C9C, 0x60E8, 0x8E53, - 0x60F0, 0x91C4, 0x60F1, 0x9CBB, 0x60F2, 0xFAC2, 0x60F3, 0x917A, - 0x60F4, 0x9CB6, 0x60F6, 0x9CB3, 0x60F7, 0x9CB4, 0x60F9, 0x8EE4, - 0x60FA, 0x9CB7, 0x60FB, 0x9CBA, 0x6100, 0x9CB5, 0x6101, 0x8F44, - 0x6103, 0x9CB8, 0x6106, 0x9CB2, 0x6108, 0x96FA, 0x6109, 0x96F9, - 0x610D, 0x9CBC, 0x610E, 0x9CBD, 0x610F, 0x88D3, 0x6111, 0xFAC3, - 0x6115, 0x9CB1, 0x611A, 0x8BF0, 0x611B, 0x88A4, 0x611F, 0x8AB4, - 0x6120, 0xFAC1, 0x6121, 0x9CB9, 0x6127, 0x9CC1, 0x6128, 0x9CC0, - 0x612C, 0x9CC5, 0x6130, 0xFAC5, 0x6134, 0x9CC6, 0x6137, 0xFAC4, - 0x613C, 0x9CC4, 0x613D, 0x9CC7, 0x613E, 0x9CBF, 0x613F, 0x9CC3, - 0x6142, 0x9CC8, 0x6144, 0x9CC9, 0x6147, 0x9CBE, 0x6148, 0x8E9C, - 0x614A, 0x9CC2, 0x614B, 0x91D4, 0x614C, 0x8D51, 0x614D, 0x9CB0, - 0x614E, 0x9054, 0x6153, 0x9CD6, 0x6155, 0x95E7, 0x6158, 0x9CCC, - 0x6159, 0x9CCD, 0x615A, 0x9CCE, 0x615D, 0x9CD5, 0x615F, 0x9CD4, - 0x6162, 0x969D, 0x6163, 0x8AB5, 0x6165, 0x9CD2, 0x6167, 0x8C64, - 0x6168, 0x8A53, 0x616B, 0x9CCF, 0x616E, 0x97B6, 0x616F, 0x9CD1, - 0x6170, 0x88D4, 0x6171, 0x9CD3, 0x6173, 0x9CCA, 0x6174, 0x9CD0, - 0x6175, 0x9CD7, 0x6176, 0x8C63, 0x6177, 0x9CCB, 0x617E, 0x977C, - 0x6182, 0x974A, 0x6187, 0x9CDA, 0x618A, 0x9CDE, 0x618E, 0x919E, - 0x6190, 0x97F7, 0x6191, 0x9CDF, 0x6194, 0x9CDC, 0x6196, 0x9CD9, - 0x6198, 0xFAC6, 0x6199, 0x9CD8, 0x619A, 0x9CDD, 0x61A4, 0x95AE, - 0x61A7, 0x93B2, 0x61A9, 0x8C65, 0x61AB, 0x9CE0, 0x61AC, 0x9CDB, - 0x61AE, 0x9CE1, 0x61B2, 0x8C9B, 0x61B6, 0x89AF, 0x61BA, 0x9CE9, - 0x61BE, 0x8AB6, 0x61C3, 0x9CE7, 0x61C6, 0x9CE8, 0x61C7, 0x8DA7, - 0x61C8, 0x9CE6, 0x61C9, 0x9CE4, 0x61CA, 0x9CE3, 0x61CB, 0x9CEA, - 0x61CC, 0x9CE2, 0x61CD, 0x9CEC, 0x61D0, 0x89F9, 0x61E3, 0x9CEE, - 0x61E6, 0x9CED, 0x61F2, 0x92A6, 0x61F4, 0x9CF1, 0x61F6, 0x9CEF, - 0x61F7, 0x9CE5, 0x61F8, 0x8C9C, 0x61FA, 0x9CF0, 0x61FC, 0x9CF4, - 0x61FD, 0x9CF3, 0x61FE, 0x9CF5, 0x61FF, 0x9CF2, 0x6200, 0x9CF6, - 0x6208, 0x9CF7, 0x6209, 0x9CF8, 0x620A, 0x95E8, 0x620C, 0x9CFA, - 0x620D, 0x9CF9, 0x620E, 0x8F5E, 0x6210, 0x90AC, 0x6211, 0x89E4, - 0x6212, 0x89FA, 0x6213, 0xFAC7, 0x6214, 0x9CFB, 0x6216, 0x88BD, - 0x621A, 0x90CA, 0x621B, 0x9CFC, 0x621D, 0xE6C1, 0x621E, 0x9D40, - 0x621F, 0x8C81, 0x6221, 0x9D41, 0x6226, 0x90ED, 0x622A, 0x9D42, - 0x622E, 0x9D43, 0x622F, 0x8B59, 0x6230, 0x9D44, 0x6232, 0x9D45, - 0x6233, 0x9D46, 0x6234, 0x91D5, 0x6238, 0x8CCB, 0x623B, 0x96DF, - 0x623F, 0x965B, 0x6240, 0x8F8A, 0x6241, 0x9D47, 0x6247, 0x90EE, - 0x6248, 0xE7BB, 0x6249, 0x94E0, 0x624B, 0x8EE8, 0x624D, 0x8DCB, - 0x624E, 0x9D48, 0x6253, 0x91C5, 0x6255, 0x95A5, 0x6258, 0x91EF, - 0x625B, 0x9D4B, 0x625E, 0x9D49, 0x6260, 0x9D4C, 0x6263, 0x9D4A, - 0x6268, 0x9D4D, 0x626E, 0x95AF, 0x6271, 0x88B5, 0x6276, 0x957D, - 0x6279, 0x94E1, 0x627C, 0x9D4E, 0x627E, 0x9D51, 0x627F, 0x8FB3, - 0x6280, 0x8B5A, 0x6282, 0x9D4F, 0x6283, 0x9D56, 0x6284, 0x8FB4, - 0x6289, 0x9D50, 0x628A, 0x9463, 0x6291, 0x977D, 0x6292, 0x9D52, - 0x6293, 0x9D53, 0x6294, 0x9D57, 0x6295, 0x938A, 0x6296, 0x9D54, - 0x6297, 0x8D52, 0x6298, 0x90DC, 0x629B, 0x9D65, 0x629C, 0x94B2, - 0x629E, 0x91F0, 0x62A6, 0xFAC8, 0x62AB, 0x94E2, 0x62AC, 0x9DAB, - 0x62B1, 0x95F8, 0x62B5, 0x92EF, 0x62B9, 0x9695, 0x62BB, 0x9D5A, - 0x62BC, 0x899F, 0x62BD, 0x928A, 0x62C2, 0x9D63, 0x62C5, 0x9253, - 0x62C6, 0x9D5D, 0x62C7, 0x9D64, 0x62C8, 0x9D5F, 0x62C9, 0x9D66, - 0x62CA, 0x9D62, 0x62CC, 0x9D61, 0x62CD, 0x948F, 0x62CF, 0x9D5B, - 0x62D0, 0x89FB, 0x62D1, 0x9D59, 0x62D2, 0x8B91, 0x62D3, 0x91F1, - 0x62D4, 0x9D55, 0x62D7, 0x9D58, 0x62D8, 0x8D53, 0x62D9, 0x90D9, - 0x62DB, 0x8FB5, 0x62DC, 0x9D60, 0x62DD, 0x9471, 0x62E0, 0x8B92, - 0x62E1, 0x8A67, 0x62EC, 0x8A87, 0x62ED, 0x9040, 0x62EE, 0x9D68, - 0x62EF, 0x9D6D, 0x62F1, 0x9D69, 0x62F3, 0x8C9D, 0x62F5, 0x9D6E, - 0x62F6, 0x8E41, 0x62F7, 0x8D89, 0x62FE, 0x8F45, 0x62FF, 0x9D5C, - 0x6301, 0x8E9D, 0x6302, 0x9D6B, 0x6307, 0x8E77, 0x6308, 0x9D6C, - 0x6309, 0x88C2, 0x630C, 0x9D67, 0x6311, 0x92A7, 0x6319, 0x8B93, - 0x631F, 0x8BB2, 0x6327, 0x9D6A, 0x6328, 0x88A5, 0x632B, 0x8DC1, - 0x632F, 0x9055, 0x633A, 0x92F0, 0x633D, 0x94D2, 0x633E, 0x9D70, - 0x633F, 0x917D, 0x6349, 0x91A8, 0x634C, 0x8E4A, 0x634D, 0x9D71, - 0x634F, 0x9D73, 0x6350, 0x9D6F, 0x6355, 0x95DF, 0x6357, 0x92BB, - 0x635C, 0x917B, 0x6367, 0x95F9, 0x6368, 0x8ECC, 0x6369, 0x9D80, - 0x636B, 0x9D7E, 0x636E, 0x9098, 0x6372, 0x8C9E, 0x6376, 0x9D78, - 0x6377, 0x8FB7, 0x637A, 0x93E6, 0x637B, 0x9450, 0x6380, 0x9D76, - 0x6383, 0x917C, 0x6388, 0x8EF6, 0x6389, 0x9D7B, 0x638C, 0x8FB6, - 0x638E, 0x9D75, 0x638F, 0x9D7A, 0x6392, 0x9472, 0x6396, 0x9D74, - 0x6398, 0x8C40, 0x639B, 0x8A7C, 0x639F, 0x9D7C, 0x63A0, 0x97A9, - 0x63A1, 0x8DCC, 0x63A2, 0x9254, 0x63A3, 0x9D79, 0x63A5, 0x90DA, - 0x63A7, 0x8D54, 0x63A8, 0x9084, 0x63A9, 0x8986, 0x63AA, 0x915B, - 0x63AB, 0x9D77, 0x63AC, 0x8B64, 0x63B2, 0x8C66, 0x63B4, 0x92CD, - 0x63B5, 0x9D7D, 0x63BB, 0x917E, 0x63BE, 0x9D81, 0x63C0, 0x9D83, - 0x63C3, 0x91B5, 0x63C4, 0x9D89, 0x63C6, 0x9D84, 0x63C9, 0x9D86, - 0x63CF, 0x9560, 0x63D0, 0x92F1, 0x63D2, 0x9D87, 0x63D6, 0x974B, - 0x63DA, 0x9767, 0x63DB, 0x8AB7, 0x63E1, 0x88AC, 0x63E3, 0x9D85, - 0x63E9, 0x9D82, 0x63EE, 0x8AF6, 0x63F4, 0x8987, 0x63F5, 0xFAC9, - 0x63F6, 0x9D88, 0x63FA, 0x9768, 0x6406, 0x9D8C, 0x640D, 0x91B9, - 0x640F, 0x9D93, 0x6413, 0x9D8D, 0x6416, 0x9D8A, 0x6417, 0x9D91, - 0x641C, 0x9D72, 0x6426, 0x9D8E, 0x6428, 0x9D92, 0x642C, 0x94C0, - 0x642D, 0x938B, 0x6434, 0x9D8B, 0x6436, 0x9D8F, 0x643A, 0x8C67, - 0x643E, 0x8DEF, 0x6442, 0x90DB, 0x644E, 0x9D97, 0x6458, 0x9345, - 0x6460, 0xFACA, 0x6467, 0x9D94, 0x6469, 0x9680, 0x646F, 0x9D95, - 0x6476, 0x9D96, 0x6478, 0x96CC, 0x647A, 0x90A0, 0x6483, 0x8C82, - 0x6488, 0x9D9D, 0x6492, 0x8E54, 0x6493, 0x9D9A, 0x6495, 0x9D99, - 0x649A, 0x9451, 0x649D, 0xFACB, 0x649E, 0x93B3, 0x64A4, 0x9350, - 0x64A5, 0x9D9B, 0x64A9, 0x9D9C, 0x64AB, 0x958F, 0x64AD, 0x9464, - 0x64AE, 0x8E42, 0x64B0, 0x90EF, 0x64B2, 0x966F, 0x64B9, 0x8A68, - 0x64BB, 0x9DA3, 0x64BC, 0x9D9E, 0x64C1, 0x9769, 0x64C2, 0x9DA5, - 0x64C5, 0x9DA1, 0x64C7, 0x9DA2, 0x64CD, 0x9180, 0x64CE, 0xFACC, - 0x64D2, 0x9DA0, 0x64D4, 0x9D5E, 0x64D8, 0x9DA4, 0x64DA, 0x9D9F, - 0x64E0, 0x9DA9, 0x64E1, 0x9DAA, 0x64E2, 0x9346, 0x64E3, 0x9DAC, - 0x64E6, 0x8E43, 0x64E7, 0x9DA7, 0x64EC, 0x8B5B, 0x64EF, 0x9DAD, - 0x64F1, 0x9DA6, 0x64F2, 0x9DB1, 0x64F4, 0x9DB0, 0x64F6, 0x9DAF, - 0x64FA, 0x9DB2, 0x64FD, 0x9DB4, 0x64FE, 0x8FEF, 0x6500, 0x9DB3, - 0x6505, 0x9DB7, 0x6518, 0x9DB5, 0x651C, 0x9DB6, 0x651D, 0x9D90, - 0x6523, 0x9DB9, 0x6524, 0x9DB8, 0x652A, 0x9D98, 0x652B, 0x9DBA, - 0x652C, 0x9DAE, 0x652F, 0x8E78, 0x6534, 0x9DBB, 0x6535, 0x9DBC, - 0x6536, 0x9DBE, 0x6537, 0x9DBD, 0x6538, 0x9DBF, 0x6539, 0x89FC, - 0x653B, 0x8D55, 0x653E, 0x95FA, 0x653F, 0x90AD, 0x6545, 0x8CCC, - 0x6548, 0x9DC1, 0x654D, 0x9DC4, 0x654E, 0xFACD, 0x654F, 0x9571, - 0x6551, 0x8B7E, 0x6555, 0x9DC3, 0x6556, 0x9DC2, 0x6557, 0x9473, - 0x6558, 0x9DC5, 0x6559, 0x8BB3, 0x655D, 0x9DC7, 0x655E, 0x9DC6, - 0x6562, 0x8AB8, 0x6563, 0x8E55, 0x6566, 0x93D6, 0x656C, 0x8C68, - 0x6570, 0x9094, 0x6572, 0x9DC8, 0x6574, 0x90AE, 0x6575, 0x9347, - 0x6577, 0x957E, 0x6578, 0x9DC9, 0x6582, 0x9DCA, 0x6583, 0x9DCB, - 0x6587, 0x95B6, 0x6588, 0x9B7C, 0x6589, 0x90C4, 0x658C, 0x956B, - 0x658E, 0x8DD6, 0x6590, 0x94E3, 0x6591, 0x94C1, 0x6597, 0x936C, - 0x6599, 0x97BF, 0x659B, 0x9DCD, 0x659C, 0x8ECE, 0x659F, 0x9DCE, - 0x65A1, 0x88B4, 0x65A4, 0x8BD2, 0x65A5, 0x90CB, 0x65A7, 0x9580, - 0x65AB, 0x9DCF, 0x65AC, 0x8E61, 0x65AD, 0x9266, 0x65AF, 0x8E7A, - 0x65B0, 0x9056, 0x65B7, 0x9DD0, 0x65B9, 0x95FB, 0x65BC, 0x8997, - 0x65BD, 0x8E7B, 0x65C1, 0x9DD3, 0x65C3, 0x9DD1, 0x65C4, 0x9DD4, - 0x65C5, 0x97B7, 0x65C6, 0x9DD2, 0x65CB, 0x90F9, 0x65CC, 0x9DD5, - 0x65CF, 0x91B0, 0x65D2, 0x9DD6, 0x65D7, 0x8AF8, 0x65D9, 0x9DD8, - 0x65DB, 0x9DD7, 0x65E0, 0x9DD9, 0x65E1, 0x9DDA, 0x65E2, 0x8AF9, - 0x65E5, 0x93FA, 0x65E6, 0x9255, 0x65E7, 0x8B8C, 0x65E8, 0x8E7C, - 0x65E9, 0x9181, 0x65EC, 0x8F7B, 0x65ED, 0x88AE, 0x65F1, 0x9DDB, - 0x65FA, 0x89A0, 0x65FB, 0x9DDF, 0x6600, 0xFACE, 0x6602, 0x8D56, - 0x6603, 0x9DDE, 0x6606, 0x8DA9, 0x6607, 0x8FB8, 0x6609, 0xFAD1, - 0x660A, 0x9DDD, 0x660C, 0x8FB9, 0x660E, 0x96BE, 0x660F, 0x8DA8, - 0x6613, 0x88D5, 0x6614, 0x90CC, 0x6615, 0xFACF, 0x661C, 0x9DE4, - 0x661E, 0xFAD3, 0x661F, 0x90AF, 0x6620, 0x8966, 0x6624, 0xFAD4, - 0x6625, 0x8F74, 0x6627, 0x9686, 0x6628, 0x8DF0, 0x662D, 0x8FBA, - 0x662E, 0xFAD2, 0x662F, 0x90A5, 0x6631, 0xFA63, 0x6634, 0x9DE3, - 0x6635, 0x9DE1, 0x6636, 0x9DE2, 0x663B, 0xFAD0, 0x663C, 0x928B, - 0x663F, 0x9E45, 0x6641, 0x9DE8, 0x6642, 0x8E9E, 0x6643, 0x8D57, - 0x6644, 0x9DE6, 0x6649, 0x9DE7, 0x664B, 0x9057, 0x664F, 0x9DE5, - 0x6652, 0x8E4E, 0x6657, 0xFAD6, 0x6659, 0xFAD7, 0x665D, 0x9DEA, - 0x665E, 0x9DE9, 0x665F, 0x9DEE, 0x6662, 0x9DEF, 0x6664, 0x9DEB, - 0x6665, 0xFAD5, 0x6666, 0x8A41, 0x6667, 0x9DEC, 0x6668, 0x9DED, - 0x6669, 0x94D3, 0x666E, 0x9581, 0x666F, 0x8C69, 0x6670, 0x9DF0, - 0x6673, 0xFAD9, 0x6674, 0x90B0, 0x6676, 0x8FBB, 0x667A, 0x9271, - 0x6681, 0x8BC5, 0x6683, 0x9DF1, 0x6684, 0x9DF5, 0x6687, 0x89C9, - 0x6688, 0x9DF2, 0x6689, 0x9DF4, 0x668E, 0x9DF3, 0x6691, 0x8F8B, - 0x6696, 0x9267, 0x6697, 0x88C3, 0x6698, 0x9DF6, 0x6699, 0xFADA, - 0x669D, 0x9DF7, 0x66A0, 0xFADB, 0x66A2, 0x92A8, 0x66A6, 0x97EF, - 0x66AB, 0x8E62, 0x66AE, 0x95E9, 0x66B2, 0xFADC, 0x66B4, 0x965C, - 0x66B8, 0x9E41, 0x66B9, 0x9DF9, 0x66BC, 0x9DFC, 0x66BE, 0x9DFB, - 0x66BF, 0xFADD, 0x66C1, 0x9DF8, 0x66C4, 0x9E40, 0x66C7, 0x93DC, - 0x66C9, 0x9DFA, 0x66D6, 0x9E42, 0x66D9, 0x8F8C, 0x66DA, 0x9E43, - 0x66DC, 0x976A, 0x66DD, 0x9498, 0x66E0, 0x9E44, 0x66E6, 0x9E46, - 0x66E9, 0x9E47, 0x66F0, 0x9E48, 0x66F2, 0x8BC8, 0x66F3, 0x8967, - 0x66F4, 0x8D58, 0x66F5, 0x9E49, 0x66F7, 0x9E4A, 0x66F8, 0x8F91, - 0x66F9, 0x9182, 0x66FA, 0xFADE, 0x66FB, 0xFA66, 0x66FC, 0x99D6, - 0x66FD, 0x915D, 0x66FE, 0x915C, 0x66FF, 0x91D6, 0x6700, 0x8DC5, - 0x6703, 0x98F0, 0x6708, 0x8C8E, 0x6709, 0x974C, 0x670B, 0x95FC, - 0x670D, 0x959E, 0x670E, 0xFADF, 0x670F, 0x9E4B, 0x6714, 0x8DF1, - 0x6715, 0x92BD, 0x6716, 0x9E4C, 0x6717, 0x984E, 0x671B, 0x965D, - 0x671D, 0x92A9, 0x671E, 0x9E4D, 0x671F, 0x8AFA, 0x6726, 0x9E4E, - 0x6727, 0x9E4F, 0x6728, 0x96D8, 0x672A, 0x96A2, 0x672B, 0x9696, - 0x672C, 0x967B, 0x672D, 0x8E44, 0x672E, 0x9E51, 0x6731, 0x8EE9, - 0x6734, 0x9670, 0x6736, 0x9E53, 0x6737, 0x9E56, 0x6738, 0x9E55, - 0x673A, 0x8AF7, 0x673D, 0x8B80, 0x673F, 0x9E52, 0x6741, 0x9E54, - 0x6746, 0x9E57, 0x6749, 0x9099, 0x674E, 0x979B, 0x674F, 0x88C7, - 0x6750, 0x8DDE, 0x6751, 0x91BA, 0x6753, 0x8EDB, 0x6756, 0x8FF1, - 0x6759, 0x9E5A, 0x675C, 0x936D, 0x675E, 0x9E58, 0x675F, 0x91A9, - 0x6760, 0x9E59, 0x6761, 0x8FF0, 0x6762, 0x96DB, 0x6763, 0x9E5B, - 0x6764, 0x9E5C, 0x6765, 0x9788, 0x6766, 0xFAE1, 0x676A, 0x9E61, - 0x676D, 0x8D59, 0x676F, 0x9474, 0x6770, 0x9E5E, 0x6771, 0x938C, - 0x6772, 0x9DDC, 0x6773, 0x9DE0, 0x6775, 0x8B6E, 0x6777, 0x9466, - 0x677C, 0x9E60, 0x677E, 0x8FBC, 0x677F, 0x94C2, 0x6785, 0x9E66, - 0x6787, 0x94F8, 0x6789, 0x9E5D, 0x678B, 0x9E63, 0x678C, 0x9E62, - 0x6790, 0x90CD, 0x6795, 0x968D, 0x6797, 0x97D1, 0x679A, 0x9687, - 0x679C, 0x89CA, 0x679D, 0x8E7D, 0x67A0, 0x9867, 0x67A1, 0x9E65, - 0x67A2, 0x9095, 0x67A6, 0x9E64, 0x67A9, 0x9E5F, 0x67AF, 0x8CCD, - 0x67B3, 0x9E6B, 0x67B4, 0x9E69, 0x67B6, 0x89CB, 0x67B7, 0x9E67, - 0x67B8, 0x9E6D, 0x67B9, 0x9E73, 0x67BB, 0xFAE2, 0x67C0, 0xFAE4, - 0x67C1, 0x91C6, 0x67C4, 0x95BF, 0x67C6, 0x9E75, 0x67CA, 0x9541, - 0x67CE, 0x9E74, 0x67CF, 0x9490, 0x67D0, 0x965E, 0x67D1, 0x8AB9, - 0x67D3, 0x90F5, 0x67D4, 0x8F5F, 0x67D8, 0x92D1, 0x67DA, 0x974D, - 0x67DD, 0x9E70, 0x67DE, 0x9E6F, 0x67E2, 0x9E71, 0x67E4, 0x9E6E, - 0x67E7, 0x9E76, 0x67E9, 0x9E6C, 0x67EC, 0x9E6A, 0x67EE, 0x9E72, - 0x67EF, 0x9E68, 0x67F1, 0x928C, 0x67F3, 0x96F6, 0x67F4, 0x8EC4, - 0x67F5, 0x8DF2, 0x67FB, 0x8DB8, 0x67FE, 0x968F, 0x67FF, 0x8A60, - 0x6801, 0xFAE5, 0x6802, 0x92CC, 0x6803, 0x93C8, 0x6804, 0x8968, - 0x6813, 0x90F0, 0x6816, 0x90B2, 0x6817, 0x8C49, 0x681E, 0x9E78, - 0x6821, 0x8D5A, 0x6822, 0x8A9C, 0x6829, 0x9E7A, 0x682A, 0x8A94, - 0x682B, 0x9E81, 0x6832, 0x9E7D, 0x6834, 0x90F1, 0x6838, 0x8A6A, - 0x6839, 0x8DAA, 0x683C, 0x8A69, 0x683D, 0x8DCD, 0x6840, 0x9E7B, - 0x6841, 0x8C85, 0x6842, 0x8C6A, 0x6843, 0x938D, 0x6844, 0xFAE6, - 0x6846, 0x9E79, 0x6848, 0x88C4, 0x684D, 0x9E7C, 0x684E, 0x9E7E, - 0x6850, 0x8BCB, 0x6851, 0x8C4B, 0x6852, 0xFAE3, 0x6853, 0x8ABA, - 0x6854, 0x8B6A, 0x6859, 0x9E82, 0x685C, 0x8DF7, 0x685D, 0x9691, - 0x685F, 0x8E56, 0x6863, 0x9E83, 0x6867, 0x954F, 0x6874, 0x9E8F, - 0x6876, 0x89B1, 0x6877, 0x9E84, 0x687E, 0x9E95, 0x687F, 0x9E85, - 0x6881, 0x97C0, 0x6883, 0x9E8C, 0x6885, 0x947E, 0x688D, 0x9E94, - 0x688F, 0x9E87, 0x6893, 0x88B2, 0x6894, 0x9E89, 0x6897, 0x8D5B, - 0x689B, 0x9E8B, 0x689D, 0x9E8A, 0x689F, 0x9E86, 0x68A0, 0x9E91, - 0x68A2, 0x8FBD, 0x68A6, 0x9AEB, 0x68A7, 0x8CE6, 0x68A8, 0x979C, - 0x68AD, 0x9E88, 0x68AF, 0x92F2, 0x68B0, 0x8A42, 0x68B1, 0x8DAB, - 0x68B3, 0x9E80, 0x68B5, 0x9E90, 0x68B6, 0x8A81, 0x68B9, 0x9E8E, - 0x68BA, 0x9E92, 0x68BC, 0x938E, 0x68C4, 0x8AFC, 0x68C6, 0x9EB0, - 0x68C8, 0xFA64, 0x68C9, 0x96C7, 0x68CA, 0x9E97, 0x68CB, 0x8AFB, - 0x68CD, 0x9E9E, 0x68CF, 0xFAE7, 0x68D2, 0x965F, 0x68D4, 0x9E9F, - 0x68D5, 0x9EA1, 0x68D7, 0x9EA5, 0x68D8, 0x9E99, 0x68DA, 0x9249, - 0x68DF, 0x938F, 0x68E0, 0x9EA9, 0x68E1, 0x9E9C, 0x68E3, 0x9EA6, - 0x68E7, 0x9EA0, 0x68EE, 0x9058, 0x68EF, 0x9EAA, 0x68F2, 0x90B1, - 0x68F9, 0x9EA8, 0x68FA, 0x8ABB, 0x6900, 0x986F, 0x6901, 0x9E96, - 0x6904, 0x9EA4, 0x6905, 0x88D6, 0x6908, 0x9E98, 0x690B, 0x96B8, - 0x690C, 0x9E9D, 0x690D, 0x9041, 0x690E, 0x92C5, 0x690F, 0x9E93, - 0x6912, 0x9EA3, 0x6919, 0x909A, 0x691A, 0x9EAD, 0x691B, 0x8A91, - 0x691C, 0x8C9F, 0x6921, 0x9EAF, 0x6922, 0x9E9A, 0x6923, 0x9EAE, - 0x6925, 0x9EA7, 0x6926, 0x9E9B, 0x6928, 0x9EAB, 0x692A, 0x9EAC, - 0x6930, 0x9EBD, 0x6934, 0x93CC, 0x6936, 0x9EA2, 0x6939, 0x9EB9, - 0x693D, 0x9EBB, 0x693F, 0x92D6, 0x694A, 0x976B, 0x6953, 0x9596, - 0x6954, 0x9EB6, 0x6955, 0x91C8, 0x6959, 0x9EBC, 0x695A, 0x915E, - 0x695C, 0x9EB3, 0x695D, 0x9EC0, 0x695E, 0x9EBF, 0x6960, 0x93ED, - 0x6961, 0x9EBE, 0x6962, 0x93E8, 0x6968, 0xFAE9, 0x696A, 0x9EC2, - 0x696B, 0x9EB5, 0x696D, 0x8BC6, 0x696E, 0x9EB8, 0x696F, 0x8F7C, - 0x6973, 0x9480, 0x6974, 0x9EBA, 0x6975, 0x8BC9, 0x6977, 0x9EB2, - 0x6978, 0x9EB4, 0x6979, 0x9EB1, 0x697C, 0x984F, 0x697D, 0x8A79, - 0x697E, 0x9EB7, 0x6981, 0x9EC1, 0x6982, 0x8A54, 0x698A, 0x8DE5, - 0x698E, 0x897C, 0x6991, 0x9ED2, 0x6994, 0x9850, 0x6995, 0x9ED5, - 0x6998, 0xFAEB, 0x699B, 0x9059, 0x699C, 0x9ED4, 0x69A0, 0x9ED3, - 0x69A7, 0x9ED0, 0x69AE, 0x9EC4, 0x69B1, 0x9EE1, 0x69B2, 0x9EC3, - 0x69B4, 0x9ED6, 0x69BB, 0x9ECE, 0x69BE, 0x9EC9, 0x69BF, 0x9EC6, - 0x69C1, 0x9EC7, 0x69C3, 0x9ECF, 0x69C7, 0xEAA0, 0x69CA, 0x9ECC, - 0x69CB, 0x8D5C, 0x69CC, 0x92C6, 0x69CD, 0x9184, 0x69CE, 0x9ECA, - 0x69D0, 0x9EC5, 0x69D3, 0x9EC8, 0x69D8, 0x976C, 0x69D9, 0x968A, - 0x69DD, 0x9ECD, 0x69DE, 0x9ED7, 0x69E2, 0xFAEC, 0x69E7, 0x9EDF, - 0x69E8, 0x9ED8, 0x69EB, 0x9EE5, 0x69ED, 0x9EE3, 0x69F2, 0x9EDE, - 0x69F9, 0x9EDD, 0x69FB, 0x92CE, 0x69FD, 0x9185, 0x69FF, 0x9EDB, - 0x6A02, 0x9ED9, 0x6A05, 0x9EE0, 0x6A0A, 0x9EE6, 0x6A0B, 0x94F3, - 0x6A0C, 0x9EEC, 0x6A12, 0x9EE7, 0x6A13, 0x9EEA, 0x6A14, 0x9EE4, - 0x6A17, 0x9294, 0x6A19, 0x9557, 0x6A1B, 0x9EDA, 0x6A1E, 0x9EE2, - 0x6A1F, 0x8FBE, 0x6A21, 0x96CD, 0x6A22, 0x9EF6, 0x6A23, 0x9EE9, - 0x6A29, 0x8CA0, 0x6A2A, 0x89A1, 0x6A2B, 0x8A7E, 0x6A2E, 0x9ED1, - 0x6A30, 0xFAED, 0x6A35, 0x8FBF, 0x6A36, 0x9EEE, 0x6A38, 0x9EF5, - 0x6A39, 0x8EF7, 0x6A3A, 0x8A92, 0x6A3D, 0x924D, 0x6A44, 0x9EEB, - 0x6A46, 0xFAEF, 0x6A47, 0x9EF0, 0x6A48, 0x9EF4, 0x6A4B, 0x8BB4, - 0x6A58, 0x8B6B, 0x6A59, 0x9EF2, 0x6A5F, 0x8B40, 0x6A61, 0x93C9, - 0x6A62, 0x9EF1, 0x6A66, 0x9EF3, 0x6A6B, 0xFAEE, 0x6A72, 0x9EED, - 0x6A73, 0xFAF0, 0x6A78, 0x9EEF, 0x6A7E, 0xFAF1, 0x6A7F, 0x8A80, - 0x6A80, 0x9268, 0x6A84, 0x9EFA, 0x6A8D, 0x9EF8, 0x6A8E, 0x8CE7, - 0x6A90, 0x9EF7, 0x6A97, 0x9F40, 0x6A9C, 0x9E77, 0x6AA0, 0x9EF9, - 0x6AA2, 0x9EFB, 0x6AA3, 0x9EFC, 0x6AAA, 0x9F4B, 0x6AAC, 0x9F47, - 0x6AAE, 0x9E8D, 0x6AB3, 0x9F46, 0x6AB8, 0x9F45, 0x6ABB, 0x9F42, - 0x6AC1, 0x9EE8, 0x6AC2, 0x9F44, 0x6AC3, 0x9F43, 0x6AD1, 0x9F49, - 0x6AD3, 0x9845, 0x6ADA, 0x9F4C, 0x6ADB, 0x8BF9, 0x6ADE, 0x9F48, - 0x6ADF, 0x9F4A, 0x6AE2, 0xFAF2, 0x6AE4, 0xFAF3, 0x6AE8, 0x94A5, - 0x6AEA, 0x9F4D, 0x6AFA, 0x9F51, 0x6AFB, 0x9F4E, 0x6B04, 0x9793, - 0x6B05, 0x9F4F, 0x6B0A, 0x9EDC, 0x6B12, 0x9F52, 0x6B16, 0x9F53, - 0x6B1D, 0x8954, 0x6B1F, 0x9F55, 0x6B20, 0x8C87, 0x6B21, 0x8E9F, - 0x6B23, 0x8BD3, 0x6B27, 0x89A2, 0x6B32, 0x977E, 0x6B37, 0x9F57, - 0x6B38, 0x9F56, 0x6B39, 0x9F59, 0x6B3A, 0x8B5C, 0x6B3D, 0x8BD4, - 0x6B3E, 0x8ABC, 0x6B43, 0x9F5C, 0x6B47, 0x9F5B, 0x6B49, 0x9F5D, - 0x6B4C, 0x89CC, 0x6B4E, 0x9256, 0x6B50, 0x9F5E, 0x6B53, 0x8ABD, - 0x6B54, 0x9F60, 0x6B59, 0x9F5F, 0x6B5B, 0x9F61, 0x6B5F, 0x9F62, - 0x6B61, 0x9F63, 0x6B62, 0x8E7E, 0x6B63, 0x90B3, 0x6B64, 0x8D9F, - 0x6B66, 0x9590, 0x6B69, 0x95E0, 0x6B6A, 0x9863, 0x6B6F, 0x8E95, - 0x6B73, 0x8DCE, 0x6B74, 0x97F0, 0x6B78, 0x9F64, 0x6B79, 0x9F65, - 0x6B7B, 0x8E80, 0x6B7F, 0x9F66, 0x6B80, 0x9F67, 0x6B83, 0x9F69, - 0x6B84, 0x9F68, 0x6B86, 0x9677, 0x6B89, 0x8F7D, 0x6B8A, 0x8EEA, - 0x6B8B, 0x8E63, 0x6B8D, 0x9F6A, 0x6B95, 0x9F6C, 0x6B96, 0x9042, - 0x6B98, 0x9F6B, 0x6B9E, 0x9F6D, 0x6BA4, 0x9F6E, 0x6BAA, 0x9F6F, - 0x6BAB, 0x9F70, 0x6BAF, 0x9F71, 0x6BB1, 0x9F73, 0x6BB2, 0x9F72, - 0x6BB3, 0x9F74, 0x6BB4, 0x89A3, 0x6BB5, 0x9269, 0x6BB7, 0x9F75, - 0x6BBA, 0x8E45, 0x6BBB, 0x8A6B, 0x6BBC, 0x9F76, 0x6BBF, 0x9361, - 0x6BC0, 0x9ACA, 0x6BC5, 0x8B42, 0x6BC6, 0x9F77, 0x6BCB, 0x9F78, - 0x6BCD, 0x95EA, 0x6BCE, 0x9688, 0x6BD2, 0x93C5, 0x6BD3, 0x9F79, - 0x6BD4, 0x94E4, 0x6BD6, 0xFAF4, 0x6BD8, 0x94F9, 0x6BDB, 0x96D1, - 0x6BDF, 0x9F7A, 0x6BEB, 0x9F7C, 0x6BEC, 0x9F7B, 0x6BEF, 0x9F7E, - 0x6BF3, 0x9F7D, 0x6C08, 0x9F81, 0x6C0F, 0x8E81, 0x6C11, 0x96AF, - 0x6C13, 0x9F82, 0x6C14, 0x9F83, 0x6C17, 0x8B43, 0x6C1B, 0x9F84, - 0x6C23, 0x9F86, 0x6C24, 0x9F85, 0x6C34, 0x9085, 0x6C37, 0x9558, - 0x6C38, 0x8969, 0x6C3E, 0x94C3, 0x6C3F, 0xFAF5, 0x6C40, 0x92F3, - 0x6C41, 0x8F60, 0x6C42, 0x8B81, 0x6C4E, 0x94C4, 0x6C50, 0x8EAC, - 0x6C55, 0x9F88, 0x6C57, 0x8ABE, 0x6C5A, 0x8998, 0x6C5C, 0xFAF6, - 0x6C5D, 0x93F0, 0x6C5E, 0x9F87, 0x6C5F, 0x8D5D, 0x6C60, 0x9272, - 0x6C62, 0x9F89, 0x6C68, 0x9F91, 0x6C6A, 0x9F8A, 0x6C6F, 0xFAF8, - 0x6C70, 0x91BF, 0x6C72, 0x8B82, 0x6C73, 0x9F92, 0x6C7A, 0x8C88, - 0x6C7D, 0x8B44, 0x6C7E, 0x9F90, 0x6C81, 0x9F8E, 0x6C82, 0x9F8B, - 0x6C83, 0x9780, 0x6C86, 0xFAF7, 0x6C88, 0x92BE, 0x6C8C, 0x93D7, - 0x6C8D, 0x9F8C, 0x6C90, 0x9F94, 0x6C92, 0x9F93, 0x6C93, 0x8C42, - 0x6C96, 0x89AB, 0x6C99, 0x8DB9, 0x6C9A, 0x9F8D, 0x6C9B, 0x9F8F, - 0x6CA1, 0x9676, 0x6CA2, 0x91F2, 0x6CAB, 0x9697, 0x6CAE, 0x9F9C, - 0x6CB1, 0x9F9D, 0x6CB3, 0x89CD, 0x6CB8, 0x95A6, 0x6CB9, 0x96FB, - 0x6CBA, 0x9F9F, 0x6CBB, 0x8EA1, 0x6CBC, 0x8FC0, 0x6CBD, 0x9F98, - 0x6CBE, 0x9F9E, 0x6CBF, 0x8988, 0x6CC1, 0x8BB5, 0x6CC4, 0x9F95, - 0x6CC5, 0x9F9A, 0x6CC9, 0x90F2, 0x6CCA, 0x9491, 0x6CCC, 0x94E5, - 0x6CD3, 0x9F97, 0x6CD5, 0x9640, 0x6CD7, 0x9F99, 0x6CD9, 0x9FA2, - 0x6CDA, 0xFAF9, 0x6CDB, 0x9FA0, 0x6CDD, 0x9F9B, 0x6CE1, 0x9641, - 0x6CE2, 0x9467, 0x6CE3, 0x8B83, 0x6CE5, 0x9344, 0x6CE8, 0x928D, - 0x6CEA, 0x9FA3, 0x6CEF, 0x9FA1, 0x6CF0, 0x91D7, 0x6CF1, 0x9F96, - 0x6CF3, 0x896A, 0x6D04, 0xFAFA, 0x6D0B, 0x976D, 0x6D0C, 0x9FAE, - 0x6D12, 0x9FAD, 0x6D17, 0x90F4, 0x6D19, 0x9FAA, 0x6D1B, 0x978C, - 0x6D1E, 0x93B4, 0x6D1F, 0x9FA4, 0x6D25, 0x92C3, 0x6D29, 0x896B, - 0x6D2A, 0x8D5E, 0x6D2B, 0x9FA7, 0x6D32, 0x8F46, 0x6D33, 0x9FAC, - 0x6D35, 0x9FAB, 0x6D36, 0x9FA6, 0x6D38, 0x9FA9, 0x6D3B, 0x8A88, - 0x6D3D, 0x9FA8, 0x6D3E, 0x9468, 0x6D41, 0x97AC, 0x6D44, 0x8FF2, - 0x6D45, 0x90F3, 0x6D59, 0x9FB4, 0x6D5A, 0x9FB2, 0x6D5C, 0x956C, - 0x6D63, 0x9FAF, 0x6D64, 0x9FB1, 0x6D66, 0x8959, 0x6D69, 0x8D5F, - 0x6D6A, 0x9851, 0x6D6C, 0x8A5C, 0x6D6E, 0x9582, 0x6D6F, 0xFAFC, - 0x6D74, 0x9781, 0x6D77, 0x8A43, 0x6D78, 0x905A, 0x6D79, 0x9FB3, - 0x6D85, 0x9FB8, 0x6D87, 0xFAFB, 0x6D88, 0x8FC1, 0x6D8C, 0x974F, - 0x6D8E, 0x9FB5, 0x6D93, 0x9FB0, 0x6D95, 0x9FB6, 0x6D96, 0xFB40, - 0x6D99, 0x97DC, 0x6D9B, 0x9393, 0x6D9C, 0x93C0, 0x6DAC, 0xFB41, - 0x6DAF, 0x8A55, 0x6DB2, 0x8974, 0x6DB5, 0x9FBC, 0x6DB8, 0x9FBF, - 0x6DBC, 0x97C1, 0x6DC0, 0x9784, 0x6DC5, 0x9FC6, 0x6DC6, 0x9FC0, - 0x6DC7, 0x9FBD, 0x6DCB, 0x97D2, 0x6DCC, 0x9FC3, 0x6DCF, 0xFB42, - 0x6DD1, 0x8F69, 0x6DD2, 0x9FC5, 0x6DD5, 0x9FCA, 0x6DD8, 0x9391, - 0x6DD9, 0x9FC8, 0x6DDE, 0x9FC2, 0x6DE1, 0x9257, 0x6DE4, 0x9FC9, - 0x6DE6, 0x9FBE, 0x6DE8, 0x9FC4, 0x6DEA, 0x9FCB, 0x6DEB, 0x88FA, - 0x6DEC, 0x9FC1, 0x6DEE, 0x9FCC, 0x6DF1, 0x905B, 0x6DF2, 0xFB44, - 0x6DF3, 0x8F7E, 0x6DF5, 0x95A3, 0x6DF7, 0x8DAC, 0x6DF8, 0xFB43, - 0x6DF9, 0x9FB9, 0x6DFA, 0x9FC7, 0x6DFB, 0x9359, 0x6DFC, 0xFB45, - 0x6E05, 0x90B4, 0x6E07, 0x8A89, 0x6E08, 0x8DCF, 0x6E09, 0x8FC2, - 0x6E0A, 0x9FBB, 0x6E0B, 0x8F61, 0x6E13, 0x8C6B, 0x6E15, 0x9FBA, - 0x6E19, 0x9FD0, 0x6E1A, 0x8F8D, 0x6E1B, 0x8CB8, 0x6E1D, 0x9FDF, - 0x6E1F, 0x9FD9, 0x6E20, 0x8B94, 0x6E21, 0x936E, 0x6E23, 0x9FD4, - 0x6E24, 0x9FDD, 0x6E25, 0x88AD, 0x6E26, 0x8951, 0x6E27, 0xFB48, - 0x6E29, 0x89B7, 0x6E2B, 0x9FD6, 0x6E2C, 0x91AA, 0x6E2D, 0x9FCD, - 0x6E2E, 0x9FCF, 0x6E2F, 0x8D60, 0x6E38, 0x9FE0, 0x6E39, 0xFB46, - 0x6E3A, 0x9FDB, 0x6E3C, 0xFB49, 0x6E3E, 0x9FD3, 0x6E43, 0x9FDA, - 0x6E4A, 0x96A9, 0x6E4D, 0x9FD8, 0x6E4E, 0x9FDC, 0x6E56, 0x8CCE, - 0x6E58, 0x8FC3, 0x6E5B, 0x9258, 0x6E5C, 0xFB47, 0x6E5F, 0x9FD2, - 0x6E67, 0x974E, 0x6E6B, 0x9FD5, 0x6E6E, 0x9FCE, 0x6E6F, 0x9392, - 0x6E72, 0x9FD1, 0x6E76, 0x9FD7, 0x6E7E, 0x9870, 0x6E7F, 0x8EBC, - 0x6E80, 0x969E, 0x6E82, 0x9FE1, 0x6E8C, 0x94AC, 0x6E8F, 0x9FED, - 0x6E90, 0x8CB9, 0x6E96, 0x8F80, 0x6E98, 0x9FE3, 0x6E9C, 0x97AD, - 0x6E9D, 0x8D61, 0x6E9F, 0x9FF0, 0x6EA2, 0x88EC, 0x6EA5, 0x9FEE, - 0x6EAA, 0x9FE2, 0x6EAF, 0x9FE8, 0x6EB2, 0x9FEA, 0x6EB6, 0x976E, - 0x6EB7, 0x9FE5, 0x6EBA, 0x934D, 0x6EBD, 0x9FE7, 0x6EBF, 0xFB4A, - 0x6EC2, 0x9FEF, 0x6EC4, 0x9FE9, 0x6EC5, 0x96C5, 0x6EC9, 0x9FE4, - 0x6ECB, 0x8EA0, 0x6ECC, 0x9FFC, 0x6ED1, 0x8A8A, 0x6ED3, 0x9FE6, - 0x6ED4, 0x9FEB, 0x6ED5, 0x9FEC, 0x6EDD, 0x91EA, 0x6EDE, 0x91D8, - 0x6EEC, 0x9FF4, 0x6EEF, 0x9FFA, 0x6EF2, 0x9FF8, 0x6EF4, 0x9348, - 0x6EF7, 0xE042, 0x6EF8, 0x9FF5, 0x6EFE, 0x9FF6, 0x6EFF, 0x9FDE, - 0x6F01, 0x8B99, 0x6F02, 0x9559, 0x6F06, 0x8EBD, 0x6F09, 0x8D97, - 0x6F0F, 0x9852, 0x6F11, 0x9FF2, 0x6F13, 0xE041, 0x6F14, 0x8989, - 0x6F15, 0x9186, 0x6F20, 0x9499, 0x6F22, 0x8ABF, 0x6F23, 0x97F8, - 0x6F2B, 0x969F, 0x6F2C, 0x92D0, 0x6F31, 0x9FF9, 0x6F32, 0x9FFB, - 0x6F38, 0x9151, 0x6F3E, 0xE040, 0x6F3F, 0x9FF7, 0x6F41, 0x9FF1, - 0x6F45, 0x8AC1, 0x6F54, 0x8C89, 0x6F58, 0xE04E, 0x6F5B, 0xE049, - 0x6F5C, 0x90F6, 0x6F5F, 0x8A83, 0x6F64, 0x8F81, 0x6F66, 0xE052, - 0x6F6D, 0xE04B, 0x6F6E, 0x92AA, 0x6F6F, 0xE048, 0x6F70, 0x92D7, - 0x6F74, 0xE06B, 0x6F78, 0xE045, 0x6F7A, 0xE044, 0x6F7C, 0xE04D, - 0x6F80, 0xE047, 0x6F81, 0xE046, 0x6F82, 0xE04C, 0x6F84, 0x909F, - 0x6F86, 0xE043, 0x6F88, 0xFB4B, 0x6F8E, 0xE04F, 0x6F91, 0xE050, - 0x6F97, 0x8AC0, 0x6FA1, 0xE055, 0x6FA3, 0xE054, 0x6FA4, 0xE056, - 0x6FAA, 0xE059, 0x6FB1, 0x9362, 0x6FB3, 0xE053, 0x6FB5, 0xFB4C, - 0x6FB9, 0xE057, 0x6FC0, 0x8C83, 0x6FC1, 0x91F7, 0x6FC2, 0xE051, - 0x6FC3, 0x945A, 0x6FC6, 0xE058, 0x6FD4, 0xE05D, 0x6FD5, 0xE05B, - 0x6FD8, 0xE05E, 0x6FDB, 0xE061, 0x6FDF, 0xE05A, 0x6FE0, 0x8D8A, - 0x6FE1, 0x9447, 0x6FE4, 0x9FB7, 0x6FEB, 0x9794, 0x6FEC, 0xE05C, - 0x6FEE, 0xE060, 0x6FEF, 0x91F3, 0x6FF1, 0xE05F, 0x6FF3, 0xE04A, - 0x6FF5, 0xFB4D, 0x6FF6, 0xE889, 0x6FFA, 0xE064, 0x6FFE, 0xE068, - 0x7001, 0xE066, 0x7005, 0xFB4E, 0x7007, 0xFB4F, 0x7009, 0xE062, - 0x700B, 0xE063, 0x700F, 0xE067, 0x7011, 0xE065, 0x7015, 0x956D, - 0x7018, 0xE06D, 0x701A, 0xE06A, 0x701B, 0xE069, 0x701D, 0xE06C, - 0x701E, 0x93D2, 0x701F, 0xE06E, 0x7026, 0x9295, 0x7027, 0x91EB, - 0x7028, 0xFB50, 0x702C, 0x90A3, 0x7030, 0xE06F, 0x7032, 0xE071, - 0x703E, 0xE070, 0x704C, 0x9FF3, 0x7051, 0xE072, 0x7058, 0x93E5, - 0x7063, 0xE073, 0x706B, 0x89CE, 0x706F, 0x9394, 0x7070, 0x8A44, - 0x7078, 0x8B84, 0x707C, 0x8EDC, 0x707D, 0x8DD0, 0x7085, 0xFB51, - 0x7089, 0x9846, 0x708A, 0x9086, 0x708E, 0x898A, 0x7092, 0xE075, - 0x7099, 0xE074, 0x70AB, 0xFB52, 0x70AC, 0xE078, 0x70AD, 0x9259, - 0x70AE, 0xE07B, 0x70AF, 0xE076, 0x70B3, 0xE07A, 0x70B8, 0xE079, - 0x70B9, 0x935F, 0x70BA, 0x88D7, 0x70BB, 0xFA62, 0x70C8, 0x97F3, - 0x70CB, 0xE07D, 0x70CF, 0x8947, 0x70D9, 0xE080, 0x70DD, 0xE07E, - 0x70DF, 0xE07C, 0x70F1, 0xE077, 0x70F9, 0x9642, 0x70FD, 0xE082, - 0x7104, 0xFB54, 0x7109, 0xE081, 0x710F, 0xFB53, 0x7114, 0x898B, - 0x7119, 0xE084, 0x711A, 0x95B0, 0x711C, 0xE083, 0x7121, 0x96B3, - 0x7126, 0x8FC5, 0x7136, 0x9152, 0x713C, 0x8FC4, 0x7146, 0xFB56, - 0x7147, 0xFB57, 0x7149, 0x97F9, 0x714C, 0xE08A, 0x714E, 0x90F7, - 0x7155, 0xE086, 0x7156, 0xE08B, 0x7159, 0x898C, 0x715C, 0xFB55, - 0x7162, 0xE089, 0x7164, 0x9481, 0x7165, 0xE085, 0x7166, 0xE088, - 0x7167, 0x8FC6, 0x7169, 0x94CF, 0x716C, 0xE08C, 0x716E, 0x8ECF, - 0x717D, 0x90F8, 0x7184, 0xE08F, 0x7188, 0xE087, 0x718A, 0x8C46, - 0x718F, 0xE08D, 0x7194, 0x976F, 0x7195, 0xE090, 0x7199, 0xEAA4, - 0x719F, 0x8F6E, 0x71A8, 0xE091, 0x71AC, 0xE092, 0x71B1, 0x944D, - 0x71B9, 0xE094, 0x71BE, 0xE095, 0x71C1, 0xFB59, 0x71C3, 0x9452, - 0x71C8, 0x9395, 0x71C9, 0xE097, 0x71CE, 0xE099, 0x71D0, 0x97D3, - 0x71D2, 0xE096, 0x71D4, 0xE098, 0x71D5, 0x898D, 0x71D7, 0xE093, - 0x71DF, 0x9A7A, 0x71E0, 0xE09A, 0x71E5, 0x9187, 0x71E6, 0x8E57, - 0x71E7, 0xE09C, 0x71EC, 0xE09B, 0x71ED, 0x9043, 0x71EE, 0x99D7, - 0x71F5, 0xE09D, 0x71F9, 0xE09F, 0x71FB, 0xE08E, 0x71FC, 0xE09E, - 0x71FE, 0xFB5A, 0x71FF, 0xE0A0, 0x7206, 0x949A, 0x720D, 0xE0A1, - 0x7210, 0xE0A2, 0x721B, 0xE0A3, 0x7228, 0xE0A4, 0x722A, 0x92DC, - 0x722C, 0xE0A6, 0x722D, 0xE0A5, 0x7230, 0xE0A7, 0x7232, 0xE0A8, - 0x7235, 0x8EDD, 0x7236, 0x9583, 0x723A, 0x96EA, 0x723B, 0xE0A9, - 0x723C, 0xE0AA, 0x723D, 0x9175, 0x723E, 0x8EA2, 0x723F, 0xE0AB, - 0x7240, 0xE0AC, 0x7246, 0xE0AD, 0x7247, 0x95D0, 0x7248, 0x94C5, - 0x724B, 0xE0AE, 0x724C, 0x9476, 0x7252, 0x92AB, 0x7258, 0xE0AF, - 0x7259, 0x89E5, 0x725B, 0x8B8D, 0x725D, 0x96C4, 0x725F, 0x96B4, - 0x7261, 0x89B2, 0x7262, 0x9853, 0x7267, 0x9671, 0x7269, 0x95A8, - 0x7272, 0x90B5, 0x7274, 0xE0B0, 0x7279, 0x93C1, 0x727D, 0x8CA1, - 0x727E, 0xE0B1, 0x7280, 0x8DD2, 0x7281, 0xE0B3, 0x7282, 0xE0B2, - 0x7287, 0xE0B4, 0x7292, 0xE0B5, 0x7296, 0xE0B6, 0x72A0, 0x8B5D, - 0x72A2, 0xE0B7, 0x72A7, 0xE0B8, 0x72AC, 0x8CA2, 0x72AF, 0x94C6, - 0x72B1, 0xFB5B, 0x72B2, 0xE0BA, 0x72B6, 0x8FF3, 0x72B9, 0xE0B9, - 0x72BE, 0xFB5C, 0x72C2, 0x8BB6, 0x72C3, 0xE0BB, 0x72C4, 0xE0BD, - 0x72C6, 0xE0BC, 0x72CE, 0xE0BE, 0x72D0, 0x8CCF, 0x72D2, 0xE0BF, - 0x72D7, 0x8BE7, 0x72D9, 0x915F, 0x72DB, 0x8D9D, 0x72E0, 0xE0C1, - 0x72E1, 0xE0C2, 0x72E2, 0xE0C0, 0x72E9, 0x8EEB, 0x72EC, 0x93C6, - 0x72ED, 0x8BB7, 0x72F7, 0xE0C4, 0x72F8, 0x924B, 0x72F9, 0xE0C3, - 0x72FC, 0x9854, 0x72FD, 0x9482, 0x730A, 0xE0C7, 0x7316, 0xE0C9, - 0x7317, 0xE0C6, 0x731B, 0x96D2, 0x731C, 0xE0C8, 0x731D, 0xE0CA, - 0x731F, 0x97C2, 0x7324, 0xFB5D, 0x7325, 0xE0CE, 0x7329, 0xE0CD, - 0x732A, 0x9296, 0x732B, 0x944C, 0x732E, 0x8CA3, 0x732F, 0xE0CC, - 0x7334, 0xE0CB, 0x7336, 0x9750, 0x7337, 0x9751, 0x733E, 0xE0CF, - 0x733F, 0x898E, 0x7344, 0x8D96, 0x7345, 0x8E82, 0x734E, 0xE0D0, - 0x734F, 0xE0D1, 0x7357, 0xE0D3, 0x7363, 0x8F62, 0x7368, 0xE0D5, - 0x736A, 0xE0D4, 0x7370, 0xE0D6, 0x7372, 0x8A6C, 0x7375, 0xE0D8, - 0x7377, 0xFB5F, 0x7378, 0xE0D7, 0x737A, 0xE0DA, 0x737B, 0xE0D9, - 0x7384, 0x8CBA, 0x7387, 0x97A6, 0x7389, 0x8BCA, 0x738B, 0x89A4, - 0x7396, 0x8BE8, 0x73A9, 0x8ADF, 0x73B2, 0x97E6, 0x73B3, 0xE0DC, - 0x73BB, 0xE0DE, 0x73BD, 0xFB60, 0x73C0, 0xE0DF, 0x73C2, 0x89CF, - 0x73C8, 0xE0DB, 0x73C9, 0xFB61, 0x73CA, 0x8E58, 0x73CD, 0x92BF, - 0x73CE, 0xE0DD, 0x73D2, 0xFB64, 0x73D6, 0xFB62, 0x73DE, 0xE0E2, - 0x73E0, 0x8EEC, 0x73E3, 0xFB63, 0x73E5, 0xE0E0, 0x73EA, 0x8C5D, - 0x73ED, 0x94C7, 0x73EE, 0xE0E1, 0x73F1, 0xE0FC, 0x73F5, 0xFB66, - 0x73F8, 0xE0E7, 0x73FE, 0x8CBB, 0x7403, 0x8B85, 0x7405, 0xE0E4, - 0x7406, 0x979D, 0x7407, 0xFB65, 0x7409, 0x97AE, 0x7422, 0x91F4, - 0x7425, 0xE0E6, 0x7426, 0xFB67, 0x7429, 0xFB69, 0x742A, 0xFB68, - 0x742E, 0xFB6A, 0x7432, 0xE0E8, 0x7433, 0x97D4, 0x7434, 0x8BD5, - 0x7435, 0x94FA, 0x7436, 0x9469, 0x743A, 0xE0E9, 0x743F, 0xE0EB, - 0x7441, 0xE0EE, 0x7455, 0xE0EA, 0x7459, 0xE0ED, 0x745A, 0x8CE8, - 0x745B, 0x896C, 0x745C, 0xE0EF, 0x745E, 0x9090, 0x745F, 0xE0EC, - 0x7460, 0x97DA, 0x7462, 0xFB6B, 0x7463, 0xE0F2, 0x7464, 0xEAA2, - 0x7469, 0xE0F0, 0x746A, 0xE0F3, 0x746F, 0xE0E5, 0x7470, 0xE0F1, - 0x7473, 0x8DBA, 0x7476, 0xE0F4, 0x747E, 0xE0F5, 0x7483, 0x979E, - 0x7489, 0xFB6C, 0x748B, 0xE0F6, 0x749E, 0xE0F7, 0x749F, 0xFB6D, - 0x74A2, 0xE0E3, 0x74A7, 0xE0F8, 0x74B0, 0x8AC2, 0x74BD, 0x8EA3, - 0x74CA, 0xE0F9, 0x74CF, 0xE0FA, 0x74D4, 0xE0FB, 0x74DC, 0x895A, - 0x74E0, 0xE140, 0x74E2, 0x955A, 0x74E3, 0xE141, 0x74E6, 0x8AA2, - 0x74E7, 0xE142, 0x74E9, 0xE143, 0x74EE, 0xE144, 0x74F0, 0xE146, - 0x74F1, 0xE147, 0x74F2, 0xE145, 0x74F6, 0x9572, 0x74F7, 0xE149, - 0x74F8, 0xE148, 0x7501, 0xFB6E, 0x7503, 0xE14B, 0x7504, 0xE14A, - 0x7505, 0xE14C, 0x750C, 0xE14D, 0x750D, 0xE14F, 0x750E, 0xE14E, - 0x7511, 0x8D99, 0x7513, 0xE151, 0x7515, 0xE150, 0x7518, 0x8AC3, - 0x751A, 0x9072, 0x751C, 0x935B, 0x751E, 0xE152, 0x751F, 0x90B6, - 0x7523, 0x8E59, 0x7525, 0x8999, 0x7526, 0xE153, 0x7528, 0x9770, - 0x752B, 0x95E1, 0x752C, 0xE154, 0x752F, 0xFAA8, 0x7530, 0x9363, - 0x7531, 0x9752, 0x7532, 0x8D62, 0x7533, 0x905C, 0x7537, 0x926A, - 0x7538, 0x99B2, 0x753A, 0x92AC, 0x753B, 0x89E6, 0x753C, 0xE155, - 0x7544, 0xE156, 0x7546, 0xE15B, 0x7549, 0xE159, 0x754A, 0xE158, - 0x754B, 0x9DC0, 0x754C, 0x8A45, 0x754D, 0xE157, 0x754F, 0x88D8, - 0x7551, 0x94A8, 0x7554, 0x94C8, 0x7559, 0x97AF, 0x755A, 0xE15C, - 0x755B, 0xE15A, 0x755C, 0x927B, 0x755D, 0x90A4, 0x7560, 0x94A9, - 0x7562, 0x954C, 0x7564, 0xE15E, 0x7565, 0x97AA, 0x7566, 0x8C6C, - 0x7567, 0xE15F, 0x7569, 0xE15D, 0x756A, 0x94D4, 0x756B, 0xE160, - 0x756D, 0xE161, 0x756F, 0xFB6F, 0x7570, 0x88D9, 0x7573, 0x8FF4, - 0x7574, 0xE166, 0x7576, 0xE163, 0x7577, 0x93EB, 0x7578, 0xE162, - 0x757F, 0x8B45, 0x7582, 0xE169, 0x7586, 0xE164, 0x7587, 0xE165, - 0x7589, 0xE168, 0x758A, 0xE167, 0x758B, 0x9544, 0x758E, 0x9161, - 0x758F, 0x9160, 0x7591, 0x8B5E, 0x7594, 0xE16A, 0x759A, 0xE16B, - 0x759D, 0xE16C, 0x75A3, 0xE16E, 0x75A5, 0xE16D, 0x75AB, 0x8975, - 0x75B1, 0xE176, 0x75B2, 0x94E6, 0x75B3, 0xE170, 0x75B5, 0xE172, - 0x75B8, 0xE174, 0x75B9, 0x905D, 0x75BC, 0xE175, 0x75BD, 0xE173, - 0x75BE, 0x8EBE, 0x75C2, 0xE16F, 0x75C3, 0xE171, 0x75C5, 0x9561, - 0x75C7, 0x8FC7, 0x75CA, 0xE178, 0x75CD, 0xE177, 0x75D2, 0xE179, - 0x75D4, 0x8EA4, 0x75D5, 0x8DAD, 0x75D8, 0x9397, 0x75D9, 0xE17A, - 0x75DB, 0x92C9, 0x75DE, 0xE17C, 0x75E2, 0x979F, 0x75E3, 0xE17B, - 0x75E9, 0x9189, 0x75F0, 0xE182, 0x75F2, 0xE184, 0x75F3, 0xE185, - 0x75F4, 0x9273, 0x75FA, 0xE183, 0x75FC, 0xE180, 0x75FE, 0xE17D, - 0x75FF, 0xE17E, 0x7601, 0xE181, 0x7609, 0xE188, 0x760B, 0xE186, - 0x760D, 0xE187, 0x761F, 0xE189, 0x7620, 0xE18B, 0x7621, 0xE18C, - 0x7622, 0xE18D, 0x7624, 0xE18E, 0x7627, 0xE18A, 0x7630, 0xE190, - 0x7634, 0xE18F, 0x763B, 0xE191, 0x7642, 0x97C3, 0x7646, 0xE194, - 0x7647, 0xE192, 0x7648, 0xE193, 0x764C, 0x8AE0, 0x7652, 0x96FC, - 0x7656, 0x95C8, 0x7658, 0xE196, 0x765C, 0xE195, 0x7661, 0xE197, - 0x7662, 0xE198, 0x7667, 0xE19C, 0x7668, 0xE199, 0x7669, 0xE19A, - 0x766A, 0xE19B, 0x766C, 0xE19D, 0x7670, 0xE19E, 0x7672, 0xE19F, - 0x7676, 0xE1A0, 0x7678, 0xE1A1, 0x767A, 0x94AD, 0x767B, 0x936F, - 0x767C, 0xE1A2, 0x767D, 0x9492, 0x767E, 0x9553, 0x7680, 0xE1A3, - 0x7682, 0xFB70, 0x7683, 0xE1A4, 0x7684, 0x9349, 0x7686, 0x8A46, - 0x7687, 0x8D63, 0x7688, 0xE1A5, 0x768B, 0xE1A6, 0x768E, 0xE1A7, - 0x7690, 0x8E48, 0x7693, 0xE1A9, 0x7696, 0xE1A8, 0x7699, 0xE1AA, - 0x769A, 0xE1AB, 0x769B, 0xFB73, 0x769C, 0xFB71, 0x769E, 0xFB72, - 0x76A6, 0xFB74, 0x76AE, 0x94E7, 0x76B0, 0xE1AC, 0x76B4, 0xE1AD, - 0x76B7, 0xEA89, 0x76B8, 0xE1AE, 0x76B9, 0xE1AF, 0x76BA, 0xE1B0, - 0x76BF, 0x8E4D, 0x76C2, 0xE1B1, 0x76C3, 0x9475, 0x76C6, 0x967E, - 0x76C8, 0x896D, 0x76CA, 0x8976, 0x76CD, 0xE1B2, 0x76D2, 0xE1B4, - 0x76D6, 0xE1B3, 0x76D7, 0x9390, 0x76DB, 0x90B7, 0x76DC, 0x9F58, - 0x76DE, 0xE1B5, 0x76DF, 0x96BF, 0x76E1, 0xE1B6, 0x76E3, 0x8AC4, - 0x76E4, 0x94D5, 0x76E5, 0xE1B7, 0x76E7, 0xE1B8, 0x76EA, 0xE1B9, - 0x76EE, 0x96DA, 0x76F2, 0x96D3, 0x76F4, 0x92BC, 0x76F8, 0x918A, - 0x76FB, 0xE1BB, 0x76FE, 0x8F82, 0x7701, 0x8FC8, 0x7704, 0xE1BE, - 0x7707, 0xE1BD, 0x7708, 0xE1BC, 0x7709, 0x94FB, 0x770B, 0x8AC5, - 0x770C, 0x8CA7, 0x771B, 0xE1C4, 0x771E, 0xE1C1, 0x771F, 0x905E, - 0x7720, 0x96B0, 0x7724, 0xE1C0, 0x7725, 0xE1C2, 0x7726, 0xE1C3, - 0x7729, 0xE1BF, 0x7737, 0xE1C5, 0x7738, 0xE1C6, 0x773A, 0x92AD, - 0x773C, 0x8AE1, 0x7740, 0x9285, 0x7746, 0xFB76, 0x7747, 0xE1C7, - 0x775A, 0xE1C8, 0x775B, 0xE1CB, 0x7761, 0x9087, 0x7763, 0x93C2, - 0x7765, 0xE1CC, 0x7766, 0x9672, 0x7768, 0xE1C9, 0x776B, 0xE1CA, - 0x7779, 0xE1CF, 0x777E, 0xE1CE, 0x777F, 0xE1CD, 0x778B, 0xE1D1, - 0x778E, 0xE1D0, 0x7791, 0xE1D2, 0x779E, 0xE1D4, 0x77A0, 0xE1D3, - 0x77A5, 0x95CB, 0x77AC, 0x8F75, 0x77AD, 0x97C4, 0x77B0, 0xE1D5, - 0x77B3, 0x93B5, 0x77B6, 0xE1D6, 0x77B9, 0xE1D7, 0x77BB, 0xE1DB, - 0x77BC, 0xE1D9, 0x77BD, 0xE1DA, 0x77BF, 0xE1D8, 0x77C7, 0xE1DC, - 0x77CD, 0xE1DD, 0x77D7, 0xE1DE, 0x77DA, 0xE1DF, 0x77DB, 0x96B5, - 0x77DC, 0xE1E0, 0x77E2, 0x96EE, 0x77E3, 0xE1E1, 0x77E5, 0x926D, - 0x77E7, 0x948A, 0x77E9, 0x8BE9, 0x77ED, 0x925A, 0x77EE, 0xE1E2, - 0x77EF, 0x8BB8, 0x77F3, 0x90CE, 0x77FC, 0xE1E3, 0x7802, 0x8DBB, - 0x780C, 0xE1E4, 0x7812, 0xE1E5, 0x7814, 0x8CA4, 0x7815, 0x8DD3, - 0x7820, 0xE1E7, 0x7821, 0xFB78, 0x7825, 0x9375, 0x7826, 0x8DD4, - 0x7827, 0x8B6D, 0x7832, 0x9643, 0x7834, 0x946A, 0x783A, 0x9376, - 0x783F, 0x8D7B, 0x7845, 0xE1E9, 0x784E, 0xFB79, 0x785D, 0x8FC9, - 0x7864, 0xFB7A, 0x786B, 0x97B0, 0x786C, 0x8D64, 0x786F, 0x8CA5, - 0x7872, 0x94A1, 0x7874, 0xE1EB, 0x787A, 0xFB7B, 0x787C, 0xE1ED, - 0x7881, 0x8CE9, 0x7886, 0xE1EC, 0x7887, 0x92F4, 0x788C, 0xE1EF, - 0x788D, 0x8A56, 0x788E, 0xE1EA, 0x7891, 0x94E8, 0x7893, 0x894F, - 0x7895, 0x8DEA, 0x7897, 0x9871, 0x789A, 0xE1EE, 0x78A3, 0xE1F0, - 0x78A7, 0x95C9, 0x78A9, 0x90D7, 0x78AA, 0xE1F2, 0x78AF, 0xE1F3, - 0x78B5, 0xE1F1, 0x78BA, 0x8A6D, 0x78BC, 0xE1F9, 0x78BE, 0xE1F8, - 0x78C1, 0x8EA5, 0x78C5, 0xE1FA, 0x78C6, 0xE1F5, 0x78CA, 0xE1FB, - 0x78CB, 0xE1F6, 0x78D0, 0x94D6, 0x78D1, 0xE1F4, 0x78D4, 0xE1F7, - 0x78DA, 0xE241, 0x78E7, 0xE240, 0x78E8, 0x9681, 0x78EC, 0xE1FC, - 0x78EF, 0x88E9, 0x78F4, 0xE243, 0x78FD, 0xE242, 0x7901, 0x8FCA, - 0x7907, 0xE244, 0x790E, 0x9162, 0x7911, 0xE246, 0x7912, 0xE245, - 0x7919, 0xE247, 0x7926, 0xE1E6, 0x792A, 0xE1E8, 0x792B, 0xE249, - 0x792C, 0xE248, 0x7930, 0xFB7C, 0x793A, 0x8EA6, 0x793C, 0x97E7, - 0x793E, 0x8ED0, 0x7940, 0xE24A, 0x7941, 0x8C56, 0x7947, 0x8B5F, - 0x7948, 0x8B46, 0x7949, 0x8E83, 0x7950, 0x9753, 0x7953, 0xE250, - 0x7955, 0xE24F, 0x7956, 0x9163, 0x7957, 0xE24C, 0x795A, 0xE24E, - 0x795D, 0x8F6A, 0x795E, 0x905F, 0x795F, 0xE24D, 0x7960, 0xE24B, - 0x7962, 0x9449, 0x7965, 0x8FCB, 0x7968, 0x955B, 0x796D, 0x8DD5, - 0x7977, 0x9398, 0x797A, 0xE251, 0x797F, 0xE252, 0x7980, 0xE268, - 0x7981, 0x8BD6, 0x7984, 0x985C, 0x7985, 0x9154, 0x798A, 0xE253, - 0x798D, 0x89D0, 0x798E, 0x92F5, 0x798F, 0x959F, 0x7994, 0xFB81, - 0x799B, 0xFB83, 0x799D, 0xE254, 0x79A6, 0x8B9A, 0x79A7, 0xE255, - 0x79AA, 0xE257, 0x79AE, 0xE258, 0x79B0, 0x9448, 0x79B3, 0xE259, - 0x79B9, 0xE25A, 0x79BA, 0xE25B, 0x79BD, 0x8BD7, 0x79BE, 0x89D1, - 0x79BF, 0x93C3, 0x79C0, 0x8F47, 0x79C1, 0x8E84, 0x79C9, 0xE25C, - 0x79CB, 0x8F48, 0x79D1, 0x89C8, 0x79D2, 0x9562, 0x79D5, 0xE25D, - 0x79D8, 0x94E9, 0x79DF, 0x9164, 0x79E1, 0xE260, 0x79E3, 0xE261, - 0x79E4, 0x9489, 0x79E6, 0x9060, 0x79E7, 0xE25E, 0x79E9, 0x9281, - 0x79EC, 0xE25F, 0x79F0, 0x8FCC, 0x79FB, 0x88DA, 0x7A00, 0x8B48, - 0x7A08, 0xE262, 0x7A0B, 0x92F6, 0x7A0D, 0xE263, 0x7A0E, 0x90C5, - 0x7A14, 0x96AB, 0x7A17, 0x9542, 0x7A18, 0xE264, 0x7A19, 0xE265, - 0x7A1A, 0x9274, 0x7A1C, 0x97C5, 0x7A1F, 0xE267, 0x7A20, 0xE266, - 0x7A2E, 0x8EED, 0x7A31, 0xE269, 0x7A32, 0x88EE, 0x7A37, 0xE26C, - 0x7A3B, 0xE26A, 0x7A3C, 0x89D2, 0x7A3D, 0x8C6D, 0x7A3E, 0xE26B, - 0x7A3F, 0x8D65, 0x7A40, 0x8D92, 0x7A42, 0x95E4, 0x7A43, 0xE26D, - 0x7A46, 0x9673, 0x7A49, 0xE26F, 0x7A4D, 0x90CF, 0x7A4E, 0x896E, - 0x7A4F, 0x89B8, 0x7A50, 0x88AA, 0x7A57, 0xE26E, 0x7A61, 0xE270, - 0x7A62, 0xE271, 0x7A63, 0x8FF5, 0x7A69, 0xE272, 0x7A6B, 0x8A6E, - 0x7A70, 0xE274, 0x7A74, 0x8C8A, 0x7A76, 0x8B86, 0x7A79, 0xE275, - 0x7A7A, 0x8BF3, 0x7A7D, 0xE276, 0x7A7F, 0x90FA, 0x7A81, 0x93CB, - 0x7A83, 0x90DE, 0x7A84, 0x8DF3, 0x7A88, 0xE277, 0x7A92, 0x9282, - 0x7A93, 0x918B, 0x7A95, 0xE279, 0x7A96, 0xE27B, 0x7A97, 0xE278, - 0x7A98, 0xE27A, 0x7A9F, 0x8C41, 0x7AA9, 0xE27C, 0x7AAA, 0x8C45, - 0x7AAE, 0x8B87, 0x7AAF, 0x9771, 0x7AB0, 0xE27E, 0x7AB6, 0xE280, - 0x7ABA, 0x894D, 0x7ABF, 0xE283, 0x7AC3, 0x8A96, 0x7AC4, 0xE282, - 0x7AC5, 0xE281, 0x7AC7, 0xE285, 0x7AC8, 0xE27D, 0x7ACA, 0xE286, - 0x7ACB, 0x97A7, 0x7ACD, 0xE287, 0x7ACF, 0xE288, 0x7AD1, 0xFB84, - 0x7AD2, 0x9AF2, 0x7AD3, 0xE28A, 0x7AD5, 0xE289, 0x7AD9, 0xE28B, - 0x7ADA, 0xE28C, 0x7ADC, 0x97B3, 0x7ADD, 0xE28D, 0x7ADF, 0xE8ED, - 0x7AE0, 0x8FCD, 0x7AE1, 0xE28E, 0x7AE2, 0xE28F, 0x7AE3, 0x8F76, - 0x7AE5, 0x93B6, 0x7AE6, 0xE290, 0x7AE7, 0xFB85, 0x7AEA, 0x9247, - 0x7AEB, 0xFB87, 0x7AED, 0xE291, 0x7AEF, 0x925B, 0x7AF0, 0xE292, - 0x7AF6, 0x8BA3, 0x7AF8, 0x995E, 0x7AF9, 0x927C, 0x7AFA, 0x8EB1, - 0x7AFF, 0x8AC6, 0x7B02, 0xE293, 0x7B04, 0xE2A0, 0x7B06, 0xE296, - 0x7B08, 0x8B88, 0x7B0A, 0xE295, 0x7B0B, 0xE2A2, 0x7B0F, 0xE294, - 0x7B11, 0x8FCE, 0x7B18, 0xE298, 0x7B19, 0xE299, 0x7B1B, 0x934A, - 0x7B1E, 0xE29A, 0x7B20, 0x8A7D, 0x7B25, 0x9079, 0x7B26, 0x9584, - 0x7B28, 0xE29C, 0x7B2C, 0x91E6, 0x7B33, 0xE297, 0x7B35, 0xE29B, - 0x7B36, 0xE29D, 0x7B39, 0x8DF9, 0x7B45, 0xE2A4, 0x7B46, 0x954D, - 0x7B48, 0x94A4, 0x7B49, 0x9399, 0x7B4B, 0x8BD8, 0x7B4C, 0xE2A3, - 0x7B4D, 0xE2A1, 0x7B4F, 0x94B3, 0x7B50, 0xE29E, 0x7B51, 0x927D, - 0x7B52, 0x939B, 0x7B54, 0x939A, 0x7B56, 0x8DF4, 0x7B5D, 0xE2B6, - 0x7B65, 0xE2A6, 0x7B67, 0xE2A8, 0x7B6C, 0xE2AB, 0x7B6E, 0xE2AC, - 0x7B70, 0xE2A9, 0x7B71, 0xE2AA, 0x7B74, 0xE2A7, 0x7B75, 0xE2A5, - 0x7B7A, 0xE29F, 0x7B86, 0x95CD, 0x7B87, 0x89D3, 0x7B8B, 0xE2B3, - 0x7B8D, 0xE2B0, 0x7B8F, 0xE2B5, 0x7B92, 0xE2B4, 0x7B94, 0x9493, - 0x7B95, 0x96A5, 0x7B97, 0x8E5A, 0x7B98, 0xE2AE, 0x7B99, 0xE2B7, - 0x7B9A, 0xE2B2, 0x7B9C, 0xE2B1, 0x7B9D, 0xE2AD, 0x7B9E, 0xFB88, - 0x7B9F, 0xE2AF, 0x7BA1, 0x8AC7, 0x7BAA, 0x925C, 0x7BAD, 0x90FB, - 0x7BB1, 0x94A0, 0x7BB4, 0xE2BC, 0x7BB8, 0x94A2, 0x7BC0, 0x90DF, - 0x7BC1, 0xE2B9, 0x7BC4, 0x94CD, 0x7BC6, 0xE2BD, 0x7BC7, 0x95D1, - 0x7BC9, 0x927A, 0x7BCB, 0xE2B8, 0x7BCC, 0xE2BA, 0x7BCF, 0xE2BB, - 0x7BDD, 0xE2BE, 0x7BE0, 0x8EC2, 0x7BE4, 0x93C4, 0x7BE5, 0xE2C3, - 0x7BE6, 0xE2C2, 0x7BE9, 0xE2BF, 0x7BED, 0x9855, 0x7BF3, 0xE2C8, - 0x7BF6, 0xE2CC, 0x7BF7, 0xE2C9, 0x7C00, 0xE2C5, 0x7C07, 0xE2C6, - 0x7C0D, 0xE2CB, 0x7C11, 0xE2C0, 0x7C12, 0x99D3, 0x7C13, 0xE2C7, - 0x7C14, 0xE2C1, 0x7C17, 0xE2CA, 0x7C1F, 0xE2D0, 0x7C21, 0x8AC8, - 0x7C23, 0xE2CD, 0x7C27, 0xE2CE, 0x7C2A, 0xE2CF, 0x7C2B, 0xE2D2, - 0x7C37, 0xE2D1, 0x7C38, 0x94F4, 0x7C3D, 0xE2D3, 0x7C3E, 0x97FA, - 0x7C3F, 0x95EB, 0x7C40, 0xE2D8, 0x7C43, 0xE2D5, 0x7C4C, 0xE2D4, - 0x7C4D, 0x90D0, 0x7C4F, 0xE2D7, 0x7C50, 0xE2D9, 0x7C54, 0xE2D6, - 0x7C56, 0xE2DD, 0x7C58, 0xE2DA, 0x7C5F, 0xE2DB, 0x7C60, 0xE2C4, - 0x7C64, 0xE2DC, 0x7C65, 0xE2DE, 0x7C6C, 0xE2DF, 0x7C73, 0x95C4, - 0x7C75, 0xE2E0, 0x7C7E, 0x96E0, 0x7C81, 0x8BCC, 0x7C82, 0x8C48, - 0x7C83, 0xE2E1, 0x7C89, 0x95B2, 0x7C8B, 0x9088, 0x7C8D, 0x96AE, - 0x7C90, 0xE2E2, 0x7C92, 0x97B1, 0x7C95, 0x9494, 0x7C97, 0x9165, - 0x7C98, 0x9453, 0x7C9B, 0x8F6C, 0x7C9F, 0x88BE, 0x7CA1, 0xE2E7, - 0x7CA2, 0xE2E5, 0x7CA4, 0xE2E3, 0x7CA5, 0x8A9F, 0x7CA7, 0x8FCF, - 0x7CA8, 0xE2E8, 0x7CAB, 0xE2E6, 0x7CAD, 0xE2E4, 0x7CAE, 0xE2EC, - 0x7CB1, 0xE2EB, 0x7CB2, 0xE2EA, 0x7CB3, 0xE2E9, 0x7CB9, 0xE2ED, - 0x7CBD, 0xE2EE, 0x7CBE, 0x90B8, 0x7CC0, 0xE2EF, 0x7CC2, 0xE2F1, - 0x7CC5, 0xE2F0, 0x7CCA, 0x8CD0, 0x7CCE, 0x9157, 0x7CD2, 0xE2F3, - 0x7CD6, 0x939C, 0x7CD8, 0xE2F2, 0x7CDC, 0xE2F4, 0x7CDE, 0x95B3, - 0x7CDF, 0x918C, 0x7CE0, 0x8D66, 0x7CE2, 0xE2F5, 0x7CE7, 0x97C6, - 0x7CEF, 0xE2F7, 0x7CF2, 0xE2F8, 0x7CF4, 0xE2F9, 0x7CF6, 0xE2FA, - 0x7CF8, 0x8E85, 0x7CFA, 0xE2FB, 0x7CFB, 0x8C6E, 0x7CFE, 0x8B8A, - 0x7D00, 0x8B49, 0x7D02, 0xE340, 0x7D04, 0x96F1, 0x7D05, 0x8D67, - 0x7D06, 0xE2FC, 0x7D0A, 0xE343, 0x7D0B, 0x96E4, 0x7D0D, 0x945B, - 0x7D10, 0x9552, 0x7D14, 0x8F83, 0x7D15, 0xE342, 0x7D17, 0x8ED1, - 0x7D18, 0x8D68, 0x7D19, 0x8E86, 0x7D1A, 0x8B89, 0x7D1B, 0x95B4, - 0x7D1C, 0xE341, 0x7D20, 0x9166, 0x7D21, 0x9661, 0x7D22, 0x8DF5, - 0x7D2B, 0x8E87, 0x7D2C, 0x92DB, 0x7D2E, 0xE346, 0x7D2F, 0x97DD, - 0x7D30, 0x8DD7, 0x7D32, 0xE347, 0x7D33, 0x9061, 0x7D35, 0xE349, - 0x7D39, 0x8FD0, 0x7D3A, 0x8DAE, 0x7D3F, 0xE348, 0x7D42, 0x8F49, - 0x7D43, 0x8CBC, 0x7D44, 0x9167, 0x7D45, 0xE344, 0x7D46, 0xE34A, - 0x7D48, 0xFB8A, 0x7D4B, 0xE345, 0x7D4C, 0x8C6F, 0x7D4E, 0xE34D, - 0x7D4F, 0xE351, 0x7D50, 0x8C8B, 0x7D56, 0xE34C, 0x7D5B, 0xE355, - 0x7D5C, 0xFB8B, 0x7D5E, 0x8D69, 0x7D61, 0x978D, 0x7D62, 0x88BA, - 0x7D63, 0xE352, 0x7D66, 0x8B8B, 0x7D68, 0xE34F, 0x7D6E, 0xE350, - 0x7D71, 0x939D, 0x7D72, 0xE34E, 0x7D73, 0xE34B, 0x7D75, 0x8A47, - 0x7D76, 0x90E2, 0x7D79, 0x8CA6, 0x7D7D, 0xE357, 0x7D89, 0xE354, - 0x7D8F, 0xE356, 0x7D93, 0xE353, 0x7D99, 0x8C70, 0x7D9A, 0x91B1, - 0x7D9B, 0xE358, 0x7D9C, 0x918E, 0x7D9F, 0xE365, 0x7DA0, 0xFB8D, - 0x7DA2, 0xE361, 0x7DA3, 0xE35B, 0x7DAB, 0xE35F, 0x7DAC, 0x8EF8, - 0x7DAD, 0x88DB, 0x7DAE, 0xE35A, 0x7DAF, 0xE362, 0x7DB0, 0xE366, - 0x7DB1, 0x8D6A, 0x7DB2, 0x96D4, 0x7DB4, 0x92D4, 0x7DB5, 0xE35C, - 0x7DB7, 0xFB8C, 0x7DB8, 0xE364, 0x7DBA, 0xE359, 0x7DBB, 0x925D, - 0x7DBD, 0xE35E, 0x7DBE, 0x88BB, 0x7DBF, 0x96C8, 0x7DC7, 0xE35D, - 0x7DCA, 0x8BD9, 0x7DCB, 0x94EA, 0x7DCF, 0x918D, 0x7DD1, 0x97CE, - 0x7DD2, 0x8F8F, 0x7DD5, 0xE38E, 0x7DD6, 0xFB8E, 0x7DD8, 0xE367, - 0x7DDA, 0x90FC, 0x7DDC, 0xE363, 0x7DDD, 0xE368, 0x7DDE, 0xE36A, - 0x7DE0, 0x92F7, 0x7DE1, 0xE36D, 0x7DE4, 0xE369, 0x7DE8, 0x95D2, - 0x7DE9, 0x8AC9, 0x7DEC, 0x96C9, 0x7DEF, 0x88DC, 0x7DF2, 0xE36C, - 0x7DF4, 0x97FB, 0x7DFB, 0xE36B, 0x7E01, 0x898F, 0x7E04, 0x93EA, - 0x7E05, 0xE36E, 0x7E09, 0xE375, 0x7E0A, 0xE36F, 0x7E0B, 0xE376, - 0x7E12, 0xE372, 0x7E1B, 0x949B, 0x7E1E, 0x8EC8, 0x7E1F, 0xE374, - 0x7E21, 0xE371, 0x7E22, 0xE377, 0x7E23, 0xE370, 0x7E26, 0x8F63, - 0x7E2B, 0x9644, 0x7E2E, 0x8F6B, 0x7E31, 0xE373, 0x7E32, 0xE380, - 0x7E35, 0xE37B, 0x7E37, 0xE37E, 0x7E39, 0xE37C, 0x7E3A, 0xE381, - 0x7E3B, 0xE37A, 0x7E3D, 0xE360, 0x7E3E, 0x90D1, 0x7E41, 0x94C9, - 0x7E43, 0xE37D, 0x7E46, 0xE378, 0x7E4A, 0x9140, 0x7E4B, 0x8C71, - 0x7E4D, 0x8F4A, 0x7E52, 0xFB8F, 0x7E54, 0x9044, 0x7E55, 0x9155, - 0x7E56, 0xE384, 0x7E59, 0xE386, 0x7E5A, 0xE387, 0x7E5D, 0xE383, - 0x7E5E, 0xE385, 0x7E66, 0xE379, 0x7E67, 0xE382, 0x7E69, 0xE38A, - 0x7E6A, 0xE389, 0x7E6D, 0x969A, 0x7E70, 0x8C4A, 0x7E79, 0xE388, - 0x7E7B, 0xE38C, 0x7E7C, 0xE38B, 0x7E7D, 0xE38F, 0x7E7F, 0xE391, - 0x7E82, 0x8E5B, 0x7E83, 0xE38D, 0x7E88, 0xE392, 0x7E89, 0xE393, - 0x7E8A, 0xFA5C, 0x7E8C, 0xE394, 0x7E8E, 0xE39A, 0x7E8F, 0x935A, - 0x7E90, 0xE396, 0x7E92, 0xE395, 0x7E93, 0xE397, 0x7E94, 0xE398, - 0x7E96, 0xE399, 0x7E9B, 0xE39B, 0x7E9C, 0xE39C, 0x7F36, 0x8ACA, - 0x7F38, 0xE39D, 0x7F3A, 0xE39E, 0x7F45, 0xE39F, 0x7F47, 0xFB90, - 0x7F4C, 0xE3A0, 0x7F4D, 0xE3A1, 0x7F4E, 0xE3A2, 0x7F50, 0xE3A3, - 0x7F51, 0xE3A4, 0x7F54, 0xE3A6, 0x7F55, 0xE3A5, 0x7F58, 0xE3A7, - 0x7F5F, 0xE3A8, 0x7F60, 0xE3A9, 0x7F67, 0xE3AC, 0x7F68, 0xE3AA, - 0x7F69, 0xE3AB, 0x7F6A, 0x8DDF, 0x7F6B, 0x8C72, 0x7F6E, 0x9275, - 0x7F70, 0x94B1, 0x7F72, 0x8F90, 0x7F75, 0x946C, 0x7F77, 0x94EB, - 0x7F78, 0xE3AD, 0x7F79, 0x9CEB, 0x7F82, 0xE3AE, 0x7F83, 0xE3B0, - 0x7F85, 0x9785, 0x7F86, 0xE3AF, 0x7F87, 0xE3B2, 0x7F88, 0xE3B1, - 0x7F8A, 0x9772, 0x7F8C, 0xE3B3, 0x7F8E, 0x94FC, 0x7F94, 0xE3B4, - 0x7F9A, 0xE3B7, 0x7F9D, 0xE3B6, 0x7F9E, 0xE3B5, 0x7FA1, 0xFB91, - 0x7FA3, 0xE3B8, 0x7FA4, 0x8C51, 0x7FA8, 0x9141, 0x7FA9, 0x8B60, - 0x7FAE, 0xE3BC, 0x7FAF, 0xE3B9, 0x7FB2, 0xE3BA, 0x7FB6, 0xE3BD, - 0x7FB8, 0xE3BE, 0x7FB9, 0xE3BB, 0x7FBD, 0x8948, 0x7FC1, 0x89A5, - 0x7FC5, 0xE3C0, 0x7FC6, 0xE3C1, 0x7FCA, 0xE3C2, 0x7FCC, 0x9782, - 0x7FD2, 0x8F4B, 0x7FD4, 0xE3C4, 0x7FD5, 0xE3C3, 0x7FE0, 0x9089, - 0x7FE1, 0xE3C5, 0x7FE6, 0xE3C6, 0x7FE9, 0xE3C7, 0x7FEB, 0x8AE3, - 0x7FF0, 0x8ACB, 0x7FF3, 0xE3C8, 0x7FF9, 0xE3C9, 0x7FFB, 0x967C, - 0x7FFC, 0x9783, 0x8000, 0x9773, 0x8001, 0x9856, 0x8003, 0x8D6C, - 0x8004, 0xE3CC, 0x8005, 0x8ED2, 0x8006, 0xE3CB, 0x800B, 0xE3CD, - 0x800C, 0x8EA7, 0x8010, 0x91CF, 0x8012, 0xE3CE, 0x8015, 0x8D6B, - 0x8017, 0x96D5, 0x8018, 0xE3CF, 0x8019, 0xE3D0, 0x801C, 0xE3D1, - 0x8021, 0xE3D2, 0x8028, 0xE3D3, 0x8033, 0x8EA8, 0x8036, 0x96EB, - 0x803B, 0xE3D5, 0x803D, 0x925E, 0x803F, 0xE3D4, 0x8046, 0xE3D7, - 0x804A, 0xE3D6, 0x8052, 0xE3D8, 0x8056, 0x90B9, 0x8058, 0xE3D9, - 0x805A, 0xE3DA, 0x805E, 0x95B7, 0x805F, 0xE3DB, 0x8061, 0x918F, - 0x8062, 0xE3DC, 0x8068, 0xE3DD, 0x806F, 0x97FC, 0x8070, 0xE3E0, - 0x8072, 0xE3DF, 0x8073, 0xE3DE, 0x8074, 0x92AE, 0x8076, 0xE3E1, - 0x8077, 0x9045, 0x8079, 0xE3E2, 0x807D, 0xE3E3, 0x807E, 0x9857, - 0x807F, 0xE3E4, 0x8084, 0xE3E5, 0x8085, 0xE3E7, 0x8086, 0xE3E6, - 0x8087, 0x94A3, 0x8089, 0x93F7, 0x808B, 0x985D, 0x808C, 0x94A7, - 0x8093, 0xE3E9, 0x8096, 0x8FD1, 0x8098, 0x9549, 0x809A, 0xE3EA, - 0x809B, 0xE3E8, 0x809D, 0x8ACC, 0x80A1, 0x8CD2, 0x80A2, 0x8E88, - 0x80A5, 0x94EC, 0x80A9, 0x8CA8, 0x80AA, 0x9662, 0x80AC, 0xE3ED, - 0x80AD, 0xE3EB, 0x80AF, 0x8D6D, 0x80B1, 0x8D6E, 0x80B2, 0x88E7, - 0x80B4, 0x8DE6, 0x80BA, 0x9478, 0x80C3, 0x88DD, 0x80C4, 0xE3F2, - 0x80C6, 0x925F, 0x80CC, 0x9477, 0x80CE, 0x91D9, 0x80D6, 0xE3F4, - 0x80D9, 0xE3F0, 0x80DA, 0xE3F3, 0x80DB, 0xE3EE, 0x80DD, 0xE3F1, - 0x80DE, 0x9645, 0x80E1, 0x8CD3, 0x80E4, 0x88FB, 0x80E5, 0xE3EF, - 0x80EF, 0xE3F6, 0x80F1, 0xE3F7, 0x80F4, 0x93B7, 0x80F8, 0x8BB9, - 0x80FC, 0xE445, 0x80FD, 0x945C, 0x8102, 0x8E89, 0x8105, 0x8BBA, - 0x8106, 0x90C6, 0x8107, 0x9865, 0x8108, 0x96AC, 0x8109, 0xE3F5, - 0x810A, 0x90D2, 0x811A, 0x8B72, 0x811B, 0xE3F8, 0x8123, 0xE3FA, - 0x8129, 0xE3F9, 0x812F, 0xE3FB, 0x8131, 0x9245, 0x8133, 0x945D, - 0x8139, 0x92AF, 0x813E, 0xE442, 0x8146, 0xE441, 0x814B, 0xE3FC, - 0x814E, 0x9074, 0x8150, 0x9585, 0x8151, 0xE444, 0x8153, 0xE443, - 0x8154, 0x8D6F, 0x8155, 0x9872, 0x815F, 0xE454, 0x8165, 0xE448, - 0x8166, 0xE449, 0x816B, 0x8EEE, 0x816E, 0xE447, 0x8170, 0x8D98, - 0x8171, 0xE446, 0x8174, 0xE44A, 0x8178, 0x92B0, 0x8179, 0x95A0, - 0x817A, 0x9142, 0x817F, 0x91DA, 0x8180, 0xE44E, 0x8182, 0xE44F, - 0x8183, 0xE44B, 0x8188, 0xE44C, 0x818A, 0xE44D, 0x818F, 0x8D70, - 0x8193, 0xE455, 0x8195, 0xE451, 0x819A, 0x9586, 0x819C, 0x968C, - 0x819D, 0x9547, 0x81A0, 0xE450, 0x81A3, 0xE453, 0x81A4, 0xE452, - 0x81A8, 0x9663, 0x81A9, 0xE456, 0x81B0, 0xE457, 0x81B3, 0x9156, - 0x81B5, 0xE458, 0x81B8, 0xE45A, 0x81BA, 0xE45E, 0x81BD, 0xE45B, - 0x81BE, 0xE459, 0x81BF, 0x945E, 0x81C0, 0xE45C, 0x81C2, 0xE45D, - 0x81C6, 0x89B0, 0x81C8, 0xE464, 0x81C9, 0xE45F, 0x81CD, 0xE460, - 0x81D1, 0xE461, 0x81D3, 0x919F, 0x81D8, 0xE463, 0x81D9, 0xE462, - 0x81DA, 0xE465, 0x81DF, 0xE466, 0x81E0, 0xE467, 0x81E3, 0x9062, - 0x81E5, 0x89E7, 0x81E7, 0xE468, 0x81E8, 0x97D5, 0x81EA, 0x8EA9, - 0x81ED, 0x8F4C, 0x81F3, 0x8E8A, 0x81F4, 0x9276, 0x81FA, 0xE469, - 0x81FB, 0xE46A, 0x81FC, 0x8950, 0x81FE, 0xE46B, 0x8201, 0xE46C, - 0x8202, 0xE46D, 0x8205, 0xE46E, 0x8207, 0xE46F, 0x8208, 0x8BBB, - 0x8209, 0x9DA8, 0x820A, 0xE470, 0x820C, 0x90E3, 0x820D, 0xE471, - 0x820E, 0x8EC9, 0x8210, 0xE472, 0x8212, 0x98AE, 0x8216, 0xE473, - 0x8217, 0x95DC, 0x8218, 0x8ADA, 0x821B, 0x9143, 0x821C, 0x8F77, - 0x821E, 0x9591, 0x821F, 0x8F4D, 0x8229, 0xE474, 0x822A, 0x8D71, - 0x822B, 0xE475, 0x822C, 0x94CA, 0x822E, 0xE484, 0x8233, 0xE477, - 0x8235, 0x91C7, 0x8236, 0x9495, 0x8237, 0x8CBD, 0x8238, 0xE476, - 0x8239, 0x9144, 0x8240, 0xE478, 0x8247, 0x92F8, 0x8258, 0xE47A, - 0x8259, 0xE479, 0x825A, 0xE47C, 0x825D, 0xE47B, 0x825F, 0xE47D, - 0x8262, 0xE480, 0x8264, 0xE47E, 0x8266, 0x8ACD, 0x8268, 0xE481, - 0x826A, 0xE482, 0x826B, 0xE483, 0x826E, 0x8DAF, 0x826F, 0x97C7, - 0x8271, 0xE485, 0x8272, 0x9046, 0x8276, 0x8990, 0x8277, 0xE486, - 0x8278, 0xE487, 0x827E, 0xE488, 0x828B, 0x88F0, 0x828D, 0xE489, - 0x8292, 0xE48A, 0x8299, 0x9587, 0x829D, 0x8EC5, 0x829F, 0xE48C, - 0x82A5, 0x8A48, 0x82A6, 0x88B0, 0x82AB, 0xE48B, 0x82AC, 0xE48E, - 0x82AD, 0x946D, 0x82AF, 0x9063, 0x82B1, 0x89D4, 0x82B3, 0x9646, - 0x82B8, 0x8C7C, 0x82B9, 0x8BDA, 0x82BB, 0xE48D, 0x82BD, 0x89E8, - 0x82C5, 0x8AA1, 0x82D1, 0x8991, 0x82D2, 0xE492, 0x82D3, 0x97E8, - 0x82D4, 0x91DB, 0x82D7, 0x9563, 0x82D9, 0xE49E, 0x82DB, 0x89D5, - 0x82DC, 0xE49C, 0x82DE, 0xE49A, 0x82DF, 0xE491, 0x82E1, 0xE48F, - 0x82E3, 0xE490, 0x82E5, 0x8EE1, 0x82E6, 0x8BEA, 0x82E7, 0x9297, - 0x82EB, 0x93CF, 0x82F1, 0x8970, 0x82F3, 0xE494, 0x82F4, 0xE493, - 0x82F9, 0xE499, 0x82FA, 0xE495, 0x82FB, 0xE498, 0x8301, 0xFB93, - 0x8302, 0x96CE, 0x8303, 0xE497, 0x8304, 0x89D6, 0x8305, 0x8A9D, - 0x8306, 0xE49B, 0x8309, 0xE49D, 0x830E, 0x8C73, 0x8316, 0xE4A1, - 0x8317, 0xE4AA, 0x8318, 0xE4AB, 0x831C, 0x88A9, 0x8323, 0xE4B2, - 0x8328, 0x88EF, 0x832B, 0xE4A9, 0x832F, 0xE4A8, 0x8331, 0xE4A3, - 0x8332, 0xE4A2, 0x8334, 0xE4A0, 0x8335, 0xE49F, 0x8336, 0x9283, - 0x8338, 0x91F9, 0x8339, 0xE4A5, 0x8340, 0xE4A4, 0x8345, 0xE4A7, - 0x8349, 0x9190, 0x834A, 0x8C74, 0x834F, 0x8960, 0x8350, 0xE4A6, - 0x8352, 0x8D72, 0x8358, 0x9191, 0x8362, 0xFB94, 0x8373, 0xE4B8, - 0x8375, 0xE4B9, 0x8377, 0x89D7, 0x837B, 0x89AC, 0x837C, 0xE4B6, - 0x837F, 0xFB95, 0x8385, 0xE4AC, 0x8387, 0xE4B4, 0x8389, 0xE4BB, - 0x838A, 0xE4B5, 0x838E, 0xE4B3, 0x8393, 0xE496, 0x8396, 0xE4B1, - 0x839A, 0xE4AD, 0x839E, 0x8ACE, 0x839F, 0xE4AF, 0x83A0, 0xE4BA, - 0x83A2, 0xE4B0, 0x83A8, 0xE4BC, 0x83AA, 0xE4AE, 0x83AB, 0x949C, - 0x83B1, 0x9789, 0x83B5, 0xE4B7, 0x83BD, 0xE4CD, 0x83C1, 0xE4C5, - 0x83C5, 0x909B, 0x83C7, 0xFB96, 0x83CA, 0x8B65, 0x83CC, 0x8BDB, - 0x83CE, 0xE4C0, 0x83D3, 0x89D9, 0x83D6, 0x8FD2, 0x83D8, 0xE4C3, - 0x83DC, 0x8DD8, 0x83DF, 0x9370, 0x83E0, 0xE4C8, 0x83E9, 0x95EC, - 0x83EB, 0xE4BF, 0x83EF, 0x89D8, 0x83F0, 0x8CD4, 0x83F1, 0x9548, - 0x83F2, 0xE4C9, 0x83F4, 0xE4BD, 0x83F6, 0xFB97, 0x83F7, 0xE4C6, - 0x83FB, 0xE4D0, 0x83FD, 0xE4C1, 0x8403, 0xE4C2, 0x8404, 0x93B8, - 0x8407, 0xE4C7, 0x840B, 0xE4C4, 0x840C, 0x9647, 0x840D, 0xE4CA, - 0x840E, 0x88DE, 0x8413, 0xE4BE, 0x8420, 0xE4CC, 0x8422, 0xE4CB, - 0x8429, 0x948B, 0x842A, 0xE4D2, 0x842C, 0xE4DD, 0x8431, 0x8A9E, - 0x8435, 0xE4E0, 0x8438, 0xE4CE, 0x843C, 0xE4D3, 0x843D, 0x978E, - 0x8446, 0xE4DC, 0x8448, 0xFB98, 0x8449, 0x9774, 0x844E, 0x97A8, - 0x8457, 0x9298, 0x845B, 0x8A8B, 0x8461, 0x9592, 0x8462, 0xE4E2, - 0x8463, 0x939F, 0x8466, 0x88AF, 0x8469, 0xE4DB, 0x846B, 0xE4D7, - 0x846C, 0x9192, 0x846D, 0xE4D1, 0x846E, 0xE4D9, 0x846F, 0xE4DE, - 0x8471, 0x944B, 0x8475, 0x88A8, 0x8477, 0xE4D6, 0x8479, 0xE4DF, - 0x847A, 0x9598, 0x8482, 0xE4DA, 0x8484, 0xE4D5, 0x848B, 0x8FD3, - 0x8490, 0x8F4E, 0x8494, 0x8EAA, 0x8499, 0x96D6, 0x849C, 0x9566, - 0x849F, 0xE4E5, 0x84A1, 0xE4EE, 0x84AD, 0xE4D8, 0x84B2, 0x8A97, - 0x84B4, 0xFB99, 0x84B8, 0x8FF6, 0x84B9, 0xE4E3, 0x84BB, 0xE4E8, - 0x84BC, 0x9193, 0x84BF, 0xE4E4, 0x84C1, 0xE4EB, 0x84C4, 0x927E, - 0x84C6, 0xE4EC, 0x84C9, 0x9775, 0x84CA, 0xE4E1, 0x84CB, 0x8A57, - 0x84CD, 0xE4E7, 0x84D0, 0xE4EA, 0x84D1, 0x96AA, 0x84D6, 0xE4ED, - 0x84D9, 0xE4E6, 0x84DA, 0xE4E9, 0x84DC, 0xFA60, 0x84EC, 0x9648, - 0x84EE, 0x9840, 0x84F4, 0xE4F1, 0x84FC, 0xE4F8, 0x84FF, 0xE4F0, - 0x8500, 0x8EC1, 0x8506, 0xE4CF, 0x8511, 0x95CC, 0x8513, 0x96A0, - 0x8514, 0xE4F7, 0x8515, 0xE4F6, 0x8517, 0xE4F2, 0x8518, 0xE4F3, - 0x851A, 0x8955, 0x851F, 0xE4F5, 0x8521, 0xE4EF, 0x8526, 0x92D3, - 0x852C, 0xE4F4, 0x852D, 0x88FC, 0x8535, 0x91A0, 0x853D, 0x95C1, - 0x8540, 0xE4F9, 0x8541, 0xE540, 0x8543, 0x94D7, 0x8548, 0xE4FC, - 0x8549, 0x8FD4, 0x854A, 0x8EC7, 0x854B, 0xE542, 0x854E, 0x8BBC, - 0x8553, 0xFB9A, 0x8555, 0xE543, 0x8557, 0x9599, 0x8558, 0xE4FB, - 0x8559, 0xFB9B, 0x855A, 0xE4D4, 0x8563, 0xE4FA, 0x8568, 0x986E, - 0x8569, 0x93A0, 0x856A, 0x9593, 0x856B, 0xFB9C, 0x856D, 0xE54A, - 0x8577, 0xE550, 0x857E, 0xE551, 0x8580, 0xE544, 0x8584, 0x9496, - 0x8587, 0xE54E, 0x8588, 0xE546, 0x858A, 0xE548, 0x8590, 0xE552, - 0x8591, 0xE547, 0x8594, 0xE54B, 0x8597, 0x8992, 0x8599, 0x93E3, - 0x859B, 0xE54C, 0x859C, 0xE54F, 0x85A4, 0xE545, 0x85A6, 0x9145, - 0x85A8, 0xE549, 0x85A9, 0x8E46, 0x85AA, 0x9064, 0x85AB, 0x8C4F, - 0x85AC, 0x96F2, 0x85AE, 0x96F7, 0x85AF, 0x8F92, 0x85B0, 0xFB9E, - 0x85B9, 0xE556, 0x85BA, 0xE554, 0x85C1, 0x986D, 0x85C9, 0xE553, - 0x85CD, 0x9795, 0x85CF, 0xE555, 0x85D0, 0xE557, 0x85D5, 0xE558, - 0x85DC, 0xE55B, 0x85DD, 0xE559, 0x85E4, 0x93A1, 0x85E5, 0xE55A, - 0x85E9, 0x94CB, 0x85EA, 0xE54D, 0x85F7, 0x8F93, 0x85F9, 0xE55C, - 0x85FA, 0xE561, 0x85FB, 0x9194, 0x85FE, 0xE560, 0x8602, 0xE541, - 0x8606, 0xE562, 0x8607, 0x9168, 0x860A, 0xE55D, 0x860B, 0xE55F, - 0x8613, 0xE55E, 0x8616, 0x9F50, 0x8617, 0x9F41, 0x861A, 0xE564, - 0x8622, 0xE563, 0x862D, 0x9796, 0x862F, 0xE1BA, 0x8630, 0xE565, - 0x863F, 0xE566, 0x864D, 0xE567, 0x864E, 0x8CD5, 0x8650, 0x8B73, - 0x8654, 0xE569, 0x8655, 0x997C, 0x865A, 0x8B95, 0x865C, 0x97B8, - 0x865E, 0x8BF1, 0x865F, 0xE56A, 0x8667, 0xE56B, 0x866B, 0x928E, - 0x8671, 0xE56C, 0x8679, 0x93F8, 0x867B, 0x88B8, 0x868A, 0x89E1, - 0x868B, 0xE571, 0x868C, 0xE572, 0x8693, 0xE56D, 0x8695, 0x8E5C, - 0x86A3, 0xE56E, 0x86A4, 0x9461, 0x86A9, 0xE56F, 0x86AA, 0xE570, - 0x86AB, 0xE57A, 0x86AF, 0xE574, 0x86B0, 0xE577, 0x86B6, 0xE573, - 0x86C4, 0xE575, 0x86C6, 0xE576, 0x86C7, 0x8ED6, 0x86C9, 0xE578, - 0x86CB, 0x9260, 0x86CD, 0x8C75, 0x86CE, 0x8A61, 0x86D4, 0xE57B, - 0x86D9, 0x8A5E, 0x86DB, 0xE581, 0x86DE, 0xE57C, 0x86DF, 0xE580, - 0x86E4, 0x94B8, 0x86E9, 0xE57D, 0x86EC, 0xE57E, 0x86ED, 0x9567, - 0x86EE, 0x94D8, 0x86EF, 0xE582, 0x86F8, 0x91FB, 0x86F9, 0xE58C, - 0x86FB, 0xE588, 0x86FE, 0x89E9, 0x8700, 0xE586, 0x8702, 0x9649, - 0x8703, 0xE587, 0x8706, 0xE584, 0x8708, 0xE585, 0x8709, 0xE58A, - 0x870A, 0xE58D, 0x870D, 0xE58B, 0x8711, 0xE589, 0x8712, 0xE583, - 0x8718, 0x9277, 0x871A, 0xE594, 0x871C, 0x96A8, 0x8725, 0xE592, - 0x8729, 0xE593, 0x8734, 0xE58E, 0x8737, 0xE590, 0x873B, 0xE591, - 0x873F, 0xE58F, 0x8749, 0x90E4, 0x874B, 0x9858, 0x874C, 0xE598, - 0x874E, 0xE599, 0x8753, 0xE59F, 0x8755, 0x9049, 0x8757, 0xE59B, - 0x8759, 0xE59E, 0x875F, 0xE596, 0x8760, 0xE595, 0x8763, 0xE5A0, - 0x8766, 0x89DA, 0x8768, 0xE59C, 0x876A, 0xE5A1, 0x876E, 0xE59D, - 0x8774, 0xE59A, 0x8776, 0x92B1, 0x8778, 0xE597, 0x877F, 0x9488, - 0x8782, 0xE5A5, 0x878D, 0x975A, 0x879F, 0xE5A4, 0x87A2, 0xE5A3, - 0x87AB, 0xE5AC, 0x87AF, 0xE5A6, 0x87B3, 0xE5AE, 0x87BA, 0x9786, - 0x87BB, 0xE5B1, 0x87BD, 0xE5A8, 0x87C0, 0xE5A9, 0x87C4, 0xE5AD, - 0x87C6, 0xE5B0, 0x87C7, 0xE5AF, 0x87CB, 0xE5A7, 0x87D0, 0xE5AA, - 0x87D2, 0xE5BB, 0x87E0, 0xE5B4, 0x87EF, 0xE5B2, 0x87F2, 0xE5B3, - 0x87F6, 0xE5B8, 0x87F7, 0xE5B9, 0x87F9, 0x8A49, 0x87FB, 0x8B61, - 0x87FE, 0xE5B7, 0x8805, 0xE5A2, 0x8807, 0xFBA1, 0x880D, 0xE5B6, - 0x880E, 0xE5BA, 0x880F, 0xE5B5, 0x8811, 0xE5BC, 0x8815, 0xE5BE, - 0x8816, 0xE5BD, 0x8821, 0xE5C0, 0x8822, 0xE5BF, 0x8823, 0xE579, - 0x8827, 0xE5C4, 0x8831, 0xE5C1, 0x8836, 0xE5C2, 0x8839, 0xE5C3, - 0x883B, 0xE5C5, 0x8840, 0x8C8C, 0x8842, 0xE5C7, 0x8844, 0xE5C6, - 0x8846, 0x8F4F, 0x884C, 0x8D73, 0x884D, 0x9FA5, 0x8852, 0xE5C8, - 0x8853, 0x8F70, 0x8857, 0x8A58, 0x8859, 0xE5C9, 0x885B, 0x8971, - 0x885D, 0x8FD5, 0x885E, 0xE5CA, 0x8861, 0x8D74, 0x8862, 0xE5CB, - 0x8863, 0x88DF, 0x8868, 0x955C, 0x886B, 0xE5CC, 0x8870, 0x908A, - 0x8872, 0xE5D3, 0x8875, 0xE5D0, 0x8877, 0x928F, 0x887D, 0xE5D1, - 0x887E, 0xE5CE, 0x887F, 0x8BDC, 0x8881, 0xE5CD, 0x8882, 0xE5D4, - 0x8888, 0x8C55, 0x888B, 0x91DC, 0x888D, 0xE5DA, 0x8892, 0xE5D6, - 0x8896, 0x91B3, 0x8897, 0xE5D5, 0x8899, 0xE5D8, 0x889E, 0xE5CF, - 0x88A2, 0xE5D9, 0x88A4, 0xE5DB, 0x88AB, 0x94ED, 0x88AE, 0xE5D7, - 0x88B0, 0xE5DC, 0x88B1, 0xE5DE, 0x88B4, 0x8CD1, 0x88B5, 0xE5D2, - 0x88B7, 0x88BF, 0x88BF, 0xE5DD, 0x88C1, 0x8DD9, 0x88C2, 0x97F4, - 0x88C3, 0xE5DF, 0x88C4, 0xE5E0, 0x88C5, 0x9195, 0x88CF, 0x97A0, - 0x88D4, 0xE5E1, 0x88D5, 0x9754, 0x88D8, 0xE5E2, 0x88D9, 0xE5E3, - 0x88DC, 0x95E2, 0x88DD, 0xE5E4, 0x88DF, 0x8DBE, 0x88E1, 0x97A1, - 0x88E8, 0xE5E9, 0x88F2, 0xE5EA, 0x88F3, 0x8FD6, 0x88F4, 0xE5E8, - 0x88F5, 0xFBA2, 0x88F8, 0x9787, 0x88F9, 0xE5E5, 0x88FC, 0xE5E7, - 0x88FD, 0x90BB, 0x88FE, 0x909E, 0x8902, 0xE5E6, 0x8904, 0xE5EB, - 0x8907, 0x95A1, 0x890A, 0xE5ED, 0x890C, 0xE5EC, 0x8910, 0x8A8C, - 0x8912, 0x964A, 0x8913, 0xE5EE, 0x891C, 0xFA5D, 0x891D, 0xE5FA, - 0x891E, 0xE5F0, 0x8925, 0xE5F1, 0x892A, 0xE5F2, 0x892B, 0xE5F3, - 0x8936, 0xE5F7, 0x8938, 0xE5F8, 0x893B, 0xE5F6, 0x8941, 0xE5F4, - 0x8943, 0xE5EF, 0x8944, 0xE5F5, 0x894C, 0xE5F9, 0x894D, 0xE8B5, - 0x8956, 0x89A6, 0x895E, 0xE5FC, 0x895F, 0x8BDD, 0x8960, 0xE5FB, - 0x8964, 0xE641, 0x8966, 0xE640, 0x896A, 0xE643, 0x896D, 0xE642, - 0x896F, 0xE644, 0x8972, 0x8F50, 0x8974, 0xE645, 0x8977, 0xE646, - 0x897E, 0xE647, 0x897F, 0x90BC, 0x8981, 0x9776, 0x8983, 0xE648, - 0x8986, 0x95A2, 0x8987, 0x9465, 0x8988, 0xE649, 0x898A, 0xE64A, - 0x898B, 0x8CA9, 0x898F, 0x8B4B, 0x8993, 0xE64B, 0x8996, 0x8E8B, - 0x8997, 0x9460, 0x8998, 0xE64C, 0x899A, 0x8A6F, 0x89A1, 0xE64D, - 0x89A6, 0xE64F, 0x89A7, 0x9797, 0x89A9, 0xE64E, 0x89AA, 0x9065, - 0x89AC, 0xE650, 0x89AF, 0xE651, 0x89B2, 0xE652, 0x89B3, 0x8ACF, - 0x89BA, 0xE653, 0x89BD, 0xE654, 0x89BF, 0xE655, 0x89C0, 0xE656, - 0x89D2, 0x8A70, 0x89DA, 0xE657, 0x89DC, 0xE658, 0x89DD, 0xE659, - 0x89E3, 0x89F0, 0x89E6, 0x9047, 0x89E7, 0xE65A, 0x89F4, 0xE65B, - 0x89F8, 0xE65C, 0x8A00, 0x8CBE, 0x8A02, 0x92F9, 0x8A03, 0xE65D, - 0x8A08, 0x8C76, 0x8A0A, 0x9075, 0x8A0C, 0xE660, 0x8A0E, 0x93A2, - 0x8A10, 0xE65F, 0x8A12, 0xFBA3, 0x8A13, 0x8C50, 0x8A16, 0xE65E, - 0x8A17, 0x91F5, 0x8A18, 0x8B4C, 0x8A1B, 0xE661, 0x8A1D, 0xE662, - 0x8A1F, 0x8FD7, 0x8A23, 0x8C8D, 0x8A25, 0xE663, 0x8A2A, 0x964B, - 0x8A2D, 0x90DD, 0x8A31, 0x8B96, 0x8A33, 0x96F3, 0x8A34, 0x9169, - 0x8A36, 0xE664, 0x8A37, 0xFBA4, 0x8A3A, 0x9066, 0x8A3B, 0x9290, - 0x8A3C, 0x8FD8, 0x8A41, 0xE665, 0x8A46, 0xE668, 0x8A48, 0xE669, - 0x8A50, 0x8DBC, 0x8A51, 0x91C0, 0x8A52, 0xE667, 0x8A54, 0x8FD9, - 0x8A55, 0x955D, 0x8A5B, 0xE666, 0x8A5E, 0x8E8C, 0x8A60, 0x8972, - 0x8A62, 0xE66D, 0x8A63, 0x8C77, 0x8A66, 0x8E8E, 0x8A69, 0x8E8D, - 0x8A6B, 0x986C, 0x8A6C, 0xE66C, 0x8A6D, 0xE66B, 0x8A6E, 0x9146, - 0x8A70, 0x8B6C, 0x8A71, 0x9862, 0x8A72, 0x8A59, 0x8A73, 0x8FDA, - 0x8A79, 0xFBA5, 0x8A7C, 0xE66A, 0x8A82, 0xE66F, 0x8A84, 0xE670, - 0x8A85, 0xE66E, 0x8A87, 0x8CD6, 0x8A89, 0x975F, 0x8A8C, 0x8E8F, - 0x8A8D, 0x9446, 0x8A91, 0xE673, 0x8A93, 0x90BE, 0x8A95, 0x9261, - 0x8A98, 0x9755, 0x8A9A, 0xE676, 0x8A9E, 0x8CEA, 0x8AA0, 0x90BD, - 0x8AA1, 0xE672, 0x8AA3, 0xE677, 0x8AA4, 0x8CEB, 0x8AA5, 0xE674, - 0x8AA6, 0xE675, 0x8AA7, 0xFBA6, 0x8AA8, 0xE671, 0x8AAC, 0x90E0, - 0x8AAD, 0x93C7, 0x8AB0, 0x924E, 0x8AB2, 0x89DB, 0x8AB9, 0x94EE, - 0x8ABC, 0x8B62, 0x8ABE, 0xFBA7, 0x8ABF, 0x92B2, 0x8AC2, 0xE67A, - 0x8AC4, 0xE678, 0x8AC7, 0x926B, 0x8ACB, 0x90BF, 0x8ACC, 0x8AD0, - 0x8ACD, 0xE679, 0x8ACF, 0x907A, 0x8AD2, 0x97C8, 0x8AD6, 0x985F, - 0x8ADA, 0xE67B, 0x8ADB, 0xE687, 0x8ADC, 0x92B3, 0x8ADE, 0xE686, - 0x8ADF, 0xFBA8, 0x8AE0, 0xE683, 0x8AE1, 0xE68B, 0x8AE2, 0xE684, - 0x8AE4, 0xE680, 0x8AE6, 0x92FA, 0x8AE7, 0xE67E, 0x8AEB, 0xE67C, - 0x8AED, 0x9740, 0x8AEE, 0x8E90, 0x8AF1, 0xE681, 0x8AF3, 0xE67D, - 0x8AF6, 0xFBAA, 0x8AF7, 0xE685, 0x8AF8, 0x8F94, 0x8AFA, 0x8CBF, - 0x8AFE, 0x91F8, 0x8B00, 0x9664, 0x8B01, 0x8979, 0x8B02, 0x88E0, - 0x8B04, 0x93A3, 0x8B07, 0xE689, 0x8B0C, 0xE688, 0x8B0E, 0x93E4, - 0x8B10, 0xE68D, 0x8B14, 0xE682, 0x8B16, 0xE68C, 0x8B17, 0xE68E, - 0x8B19, 0x8CAA, 0x8B1A, 0xE68A, 0x8B1B, 0x8D75, 0x8B1D, 0x8ED3, - 0x8B20, 0xE68F, 0x8B21, 0x9777, 0x8B26, 0xE692, 0x8B28, 0xE695, - 0x8B2B, 0xE693, 0x8B2C, 0x9554, 0x8B33, 0xE690, 0x8B39, 0x8BDE, - 0x8B3E, 0xE694, 0x8B41, 0xE696, 0x8B49, 0xE69A, 0x8B4C, 0xE697, - 0x8B4E, 0xE699, 0x8B4F, 0xE698, 0x8B53, 0xFBAB, 0x8B56, 0xE69B, - 0x8B58, 0x8EAF, 0x8B5A, 0xE69D, 0x8B5B, 0xE69C, 0x8B5C, 0x9588, - 0x8B5F, 0xE69F, 0x8B66, 0x8C78, 0x8B6B, 0xE69E, 0x8B6C, 0xE6A0, - 0x8B6F, 0xE6A1, 0x8B70, 0x8B63, 0x8B71, 0xE3BF, 0x8B72, 0x8FF7, - 0x8B74, 0xE6A2, 0x8B77, 0x8CEC, 0x8B7D, 0xE6A3, 0x8B7F, 0xFBAC, - 0x8B80, 0xE6A4, 0x8B83, 0x8E5D, 0x8B8A, 0x9DCC, 0x8B8C, 0xE6A5, - 0x8B8E, 0xE6A6, 0x8B90, 0x8F51, 0x8B92, 0xE6A7, 0x8B93, 0xE6A8, - 0x8B96, 0xE6A9, 0x8B99, 0xE6AA, 0x8B9A, 0xE6AB, 0x8C37, 0x924A, - 0x8C3A, 0xE6AC, 0x8C3F, 0xE6AE, 0x8C41, 0xE6AD, 0x8C46, 0x93A4, - 0x8C48, 0xE6AF, 0x8C4A, 0x964C, 0x8C4C, 0xE6B0, 0x8C4E, 0xE6B1, - 0x8C50, 0xE6B2, 0x8C55, 0xE6B3, 0x8C5A, 0x93D8, 0x8C61, 0x8FDB, - 0x8C62, 0xE6B4, 0x8C6A, 0x8D8B, 0x8C6B, 0x98AC, 0x8C6C, 0xE6B5, - 0x8C78, 0xE6B6, 0x8C79, 0x955E, 0x8C7A, 0xE6B7, 0x8C7C, 0xE6BF, - 0x8C82, 0xE6B8, 0x8C85, 0xE6BA, 0x8C89, 0xE6B9, 0x8C8A, 0xE6BB, - 0x8C8C, 0x9665, 0x8C8D, 0xE6BC, 0x8C8E, 0xE6BD, 0x8C94, 0xE6BE, - 0x8C98, 0xE6C0, 0x8C9D, 0x8A4C, 0x8C9E, 0x92E5, 0x8CA0, 0x9589, - 0x8CA1, 0x8DE0, 0x8CA2, 0x8D76, 0x8CA7, 0x956E, 0x8CA8, 0x89DD, - 0x8CA9, 0x94CC, 0x8CAA, 0xE6C3, 0x8CAB, 0x8AD1, 0x8CAC, 0x90D3, - 0x8CAD, 0xE6C2, 0x8CAE, 0xE6C7, 0x8CAF, 0x9299, 0x8CB0, 0x96E1, - 0x8CB2, 0xE6C5, 0x8CB3, 0xE6C6, 0x8CB4, 0x8B4D, 0x8CB6, 0xE6C8, - 0x8CB7, 0x9483, 0x8CB8, 0x91DD, 0x8CBB, 0x94EF, 0x8CBC, 0x935C, - 0x8CBD, 0xE6C4, 0x8CBF, 0x9666, 0x8CC0, 0x89EA, 0x8CC1, 0xE6CA, - 0x8CC2, 0x9847, 0x8CC3, 0x92C0, 0x8CC4, 0x9864, 0x8CC7, 0x8E91, - 0x8CC8, 0xE6C9, 0x8CCA, 0x91AF, 0x8CCD, 0xE6DA, 0x8CCE, 0x9147, - 0x8CD1, 0x93F6, 0x8CD3, 0x956F, 0x8CDA, 0xE6CD, 0x8CDB, 0x8E5E, - 0x8CDC, 0x8E92, 0x8CDE, 0x8FDC, 0x8CE0, 0x9485, 0x8CE2, 0x8CAB, - 0x8CE3, 0xE6CC, 0x8CE4, 0xE6CB, 0x8CE6, 0x958A, 0x8CEA, 0x8EBF, - 0x8CED, 0x9371, 0x8CF0, 0xFBAD, 0x8CF4, 0xFBAE, 0x8CFA, 0xE6CF, - 0x8CFB, 0xE6D0, 0x8CFC, 0x8D77, 0x8CFD, 0xE6CE, 0x8D04, 0xE6D1, - 0x8D05, 0xE6D2, 0x8D07, 0xE6D4, 0x8D08, 0x91A1, 0x8D0A, 0xE6D3, - 0x8D0B, 0x8AE4, 0x8D0D, 0xE6D6, 0x8D0F, 0xE6D5, 0x8D10, 0xE6D7, - 0x8D12, 0xFBAF, 0x8D13, 0xE6D9, 0x8D14, 0xE6DB, 0x8D16, 0xE6DC, - 0x8D64, 0x90D4, 0x8D66, 0x8ECD, 0x8D67, 0xE6DD, 0x8D6B, 0x8A71, - 0x8D6D, 0xE6DE, 0x8D70, 0x9196, 0x8D71, 0xE6DF, 0x8D73, 0xE6E0, - 0x8D74, 0x958B, 0x8D76, 0xFBB0, 0x8D77, 0x8B4E, 0x8D81, 0xE6E1, - 0x8D85, 0x92B4, 0x8D8A, 0x897A, 0x8D99, 0xE6E2, 0x8DA3, 0x8EEF, - 0x8DA8, 0x9096, 0x8DB3, 0x91AB, 0x8DBA, 0xE6E5, 0x8DBE, 0xE6E4, - 0x8DC2, 0xE6E3, 0x8DCB, 0xE6EB, 0x8DCC, 0xE6E9, 0x8DCF, 0xE6E6, - 0x8DD6, 0xE6E8, 0x8DDA, 0xE6E7, 0x8DDB, 0xE6EA, 0x8DDD, 0x8B97, - 0x8DDF, 0xE6EE, 0x8DE1, 0x90D5, 0x8DE3, 0xE6EF, 0x8DE8, 0x8CD7, - 0x8DEA, 0xE6EC, 0x8DEB, 0xE6ED, 0x8DEF, 0x9848, 0x8DF3, 0x92B5, - 0x8DF5, 0x9148, 0x8DFC, 0xE6F0, 0x8DFF, 0xE6F3, 0x8E08, 0xE6F1, - 0x8E09, 0xE6F2, 0x8E0A, 0x9778, 0x8E0F, 0x93A5, 0x8E10, 0xE6F6, - 0x8E1D, 0xE6F4, 0x8E1E, 0xE6F5, 0x8E1F, 0xE6F7, 0x8E2A, 0xE748, - 0x8E30, 0xE6FA, 0x8E34, 0xE6FB, 0x8E35, 0xE6F9, 0x8E42, 0xE6F8, - 0x8E44, 0x92FB, 0x8E47, 0xE740, 0x8E48, 0xE744, 0x8E49, 0xE741, - 0x8E4A, 0xE6FC, 0x8E4C, 0xE742, 0x8E50, 0xE743, 0x8E55, 0xE74A, - 0x8E59, 0xE745, 0x8E5F, 0x90D6, 0x8E60, 0xE747, 0x8E63, 0xE749, - 0x8E64, 0xE746, 0x8E72, 0xE74C, 0x8E74, 0x8F52, 0x8E76, 0xE74B, - 0x8E7C, 0xE74D, 0x8E81, 0xE74E, 0x8E84, 0xE751, 0x8E85, 0xE750, - 0x8E87, 0xE74F, 0x8E8A, 0xE753, 0x8E8B, 0xE752, 0x8E8D, 0x96F4, - 0x8E91, 0xE755, 0x8E93, 0xE754, 0x8E94, 0xE756, 0x8E99, 0xE757, - 0x8EA1, 0xE759, 0x8EAA, 0xE758, 0x8EAB, 0x9067, 0x8EAC, 0xE75A, - 0x8EAF, 0x8BEB, 0x8EB0, 0xE75B, 0x8EB1, 0xE75D, 0x8EBE, 0xE75E, - 0x8EC5, 0xE75F, 0x8EC6, 0xE75C, 0x8EC8, 0xE760, 0x8ECA, 0x8ED4, - 0x8ECB, 0xE761, 0x8ECC, 0x8B4F, 0x8ECD, 0x8C52, 0x8ECF, 0xFBB2, - 0x8ED2, 0x8CAC, 0x8EDB, 0xE762, 0x8EDF, 0x93EE, 0x8EE2, 0x935D, - 0x8EE3, 0xE763, 0x8EEB, 0xE766, 0x8EF8, 0x8EB2, 0x8EFB, 0xE765, - 0x8EFC, 0xE764, 0x8EFD, 0x8C79, 0x8EFE, 0xE767, 0x8F03, 0x8A72, - 0x8F05, 0xE769, 0x8F09, 0x8DDA, 0x8F0A, 0xE768, 0x8F0C, 0xE771, - 0x8F12, 0xE76B, 0x8F13, 0xE76D, 0x8F14, 0x95E3, 0x8F15, 0xE76A, - 0x8F19, 0xE76C, 0x8F1B, 0xE770, 0x8F1C, 0xE76E, 0x8F1D, 0x8B50, - 0x8F1F, 0xE76F, 0x8F26, 0xE772, 0x8F29, 0x9479, 0x8F2A, 0x97D6, - 0x8F2F, 0x8F53, 0x8F33, 0xE773, 0x8F38, 0x9741, 0x8F39, 0xE775, - 0x8F3B, 0xE774, 0x8F3E, 0xE778, 0x8F3F, 0x9760, 0x8F42, 0xE777, - 0x8F44, 0x8A8D, 0x8F45, 0xE776, 0x8F46, 0xE77B, 0x8F49, 0xE77A, - 0x8F4C, 0xE779, 0x8F4D, 0x9351, 0x8F4E, 0xE77C, 0x8F57, 0xE77D, - 0x8F5C, 0xE77E, 0x8F5F, 0x8D8C, 0x8F61, 0x8C44, 0x8F62, 0xE780, - 0x8F63, 0xE781, 0x8F64, 0xE782, 0x8F9B, 0x9068, 0x8F9C, 0xE783, - 0x8F9E, 0x8EAB, 0x8F9F, 0xE784, 0x8FA3, 0xE785, 0x8FA7, 0x999F, - 0x8FA8, 0x999E, 0x8FAD, 0xE786, 0x8FAE, 0xE390, 0x8FAF, 0xE787, - 0x8FB0, 0x9243, 0x8FB1, 0x904A, 0x8FB2, 0x945F, 0x8FB7, 0xE788, - 0x8FBA, 0x95D3, 0x8FBB, 0x92D2, 0x8FBC, 0x8D9E, 0x8FBF, 0x9248, - 0x8FC2, 0x8949, 0x8FC4, 0x9698, 0x8FC5, 0x9076, 0x8FCE, 0x8C7D, - 0x8FD1, 0x8BDF, 0x8FD4, 0x95D4, 0x8FDA, 0xE789, 0x8FE2, 0xE78B, - 0x8FE5, 0xE78A, 0x8FE6, 0x89DE, 0x8FE9, 0x93F4, 0x8FEA, 0xE78C, - 0x8FEB, 0x9497, 0x8FED, 0x9352, 0x8FEF, 0xE78D, 0x8FF0, 0x8F71, - 0x8FF4, 0xE78F, 0x8FF7, 0x96C0, 0x8FF8, 0xE79E, 0x8FF9, 0xE791, - 0x8FFA, 0xE792, 0x8FFD, 0x92C7, 0x9000, 0x91DE, 0x9001, 0x9197, - 0x9003, 0x93A6, 0x9005, 0xE790, 0x9006, 0x8B74, 0x900B, 0xE799, - 0x900D, 0xE796, 0x900E, 0xE7A3, 0x900F, 0x93A7, 0x9010, 0x9280, - 0x9011, 0xE793, 0x9013, 0x92FC, 0x9014, 0x9372, 0x9015, 0xE794, - 0x9016, 0xE798, 0x9017, 0x9080, 0x9019, 0x9487, 0x901A, 0x92CA, - 0x901D, 0x90C0, 0x901E, 0xE797, 0x901F, 0x91AC, 0x9020, 0x91A2, - 0x9021, 0xE795, 0x9022, 0x88A7, 0x9023, 0x9841, 0x9027, 0xE79A, - 0x902E, 0x91DF, 0x9031, 0x8F54, 0x9032, 0x9069, 0x9035, 0xE79C, - 0x9036, 0xE79B, 0x9038, 0x88ED, 0x9039, 0xE79D, 0x903C, 0x954E, - 0x903E, 0xE7A5, 0x9041, 0x93D9, 0x9042, 0x908B, 0x9045, 0x9278, - 0x9047, 0x8BF6, 0x9049, 0xE7A4, 0x904A, 0x9756, 0x904B, 0x895E, - 0x904D, 0x95D5, 0x904E, 0x89DF, 0x904F, 0xE79F, 0x9050, 0xE7A0, - 0x9051, 0xE7A1, 0x9052, 0xE7A2, 0x9053, 0x93B9, 0x9054, 0x9242, - 0x9055, 0x88E1, 0x9056, 0xE7A6, 0x9058, 0xE7A7, 0x9059, 0xEAA1, - 0x905C, 0x91BB, 0x905E, 0xE7A8, 0x9060, 0x8993, 0x9061, 0x916B, - 0x9063, 0x8CAD, 0x9065, 0x9779, 0x9067, 0xFBB5, 0x9068, 0xE7A9, - 0x9069, 0x934B, 0x906D, 0x9198, 0x906E, 0x8ED5, 0x906F, 0xE7AA, - 0x9072, 0xE7AD, 0x9075, 0x8F85, 0x9076, 0xE7AB, 0x9077, 0x914A, - 0x9078, 0x9149, 0x907A, 0x88E2, 0x907C, 0x97C9, 0x907D, 0xE7AF, - 0x907F, 0x94F0, 0x9080, 0xE7B1, 0x9081, 0xE7B0, 0x9082, 0xE7AE, - 0x9083, 0xE284, 0x9084, 0x8AD2, 0x9087, 0xE78E, 0x9089, 0xE7B3, - 0x908A, 0xE7B2, 0x908F, 0xE7B4, 0x9091, 0x9757, 0x90A3, 0x93DF, - 0x90A6, 0x964D, 0x90A8, 0xE7B5, 0x90AA, 0x8ED7, 0x90AF, 0xE7B6, - 0x90B1, 0xE7B7, 0x90B5, 0xE7B8, 0x90B8, 0x9340, 0x90C1, 0x88E8, - 0x90CA, 0x8D78, 0x90CE, 0x9859, 0x90DB, 0xE7BC, 0x90DE, 0xFBB6, - 0x90E1, 0x8C53, 0x90E2, 0xE7B9, 0x90E4, 0xE7BA, 0x90E8, 0x9594, - 0x90ED, 0x8A73, 0x90F5, 0x9758, 0x90F7, 0x8BBD, 0x90FD, 0x9373, - 0x9102, 0xE7BD, 0x9112, 0xE7BE, 0x9115, 0xFBB8, 0x9119, 0xE7BF, - 0x9127, 0xFBB9, 0x912D, 0x9341, 0x9130, 0xE7C1, 0x9132, 0xE7C0, - 0x9149, 0x93D1, 0x914A, 0xE7C2, 0x914B, 0x8F55, 0x914C, 0x8EDE, - 0x914D, 0x947A, 0x914E, 0x9291, 0x9152, 0x8EF0, 0x9154, 0x908C, - 0x9156, 0xE7C3, 0x9158, 0xE7C4, 0x9162, 0x907C, 0x9163, 0xE7C5, - 0x9165, 0xE7C6, 0x9169, 0xE7C7, 0x916A, 0x978F, 0x916C, 0x8F56, - 0x9172, 0xE7C9, 0x9173, 0xE7C8, 0x9175, 0x8D79, 0x9177, 0x8D93, - 0x9178, 0x8E5F, 0x9182, 0xE7CC, 0x9187, 0x8F86, 0x9189, 0xE7CB, - 0x918B, 0xE7CA, 0x918D, 0x91E7, 0x9190, 0x8CED, 0x9192, 0x90C1, - 0x9197, 0x94AE, 0x919C, 0x8F58, 0x91A2, 0xE7CD, 0x91A4, 0x8FDD, - 0x91AA, 0xE7D0, 0x91AB, 0xE7CE, 0x91AF, 0xE7CF, 0x91B4, 0xE7D2, - 0x91B5, 0xE7D1, 0x91B8, 0x8FF8, 0x91BA, 0xE7D3, 0x91C0, 0xE7D4, - 0x91C1, 0xE7D5, 0x91C6, 0x94CE, 0x91C7, 0x8DD1, 0x91C8, 0x8EDF, - 0x91C9, 0xE7D6, 0x91CB, 0xE7D7, 0x91CC, 0x97A2, 0x91CD, 0x8F64, - 0x91CE, 0x96EC, 0x91CF, 0x97CA, 0x91D0, 0xE7D8, 0x91D1, 0x8BE0, - 0x91D6, 0xE7D9, 0x91D7, 0xFBBB, 0x91D8, 0x9342, 0x91DA, 0xFBBA, - 0x91DB, 0xE7DC, 0x91DC, 0x8A98, 0x91DD, 0x906A, 0x91DE, 0xFBBC, - 0x91DF, 0xE7DA, 0x91E1, 0xE7DB, 0x91E3, 0x92DE, 0x91E4, 0xFBBF, - 0x91E5, 0xFBC0, 0x91E6, 0x9674, 0x91E7, 0x8BFA, 0x91ED, 0xFBBD, - 0x91EE, 0xFBBE, 0x91F5, 0xE7DE, 0x91F6, 0xE7DF, 0x91FC, 0xE7DD, - 0x91FF, 0xE7E1, 0x9206, 0xFBC1, 0x920A, 0xFBC3, 0x920D, 0x93DD, - 0x920E, 0x8A62, 0x9210, 0xFBC2, 0x9211, 0xE7E5, 0x9214, 0xE7E2, - 0x9215, 0xE7E4, 0x921E, 0xE7E0, 0x9229, 0xE86E, 0x922C, 0xE7E3, - 0x9234, 0x97E9, 0x9237, 0x8CD8, 0x9239, 0xFBCA, 0x923A, 0xFBC4, - 0x923C, 0xFBC6, 0x923F, 0xE7ED, 0x9240, 0xFBC5, 0x9244, 0x9353, - 0x9245, 0xE7E8, 0x9248, 0xE7EB, 0x9249, 0xE7E9, 0x924B, 0xE7EE, - 0x924E, 0xFBC7, 0x9250, 0xE7EF, 0x9251, 0xFBC9, 0x9257, 0xE7E7, - 0x9259, 0xFBC8, 0x925A, 0xE7F4, 0x925B, 0x8994, 0x925E, 0xE7E6, - 0x9262, 0x94AB, 0x9264, 0xE7EA, 0x9266, 0x8FDE, 0x9267, 0xFBCB, - 0x9271, 0x8D7A, 0x9277, 0xFBCD, 0x9278, 0xFBCE, 0x927E, 0x9667, - 0x9280, 0x8BE2, 0x9283, 0x8F65, 0x9285, 0x93BA, 0x9288, 0xFA5F, - 0x9291, 0x914C, 0x9293, 0xE7F2, 0x9295, 0xE7EC, 0x9296, 0xE7F1, - 0x9298, 0x96C1, 0x929A, 0x92B6, 0x929B, 0xE7F3, 0x929C, 0xE7F0, - 0x92A7, 0xFBCC, 0x92AD, 0x914B, 0x92B7, 0xE7F7, 0x92B9, 0xE7F6, - 0x92CF, 0xE7F5, 0x92D0, 0xFBD2, 0x92D2, 0x964E, 0x92D3, 0xFBD6, - 0x92D5, 0xFBD4, 0x92D7, 0xFBD0, 0x92D9, 0xFBD1, 0x92E0, 0xFBD5, - 0x92E4, 0x8F9B, 0x92E7, 0xFBCF, 0x92E9, 0xE7F8, 0x92EA, 0x95DD, - 0x92ED, 0x8973, 0x92F2, 0x9565, 0x92F3, 0x9292, 0x92F8, 0x8B98, - 0x92F9, 0xFA65, 0x92FA, 0xE7FA, 0x92FB, 0xFBD9, 0x92FC, 0x8D7C, - 0x92FF, 0xFBDC, 0x9302, 0xFBDE, 0x9306, 0x8E4B, 0x930F, 0xE7F9, - 0x9310, 0x908D, 0x9318, 0x908E, 0x9319, 0xE840, 0x931A, 0xE842, - 0x931D, 0xFBDD, 0x931E, 0xFBDB, 0x9320, 0x8FF9, 0x9321, 0xFBD8, - 0x9322, 0xE841, 0x9323, 0xE843, 0x9325, 0xFBD7, 0x9326, 0x8BD1, - 0x9328, 0x9564, 0x932B, 0x8EE0, 0x932C, 0x9842, 0x932E, 0xE7FC, - 0x932F, 0x8DF6, 0x9332, 0x985E, 0x9335, 0xE845, 0x933A, 0xE844, - 0x933B, 0xE846, 0x9344, 0xE7FB, 0x9348, 0xFA5E, 0x934B, 0x93E7, - 0x934D, 0x9374, 0x9354, 0x92D5, 0x9356, 0xE84B, 0x9357, 0xFBE0, - 0x935B, 0x9262, 0x935C, 0xE847, 0x9360, 0xE848, 0x936C, 0x8C4C, - 0x936E, 0xE84A, 0x9370, 0xFBDF, 0x9375, 0x8CAE, 0x937C, 0xE849, - 0x937E, 0x8FDF, 0x938C, 0x8A99, 0x9394, 0xE84F, 0x9396, 0x8DBD, - 0x9397, 0x9199, 0x939A, 0x92C8, 0x93A4, 0xFBE1, 0x93A7, 0x8A5A, - 0x93AC, 0xE84D, 0x93AD, 0xE84E, 0x93AE, 0x92C1, 0x93B0, 0xE84C, - 0x93B9, 0xE850, 0x93C3, 0xE856, 0x93C6, 0xFBE2, 0x93C8, 0xE859, - 0x93D0, 0xE858, 0x93D1, 0x934C, 0x93D6, 0xE851, 0x93D7, 0xE852, - 0x93D8, 0xE855, 0x93DD, 0xE857, 0x93DE, 0xFBE3, 0x93E1, 0x8BBE, - 0x93E4, 0xE85A, 0x93E5, 0xE854, 0x93E8, 0xE853, 0x93F8, 0xFBE4, - 0x9403, 0xE85E, 0x9407, 0xE85F, 0x9410, 0xE860, 0x9413, 0xE85D, - 0x9414, 0xE85C, 0x9418, 0x8FE0, 0x9419, 0x93A8, 0x941A, 0xE85B, - 0x9421, 0xE864, 0x942B, 0xE862, 0x9431, 0xFBE5, 0x9435, 0xE863, - 0x9436, 0xE861, 0x9438, 0x91F6, 0x943A, 0xE865, 0x9441, 0xE866, - 0x9444, 0xE868, 0x9445, 0xFBE6, 0x9448, 0xFBE7, 0x9451, 0x8AD3, - 0x9452, 0xE867, 0x9453, 0x96F8, 0x945A, 0xE873, 0x945B, 0xE869, - 0x945E, 0xE86C, 0x9460, 0xE86A, 0x9462, 0xE86B, 0x946A, 0xE86D, - 0x9470, 0xE86F, 0x9475, 0xE870, 0x9477, 0xE871, 0x947C, 0xE874, - 0x947D, 0xE872, 0x947E, 0xE875, 0x947F, 0xE877, 0x9481, 0xE876, - 0x9577, 0x92B7, 0x9580, 0x96E5, 0x9582, 0xE878, 0x9583, 0x914D, - 0x9587, 0xE879, 0x9589, 0x95C2, 0x958A, 0xE87A, 0x958B, 0x8A4A, - 0x958F, 0x895B, 0x9591, 0x8AD5, 0x9592, 0xFBE8, 0x9593, 0x8AD4, - 0x9594, 0xE87B, 0x9596, 0xE87C, 0x9598, 0xE87D, 0x9599, 0xE87E, - 0x95A0, 0xE880, 0x95A2, 0x8AD6, 0x95A3, 0x8A74, 0x95A4, 0x8D7D, - 0x95A5, 0x94B4, 0x95A7, 0xE882, 0x95A8, 0xE881, 0x95AD, 0xE883, - 0x95B2, 0x897B, 0x95B9, 0xE886, 0x95BB, 0xE885, 0x95BC, 0xE884, - 0x95BE, 0xE887, 0x95C3, 0xE88A, 0x95C7, 0x88C5, 0x95CA, 0xE888, - 0x95CC, 0xE88C, 0x95CD, 0xE88B, 0x95D4, 0xE88E, 0x95D5, 0xE88D, - 0x95D6, 0xE88F, 0x95D8, 0x93AC, 0x95DC, 0xE890, 0x95E1, 0xE891, - 0x95E2, 0xE893, 0x95E5, 0xE892, 0x961C, 0x958C, 0x9621, 0xE894, - 0x9628, 0xE895, 0x962A, 0x8DE3, 0x962E, 0xE896, 0x962F, 0xE897, - 0x9632, 0x9668, 0x963B, 0x916A, 0x963F, 0x88A2, 0x9640, 0x91C9, - 0x9642, 0xE898, 0x9644, 0x958D, 0x964B, 0xE89B, 0x964C, 0xE899, - 0x964D, 0x8D7E, 0x964F, 0xE89A, 0x9650, 0x8CC0, 0x965B, 0x95C3, - 0x965C, 0xE89D, 0x965D, 0xE89F, 0x965E, 0xE89E, 0x965F, 0xE8A0, - 0x9662, 0x8940, 0x9663, 0x9077, 0x9664, 0x8F9C, 0x9665, 0x8AD7, - 0x9666, 0xE8A1, 0x966A, 0x9486, 0x966C, 0xE8A3, 0x9670, 0x8941, - 0x9672, 0xE8A2, 0x9673, 0x92C2, 0x9675, 0x97CB, 0x9676, 0x93A9, - 0x9677, 0xE89C, 0x9678, 0x97A4, 0x967A, 0x8CAF, 0x967D, 0x977A, - 0x9685, 0x8BF7, 0x9686, 0x97B2, 0x9688, 0x8C47, 0x968A, 0x91E0, - 0x968B, 0xE440, 0x968D, 0xE8A4, 0x968E, 0x8A4B, 0x968F, 0x908F, - 0x9694, 0x8A75, 0x9695, 0xE8A6, 0x9697, 0xE8A7, 0x9698, 0xE8A5, - 0x9699, 0x8C84, 0x969B, 0x8DDB, 0x969C, 0x8FE1, 0x969D, 0xFBEB, - 0x96A0, 0x8942, 0x96A3, 0x97D7, 0x96A7, 0xE8A9, 0x96A8, 0xE7AC, - 0x96AA, 0xE8A8, 0x96AF, 0xFBEC, 0x96B0, 0xE8AC, 0x96B1, 0xE8AA, - 0x96B2, 0xE8AB, 0x96B4, 0xE8AD, 0x96B6, 0xE8AE, 0x96B7, 0x97EA, - 0x96B8, 0xE8AF, 0x96B9, 0xE8B0, 0x96BB, 0x90C7, 0x96BC, 0x94B9, - 0x96C0, 0x909D, 0x96C1, 0x8AE5, 0x96C4, 0x9759, 0x96C5, 0x89EB, - 0x96C6, 0x8F57, 0x96C7, 0x8CD9, 0x96C9, 0xE8B3, 0x96CB, 0xE8B2, - 0x96CC, 0x8E93, 0x96CD, 0xE8B4, 0x96CE, 0xE8B1, 0x96D1, 0x8E47, - 0x96D5, 0xE8B8, 0x96D6, 0xE5AB, 0x96D9, 0x99D4, 0x96DB, 0x9097, - 0x96DC, 0xE8B6, 0x96E2, 0x97A3, 0x96E3, 0x93EF, 0x96E8, 0x894A, - 0x96EA, 0x90E1, 0x96EB, 0x8EB4, 0x96F0, 0x95B5, 0x96F2, 0x895F, - 0x96F6, 0x97EB, 0x96F7, 0x978B, 0x96F9, 0xE8B9, 0x96FB, 0x9364, - 0x9700, 0x8EF9, 0x9704, 0xE8BA, 0x9706, 0xE8BB, 0x9707, 0x906B, - 0x9708, 0xE8BC, 0x970A, 0x97EC, 0x970D, 0xE8B7, 0x970E, 0xE8BE, - 0x970F, 0xE8C0, 0x9711, 0xE8BF, 0x9713, 0xE8BD, 0x9716, 0xE8C1, - 0x9719, 0xE8C2, 0x971C, 0x919A, 0x971E, 0x89E0, 0x9724, 0xE8C3, - 0x9727, 0x96B6, 0x972A, 0xE8C4, 0x9730, 0xE8C5, 0x9732, 0x9849, - 0x9733, 0xFBED, 0x9738, 0x9E50, 0x9739, 0xE8C6, 0x973B, 0xFBEE, - 0x973D, 0xE8C7, 0x973E, 0xE8C8, 0x9742, 0xE8CC, 0x9743, 0xFBEF, - 0x9744, 0xE8C9, 0x9746, 0xE8CA, 0x9748, 0xE8CB, 0x9749, 0xE8CD, - 0x974D, 0xFBF0, 0x974F, 0xFBF1, 0x9751, 0xFBF2, 0x9752, 0x90C2, - 0x9755, 0xFBF3, 0x9756, 0x96F5, 0x9759, 0x90C3, 0x975C, 0xE8CE, - 0x975E, 0x94F1, 0x9760, 0xE8CF, 0x9761, 0xEA72, 0x9762, 0x96CA, - 0x9764, 0xE8D0, 0x9766, 0xE8D1, 0x9768, 0xE8D2, 0x9769, 0x8A76, - 0x976B, 0xE8D4, 0x976D, 0x9078, 0x9771, 0xE8D5, 0x9774, 0x8C43, - 0x9779, 0xE8D6, 0x977A, 0xE8DA, 0x977C, 0xE8D8, 0x9781, 0xE8D9, - 0x9784, 0x8A93, 0x9785, 0xE8D7, 0x9786, 0xE8DB, 0x978B, 0xE8DC, - 0x978D, 0x88C6, 0x978F, 0xE8DD, 0x9790, 0xE8DE, 0x9798, 0x8FE2, - 0x979C, 0xE8DF, 0x97A0, 0x8B66, 0x97A3, 0xE8E2, 0x97A6, 0xE8E1, - 0x97A8, 0xE8E0, 0x97AB, 0xE691, 0x97AD, 0x95DA, 0x97B3, 0xE8E3, - 0x97B4, 0xE8E4, 0x97C3, 0xE8E5, 0x97C6, 0xE8E6, 0x97C8, 0xE8E7, - 0x97CB, 0xE8E8, 0x97D3, 0x8AD8, 0x97DC, 0xE8E9, 0x97ED, 0xE8EA, - 0x97EE, 0x9442, 0x97F2, 0xE8EC, 0x97F3, 0x89B9, 0x97F5, 0xE8EF, - 0x97F6, 0xE8EE, 0x97FB, 0x8943, 0x97FF, 0x8BBF, 0x9801, 0x95C5, - 0x9802, 0x92B8, 0x9803, 0x8DA0, 0x9805, 0x8D80, 0x9806, 0x8F87, - 0x9808, 0x907B, 0x980C, 0xE8F1, 0x980F, 0xE8F0, 0x9810, 0x9761, - 0x9811, 0x8AE6, 0x9812, 0x94D0, 0x9813, 0x93DA, 0x9817, 0x909C, - 0x9818, 0x97CC, 0x981A, 0x8C7A, 0x9821, 0xE8F4, 0x9824, 0xE8F3, - 0x982C, 0x966A, 0x982D, 0x93AA, 0x9834, 0x896F, 0x9837, 0xE8F5, - 0x9838, 0xE8F2, 0x983B, 0x9570, 0x983C, 0x978A, 0x983D, 0xE8F6, - 0x9846, 0xE8F7, 0x984B, 0xE8F9, 0x984C, 0x91E8, 0x984D, 0x8A7A, - 0x984E, 0x8A7B, 0x984F, 0xE8F8, 0x9854, 0x8AE7, 0x9855, 0x8CB0, - 0x9857, 0xFBF4, 0x9858, 0x8AE8, 0x985B, 0x935E, 0x985E, 0x97DE, - 0x9865, 0xFBF5, 0x9867, 0x8CDA, 0x986B, 0xE8FA, 0x986F, 0xE8FB, - 0x9870, 0xE8FC, 0x9871, 0xE940, 0x9873, 0xE942, 0x9874, 0xE941, - 0x98A8, 0x9597, 0x98AA, 0xE943, 0x98AF, 0xE944, 0x98B1, 0xE945, - 0x98B6, 0xE946, 0x98C3, 0xE948, 0x98C4, 0xE947, 0x98C6, 0xE949, - 0x98DB, 0x94F2, 0x98DC, 0xE3CA, 0x98DF, 0x9048, 0x98E2, 0x8B51, - 0x98E9, 0xE94A, 0x98EB, 0xE94B, 0x98ED, 0x99AA, 0x98EE, 0x9F5A, - 0x98EF, 0x94D1, 0x98F2, 0x88F9, 0x98F4, 0x88B9, 0x98FC, 0x8E94, - 0x98FD, 0x964F, 0x98FE, 0x8FFC, 0x9903, 0xE94C, 0x9905, 0x96DD, - 0x9909, 0xE94D, 0x990A, 0x977B, 0x990C, 0x8961, 0x9910, 0x8E60, - 0x9912, 0xE94E, 0x9913, 0x89EC, 0x9914, 0xE94F, 0x9918, 0xE950, - 0x991D, 0xE952, 0x991E, 0xE953, 0x9920, 0xE955, 0x9921, 0xE951, - 0x9924, 0xE954, 0x9927, 0xFBF8, 0x9928, 0x8AD9, 0x992C, 0xE956, - 0x992E, 0xE957, 0x993D, 0xE958, 0x993E, 0xE959, 0x9942, 0xE95A, - 0x9945, 0xE95C, 0x9949, 0xE95B, 0x994B, 0xE95E, 0x994C, 0xE961, - 0x9950, 0xE95D, 0x9951, 0xE95F, 0x9952, 0xE960, 0x9955, 0xE962, - 0x9957, 0x8BC0, 0x9996, 0x8EF1, 0x9997, 0xE963, 0x9998, 0xE964, - 0x9999, 0x8D81, 0x999E, 0xFBFA, 0x99A5, 0xE965, 0x99A8, 0x8A5D, - 0x99AC, 0x946E, 0x99AD, 0xE966, 0x99AE, 0xE967, 0x99B3, 0x9279, - 0x99B4, 0x93E9, 0x99BC, 0xE968, 0x99C1, 0x949D, 0x99C4, 0x91CA, - 0x99C5, 0x8977, 0x99C6, 0x8BEC, 0x99C8, 0x8BED, 0x99D0, 0x9293, - 0x99D1, 0xE96D, 0x99D2, 0x8BEE, 0x99D5, 0x89ED, 0x99D8, 0xE96C, - 0x99DB, 0xE96A, 0x99DD, 0xE96B, 0x99DF, 0xE969, 0x99E2, 0xE977, - 0x99ED, 0xE96E, 0x99EE, 0xE96F, 0x99F1, 0xE970, 0x99F2, 0xE971, - 0x99F8, 0xE973, 0x99FB, 0xE972, 0x99FF, 0x8F78, 0x9A01, 0xE974, - 0x9A05, 0xE976, 0x9A0E, 0x8B52, 0x9A0F, 0xE975, 0x9A12, 0x919B, - 0x9A13, 0x8CB1, 0x9A19, 0xE978, 0x9A28, 0x91CB, 0x9A2B, 0xE979, - 0x9A30, 0x93AB, 0x9A37, 0xE97A, 0x9A3E, 0xE980, 0x9A40, 0xE97D, - 0x9A42, 0xE97C, 0x9A43, 0xE97E, 0x9A45, 0xE97B, 0x9A4D, 0xE982, - 0x9A4E, 0xFBFB, 0x9A55, 0xE981, 0x9A57, 0xE984, 0x9A5A, 0x8BC1, - 0x9A5B, 0xE983, 0x9A5F, 0xE985, 0x9A62, 0xE986, 0x9A64, 0xE988, - 0x9A65, 0xE987, 0x9A69, 0xE989, 0x9A6A, 0xE98B, 0x9A6B, 0xE98A, - 0x9AA8, 0x8D9C, 0x9AAD, 0xE98C, 0x9AB0, 0xE98D, 0x9AB8, 0x8A5B, - 0x9ABC, 0xE98E, 0x9AC0, 0xE98F, 0x9AC4, 0x9091, 0x9ACF, 0xE990, - 0x9AD1, 0xE991, 0x9AD3, 0xE992, 0x9AD4, 0xE993, 0x9AD8, 0x8D82, - 0x9AD9, 0xFBFC, 0x9ADC, 0xFC40, 0x9ADE, 0xE994, 0x9ADF, 0xE995, - 0x9AE2, 0xE996, 0x9AE3, 0xE997, 0x9AE6, 0xE998, 0x9AEA, 0x94AF, - 0x9AEB, 0xE99A, 0x9AED, 0x9545, 0x9AEE, 0xE99B, 0x9AEF, 0xE999, - 0x9AF1, 0xE99D, 0x9AF4, 0xE99C, 0x9AF7, 0xE99E, 0x9AFB, 0xE99F, - 0x9B06, 0xE9A0, 0x9B18, 0xE9A1, 0x9B1A, 0xE9A2, 0x9B1F, 0xE9A3, - 0x9B22, 0xE9A4, 0x9B23, 0xE9A5, 0x9B25, 0xE9A6, 0x9B27, 0xE9A7, - 0x9B28, 0xE9A8, 0x9B29, 0xE9A9, 0x9B2A, 0xE9AA, 0x9B2E, 0xE9AB, - 0x9B2F, 0xE9AC, 0x9B31, 0x9F54, 0x9B32, 0xE9AD, 0x9B3B, 0xE2F6, - 0x9B3C, 0x8B53, 0x9B41, 0x8A40, 0x9B42, 0x8DB0, 0x9B43, 0xE9AF, - 0x9B44, 0xE9AE, 0x9B45, 0x96A3, 0x9B4D, 0xE9B1, 0x9B4E, 0xE9B2, - 0x9B4F, 0xE9B0, 0x9B51, 0xE9B3, 0x9B54, 0x9682, 0x9B58, 0xE9B4, - 0x9B5A, 0x8B9B, 0x9B6F, 0x9844, 0x9B72, 0xFC42, 0x9B74, 0xE9B5, - 0x9B75, 0xFC41, 0x9B83, 0xE9B7, 0x9B8E, 0x88BC, 0x9B8F, 0xFC43, - 0x9B91, 0xE9B8, 0x9B92, 0x95A9, 0x9B93, 0xE9B6, 0x9B96, 0xE9B9, - 0x9B97, 0xE9BA, 0x9B9F, 0xE9BB, 0x9BA0, 0xE9BC, 0x9BA8, 0xE9BD, - 0x9BAA, 0x968E, 0x9BAB, 0x8E4C, 0x9BAD, 0x8DF8, 0x9BAE, 0x914E, - 0x9BB1, 0xFC44, 0x9BB4, 0xE9BE, 0x9BB9, 0xE9C1, 0x9BBB, 0xFC45, - 0x9BC0, 0xE9BF, 0x9BC6, 0xE9C2, 0x9BC9, 0x8CEF, 0x9BCA, 0xE9C0, - 0x9BCF, 0xE9C3, 0x9BD1, 0xE9C4, 0x9BD2, 0xE9C5, 0x9BD4, 0xE9C9, - 0x9BD6, 0x8E49, 0x9BDB, 0x91E2, 0x9BE1, 0xE9CA, 0x9BE2, 0xE9C7, - 0x9BE3, 0xE9C6, 0x9BE4, 0xE9C8, 0x9BE8, 0x8C7E, 0x9BF0, 0xE9CE, - 0x9BF1, 0xE9CD, 0x9BF2, 0xE9CC, 0x9BF5, 0x88B1, 0x9C00, 0xFC46, - 0x9C04, 0xE9D8, 0x9C06, 0xE9D4, 0x9C08, 0xE9D5, 0x9C09, 0xE9D1, - 0x9C0A, 0xE9D7, 0x9C0C, 0xE9D3, 0x9C0D, 0x8A82, 0x9C10, 0x986B, - 0x9C12, 0xE9D6, 0x9C13, 0xE9D2, 0x9C14, 0xE9D0, 0x9C15, 0xE9CF, - 0x9C1B, 0xE9DA, 0x9C21, 0xE9DD, 0x9C24, 0xE9DC, 0x9C25, 0xE9DB, - 0x9C2D, 0x9568, 0x9C2E, 0xE9D9, 0x9C2F, 0x88F1, 0x9C30, 0xE9DE, - 0x9C32, 0xE9E0, 0x9C39, 0x8A8F, 0x9C3A, 0xE9CB, 0x9C3B, 0x8956, - 0x9C3E, 0xE9E2, 0x9C46, 0xE9E1, 0x9C47, 0xE9DF, 0x9C48, 0x924C, - 0x9C52, 0x9690, 0x9C57, 0x97D8, 0x9C5A, 0xE9E3, 0x9C60, 0xE9E4, - 0x9C67, 0xE9E5, 0x9C76, 0xE9E6, 0x9C78, 0xE9E7, 0x9CE5, 0x92B9, - 0x9CE7, 0xE9E8, 0x9CE9, 0x94B5, 0x9CEB, 0xE9ED, 0x9CEC, 0xE9E9, - 0x9CF0, 0xE9EA, 0x9CF3, 0x9650, 0x9CF4, 0x96C2, 0x9CF6, 0x93CE, - 0x9D03, 0xE9EE, 0x9D06, 0xE9EF, 0x9D07, 0x93BC, 0x9D08, 0xE9EC, - 0x9D09, 0xE9EB, 0x9D0E, 0x89A8, 0x9D12, 0xE9F7, 0x9D15, 0xE9F6, - 0x9D1B, 0x8995, 0x9D1F, 0xE9F4, 0x9D23, 0xE9F3, 0x9D26, 0xE9F1, - 0x9D28, 0x8A9B, 0x9D2A, 0xE9F0, 0x9D2B, 0x8EB0, 0x9D2C, 0x89A7, - 0x9D3B, 0x8D83, 0x9D3E, 0xE9FA, 0x9D3F, 0xE9F9, 0x9D41, 0xE9F8, - 0x9D44, 0xE9F5, 0x9D46, 0xE9FB, 0x9D48, 0xE9FC, 0x9D50, 0xEA44, - 0x9D51, 0xEA43, 0x9D59, 0xEA45, 0x9D5C, 0x894C, 0x9D5D, 0xEA40, - 0x9D5E, 0xEA41, 0x9D60, 0x8D94, 0x9D61, 0x96B7, 0x9D64, 0xEA42, - 0x9D6B, 0xFC48, 0x9D6C, 0x9651, 0x9D6F, 0xEA4A, 0x9D70, 0xFC47, - 0x9D72, 0xEA46, 0x9D7A, 0xEA4B, 0x9D87, 0xEA48, 0x9D89, 0xEA47, - 0x9D8F, 0x8C7B, 0x9D9A, 0xEA4C, 0x9DA4, 0xEA4D, 0x9DA9, 0xEA4E, - 0x9DAB, 0xEA49, 0x9DAF, 0xE9F2, 0x9DB2, 0xEA4F, 0x9DB4, 0x92DF, - 0x9DB8, 0xEA53, 0x9DBA, 0xEA54, 0x9DBB, 0xEA52, 0x9DC1, 0xEA51, - 0x9DC2, 0xEA57, 0x9DC4, 0xEA50, 0x9DC6, 0xEA55, 0x9DCF, 0xEA56, - 0x9DD3, 0xEA59, 0x9DD9, 0xEA58, 0x9DE6, 0xEA5B, 0x9DED, 0xEA5C, - 0x9DEF, 0xEA5D, 0x9DF2, 0x9868, 0x9DF8, 0xEA5A, 0x9DF9, 0x91E9, - 0x9DFA, 0x8DEB, 0x9DFD, 0xEA5E, 0x9E19, 0xFC4A, 0x9E1A, 0xEA5F, - 0x9E1B, 0xEA60, 0x9E1E, 0xEA61, 0x9E75, 0xEA62, 0x9E78, 0x8CB2, - 0x9E79, 0xEA63, 0x9E7D, 0xEA64, 0x9E7F, 0x8EAD, 0x9E81, 0xEA65, - 0x9E88, 0xEA66, 0x9E8B, 0xEA67, 0x9E8C, 0xEA68, 0x9E91, 0xEA6B, - 0x9E92, 0xEA69, 0x9E93, 0x985B, 0x9E95, 0xEA6A, 0x9E97, 0x97ED, - 0x9E9D, 0xEA6C, 0x9E9F, 0x97D9, 0x9EA5, 0xEA6D, 0x9EA6, 0x949E, - 0x9EA9, 0xEA6E, 0x9EAA, 0xEA70, 0x9EAD, 0xEA71, 0x9EB8, 0xEA6F, - 0x9EB9, 0x8D8D, 0x9EBA, 0x96CB, 0x9EBB, 0x9683, 0x9EBC, 0x9BF5, - 0x9EBE, 0x9F80, 0x9EBF, 0x969B, 0x9EC4, 0x89A9, 0x9ECC, 0xEA73, - 0x9ECD, 0x8B6F, 0x9ECE, 0xEA74, 0x9ECF, 0xEA75, 0x9ED0, 0xEA76, - 0x9ED1, 0xFC4B, 0x9ED2, 0x8D95, 0x9ED4, 0xEA77, 0x9ED8, 0xE0D2, - 0x9ED9, 0x96D9, 0x9EDB, 0x91E1, 0x9EDC, 0xEA78, 0x9EDD, 0xEA7A, - 0x9EDE, 0xEA79, 0x9EE0, 0xEA7B, 0x9EE5, 0xEA7C, 0x9EE8, 0xEA7D, - 0x9EEF, 0xEA7E, 0x9EF4, 0xEA80, 0x9EF6, 0xEA81, 0x9EF7, 0xEA82, - 0x9EF9, 0xEA83, 0x9EFB, 0xEA84, 0x9EFC, 0xEA85, 0x9EFD, 0xEA86, - 0x9F07, 0xEA87, 0x9F08, 0xEA88, 0x9F0E, 0x9343, 0x9F13, 0x8CDB, - 0x9F15, 0xEA8A, 0x9F20, 0x916C, 0x9F21, 0xEA8B, 0x9F2C, 0xEA8C, - 0x9F3B, 0x9540, 0x9F3E, 0xEA8D, 0x9F4A, 0xEA8E, 0x9F4B, 0xE256, - 0x9F4E, 0xE6D8, 0x9F4F, 0xE8EB, 0x9F52, 0xEA8F, 0x9F54, 0xEA90, - 0x9F5F, 0xEA92, 0x9F60, 0xEA93, 0x9F61, 0xEA94, 0x9F62, 0x97EE, - 0x9F63, 0xEA91, 0x9F66, 0xEA95, 0x9F67, 0xEA96, 0x9F6A, 0xEA98, - 0x9F6C, 0xEA97, 0x9F72, 0xEA9A, 0x9F76, 0xEA9B, 0x9F77, 0xEA99, - 0x9F8D, 0x97B4, 0x9F95, 0xEA9C, 0x9F9C, 0xEA9D, 0x9F9D, 0xE273, - 0x9FA0, 0xEA9E, 0xF929, 0xFAE0, 0xF9DC, 0xFBE9, 0xFA0E, 0xFA90, - 0xFA0F, 0xFA9B, 0xFA10, 0xFA9C, 0xFA11, 0xFAB1, 0xFA12, 0xFAD8, - 0xFA13, 0xFAE8, 0xFA14, 0xFAEA, 0xFA15, 0xFB58, 0xFA16, 0xFB5E, - 0xFA17, 0xFB75, 0xFA18, 0xFB7D, 0xFA19, 0xFB7E, 0xFA1A, 0xFB80, - 0xFA1B, 0xFB82, 0xFA1C, 0xFB86, 0xFA1D, 0xFB89, 0xFA1E, 0xFB92, - 0xFA1F, 0xFB9D, 0xFA20, 0xFB9F, 0xFA21, 0xFBA0, 0xFA22, 0xFBA9, - 0xFA23, 0xFBB1, 0xFA24, 0xFBB3, 0xFA25, 0xFBB4, 0xFA26, 0xFBB7, - 0xFA27, 0xFBD3, 0xFA28, 0xFBDA, 0xFA29, 0xFBEA, 0xFA2A, 0xFBF6, - 0xFA2B, 0xFBF7, 0xFA2C, 0xFBF9, 0xFA2D, 0xFC49, 0xFF01, 0x8149, - 0xFF02, 0xFA57, 0xFF03, 0x8194, 0xFF04, 0x8190, 0xFF05, 0x8193, - 0xFF06, 0x8195, 0xFF07, 0xFA56, 0xFF08, 0x8169, 0xFF09, 0x816A, - 0xFF0A, 0x8196, 0xFF0B, 0x817B, 0xFF0C, 0x8143, 0xFF0D, 0x817C, - 0xFF0E, 0x8144, 0xFF0F, 0x815E, 0xFF10, 0x824F, 0xFF11, 0x8250, - 0xFF12, 0x8251, 0xFF13, 0x8252, 0xFF14, 0x8253, 0xFF15, 0x8254, - 0xFF16, 0x8255, 0xFF17, 0x8256, 0xFF18, 0x8257, 0xFF19, 0x8258, - 0xFF1A, 0x8146, 0xFF1B, 0x8147, 0xFF1C, 0x8183, 0xFF1D, 0x8181, - 0xFF1E, 0x8184, 0xFF1F, 0x8148, 0xFF20, 0x8197, 0xFF21, 0x8260, - 0xFF22, 0x8261, 0xFF23, 0x8262, 0xFF24, 0x8263, 0xFF25, 0x8264, - 0xFF26, 0x8265, 0xFF27, 0x8266, 0xFF28, 0x8267, 0xFF29, 0x8268, - 0xFF2A, 0x8269, 0xFF2B, 0x826A, 0xFF2C, 0x826B, 0xFF2D, 0x826C, - 0xFF2E, 0x826D, 0xFF2F, 0x826E, 0xFF30, 0x826F, 0xFF31, 0x8270, - 0xFF32, 0x8271, 0xFF33, 0x8272, 0xFF34, 0x8273, 0xFF35, 0x8274, - 0xFF36, 0x8275, 0xFF37, 0x8276, 0xFF38, 0x8277, 0xFF39, 0x8278, - 0xFF3A, 0x8279, 0xFF3B, 0x816D, 0xFF3C, 0x815F, 0xFF3D, 0x816E, - 0xFF3E, 0x814F, 0xFF3F, 0x8151, 0xFF40, 0x814D, 0xFF41, 0x8281, - 0xFF42, 0x8282, 0xFF43, 0x8283, 0xFF44, 0x8284, 0xFF45, 0x8285, - 0xFF46, 0x8286, 0xFF47, 0x8287, 0xFF48, 0x8288, 0xFF49, 0x8289, - 0xFF4A, 0x828A, 0xFF4B, 0x828B, 0xFF4C, 0x828C, 0xFF4D, 0x828D, - 0xFF4E, 0x828E, 0xFF4F, 0x828F, 0xFF50, 0x8290, 0xFF51, 0x8291, - 0xFF52, 0x8292, 0xFF53, 0x8293, 0xFF54, 0x8294, 0xFF55, 0x8295, - 0xFF56, 0x8296, 0xFF57, 0x8297, 0xFF58, 0x8298, 0xFF59, 0x8299, - 0xFF5A, 0x829A, 0xFF5B, 0x816F, 0xFF5C, 0x8162, 0xFF5D, 0x8170, - 0xFF5E, 0x8160, 0xFF61, 0x00A1, 0xFF62, 0x00A2, 0xFF63, 0x00A3, - 0xFF64, 0x00A4, 0xFF65, 0x00A5, 0xFF66, 0x00A6, 0xFF67, 0x00A7, - 0xFF68, 0x00A8, 0xFF69, 0x00A9, 0xFF6A, 0x00AA, 0xFF6B, 0x00AB, - 0xFF6C, 0x00AC, 0xFF6D, 0x00AD, 0xFF6E, 0x00AE, 0xFF6F, 0x00AF, - 0xFF70, 0x00B0, 0xFF71, 0x00B1, 0xFF72, 0x00B2, 0xFF73, 0x00B3, - 0xFF74, 0x00B4, 0xFF75, 0x00B5, 0xFF76, 0x00B6, 0xFF77, 0x00B7, - 0xFF78, 0x00B8, 0xFF79, 0x00B9, 0xFF7A, 0x00BA, 0xFF7B, 0x00BB, - 0xFF7C, 0x00BC, 0xFF7D, 0x00BD, 0xFF7E, 0x00BE, 0xFF7F, 0x00BF, - 0xFF80, 0x00C0, 0xFF81, 0x00C1, 0xFF82, 0x00C2, 0xFF83, 0x00C3, - 0xFF84, 0x00C4, 0xFF85, 0x00C5, 0xFF86, 0x00C6, 0xFF87, 0x00C7, - 0xFF88, 0x00C8, 0xFF89, 0x00C9, 0xFF8A, 0x00CA, 0xFF8B, 0x00CB, - 0xFF8C, 0x00CC, 0xFF8D, 0x00CD, 0xFF8E, 0x00CE, 0xFF8F, 0x00CF, - 0xFF90, 0x00D0, 0xFF91, 0x00D1, 0xFF92, 0x00D2, 0xFF93, 0x00D3, - 0xFF94, 0x00D4, 0xFF95, 0x00D5, 0xFF96, 0x00D6, 0xFF97, 0x00D7, - 0xFF98, 0x00D8, 0xFF99, 0x00D9, 0xFF9A, 0x00DA, 0xFF9B, 0x00DB, - 0xFF9C, 0x00DC, 0xFF9D, 0x00DD, 0xFF9E, 0x00DE, 0xFF9F, 0x00DF, - 0xFFE0, 0x8191, 0xFFE1, 0x8192, 0xFFE2, 0x81CA, 0xFFE3, 0x8150, - 0xFFE4, 0xFA55, 0xFFE5, 0x818F, 0, 0 -}; - -#if !_TINY_TABLE -static -const WCHAR sjis2uni[] = { -/* SJIS - Unicode, SJIS - Unicode, SJIS - Unicode, SJIS - Unicode, */ - 0x00A1, 0xFF61, 0x00A2, 0xFF62, 0x00A3, 0xFF63, 0x00A4, 0xFF64, - 0x00A5, 0xFF65, 0x00A6, 0xFF66, 0x00A7, 0xFF67, 0x00A8, 0xFF68, - 0x00A9, 0xFF69, 0x00AA, 0xFF6A, 0x00AB, 0xFF6B, 0x00AC, 0xFF6C, - 0x00AD, 0xFF6D, 0x00AE, 0xFF6E, 0x00AF, 0xFF6F, 0x00B0, 0xFF70, - 0x00B1, 0xFF71, 0x00B2, 0xFF72, 0x00B3, 0xFF73, 0x00B4, 0xFF74, - 0x00B5, 0xFF75, 0x00B6, 0xFF76, 0x00B7, 0xFF77, 0x00B8, 0xFF78, - 0x00B9, 0xFF79, 0x00BA, 0xFF7A, 0x00BB, 0xFF7B, 0x00BC, 0xFF7C, - 0x00BD, 0xFF7D, 0x00BE, 0xFF7E, 0x00BF, 0xFF7F, 0x00C0, 0xFF80, - 0x00C1, 0xFF81, 0x00C2, 0xFF82, 0x00C3, 0xFF83, 0x00C4, 0xFF84, - 0x00C5, 0xFF85, 0x00C6, 0xFF86, 0x00C7, 0xFF87, 0x00C8, 0xFF88, - 0x00C9, 0xFF89, 0x00CA, 0xFF8A, 0x00CB, 0xFF8B, 0x00CC, 0xFF8C, - 0x00CD, 0xFF8D, 0x00CE, 0xFF8E, 0x00CF, 0xFF8F, 0x00D0, 0xFF90, - 0x00D1, 0xFF91, 0x00D2, 0xFF92, 0x00D3, 0xFF93, 0x00D4, 0xFF94, - 0x00D5, 0xFF95, 0x00D6, 0xFF96, 0x00D7, 0xFF97, 0x00D8, 0xFF98, - 0x00D9, 0xFF99, 0x00DA, 0xFF9A, 0x00DB, 0xFF9B, 0x00DC, 0xFF9C, - 0x00DD, 0xFF9D, 0x00DE, 0xFF9E, 0x00DF, 0xFF9F, 0x8140, 0x3000, - 0x8141, 0x3001, 0x8142, 0x3002, 0x8143, 0xFF0C, 0x8144, 0xFF0E, - 0x8145, 0x30FB, 0x8146, 0xFF1A, 0x8147, 0xFF1B, 0x8148, 0xFF1F, - 0x8149, 0xFF01, 0x814A, 0x309B, 0x814B, 0x309C, 0x814C, 0x00B4, - 0x814D, 0xFF40, 0x814E, 0x00A8, 0x814F, 0xFF3E, 0x8150, 0xFFE3, - 0x8151, 0xFF3F, 0x8152, 0x30FD, 0x8153, 0x30FE, 0x8154, 0x309D, - 0x8155, 0x309E, 0x8156, 0x3003, 0x8157, 0x4EDD, 0x8158, 0x3005, - 0x8159, 0x3006, 0x815A, 0x3007, 0x815B, 0x30FC, 0x815C, 0x2015, - 0x815D, 0x2010, 0x815E, 0xFF0F, 0x815F, 0xFF3C, 0x8160, 0xFF5E, - 0x8161, 0x2225, 0x8162, 0xFF5C, 0x8163, 0x2026, 0x8164, 0x2025, - 0x8165, 0x2018, 0x8166, 0x2019, 0x8167, 0x201C, 0x8168, 0x201D, - 0x8169, 0xFF08, 0x816A, 0xFF09, 0x816B, 0x3014, 0x816C, 0x3015, - 0x816D, 0xFF3B, 0x816E, 0xFF3D, 0x816F, 0xFF5B, 0x8170, 0xFF5D, - 0x8171, 0x3008, 0x8172, 0x3009, 0x8173, 0x300A, 0x8174, 0x300B, - 0x8175, 0x300C, 0x8176, 0x300D, 0x8177, 0x300E, 0x8178, 0x300F, - 0x8179, 0x3010, 0x817A, 0x3011, 0x817B, 0xFF0B, 0x817C, 0xFF0D, - 0x817D, 0x00B1, 0x817E, 0x00D7, 0x8180, 0x00F7, 0x8181, 0xFF1D, - 0x8182, 0x2260, 0x8183, 0xFF1C, 0x8184, 0xFF1E, 0x8185, 0x2266, - 0x8186, 0x2267, 0x8187, 0x221E, 0x8188, 0x2234, 0x8189, 0x2642, - 0x818A, 0x2640, 0x818B, 0x00B0, 0x818C, 0x2032, 0x818D, 0x2033, - 0x818E, 0x2103, 0x818F, 0xFFE5, 0x8190, 0xFF04, 0x8191, 0xFFE0, - 0x8192, 0xFFE1, 0x8193, 0xFF05, 0x8194, 0xFF03, 0x8195, 0xFF06, - 0x8196, 0xFF0A, 0x8197, 0xFF20, 0x8198, 0x00A7, 0x8199, 0x2606, - 0x819A, 0x2605, 0x819B, 0x25CB, 0x819C, 0x25CF, 0x819D, 0x25CE, - 0x819E, 0x25C7, 0x819F, 0x25C6, 0x81A0, 0x25A1, 0x81A1, 0x25A0, - 0x81A2, 0x25B3, 0x81A3, 0x25B2, 0x81A4, 0x25BD, 0x81A5, 0x25BC, - 0x81A6, 0x203B, 0x81A7, 0x3012, 0x81A8, 0x2192, 0x81A9, 0x2190, - 0x81AA, 0x2191, 0x81AB, 0x2193, 0x81AC, 0x3013, 0x81B8, 0x2208, - 0x81B9, 0x220B, 0x81BA, 0x2286, 0x81BB, 0x2287, 0x81BC, 0x2282, - 0x81BD, 0x2283, 0x81BE, 0x222A, 0x81BF, 0x2229, 0x81C8, 0x2227, - 0x81C9, 0x2228, 0x81CA, 0xFFE2, 0x81CB, 0x21D2, 0x81CC, 0x21D4, - 0x81CD, 0x2200, 0x81CE, 0x2203, 0x81DA, 0x2220, 0x81DB, 0x22A5, - 0x81DC, 0x2312, 0x81DD, 0x2202, 0x81DE, 0x2207, 0x81DF, 0x2261, - 0x81E0, 0x2252, 0x81E1, 0x226A, 0x81E2, 0x226B, 0x81E3, 0x221A, - 0x81E4, 0x223D, 0x81E5, 0x221D, 0x81E6, 0x2235, 0x81E7, 0x222B, - 0x81E8, 0x222C, 0x81F0, 0x212B, 0x81F1, 0x2030, 0x81F2, 0x266F, - 0x81F3, 0x266D, 0x81F4, 0x266A, 0x81F5, 0x2020, 0x81F6, 0x2021, - 0x81F7, 0x00B6, 0x81FC, 0x25EF, 0x824F, 0xFF10, 0x8250, 0xFF11, - 0x8251, 0xFF12, 0x8252, 0xFF13, 0x8253, 0xFF14, 0x8254, 0xFF15, - 0x8255, 0xFF16, 0x8256, 0xFF17, 0x8257, 0xFF18, 0x8258, 0xFF19, - 0x8260, 0xFF21, 0x8261, 0xFF22, 0x8262, 0xFF23, 0x8263, 0xFF24, - 0x8264, 0xFF25, 0x8265, 0xFF26, 0x8266, 0xFF27, 0x8267, 0xFF28, - 0x8268, 0xFF29, 0x8269, 0xFF2A, 0x826A, 0xFF2B, 0x826B, 0xFF2C, - 0x826C, 0xFF2D, 0x826D, 0xFF2E, 0x826E, 0xFF2F, 0x826F, 0xFF30, - 0x8270, 0xFF31, 0x8271, 0xFF32, 0x8272, 0xFF33, 0x8273, 0xFF34, - 0x8274, 0xFF35, 0x8275, 0xFF36, 0x8276, 0xFF37, 0x8277, 0xFF38, - 0x8278, 0xFF39, 0x8279, 0xFF3A, 0x8281, 0xFF41, 0x8282, 0xFF42, - 0x8283, 0xFF43, 0x8284, 0xFF44, 0x8285, 0xFF45, 0x8286, 0xFF46, - 0x8287, 0xFF47, 0x8288, 0xFF48, 0x8289, 0xFF49, 0x828A, 0xFF4A, - 0x828B, 0xFF4B, 0x828C, 0xFF4C, 0x828D, 0xFF4D, 0x828E, 0xFF4E, - 0x828F, 0xFF4F, 0x8290, 0xFF50, 0x8291, 0xFF51, 0x8292, 0xFF52, - 0x8293, 0xFF53, 0x8294, 0xFF54, 0x8295, 0xFF55, 0x8296, 0xFF56, - 0x8297, 0xFF57, 0x8298, 0xFF58, 0x8299, 0xFF59, 0x829A, 0xFF5A, - 0x829F, 0x3041, 0x82A0, 0x3042, 0x82A1, 0x3043, 0x82A2, 0x3044, - 0x82A3, 0x3045, 0x82A4, 0x3046, 0x82A5, 0x3047, 0x82A6, 0x3048, - 0x82A7, 0x3049, 0x82A8, 0x304A, 0x82A9, 0x304B, 0x82AA, 0x304C, - 0x82AB, 0x304D, 0x82AC, 0x304E, 0x82AD, 0x304F, 0x82AE, 0x3050, - 0x82AF, 0x3051, 0x82B0, 0x3052, 0x82B1, 0x3053, 0x82B2, 0x3054, - 0x82B3, 0x3055, 0x82B4, 0x3056, 0x82B5, 0x3057, 0x82B6, 0x3058, - 0x82B7, 0x3059, 0x82B8, 0x305A, 0x82B9, 0x305B, 0x82BA, 0x305C, - 0x82BB, 0x305D, 0x82BC, 0x305E, 0x82BD, 0x305F, 0x82BE, 0x3060, - 0x82BF, 0x3061, 0x82C0, 0x3062, 0x82C1, 0x3063, 0x82C2, 0x3064, - 0x82C3, 0x3065, 0x82C4, 0x3066, 0x82C5, 0x3067, 0x82C6, 0x3068, - 0x82C7, 0x3069, 0x82C8, 0x306A, 0x82C9, 0x306B, 0x82CA, 0x306C, - 0x82CB, 0x306D, 0x82CC, 0x306E, 0x82CD, 0x306F, 0x82CE, 0x3070, - 0x82CF, 0x3071, 0x82D0, 0x3072, 0x82D1, 0x3073, 0x82D2, 0x3074, - 0x82D3, 0x3075, 0x82D4, 0x3076, 0x82D5, 0x3077, 0x82D6, 0x3078, - 0x82D7, 0x3079, 0x82D8, 0x307A, 0x82D9, 0x307B, 0x82DA, 0x307C, - 0x82DB, 0x307D, 0x82DC, 0x307E, 0x82DD, 0x307F, 0x82DE, 0x3080, - 0x82DF, 0x3081, 0x82E0, 0x3082, 0x82E1, 0x3083, 0x82E2, 0x3084, - 0x82E3, 0x3085, 0x82E4, 0x3086, 0x82E5, 0x3087, 0x82E6, 0x3088, - 0x82E7, 0x3089, 0x82E8, 0x308A, 0x82E9, 0x308B, 0x82EA, 0x308C, - 0x82EB, 0x308D, 0x82EC, 0x308E, 0x82ED, 0x308F, 0x82EE, 0x3090, - 0x82EF, 0x3091, 0x82F0, 0x3092, 0x82F1, 0x3093, 0x8340, 0x30A1, - 0x8341, 0x30A2, 0x8342, 0x30A3, 0x8343, 0x30A4, 0x8344, 0x30A5, - 0x8345, 0x30A6, 0x8346, 0x30A7, 0x8347, 0x30A8, 0x8348, 0x30A9, - 0x8349, 0x30AA, 0x834A, 0x30AB, 0x834B, 0x30AC, 0x834C, 0x30AD, - 0x834D, 0x30AE, 0x834E, 0x30AF, 0x834F, 0x30B0, 0x8350, 0x30B1, - 0x8351, 0x30B2, 0x8352, 0x30B3, 0x8353, 0x30B4, 0x8354, 0x30B5, - 0x8355, 0x30B6, 0x8356, 0x30B7, 0x8357, 0x30B8, 0x8358, 0x30B9, - 0x8359, 0x30BA, 0x835A, 0x30BB, 0x835B, 0x30BC, 0x835C, 0x30BD, - 0x835D, 0x30BE, 0x835E, 0x30BF, 0x835F, 0x30C0, 0x8360, 0x30C1, - 0x8361, 0x30C2, 0x8362, 0x30C3, 0x8363, 0x30C4, 0x8364, 0x30C5, - 0x8365, 0x30C6, 0x8366, 0x30C7, 0x8367, 0x30C8, 0x8368, 0x30C9, - 0x8369, 0x30CA, 0x836A, 0x30CB, 0x836B, 0x30CC, 0x836C, 0x30CD, - 0x836D, 0x30CE, 0x836E, 0x30CF, 0x836F, 0x30D0, 0x8370, 0x30D1, - 0x8371, 0x30D2, 0x8372, 0x30D3, 0x8373, 0x30D4, 0x8374, 0x30D5, - 0x8375, 0x30D6, 0x8376, 0x30D7, 0x8377, 0x30D8, 0x8378, 0x30D9, - 0x8379, 0x30DA, 0x837A, 0x30DB, 0x837B, 0x30DC, 0x837C, 0x30DD, - 0x837D, 0x30DE, 0x837E, 0x30DF, 0x8380, 0x30E0, 0x8381, 0x30E1, - 0x8382, 0x30E2, 0x8383, 0x30E3, 0x8384, 0x30E4, 0x8385, 0x30E5, - 0x8386, 0x30E6, 0x8387, 0x30E7, 0x8388, 0x30E8, 0x8389, 0x30E9, - 0x838A, 0x30EA, 0x838B, 0x30EB, 0x838C, 0x30EC, 0x838D, 0x30ED, - 0x838E, 0x30EE, 0x838F, 0x30EF, 0x8390, 0x30F0, 0x8391, 0x30F1, - 0x8392, 0x30F2, 0x8393, 0x30F3, 0x8394, 0x30F4, - 0x8395, 0x30F5, 0x8396, 0x30F6, 0x839F, 0x0391, 0x83A0, 0x0392, - 0x83A1, 0x0393, 0x83A2, 0x0394, 0x83A3, 0x0395, 0x83A4, 0x0396, - 0x83A5, 0x0397, 0x83A6, 0x0398, 0x83A7, 0x0399, 0x83A8, 0x039A, - 0x83A9, 0x039B, 0x83AA, 0x039C, 0x83AB, 0x039D, 0x83AC, 0x039E, - 0x83AD, 0x039F, 0x83AE, 0x03A0, 0x83AF, 0x03A1, 0x83B0, 0x03A3, - 0x83B1, 0x03A4, 0x83B2, 0x03A5, 0x83B3, 0x03A6, 0x83B4, 0x03A7, - 0x83B5, 0x03A8, 0x83B6, 0x03A9, 0x83BF, 0x03B1, 0x83C0, 0x03B2, - 0x83C1, 0x03B3, 0x83C2, 0x03B4, 0x83C3, 0x03B5, 0x83C4, 0x03B6, - 0x83C5, 0x03B7, 0x83C6, 0x03B8, 0x83C7, 0x03B9, 0x83C8, 0x03BA, - 0x83C9, 0x03BB, 0x83CA, 0x03BC, 0x83CB, 0x03BD, 0x83CC, 0x03BE, - 0x83CD, 0x03BF, 0x83CE, 0x03C0, 0x83CF, 0x03C1, 0x83D0, 0x03C3, - 0x83D1, 0x03C4, 0x83D2, 0x03C5, 0x83D3, 0x03C6, 0x83D4, 0x03C7, - 0x83D5, 0x03C8, 0x83D6, 0x03C9, 0x8440, 0x0410, 0x8441, 0x0411, - 0x8442, 0x0412, 0x8443, 0x0413, 0x8444, 0x0414, 0x8445, 0x0415, - 0x8446, 0x0401, 0x8447, 0x0416, 0x8448, 0x0417, 0x8449, 0x0418, - 0x844A, 0x0419, 0x844B, 0x041A, 0x844C, 0x041B, 0x844D, 0x041C, - 0x844E, 0x041D, 0x844F, 0x041E, 0x8450, 0x041F, 0x8451, 0x0420, - 0x8452, 0x0421, 0x8453, 0x0422, 0x8454, 0x0423, 0x8455, 0x0424, - 0x8456, 0x0425, 0x8457, 0x0426, 0x8458, 0x0427, 0x8459, 0x0428, - 0x845A, 0x0429, 0x845B, 0x042A, 0x845C, 0x042B, 0x845D, 0x042C, - 0x845E, 0x042D, 0x845F, 0x042E, 0x8460, 0x042F, 0x8470, 0x0430, - 0x8471, 0x0431, 0x8472, 0x0432, 0x8473, 0x0433, 0x8474, 0x0434, - 0x8475, 0x0435, 0x8476, 0x0451, 0x8477, 0x0436, 0x8478, 0x0437, - 0x8479, 0x0438, 0x847A, 0x0439, 0x847B, 0x043A, 0x847C, 0x043B, - 0x847D, 0x043C, 0x847E, 0x043D, 0x8480, 0x043E, 0x8481, 0x043F, - 0x8482, 0x0440, 0x8483, 0x0441, 0x8484, 0x0442, 0x8485, 0x0443, - 0x8486, 0x0444, 0x8487, 0x0445, 0x8488, 0x0446, 0x8489, 0x0447, - 0x848A, 0x0448, 0x848B, 0x0449, 0x848C, 0x044A, 0x848D, 0x044B, - 0x848E, 0x044C, 0x848F, 0x044D, 0x8490, 0x044E, 0x8491, 0x044F, - 0x849F, 0x2500, 0x84A0, 0x2502, 0x84A1, 0x250C, 0x84A2, 0x2510, - 0x84A3, 0x2518, 0x84A4, 0x2514, 0x84A5, 0x251C, 0x84A6, 0x252C, - 0x84A7, 0x2524, 0x84A8, 0x2534, 0x84A9, 0x253C, 0x84AA, 0x2501, - 0x84AB, 0x2503, 0x84AC, 0x250F, 0x84AD, 0x2513, 0x84AE, 0x251B, - 0x84AF, 0x2517, 0x84B0, 0x2523, 0x84B1, 0x2533, 0x84B2, 0x252B, - 0x84B3, 0x253B, 0x84B4, 0x254B, 0x84B5, 0x2520, 0x84B6, 0x252F, - 0x84B7, 0x2528, 0x84B8, 0x2537, 0x84B9, 0x253F, 0x84BA, 0x251D, - 0x84BB, 0x2530, 0x84BC, 0x2525, 0x84BD, 0x2538, 0x84BE, 0x2542, - 0x8740, 0x2460, 0x8741, 0x2461, 0x8742, 0x2462, 0x8743, 0x2463, - 0x8744, 0x2464, 0x8745, 0x2465, 0x8746, 0x2466, 0x8747, 0x2467, - 0x8748, 0x2468, 0x8749, 0x2469, 0x874A, 0x246A, 0x874B, 0x246B, - 0x874C, 0x246C, 0x874D, 0x246D, 0x874E, 0x246E, 0x874F, 0x246F, - 0x8750, 0x2470, 0x8751, 0x2471, 0x8752, 0x2472, 0x8753, 0x2473, - 0x8754, 0x2160, 0x8755, 0x2161, 0x8756, 0x2162, 0x8757, 0x2163, - 0x8758, 0x2164, 0x8759, 0x2165, 0x875A, 0x2166, 0x875B, 0x2167, - 0x875C, 0x2168, 0x875D, 0x2169, 0x875F, 0x3349, 0x8760, 0x3314, - 0x8761, 0x3322, 0x8762, 0x334D, 0x8763, 0x3318, 0x8764, 0x3327, - 0x8765, 0x3303, 0x8766, 0x3336, 0x8767, 0x3351, 0x8768, 0x3357, - 0x8769, 0x330D, 0x876A, 0x3326, 0x876B, 0x3323, 0x876C, 0x332B, - 0x876D, 0x334A, 0x876E, 0x333B, 0x876F, 0x339C, 0x8770, 0x339D, - 0x8771, 0x339E, 0x8772, 0x338E, 0x8773, 0x338F, 0x8774, 0x33C4, - 0x8775, 0x33A1, 0x877E, 0x337B, 0x8780, 0x301D, 0x8781, 0x301F, - 0x8782, 0x2116, 0x8783, 0x33CD, 0x8784, 0x2121, 0x8785, 0x32A4, - 0x8786, 0x32A5, 0x8787, 0x32A6, 0x8788, 0x32A7, 0x8789, 0x32A8, - 0x878A, 0x3231, 0x878B, 0x3232, 0x878C, 0x3239, 0x878D, 0x337E, - 0x878E, 0x337D, 0x878F, 0x337C, 0x8793, 0x222E, 0x8794, 0x2211, - 0x8798, 0x221F, 0x8799, 0x22BF, 0x889F, 0x4E9C, 0x88A0, 0x5516, - 0x88A1, 0x5A03, 0x88A2, 0x963F, 0x88A3, 0x54C0, 0x88A4, 0x611B, - 0x88A5, 0x6328, 0x88A6, 0x59F6, 0x88A7, 0x9022, 0x88A8, 0x8475, - 0x88A9, 0x831C, 0x88AA, 0x7A50, 0x88AB, 0x60AA, 0x88AC, 0x63E1, - 0x88AD, 0x6E25, 0x88AE, 0x65ED, 0x88AF, 0x8466, 0x88B0, 0x82A6, - 0x88B1, 0x9BF5, 0x88B2, 0x6893, 0x88B3, 0x5727, 0x88B4, 0x65A1, - 0x88B5, 0x6271, 0x88B6, 0x5B9B, 0x88B7, 0x59D0, 0x88B8, 0x867B, - 0x88B9, 0x98F4, 0x88BA, 0x7D62, 0x88BB, 0x7DBE, 0x88BC, 0x9B8E, - 0x88BD, 0x6216, 0x88BE, 0x7C9F, 0x88BF, 0x88B7, 0x88C0, 0x5B89, - 0x88C1, 0x5EB5, 0x88C2, 0x6309, 0x88C3, 0x6697, 0x88C4, 0x6848, - 0x88C5, 0x95C7, 0x88C6, 0x978D, 0x88C7, 0x674F, 0x88C8, 0x4EE5, - 0x88C9, 0x4F0A, 0x88CA, 0x4F4D, 0x88CB, 0x4F9D, 0x88CC, 0x5049, - 0x88CD, 0x56F2, 0x88CE, 0x5937, 0x88CF, 0x59D4, 0x88D0, 0x5A01, - 0x88D1, 0x5C09, 0x88D2, 0x60DF, 0x88D3, 0x610F, 0x88D4, 0x6170, - 0x88D5, 0x6613, 0x88D6, 0x6905, 0x88D7, 0x70BA, 0x88D8, 0x754F, - 0x88D9, 0x7570, 0x88DA, 0x79FB, 0x88DB, 0x7DAD, 0x88DC, 0x7DEF, - 0x88DD, 0x80C3, 0x88DE, 0x840E, 0x88DF, 0x8863, 0x88E0, 0x8B02, - 0x88E1, 0x9055, 0x88E2, 0x907A, 0x88E3, 0x533B, 0x88E4, 0x4E95, - 0x88E5, 0x4EA5, 0x88E6, 0x57DF, 0x88E7, 0x80B2, 0x88E8, 0x90C1, - 0x88E9, 0x78EF, 0x88EA, 0x4E00, 0x88EB, 0x58F1, 0x88EC, 0x6EA2, - 0x88ED, 0x9038, 0x88EE, 0x7A32, 0x88EF, 0x8328, 0x88F0, 0x828B, - 0x88F1, 0x9C2F, 0x88F2, 0x5141, 0x88F3, 0x5370, 0x88F4, 0x54BD, - 0x88F5, 0x54E1, 0x88F6, 0x56E0, 0x88F7, 0x59FB, 0x88F8, 0x5F15, - 0x88F9, 0x98F2, 0x88FA, 0x6DEB, 0x88FB, 0x80E4, 0x88FC, 0x852D, - 0x8940, 0x9662, 0x8941, 0x9670, 0x8942, 0x96A0, 0x8943, 0x97FB, - 0x8944, 0x540B, 0x8945, 0x53F3, 0x8946, 0x5B87, 0x8947, 0x70CF, - 0x8948, 0x7FBD, 0x8949, 0x8FC2, 0x894A, 0x96E8, 0x894B, 0x536F, - 0x894C, 0x9D5C, 0x894D, 0x7ABA, 0x894E, 0x4E11, 0x894F, 0x7893, - 0x8950, 0x81FC, 0x8951, 0x6E26, 0x8952, 0x5618, 0x8953, 0x5504, - 0x8954, 0x6B1D, 0x8955, 0x851A, 0x8956, 0x9C3B, 0x8957, 0x59E5, - 0x8958, 0x53A9, 0x8959, 0x6D66, 0x895A, 0x74DC, 0x895B, 0x958F, - 0x895C, 0x5642, 0x895D, 0x4E91, 0x895E, 0x904B, 0x895F, 0x96F2, - 0x8960, 0x834F, 0x8961, 0x990C, 0x8962, 0x53E1, 0x8963, 0x55B6, - 0x8964, 0x5B30, 0x8965, 0x5F71, 0x8966, 0x6620, 0x8967, 0x66F3, - 0x8968, 0x6804, 0x8969, 0x6C38, 0x896A, 0x6CF3, 0x896B, 0x6D29, - 0x896C, 0x745B, 0x896D, 0x76C8, 0x896E, 0x7A4E, 0x896F, 0x9834, - 0x8970, 0x82F1, 0x8971, 0x885B, 0x8972, 0x8A60, 0x8973, 0x92ED, - 0x8974, 0x6DB2, 0x8975, 0x75AB, 0x8976, 0x76CA, 0x8977, 0x99C5, - 0x8978, 0x60A6, 0x8979, 0x8B01, 0x897A, 0x8D8A, 0x897B, 0x95B2, - 0x897C, 0x698E, 0x897D, 0x53AD, 0x897E, 0x5186, 0x8980, 0x5712, - 0x8981, 0x5830, 0x8982, 0x5944, 0x8983, 0x5BB4, 0x8984, 0x5EF6, - 0x8985, 0x6028, 0x8986, 0x63A9, 0x8987, 0x63F4, 0x8988, 0x6CBF, - 0x8989, 0x6F14, 0x898A, 0x708E, 0x898B, 0x7114, 0x898C, 0x7159, - 0x898D, 0x71D5, 0x898E, 0x733F, 0x898F, 0x7E01, 0x8990, 0x8276, - 0x8991, 0x82D1, 0x8992, 0x8597, 0x8993, 0x9060, 0x8994, 0x925B, - 0x8995, 0x9D1B, 0x8996, 0x5869, 0x8997, 0x65BC, 0x8998, 0x6C5A, - 0x8999, 0x7525, 0x899A, 0x51F9, 0x899B, 0x592E, 0x899C, 0x5965, - 0x899D, 0x5F80, 0x899E, 0x5FDC, 0x899F, 0x62BC, 0x89A0, 0x65FA, - 0x89A1, 0x6A2A, 0x89A2, 0x6B27, 0x89A3, 0x6BB4, 0x89A4, 0x738B, - 0x89A5, 0x7FC1, 0x89A6, 0x8956, 0x89A7, 0x9D2C, 0x89A8, 0x9D0E, - 0x89A9, 0x9EC4, 0x89AA, 0x5CA1, 0x89AB, 0x6C96, 0x89AC, 0x837B, - 0x89AD, 0x5104, 0x89AE, 0x5C4B, 0x89AF, 0x61B6, 0x89B0, 0x81C6, - 0x89B1, 0x6876, 0x89B2, 0x7261, 0x89B3, 0x4E59, 0x89B4, 0x4FFA, - 0x89B5, 0x5378, 0x89B6, 0x6069, 0x89B7, 0x6E29, 0x89B8, 0x7A4F, - 0x89B9, 0x97F3, 0x89BA, 0x4E0B, 0x89BB, 0x5316, 0x89BC, 0x4EEE, - 0x89BD, 0x4F55, 0x89BE, 0x4F3D, 0x89BF, 0x4FA1, 0x89C0, 0x4F73, - 0x89C1, 0x52A0, 0x89C2, 0x53EF, 0x89C3, 0x5609, 0x89C4, 0x590F, - 0x89C5, 0x5AC1, 0x89C6, 0x5BB6, 0x89C7, 0x5BE1, 0x89C8, 0x79D1, - 0x89C9, 0x6687, 0x89CA, 0x679C, 0x89CB, 0x67B6, 0x89CC, 0x6B4C, - 0x89CD, 0x6CB3, 0x89CE, 0x706B, 0x89CF, 0x73C2, 0x89D0, 0x798D, - 0x89D1, 0x79BE, 0x89D2, 0x7A3C, 0x89D3, 0x7B87, 0x89D4, 0x82B1, - 0x89D5, 0x82DB, 0x89D6, 0x8304, 0x89D7, 0x8377, 0x89D8, 0x83EF, - 0x89D9, 0x83D3, 0x89DA, 0x8766, 0x89DB, 0x8AB2, 0x89DC, 0x5629, - 0x89DD, 0x8CA8, 0x89DE, 0x8FE6, 0x89DF, 0x904E, 0x89E0, 0x971E, - 0x89E1, 0x868A, 0x89E2, 0x4FC4, 0x89E3, 0x5CE8, 0x89E4, 0x6211, - 0x89E5, 0x7259, 0x89E6, 0x753B, 0x89E7, 0x81E5, 0x89E8, 0x82BD, - 0x89E9, 0x86FE, 0x89EA, 0x8CC0, 0x89EB, 0x96C5, 0x89EC, 0x9913, - 0x89ED, 0x99D5, 0x89EE, 0x4ECB, 0x89EF, 0x4F1A, 0x89F0, 0x89E3, - 0x89F1, 0x56DE, 0x89F2, 0x584A, 0x89F3, 0x58CA, 0x89F4, 0x5EFB, - 0x89F5, 0x5FEB, 0x89F6, 0x602A, 0x89F7, 0x6094, 0x89F8, 0x6062, - 0x89F9, 0x61D0, 0x89FA, 0x6212, 0x89FB, 0x62D0, 0x89FC, 0x6539, - 0x8A40, 0x9B41, 0x8A41, 0x6666, 0x8A42, 0x68B0, 0x8A43, 0x6D77, - 0x8A44, 0x7070, 0x8A45, 0x754C, 0x8A46, 0x7686, 0x8A47, 0x7D75, - 0x8A48, 0x82A5, 0x8A49, 0x87F9, 0x8A4A, 0x958B, 0x8A4B, 0x968E, - 0x8A4C, 0x8C9D, 0x8A4D, 0x51F1, 0x8A4E, 0x52BE, 0x8A4F, 0x5916, - 0x8A50, 0x54B3, 0x8A51, 0x5BB3, 0x8A52, 0x5D16, 0x8A53, 0x6168, - 0x8A54, 0x6982, 0x8A55, 0x6DAF, 0x8A56, 0x788D, 0x8A57, 0x84CB, - 0x8A58, 0x8857, 0x8A59, 0x8A72, 0x8A5A, 0x93A7, 0x8A5B, 0x9AB8, - 0x8A5C, 0x6D6C, 0x8A5D, 0x99A8, 0x8A5E, 0x86D9, 0x8A5F, 0x57A3, - 0x8A60, 0x67FF, 0x8A61, 0x86CE, 0x8A62, 0x920E, 0x8A63, 0x5283, - 0x8A64, 0x5687, 0x8A65, 0x5404, 0x8A66, 0x5ED3, 0x8A67, 0x62E1, - 0x8A68, 0x64B9, 0x8A69, 0x683C, 0x8A6A, 0x6838, 0x8A6B, 0x6BBB, - 0x8A6C, 0x7372, 0x8A6D, 0x78BA, 0x8A6E, 0x7A6B, 0x8A6F, 0x899A, - 0x8A70, 0x89D2, 0x8A71, 0x8D6B, 0x8A72, 0x8F03, 0x8A73, 0x90ED, - 0x8A74, 0x95A3, 0x8A75, 0x9694, 0x8A76, 0x9769, 0x8A77, 0x5B66, - 0x8A78, 0x5CB3, 0x8A79, 0x697D, 0x8A7A, 0x984D, 0x8A7B, 0x984E, - 0x8A7C, 0x639B, 0x8A7D, 0x7B20, 0x8A7E, 0x6A2B, 0x8A80, 0x6A7F, - 0x8A81, 0x68B6, 0x8A82, 0x9C0D, 0x8A83, 0x6F5F, 0x8A84, 0x5272, - 0x8A85, 0x559D, 0x8A86, 0x6070, 0x8A87, 0x62EC, 0x8A88, 0x6D3B, - 0x8A89, 0x6E07, 0x8A8A, 0x6ED1, 0x8A8B, 0x845B, 0x8A8C, 0x8910, - 0x8A8D, 0x8F44, 0x8A8E, 0x4E14, 0x8A8F, 0x9C39, 0x8A90, 0x53F6, - 0x8A91, 0x691B, 0x8A92, 0x6A3A, 0x8A93, 0x9784, 0x8A94, 0x682A, - 0x8A95, 0x515C, 0x8A96, 0x7AC3, 0x8A97, 0x84B2, 0x8A98, 0x91DC, - 0x8A99, 0x938C, 0x8A9A, 0x565B, 0x8A9B, 0x9D28, 0x8A9C, 0x6822, - 0x8A9D, 0x8305, 0x8A9E, 0x8431, 0x8A9F, 0x7CA5, 0x8AA0, 0x5208, - 0x8AA1, 0x82C5, 0x8AA2, 0x74E6, 0x8AA3, 0x4E7E, 0x8AA4, 0x4F83, - 0x8AA5, 0x51A0, 0x8AA6, 0x5BD2, 0x8AA7, 0x520A, 0x8AA8, 0x52D8, - 0x8AA9, 0x52E7, 0x8AAA, 0x5DFB, 0x8AAB, 0x559A, 0x8AAC, 0x582A, - 0x8AAD, 0x59E6, 0x8AAE, 0x5B8C, 0x8AAF, 0x5B98, 0x8AB0, 0x5BDB, - 0x8AB1, 0x5E72, 0x8AB2, 0x5E79, 0x8AB3, 0x60A3, 0x8AB4, 0x611F, - 0x8AB5, 0x6163, 0x8AB6, 0x61BE, 0x8AB7, 0x63DB, 0x8AB8, 0x6562, - 0x8AB9, 0x67D1, 0x8ABA, 0x6853, 0x8ABB, 0x68FA, 0x8ABC, 0x6B3E, - 0x8ABD, 0x6B53, 0x8ABE, 0x6C57, 0x8ABF, 0x6F22, 0x8AC0, 0x6F97, - 0x8AC1, 0x6F45, 0x8AC2, 0x74B0, 0x8AC3, 0x7518, 0x8AC4, 0x76E3, - 0x8AC5, 0x770B, 0x8AC6, 0x7AFF, 0x8AC7, 0x7BA1, 0x8AC8, 0x7C21, - 0x8AC9, 0x7DE9, 0x8ACA, 0x7F36, 0x8ACB, 0x7FF0, 0x8ACC, 0x809D, - 0x8ACD, 0x8266, 0x8ACE, 0x839E, 0x8ACF, 0x89B3, 0x8AD0, 0x8ACC, - 0x8AD1, 0x8CAB, 0x8AD2, 0x9084, 0x8AD3, 0x9451, 0x8AD4, 0x9593, - 0x8AD5, 0x9591, 0x8AD6, 0x95A2, 0x8AD7, 0x9665, 0x8AD8, 0x97D3, - 0x8AD9, 0x9928, 0x8ADA, 0x8218, 0x8ADB, 0x4E38, 0x8ADC, 0x542B, - 0x8ADD, 0x5CB8, 0x8ADE, 0x5DCC, 0x8ADF, 0x73A9, 0x8AE0, 0x764C, - 0x8AE1, 0x773C, 0x8AE2, 0x5CA9, 0x8AE3, 0x7FEB, 0x8AE4, 0x8D0B, - 0x8AE5, 0x96C1, 0x8AE6, 0x9811, 0x8AE7, 0x9854, 0x8AE8, 0x9858, - 0x8AE9, 0x4F01, 0x8AEA, 0x4F0E, 0x8AEB, 0x5371, 0x8AEC, 0x559C, - 0x8AED, 0x5668, 0x8AEE, 0x57FA, 0x8AEF, 0x5947, 0x8AF0, 0x5B09, - 0x8AF1, 0x5BC4, 0x8AF2, 0x5C90, 0x8AF3, 0x5E0C, 0x8AF4, 0x5E7E, - 0x8AF5, 0x5FCC, 0x8AF6, 0x63EE, 0x8AF7, 0x673A, 0x8AF8, 0x65D7, - 0x8AF9, 0x65E2, 0x8AFA, 0x671F, 0x8AFB, 0x68CB, 0x8AFC, 0x68C4, - 0x8B40, 0x6A5F, 0x8B41, 0x5E30, 0x8B42, 0x6BC5, 0x8B43, 0x6C17, - 0x8B44, 0x6C7D, 0x8B45, 0x757F, 0x8B46, 0x7948, 0x8B47, 0x5B63, - 0x8B48, 0x7A00, 0x8B49, 0x7D00, 0x8B4A, 0x5FBD, 0x8B4B, 0x898F, - 0x8B4C, 0x8A18, 0x8B4D, 0x8CB4, 0x8B4E, 0x8D77, 0x8B4F, 0x8ECC, - 0x8B50, 0x8F1D, 0x8B51, 0x98E2, 0x8B52, 0x9A0E, 0x8B53, 0x9B3C, - 0x8B54, 0x4E80, 0x8B55, 0x507D, 0x8B56, 0x5100, 0x8B57, 0x5993, - 0x8B58, 0x5B9C, 0x8B59, 0x622F, 0x8B5A, 0x6280, 0x8B5B, 0x64EC, - 0x8B5C, 0x6B3A, 0x8B5D, 0x72A0, 0x8B5E, 0x7591, 0x8B5F, 0x7947, - 0x8B60, 0x7FA9, 0x8B61, 0x87FB, 0x8B62, 0x8ABC, 0x8B63, 0x8B70, - 0x8B64, 0x63AC, 0x8B65, 0x83CA, 0x8B66, 0x97A0, 0x8B67, 0x5409, - 0x8B68, 0x5403, 0x8B69, 0x55AB, 0x8B6A, 0x6854, 0x8B6B, 0x6A58, - 0x8B6C, 0x8A70, 0x8B6D, 0x7827, 0x8B6E, 0x6775, 0x8B6F, 0x9ECD, - 0x8B70, 0x5374, 0x8B71, 0x5BA2, 0x8B72, 0x811A, 0x8B73, 0x8650, - 0x8B74, 0x9006, 0x8B75, 0x4E18, 0x8B76, 0x4E45, 0x8B77, 0x4EC7, - 0x8B78, 0x4F11, 0x8B79, 0x53CA, 0x8B7A, 0x5438, 0x8B7B, 0x5BAE, - 0x8B7C, 0x5F13, 0x8B7D, 0x6025, 0x8B7E, 0x6551, 0x8B80, 0x673D, - 0x8B81, 0x6C42, 0x8B82, 0x6C72, 0x8B83, 0x6CE3, 0x8B84, 0x7078, - 0x8B85, 0x7403, 0x8B86, 0x7A76, 0x8B87, 0x7AAE, 0x8B88, 0x7B08, - 0x8B89, 0x7D1A, 0x8B8A, 0x7CFE, 0x8B8B, 0x7D66, 0x8B8C, 0x65E7, - 0x8B8D, 0x725B, 0x8B8E, 0x53BB, 0x8B8F, 0x5C45, 0x8B90, 0x5DE8, - 0x8B91, 0x62D2, 0x8B92, 0x62E0, 0x8B93, 0x6319, 0x8B94, 0x6E20, - 0x8B95, 0x865A, 0x8B96, 0x8A31, 0x8B97, 0x8DDD, 0x8B98, 0x92F8, - 0x8B99, 0x6F01, 0x8B9A, 0x79A6, 0x8B9B, 0x9B5A, 0x8B9C, 0x4EA8, - 0x8B9D, 0x4EAB, 0x8B9E, 0x4EAC, 0x8B9F, 0x4F9B, 0x8BA0, 0x4FA0, - 0x8BA1, 0x50D1, 0x8BA2, 0x5147, 0x8BA3, 0x7AF6, 0x8BA4, 0x5171, - 0x8BA5, 0x51F6, 0x8BA6, 0x5354, 0x8BA7, 0x5321, 0x8BA8, 0x537F, - 0x8BA9, 0x53EB, 0x8BAA, 0x55AC, 0x8BAB, 0x5883, 0x8BAC, 0x5CE1, - 0x8BAD, 0x5F37, 0x8BAE, 0x5F4A, 0x8BAF, 0x602F, 0x8BB0, 0x6050, - 0x8BB1, 0x606D, 0x8BB2, 0x631F, 0x8BB3, 0x6559, 0x8BB4, 0x6A4B, - 0x8BB5, 0x6CC1, 0x8BB6, 0x72C2, 0x8BB7, 0x72ED, 0x8BB8, 0x77EF, - 0x8BB9, 0x80F8, 0x8BBA, 0x8105, 0x8BBB, 0x8208, 0x8BBC, 0x854E, - 0x8BBD, 0x90F7, 0x8BBE, 0x93E1, 0x8BBF, 0x97FF, 0x8BC0, 0x9957, - 0x8BC1, 0x9A5A, 0x8BC2, 0x4EF0, 0x8BC3, 0x51DD, 0x8BC4, 0x5C2D, - 0x8BC5, 0x6681, 0x8BC6, 0x696D, 0x8BC7, 0x5C40, 0x8BC8, 0x66F2, - 0x8BC9, 0x6975, 0x8BCA, 0x7389, 0x8BCB, 0x6850, 0x8BCC, 0x7C81, - 0x8BCD, 0x50C5, 0x8BCE, 0x52E4, 0x8BCF, 0x5747, 0x8BD0, 0x5DFE, - 0x8BD1, 0x9326, 0x8BD2, 0x65A4, 0x8BD3, 0x6B23, 0x8BD4, 0x6B3D, - 0x8BD5, 0x7434, 0x8BD6, 0x7981, 0x8BD7, 0x79BD, 0x8BD8, 0x7B4B, - 0x8BD9, 0x7DCA, 0x8BDA, 0x82B9, 0x8BDB, 0x83CC, 0x8BDC, 0x887F, - 0x8BDD, 0x895F, 0x8BDE, 0x8B39, 0x8BDF, 0x8FD1, 0x8BE0, 0x91D1, - 0x8BE1, 0x541F, 0x8BE2, 0x9280, 0x8BE3, 0x4E5D, 0x8BE4, 0x5036, - 0x8BE5, 0x53E5, 0x8BE6, 0x533A, 0x8BE7, 0x72D7, 0x8BE8, 0x7396, - 0x8BE9, 0x77E9, 0x8BEA, 0x82E6, 0x8BEB, 0x8EAF, 0x8BEC, 0x99C6, - 0x8BED, 0x99C8, 0x8BEE, 0x99D2, 0x8BEF, 0x5177, 0x8BF0, 0x611A, - 0x8BF1, 0x865E, 0x8BF2, 0x55B0, 0x8BF3, 0x7A7A, 0x8BF4, 0x5076, - 0x8BF5, 0x5BD3, 0x8BF6, 0x9047, 0x8BF7, 0x9685, 0x8BF8, 0x4E32, - 0x8BF9, 0x6ADB, 0x8BFA, 0x91E7, 0x8BFB, 0x5C51, 0x8BFC, 0x5C48, - 0x8C40, 0x6398, 0x8C41, 0x7A9F, 0x8C42, 0x6C93, 0x8C43, 0x9774, - 0x8C44, 0x8F61, 0x8C45, 0x7AAA, 0x8C46, 0x718A, 0x8C47, 0x9688, - 0x8C48, 0x7C82, 0x8C49, 0x6817, 0x8C4A, 0x7E70, 0x8C4B, 0x6851, - 0x8C4C, 0x936C, 0x8C4D, 0x52F2, 0x8C4E, 0x541B, 0x8C4F, 0x85AB, - 0x8C50, 0x8A13, 0x8C51, 0x7FA4, 0x8C52, 0x8ECD, 0x8C53, 0x90E1, - 0x8C54, 0x5366, 0x8C55, 0x8888, 0x8C56, 0x7941, 0x8C57, 0x4FC2, - 0x8C58, 0x50BE, 0x8C59, 0x5211, 0x8C5A, 0x5144, 0x8C5B, 0x5553, - 0x8C5C, 0x572D, 0x8C5D, 0x73EA, 0x8C5E, 0x578B, 0x8C5F, 0x5951, - 0x8C60, 0x5F62, 0x8C61, 0x5F84, 0x8C62, 0x6075, 0x8C63, 0x6176, - 0x8C64, 0x6167, 0x8C65, 0x61A9, 0x8C66, 0x63B2, 0x8C67, 0x643A, - 0x8C68, 0x656C, 0x8C69, 0x666F, 0x8C6A, 0x6842, 0x8C6B, 0x6E13, - 0x8C6C, 0x7566, 0x8C6D, 0x7A3D, 0x8C6E, 0x7CFB, 0x8C6F, 0x7D4C, - 0x8C70, 0x7D99, 0x8C71, 0x7E4B, 0x8C72, 0x7F6B, 0x8C73, 0x830E, - 0x8C74, 0x834A, 0x8C75, 0x86CD, 0x8C76, 0x8A08, 0x8C77, 0x8A63, - 0x8C78, 0x8B66, 0x8C79, 0x8EFD, 0x8C7A, 0x981A, 0x8C7B, 0x9D8F, - 0x8C7C, 0x82B8, 0x8C7D, 0x8FCE, 0x8C7E, 0x9BE8, 0x8C80, 0x5287, - 0x8C81, 0x621F, 0x8C82, 0x6483, 0x8C83, 0x6FC0, 0x8C84, 0x9699, - 0x8C85, 0x6841, 0x8C86, 0x5091, 0x8C87, 0x6B20, 0x8C88, 0x6C7A, - 0x8C89, 0x6F54, 0x8C8A, 0x7A74, 0x8C8B, 0x7D50, 0x8C8C, 0x8840, - 0x8C8D, 0x8A23, 0x8C8E, 0x6708, 0x8C8F, 0x4EF6, 0x8C90, 0x5039, - 0x8C91, 0x5026, 0x8C92, 0x5065, 0x8C93, 0x517C, 0x8C94, 0x5238, - 0x8C95, 0x5263, 0x8C96, 0x55A7, 0x8C97, 0x570F, 0x8C98, 0x5805, - 0x8C99, 0x5ACC, 0x8C9A, 0x5EFA, 0x8C9B, 0x61B2, 0x8C9C, 0x61F8, - 0x8C9D, 0x62F3, 0x8C9E, 0x6372, 0x8C9F, 0x691C, 0x8CA0, 0x6A29, - 0x8CA1, 0x727D, 0x8CA2, 0x72AC, 0x8CA3, 0x732E, 0x8CA4, 0x7814, - 0x8CA5, 0x786F, 0x8CA6, 0x7D79, 0x8CA7, 0x770C, 0x8CA8, 0x80A9, - 0x8CA9, 0x898B, 0x8CAA, 0x8B19, 0x8CAB, 0x8CE2, 0x8CAC, 0x8ED2, - 0x8CAD, 0x9063, 0x8CAE, 0x9375, 0x8CAF, 0x967A, 0x8CB0, 0x9855, - 0x8CB1, 0x9A13, 0x8CB2, 0x9E78, 0x8CB3, 0x5143, 0x8CB4, 0x539F, - 0x8CB5, 0x53B3, 0x8CB6, 0x5E7B, 0x8CB7, 0x5F26, 0x8CB8, 0x6E1B, - 0x8CB9, 0x6E90, 0x8CBA, 0x7384, 0x8CBB, 0x73FE, 0x8CBC, 0x7D43, - 0x8CBD, 0x8237, 0x8CBE, 0x8A00, 0x8CBF, 0x8AFA, 0x8CC0, 0x9650, - 0x8CC1, 0x4E4E, 0x8CC2, 0x500B, 0x8CC3, 0x53E4, 0x8CC4, 0x547C, - 0x8CC5, 0x56FA, 0x8CC6, 0x59D1, 0x8CC7, 0x5B64, 0x8CC8, 0x5DF1, - 0x8CC9, 0x5EAB, 0x8CCA, 0x5F27, 0x8CCB, 0x6238, 0x8CCC, 0x6545, - 0x8CCD, 0x67AF, 0x8CCE, 0x6E56, 0x8CCF, 0x72D0, 0x8CD0, 0x7CCA, - 0x8CD1, 0x88B4, 0x8CD2, 0x80A1, 0x8CD3, 0x80E1, 0x8CD4, 0x83F0, - 0x8CD5, 0x864E, 0x8CD6, 0x8A87, 0x8CD7, 0x8DE8, 0x8CD8, 0x9237, - 0x8CD9, 0x96C7, 0x8CDA, 0x9867, 0x8CDB, 0x9F13, 0x8CDC, 0x4E94, - 0x8CDD, 0x4E92, 0x8CDE, 0x4F0D, 0x8CDF, 0x5348, 0x8CE0, 0x5449, - 0x8CE1, 0x543E, 0x8CE2, 0x5A2F, 0x8CE3, 0x5F8C, 0x8CE4, 0x5FA1, - 0x8CE5, 0x609F, 0x8CE6, 0x68A7, 0x8CE7, 0x6A8E, 0x8CE8, 0x745A, - 0x8CE9, 0x7881, 0x8CEA, 0x8A9E, 0x8CEB, 0x8AA4, 0x8CEC, 0x8B77, - 0x8CED, 0x9190, 0x8CEE, 0x4E5E, 0x8CEF, 0x9BC9, 0x8CF0, 0x4EA4, - 0x8CF1, 0x4F7C, 0x8CF2, 0x4FAF, 0x8CF3, 0x5019, 0x8CF4, 0x5016, - 0x8CF5, 0x5149, 0x8CF6, 0x516C, 0x8CF7, 0x529F, 0x8CF8, 0x52B9, - 0x8CF9, 0x52FE, 0x8CFA, 0x539A, 0x8CFB, 0x53E3, 0x8CFC, 0x5411, - 0x8D40, 0x540E, 0x8D41, 0x5589, 0x8D42, 0x5751, 0x8D43, 0x57A2, - 0x8D44, 0x597D, 0x8D45, 0x5B54, 0x8D46, 0x5B5D, 0x8D47, 0x5B8F, - 0x8D48, 0x5DE5, 0x8D49, 0x5DE7, 0x8D4A, 0x5DF7, 0x8D4B, 0x5E78, - 0x8D4C, 0x5E83, 0x8D4D, 0x5E9A, 0x8D4E, 0x5EB7, 0x8D4F, 0x5F18, - 0x8D50, 0x6052, 0x8D51, 0x614C, 0x8D52, 0x6297, 0x8D53, 0x62D8, - 0x8D54, 0x63A7, 0x8D55, 0x653B, 0x8D56, 0x6602, 0x8D57, 0x6643, - 0x8D58, 0x66F4, 0x8D59, 0x676D, 0x8D5A, 0x6821, 0x8D5B, 0x6897, - 0x8D5C, 0x69CB, 0x8D5D, 0x6C5F, 0x8D5E, 0x6D2A, 0x8D5F, 0x6D69, - 0x8D60, 0x6E2F, 0x8D61, 0x6E9D, 0x8D62, 0x7532, 0x8D63, 0x7687, - 0x8D64, 0x786C, 0x8D65, 0x7A3F, 0x8D66, 0x7CE0, 0x8D67, 0x7D05, - 0x8D68, 0x7D18, 0x8D69, 0x7D5E, 0x8D6A, 0x7DB1, 0x8D6B, 0x8015, - 0x8D6C, 0x8003, 0x8D6D, 0x80AF, 0x8D6E, 0x80B1, 0x8D6F, 0x8154, - 0x8D70, 0x818F, 0x8D71, 0x822A, 0x8D72, 0x8352, 0x8D73, 0x884C, - 0x8D74, 0x8861, 0x8D75, 0x8B1B, 0x8D76, 0x8CA2, 0x8D77, 0x8CFC, - 0x8D78, 0x90CA, 0x8D79, 0x9175, 0x8D7A, 0x9271, 0x8D7B, 0x783F, - 0x8D7C, 0x92FC, 0x8D7D, 0x95A4, 0x8D7E, 0x964D, 0x8D80, 0x9805, - 0x8D81, 0x9999, 0x8D82, 0x9AD8, 0x8D83, 0x9D3B, 0x8D84, 0x525B, - 0x8D85, 0x52AB, 0x8D86, 0x53F7, 0x8D87, 0x5408, 0x8D88, 0x58D5, - 0x8D89, 0x62F7, 0x8D8A, 0x6FE0, 0x8D8B, 0x8C6A, 0x8D8C, 0x8F5F, - 0x8D8D, 0x9EB9, 0x8D8E, 0x514B, 0x8D8F, 0x523B, 0x8D90, 0x544A, - 0x8D91, 0x56FD, 0x8D92, 0x7A40, 0x8D93, 0x9177, 0x8D94, 0x9D60, - 0x8D95, 0x9ED2, 0x8D96, 0x7344, 0x8D97, 0x6F09, 0x8D98, 0x8170, - 0x8D99, 0x7511, 0x8D9A, 0x5FFD, 0x8D9B, 0x60DA, 0x8D9C, 0x9AA8, - 0x8D9D, 0x72DB, 0x8D9E, 0x8FBC, 0x8D9F, 0x6B64, 0x8DA0, 0x9803, - 0x8DA1, 0x4ECA, 0x8DA2, 0x56F0, 0x8DA3, 0x5764, 0x8DA4, 0x58BE, - 0x8DA5, 0x5A5A, 0x8DA6, 0x6068, 0x8DA7, 0x61C7, 0x8DA8, 0x660F, - 0x8DA9, 0x6606, 0x8DAA, 0x6839, 0x8DAB, 0x68B1, 0x8DAC, 0x6DF7, - 0x8DAD, 0x75D5, 0x8DAE, 0x7D3A, 0x8DAF, 0x826E, 0x8DB0, 0x9B42, - 0x8DB1, 0x4E9B, 0x8DB2, 0x4F50, 0x8DB3, 0x53C9, 0x8DB4, 0x5506, - 0x8DB5, 0x5D6F, 0x8DB6, 0x5DE6, 0x8DB7, 0x5DEE, 0x8DB8, 0x67FB, - 0x8DB9, 0x6C99, 0x8DBA, 0x7473, 0x8DBB, 0x7802, 0x8DBC, 0x8A50, - 0x8DBD, 0x9396, 0x8DBE, 0x88DF, 0x8DBF, 0x5750, 0x8DC0, 0x5EA7, - 0x8DC1, 0x632B, 0x8DC2, 0x50B5, 0x8DC3, 0x50AC, 0x8DC4, 0x518D, - 0x8DC5, 0x6700, 0x8DC6, 0x54C9, 0x8DC7, 0x585E, 0x8DC8, 0x59BB, - 0x8DC9, 0x5BB0, 0x8DCA, 0x5F69, 0x8DCB, 0x624D, 0x8DCC, 0x63A1, - 0x8DCD, 0x683D, 0x8DCE, 0x6B73, 0x8DCF, 0x6E08, 0x8DD0, 0x707D, - 0x8DD1, 0x91C7, 0x8DD2, 0x7280, 0x8DD3, 0x7815, 0x8DD4, 0x7826, - 0x8DD5, 0x796D, 0x8DD6, 0x658E, 0x8DD7, 0x7D30, 0x8DD8, 0x83DC, - 0x8DD9, 0x88C1, 0x8DDA, 0x8F09, 0x8DDB, 0x969B, 0x8DDC, 0x5264, - 0x8DDD, 0x5728, 0x8DDE, 0x6750, 0x8DDF, 0x7F6A, 0x8DE0, 0x8CA1, - 0x8DE1, 0x51B4, 0x8DE2, 0x5742, 0x8DE3, 0x962A, 0x8DE4, 0x583A, - 0x8DE5, 0x698A, 0x8DE6, 0x80B4, 0x8DE7, 0x54B2, 0x8DE8, 0x5D0E, - 0x8DE9, 0x57FC, 0x8DEA, 0x7895, 0x8DEB, 0x9DFA, 0x8DEC, 0x4F5C, - 0x8DED, 0x524A, 0x8DEE, 0x548B, 0x8DEF, 0x643E, 0x8DF0, 0x6628, - 0x8DF1, 0x6714, 0x8DF2, 0x67F5, 0x8DF3, 0x7A84, 0x8DF4, 0x7B56, - 0x8DF5, 0x7D22, 0x8DF6, 0x932F, 0x8DF7, 0x685C, 0x8DF8, 0x9BAD, - 0x8DF9, 0x7B39, 0x8DFA, 0x5319, 0x8DFB, 0x518A, 0x8DFC, 0x5237, - 0x8E40, 0x5BDF, 0x8E41, 0x62F6, 0x8E42, 0x64AE, 0x8E43, 0x64E6, - 0x8E44, 0x672D, 0x8E45, 0x6BBA, 0x8E46, 0x85A9, 0x8E47, 0x96D1, - 0x8E48, 0x7690, 0x8E49, 0x9BD6, 0x8E4A, 0x634C, 0x8E4B, 0x9306, - 0x8E4C, 0x9BAB, 0x8E4D, 0x76BF, 0x8E4E, 0x6652, 0x8E4F, 0x4E09, - 0x8E50, 0x5098, 0x8E51, 0x53C2, 0x8E52, 0x5C71, 0x8E53, 0x60E8, - 0x8E54, 0x6492, 0x8E55, 0x6563, 0x8E56, 0x685F, 0x8E57, 0x71E6, - 0x8E58, 0x73CA, 0x8E59, 0x7523, 0x8E5A, 0x7B97, 0x8E5B, 0x7E82, - 0x8E5C, 0x8695, 0x8E5D, 0x8B83, 0x8E5E, 0x8CDB, 0x8E5F, 0x9178, - 0x8E60, 0x9910, 0x8E61, 0x65AC, 0x8E62, 0x66AB, 0x8E63, 0x6B8B, - 0x8E64, 0x4ED5, 0x8E65, 0x4ED4, 0x8E66, 0x4F3A, 0x8E67, 0x4F7F, - 0x8E68, 0x523A, 0x8E69, 0x53F8, 0x8E6A, 0x53F2, 0x8E6B, 0x55E3, - 0x8E6C, 0x56DB, 0x8E6D, 0x58EB, 0x8E6E, 0x59CB, 0x8E6F, 0x59C9, - 0x8E70, 0x59FF, 0x8E71, 0x5B50, 0x8E72, 0x5C4D, 0x8E73, 0x5E02, - 0x8E74, 0x5E2B, 0x8E75, 0x5FD7, 0x8E76, 0x601D, 0x8E77, 0x6307, - 0x8E78, 0x652F, 0x8E79, 0x5B5C, 0x8E7A, 0x65AF, 0x8E7B, 0x65BD, - 0x8E7C, 0x65E8, 0x8E7D, 0x679D, 0x8E7E, 0x6B62, 0x8E80, 0x6B7B, - 0x8E81, 0x6C0F, 0x8E82, 0x7345, 0x8E83, 0x7949, 0x8E84, 0x79C1, - 0x8E85, 0x7CF8, 0x8E86, 0x7D19, 0x8E87, 0x7D2B, 0x8E88, 0x80A2, - 0x8E89, 0x8102, 0x8E8A, 0x81F3, 0x8E8B, 0x8996, 0x8E8C, 0x8A5E, - 0x8E8D, 0x8A69, 0x8E8E, 0x8A66, 0x8E8F, 0x8A8C, 0x8E90, 0x8AEE, - 0x8E91, 0x8CC7, 0x8E92, 0x8CDC, 0x8E93, 0x96CC, 0x8E94, 0x98FC, - 0x8E95, 0x6B6F, 0x8E96, 0x4E8B, 0x8E97, 0x4F3C, 0x8E98, 0x4F8D, - 0x8E99, 0x5150, 0x8E9A, 0x5B57, 0x8E9B, 0x5BFA, 0x8E9C, 0x6148, - 0x8E9D, 0x6301, 0x8E9E, 0x6642, 0x8E9F, 0x6B21, 0x8EA0, 0x6ECB, - 0x8EA1, 0x6CBB, 0x8EA2, 0x723E, 0x8EA3, 0x74BD, 0x8EA4, 0x75D4, - 0x8EA5, 0x78C1, 0x8EA6, 0x793A, 0x8EA7, 0x800C, 0x8EA8, 0x8033, - 0x8EA9, 0x81EA, 0x8EAA, 0x8494, 0x8EAB, 0x8F9E, 0x8EAC, 0x6C50, - 0x8EAD, 0x9E7F, 0x8EAE, 0x5F0F, 0x8EAF, 0x8B58, 0x8EB0, 0x9D2B, - 0x8EB1, 0x7AFA, 0x8EB2, 0x8EF8, 0x8EB3, 0x5B8D, 0x8EB4, 0x96EB, - 0x8EB5, 0x4E03, 0x8EB6, 0x53F1, 0x8EB7, 0x57F7, 0x8EB8, 0x5931, - 0x8EB9, 0x5AC9, 0x8EBA, 0x5BA4, 0x8EBB, 0x6089, 0x8EBC, 0x6E7F, - 0x8EBD, 0x6F06, 0x8EBE, 0x75BE, 0x8EBF, 0x8CEA, 0x8EC0, 0x5B9F, - 0x8EC1, 0x8500, 0x8EC2, 0x7BE0, 0x8EC3, 0x5072, 0x8EC4, 0x67F4, - 0x8EC5, 0x829D, 0x8EC6, 0x5C61, 0x8EC7, 0x854A, 0x8EC8, 0x7E1E, - 0x8EC9, 0x820E, 0x8ECA, 0x5199, 0x8ECB, 0x5C04, 0x8ECC, 0x6368, - 0x8ECD, 0x8D66, 0x8ECE, 0x659C, 0x8ECF, 0x716E, 0x8ED0, 0x793E, - 0x8ED1, 0x7D17, 0x8ED2, 0x8005, 0x8ED3, 0x8B1D, 0x8ED4, 0x8ECA, - 0x8ED5, 0x906E, 0x8ED6, 0x86C7, 0x8ED7, 0x90AA, 0x8ED8, 0x501F, - 0x8ED9, 0x52FA, 0x8EDA, 0x5C3A, 0x8EDB, 0x6753, 0x8EDC, 0x707C, - 0x8EDD, 0x7235, 0x8EDE, 0x914C, 0x8EDF, 0x91C8, 0x8EE0, 0x932B, - 0x8EE1, 0x82E5, 0x8EE2, 0x5BC2, 0x8EE3, 0x5F31, 0x8EE4, 0x60F9, - 0x8EE5, 0x4E3B, 0x8EE6, 0x53D6, 0x8EE7, 0x5B88, 0x8EE8, 0x624B, - 0x8EE9, 0x6731, 0x8EEA, 0x6B8A, 0x8EEB, 0x72E9, 0x8EEC, 0x73E0, - 0x8EED, 0x7A2E, 0x8EEE, 0x816B, 0x8EEF, 0x8DA3, 0x8EF0, 0x9152, - 0x8EF1, 0x9996, 0x8EF2, 0x5112, 0x8EF3, 0x53D7, 0x8EF4, 0x546A, - 0x8EF5, 0x5BFF, 0x8EF6, 0x6388, 0x8EF7, 0x6A39, 0x8EF8, 0x7DAC, - 0x8EF9, 0x9700, 0x8EFA, 0x56DA, 0x8EFB, 0x53CE, 0x8EFC, 0x5468, - 0x8F40, 0x5B97, 0x8F41, 0x5C31, 0x8F42, 0x5DDE, 0x8F43, 0x4FEE, - 0x8F44, 0x6101, 0x8F45, 0x62FE, 0x8F46, 0x6D32, 0x8F47, 0x79C0, - 0x8F48, 0x79CB, 0x8F49, 0x7D42, 0x8F4A, 0x7E4D, 0x8F4B, 0x7FD2, - 0x8F4C, 0x81ED, 0x8F4D, 0x821F, 0x8F4E, 0x8490, 0x8F4F, 0x8846, - 0x8F50, 0x8972, 0x8F51, 0x8B90, 0x8F52, 0x8E74, 0x8F53, 0x8F2F, - 0x8F54, 0x9031, 0x8F55, 0x914B, 0x8F56, 0x916C, 0x8F57, 0x96C6, - 0x8F58, 0x919C, 0x8F59, 0x4EC0, 0x8F5A, 0x4F4F, 0x8F5B, 0x5145, - 0x8F5C, 0x5341, 0x8F5D, 0x5F93, 0x8F5E, 0x620E, 0x8F5F, 0x67D4, - 0x8F60, 0x6C41, 0x8F61, 0x6E0B, 0x8F62, 0x7363, 0x8F63, 0x7E26, - 0x8F64, 0x91CD, 0x8F65, 0x9283, 0x8F66, 0x53D4, 0x8F67, 0x5919, - 0x8F68, 0x5BBF, 0x8F69, 0x6DD1, 0x8F6A, 0x795D, 0x8F6B, 0x7E2E, - 0x8F6C, 0x7C9B, 0x8F6D, 0x587E, 0x8F6E, 0x719F, 0x8F6F, 0x51FA, - 0x8F70, 0x8853, 0x8F71, 0x8FF0, 0x8F72, 0x4FCA, 0x8F73, 0x5CFB, - 0x8F74, 0x6625, 0x8F75, 0x77AC, 0x8F76, 0x7AE3, 0x8F77, 0x821C, - 0x8F78, 0x99FF, 0x8F79, 0x51C6, 0x8F7A, 0x5FAA, 0x8F7B, 0x65EC, - 0x8F7C, 0x696F, 0x8F7D, 0x6B89, 0x8F7E, 0x6DF3, 0x8F80, 0x6E96, - 0x8F81, 0x6F64, 0x8F82, 0x76FE, 0x8F83, 0x7D14, 0x8F84, 0x5DE1, - 0x8F85, 0x9075, 0x8F86, 0x9187, 0x8F87, 0x9806, 0x8F88, 0x51E6, - 0x8F89, 0x521D, 0x8F8A, 0x6240, 0x8F8B, 0x6691, 0x8F8C, 0x66D9, - 0x8F8D, 0x6E1A, 0x8F8E, 0x5EB6, 0x8F8F, 0x7DD2, 0x8F90, 0x7F72, - 0x8F91, 0x66F8, 0x8F92, 0x85AF, 0x8F93, 0x85F7, 0x8F94, 0x8AF8, - 0x8F95, 0x52A9, 0x8F96, 0x53D9, 0x8F97, 0x5973, 0x8F98, 0x5E8F, - 0x8F99, 0x5F90, 0x8F9A, 0x6055, 0x8F9B, 0x92E4, 0x8F9C, 0x9664, - 0x8F9D, 0x50B7, 0x8F9E, 0x511F, 0x8F9F, 0x52DD, 0x8FA0, 0x5320, - 0x8FA1, 0x5347, 0x8FA2, 0x53EC, 0x8FA3, 0x54E8, 0x8FA4, 0x5546, - 0x8FA5, 0x5531, 0x8FA6, 0x5617, 0x8FA7, 0x5968, 0x8FA8, 0x59BE, - 0x8FA9, 0x5A3C, 0x8FAA, 0x5BB5, 0x8FAB, 0x5C06, 0x8FAC, 0x5C0F, - 0x8FAD, 0x5C11, 0x8FAE, 0x5C1A, 0x8FAF, 0x5E84, 0x8FB0, 0x5E8A, - 0x8FB1, 0x5EE0, 0x8FB2, 0x5F70, 0x8FB3, 0x627F, 0x8FB4, 0x6284, - 0x8FB5, 0x62DB, 0x8FB6, 0x638C, 0x8FB7, 0x6377, 0x8FB8, 0x6607, - 0x8FB9, 0x660C, 0x8FBA, 0x662D, 0x8FBB, 0x6676, 0x8FBC, 0x677E, - 0x8FBD, 0x68A2, 0x8FBE, 0x6A1F, 0x8FBF, 0x6A35, 0x8FC0, 0x6CBC, - 0x8FC1, 0x6D88, 0x8FC2, 0x6E09, 0x8FC3, 0x6E58, 0x8FC4, 0x713C, - 0x8FC5, 0x7126, 0x8FC6, 0x7167, 0x8FC7, 0x75C7, 0x8FC8, 0x7701, - 0x8FC9, 0x785D, 0x8FCA, 0x7901, 0x8FCB, 0x7965, 0x8FCC, 0x79F0, - 0x8FCD, 0x7AE0, 0x8FCE, 0x7B11, 0x8FCF, 0x7CA7, 0x8FD0, 0x7D39, - 0x8FD1, 0x8096, 0x8FD2, 0x83D6, 0x8FD3, 0x848B, 0x8FD4, 0x8549, - 0x8FD5, 0x885D, 0x8FD6, 0x88F3, 0x8FD7, 0x8A1F, 0x8FD8, 0x8A3C, - 0x8FD9, 0x8A54, 0x8FDA, 0x8A73, 0x8FDB, 0x8C61, 0x8FDC, 0x8CDE, - 0x8FDD, 0x91A4, 0x8FDE, 0x9266, 0x8FDF, 0x937E, 0x8FE0, 0x9418, - 0x8FE1, 0x969C, 0x8FE2, 0x9798, 0x8FE3, 0x4E0A, 0x8FE4, 0x4E08, - 0x8FE5, 0x4E1E, 0x8FE6, 0x4E57, 0x8FE7, 0x5197, 0x8FE8, 0x5270, - 0x8FE9, 0x57CE, 0x8FEA, 0x5834, 0x8FEB, 0x58CC, 0x8FEC, 0x5B22, - 0x8FED, 0x5E38, 0x8FEE, 0x60C5, 0x8FEF, 0x64FE, 0x8FF0, 0x6761, - 0x8FF1, 0x6756, 0x8FF2, 0x6D44, 0x8FF3, 0x72B6, 0x8FF4, 0x7573, - 0x8FF5, 0x7A63, 0x8FF6, 0x84B8, 0x8FF7, 0x8B72, 0x8FF8, 0x91B8, - 0x8FF9, 0x9320, 0x8FFA, 0x5631, 0x8FFB, 0x57F4, 0x8FFC, 0x98FE, - 0x9040, 0x62ED, 0x9041, 0x690D, 0x9042, 0x6B96, 0x9043, 0x71ED, - 0x9044, 0x7E54, 0x9045, 0x8077, 0x9046, 0x8272, 0x9047, 0x89E6, - 0x9048, 0x98DF, 0x9049, 0x8755, 0x904A, 0x8FB1, 0x904B, 0x5C3B, - 0x904C, 0x4F38, 0x904D, 0x4FE1, 0x904E, 0x4FB5, 0x904F, 0x5507, - 0x9050, 0x5A20, 0x9051, 0x5BDD, 0x9052, 0x5BE9, 0x9053, 0x5FC3, - 0x9054, 0x614E, 0x9055, 0x632F, 0x9056, 0x65B0, 0x9057, 0x664B, - 0x9058, 0x68EE, 0x9059, 0x699B, 0x905A, 0x6D78, 0x905B, 0x6DF1, - 0x905C, 0x7533, 0x905D, 0x75B9, 0x905E, 0x771F, 0x905F, 0x795E, - 0x9060, 0x79E6, 0x9061, 0x7D33, 0x9062, 0x81E3, 0x9063, 0x82AF, - 0x9064, 0x85AA, 0x9065, 0x89AA, 0x9066, 0x8A3A, 0x9067, 0x8EAB, - 0x9068, 0x8F9B, 0x9069, 0x9032, 0x906A, 0x91DD, 0x906B, 0x9707, - 0x906C, 0x4EBA, 0x906D, 0x4EC1, 0x906E, 0x5203, 0x906F, 0x5875, - 0x9070, 0x58EC, 0x9071, 0x5C0B, 0x9072, 0x751A, 0x9073, 0x5C3D, - 0x9074, 0x814E, 0x9075, 0x8A0A, 0x9076, 0x8FC5, 0x9077, 0x9663, - 0x9078, 0x976D, 0x9079, 0x7B25, 0x907A, 0x8ACF, 0x907B, 0x9808, - 0x907C, 0x9162, 0x907D, 0x56F3, 0x907E, 0x53A8, 0x9080, 0x9017, - 0x9081, 0x5439, 0x9082, 0x5782, 0x9083, 0x5E25, 0x9084, 0x63A8, - 0x9085, 0x6C34, 0x9086, 0x708A, 0x9087, 0x7761, 0x9088, 0x7C8B, - 0x9089, 0x7FE0, 0x908A, 0x8870, 0x908B, 0x9042, 0x908C, 0x9154, - 0x908D, 0x9310, 0x908E, 0x9318, 0x908F, 0x968F, 0x9090, 0x745E, - 0x9091, 0x9AC4, 0x9092, 0x5D07, 0x9093, 0x5D69, 0x9094, 0x6570, - 0x9095, 0x67A2, 0x9096, 0x8DA8, 0x9097, 0x96DB, 0x9098, 0x636E, - 0x9099, 0x6749, 0x909A, 0x6919, 0x909B, 0x83C5, 0x909C, 0x9817, - 0x909D, 0x96C0, 0x909E, 0x88FE, 0x909F, 0x6F84, 0x90A0, 0x647A, - 0x90A1, 0x5BF8, 0x90A2, 0x4E16, 0x90A3, 0x702C, 0x90A4, 0x755D, - 0x90A5, 0x662F, 0x90A6, 0x51C4, 0x90A7, 0x5236, 0x90A8, 0x52E2, - 0x90A9, 0x59D3, 0x90AA, 0x5F81, 0x90AB, 0x6027, 0x90AC, 0x6210, - 0x90AD, 0x653F, 0x90AE, 0x6574, 0x90AF, 0x661F, 0x90B0, 0x6674, - 0x90B1, 0x68F2, 0x90B2, 0x6816, 0x90B3, 0x6B63, 0x90B4, 0x6E05, - 0x90B5, 0x7272, 0x90B6, 0x751F, 0x90B7, 0x76DB, 0x90B8, 0x7CBE, - 0x90B9, 0x8056, 0x90BA, 0x58F0, 0x90BB, 0x88FD, 0x90BC, 0x897F, - 0x90BD, 0x8AA0, 0x90BE, 0x8A93, 0x90BF, 0x8ACB, 0x90C0, 0x901D, - 0x90C1, 0x9192, 0x90C2, 0x9752, 0x90C3, 0x9759, 0x90C4, 0x6589, - 0x90C5, 0x7A0E, 0x90C6, 0x8106, 0x90C7, 0x96BB, 0x90C8, 0x5E2D, - 0x90C9, 0x60DC, 0x90CA, 0x621A, 0x90CB, 0x65A5, 0x90CC, 0x6614, - 0x90CD, 0x6790, 0x90CE, 0x77F3, 0x90CF, 0x7A4D, 0x90D0, 0x7C4D, - 0x90D1, 0x7E3E, 0x90D2, 0x810A, 0x90D3, 0x8CAC, 0x90D4, 0x8D64, - 0x90D5, 0x8DE1, 0x90D6, 0x8E5F, 0x90D7, 0x78A9, 0x90D8, 0x5207, - 0x90D9, 0x62D9, 0x90DA, 0x63A5, 0x90DB, 0x6442, 0x90DC, 0x6298, - 0x90DD, 0x8A2D, 0x90DE, 0x7A83, 0x90DF, 0x7BC0, 0x90E0, 0x8AAC, - 0x90E1, 0x96EA, 0x90E2, 0x7D76, 0x90E3, 0x820C, 0x90E4, 0x8749, - 0x90E5, 0x4ED9, 0x90E6, 0x5148, 0x90E7, 0x5343, 0x90E8, 0x5360, - 0x90E9, 0x5BA3, 0x90EA, 0x5C02, 0x90EB, 0x5C16, 0x90EC, 0x5DDD, - 0x90ED, 0x6226, 0x90EE, 0x6247, 0x90EF, 0x64B0, 0x90F0, 0x6813, - 0x90F1, 0x6834, 0x90F2, 0x6CC9, 0x90F3, 0x6D45, 0x90F4, 0x6D17, - 0x90F5, 0x67D3, 0x90F6, 0x6F5C, 0x90F7, 0x714E, 0x90F8, 0x717D, - 0x90F9, 0x65CB, 0x90FA, 0x7A7F, 0x90FB, 0x7BAD, 0x90FC, 0x7DDA, - 0x9140, 0x7E4A, 0x9141, 0x7FA8, 0x9142, 0x817A, 0x9143, 0x821B, - 0x9144, 0x8239, 0x9145, 0x85A6, 0x9146, 0x8A6E, 0x9147, 0x8CCE, - 0x9148, 0x8DF5, 0x9149, 0x9078, 0x914A, 0x9077, 0x914B, 0x92AD, - 0x914C, 0x9291, 0x914D, 0x9583, 0x914E, 0x9BAE, 0x914F, 0x524D, - 0x9150, 0x5584, 0x9151, 0x6F38, 0x9152, 0x7136, 0x9153, 0x5168, - 0x9154, 0x7985, 0x9155, 0x7E55, 0x9156, 0x81B3, 0x9157, 0x7CCE, - 0x9158, 0x564C, 0x9159, 0x5851, 0x915A, 0x5CA8, 0x915B, 0x63AA, - 0x915C, 0x66FE, 0x915D, 0x66FD, 0x915E, 0x695A, 0x915F, 0x72D9, - 0x9160, 0x758F, 0x9161, 0x758E, 0x9162, 0x790E, 0x9163, 0x7956, - 0x9164, 0x79DF, 0x9165, 0x7C97, 0x9166, 0x7D20, 0x9167, 0x7D44, - 0x9168, 0x8607, 0x9169, 0x8A34, 0x916A, 0x963B, 0x916B, 0x9061, - 0x916C, 0x9F20, 0x916D, 0x50E7, 0x916E, 0x5275, 0x916F, 0x53CC, - 0x9170, 0x53E2, 0x9171, 0x5009, 0x9172, 0x55AA, 0x9173, 0x58EE, - 0x9174, 0x594F, 0x9175, 0x723D, 0x9176, 0x5B8B, 0x9177, 0x5C64, - 0x9178, 0x531D, 0x9179, 0x60E3, 0x917A, 0x60F3, 0x917B, 0x635C, - 0x917C, 0x6383, 0x917D, 0x633F, 0x917E, 0x63BB, 0x9180, 0x64CD, - 0x9181, 0x65E9, 0x9182, 0x66F9, 0x9183, 0x5DE3, 0x9184, 0x69CD, - 0x9185, 0x69FD, 0x9186, 0x6F15, 0x9187, 0x71E5, 0x9188, 0x4E89, - 0x9189, 0x75E9, 0x918A, 0x76F8, 0x918B, 0x7A93, 0x918C, 0x7CDF, - 0x918D, 0x7DCF, 0x918E, 0x7D9C, 0x918F, 0x8061, 0x9190, 0x8349, - 0x9191, 0x8358, 0x9192, 0x846C, 0x9193, 0x84BC, 0x9194, 0x85FB, - 0x9195, 0x88C5, 0x9196, 0x8D70, 0x9197, 0x9001, 0x9198, 0x906D, - 0x9199, 0x9397, 0x919A, 0x971C, 0x919B, 0x9A12, 0x919C, 0x50CF, - 0x919D, 0x5897, 0x919E, 0x618E, 0x919F, 0x81D3, 0x91A0, 0x8535, - 0x91A1, 0x8D08, 0x91A2, 0x9020, 0x91A3, 0x4FC3, 0x91A4, 0x5074, - 0x91A5, 0x5247, 0x91A6, 0x5373, 0x91A7, 0x606F, 0x91A8, 0x6349, - 0x91A9, 0x675F, 0x91AA, 0x6E2C, 0x91AB, 0x8DB3, 0x91AC, 0x901F, - 0x91AD, 0x4FD7, 0x91AE, 0x5C5E, 0x91AF, 0x8CCA, 0x91B0, 0x65CF, - 0x91B1, 0x7D9A, 0x91B2, 0x5352, 0x91B3, 0x8896, 0x91B4, 0x5176, - 0x91B5, 0x63C3, 0x91B6, 0x5B58, 0x91B7, 0x5B6B, 0x91B8, 0x5C0A, - 0x91B9, 0x640D, 0x91BA, 0x6751, 0x91BB, 0x905C, 0x91BC, 0x4ED6, - 0x91BD, 0x591A, 0x91BE, 0x592A, 0x91BF, 0x6C70, 0x91C0, 0x8A51, - 0x91C1, 0x553E, 0x91C2, 0x5815, 0x91C3, 0x59A5, 0x91C4, 0x60F0, - 0x91C5, 0x6253, 0x91C6, 0x67C1, 0x91C7, 0x8235, 0x91C8, 0x6955, - 0x91C9, 0x9640, 0x91CA, 0x99C4, 0x91CB, 0x9A28, 0x91CC, 0x4F53, - 0x91CD, 0x5806, 0x91CE, 0x5BFE, 0x91CF, 0x8010, 0x91D0, 0x5CB1, - 0x91D1, 0x5E2F, 0x91D2, 0x5F85, 0x91D3, 0x6020, 0x91D4, 0x614B, - 0x91D5, 0x6234, 0x91D6, 0x66FF, 0x91D7, 0x6CF0, 0x91D8, 0x6EDE, - 0x91D9, 0x80CE, 0x91DA, 0x817F, 0x91DB, 0x82D4, 0x91DC, 0x888B, - 0x91DD, 0x8CB8, 0x91DE, 0x9000, 0x91DF, 0x902E, 0x91E0, 0x968A, - 0x91E1, 0x9EDB, 0x91E2, 0x9BDB, 0x91E3, 0x4EE3, 0x91E4, 0x53F0, - 0x91E5, 0x5927, 0x91E6, 0x7B2C, 0x91E7, 0x918D, 0x91E8, 0x984C, - 0x91E9, 0x9DF9, 0x91EA, 0x6EDD, 0x91EB, 0x7027, 0x91EC, 0x5353, - 0x91ED, 0x5544, 0x91EE, 0x5B85, 0x91EF, 0x6258, 0x91F0, 0x629E, - 0x91F1, 0x62D3, 0x91F2, 0x6CA2, 0x91F3, 0x6FEF, 0x91F4, 0x7422, - 0x91F5, 0x8A17, 0x91F6, 0x9438, 0x91F7, 0x6FC1, 0x91F8, 0x8AFE, - 0x91F9, 0x8338, 0x91FA, 0x51E7, 0x91FB, 0x86F8, 0x91FC, 0x53EA, - 0x9240, 0x53E9, 0x9241, 0x4F46, 0x9242, 0x9054, 0x9243, 0x8FB0, - 0x9244, 0x596A, 0x9245, 0x8131, 0x9246, 0x5DFD, 0x9247, 0x7AEA, - 0x9248, 0x8FBF, 0x9249, 0x68DA, 0x924A, 0x8C37, 0x924B, 0x72F8, - 0x924C, 0x9C48, 0x924D, 0x6A3D, 0x924E, 0x8AB0, 0x924F, 0x4E39, - 0x9250, 0x5358, 0x9251, 0x5606, 0x9252, 0x5766, 0x9253, 0x62C5, - 0x9254, 0x63A2, 0x9255, 0x65E6, 0x9256, 0x6B4E, 0x9257, 0x6DE1, - 0x9258, 0x6E5B, 0x9259, 0x70AD, 0x925A, 0x77ED, 0x925B, 0x7AEF, - 0x925C, 0x7BAA, 0x925D, 0x7DBB, 0x925E, 0x803D, 0x925F, 0x80C6, - 0x9260, 0x86CB, 0x9261, 0x8A95, 0x9262, 0x935B, 0x9263, 0x56E3, - 0x9264, 0x58C7, 0x9265, 0x5F3E, 0x9266, 0x65AD, 0x9267, 0x6696, - 0x9268, 0x6A80, 0x9269, 0x6BB5, 0x926A, 0x7537, 0x926B, 0x8AC7, - 0x926C, 0x5024, 0x926D, 0x77E5, 0x926E, 0x5730, 0x926F, 0x5F1B, - 0x9270, 0x6065, 0x9271, 0x667A, 0x9272, 0x6C60, 0x9273, 0x75F4, - 0x9274, 0x7A1A, 0x9275, 0x7F6E, 0x9276, 0x81F4, 0x9277, 0x8718, - 0x9278, 0x9045, 0x9279, 0x99B3, 0x927A, 0x7BC9, 0x927B, 0x755C, - 0x927C, 0x7AF9, 0x927D, 0x7B51, 0x927E, 0x84C4, 0x9280, 0x9010, - 0x9281, 0x79E9, 0x9282, 0x7A92, 0x9283, 0x8336, 0x9284, 0x5AE1, - 0x9285, 0x7740, 0x9286, 0x4E2D, 0x9287, 0x4EF2, 0x9288, 0x5B99, - 0x9289, 0x5FE0, 0x928A, 0x62BD, 0x928B, 0x663C, 0x928C, 0x67F1, - 0x928D, 0x6CE8, 0x928E, 0x866B, 0x928F, 0x8877, 0x9290, 0x8A3B, - 0x9291, 0x914E, 0x9292, 0x92F3, 0x9293, 0x99D0, 0x9294, 0x6A17, - 0x9295, 0x7026, 0x9296, 0x732A, 0x9297, 0x82E7, 0x9298, 0x8457, - 0x9299, 0x8CAF, 0x929A, 0x4E01, 0x929B, 0x5146, 0x929C, 0x51CB, - 0x929D, 0x558B, 0x929E, 0x5BF5, 0x929F, 0x5E16, 0x92A0, 0x5E33, - 0x92A1, 0x5E81, 0x92A2, 0x5F14, 0x92A3, 0x5F35, 0x92A4, 0x5F6B, - 0x92A5, 0x5FB4, 0x92A6, 0x61F2, 0x92A7, 0x6311, 0x92A8, 0x66A2, - 0x92A9, 0x671D, 0x92AA, 0x6F6E, 0x92AB, 0x7252, 0x92AC, 0x753A, - 0x92AD, 0x773A, 0x92AE, 0x8074, 0x92AF, 0x8139, 0x92B0, 0x8178, - 0x92B1, 0x8776, 0x92B2, 0x8ABF, 0x92B3, 0x8ADC, 0x92B4, 0x8D85, - 0x92B5, 0x8DF3, 0x92B6, 0x929A, 0x92B7, 0x9577, 0x92B8, 0x9802, - 0x92B9, 0x9CE5, 0x92BA, 0x52C5, 0x92BB, 0x6357, 0x92BC, 0x76F4, - 0x92BD, 0x6715, 0x92BE, 0x6C88, 0x92BF, 0x73CD, 0x92C0, 0x8CC3, - 0x92C1, 0x93AE, 0x92C2, 0x9673, 0x92C3, 0x6D25, 0x92C4, 0x589C, - 0x92C5, 0x690E, 0x92C6, 0x69CC, 0x92C7, 0x8FFD, 0x92C8, 0x939A, - 0x92C9, 0x75DB, 0x92CA, 0x901A, 0x92CB, 0x585A, 0x92CC, 0x6802, - 0x92CD, 0x63B4, 0x92CE, 0x69FB, 0x92CF, 0x4F43, 0x92D0, 0x6F2C, - 0x92D1, 0x67D8, 0x92D2, 0x8FBB, 0x92D3, 0x8526, 0x92D4, 0x7DB4, - 0x92D5, 0x9354, 0x92D6, 0x693F, 0x92D7, 0x6F70, 0x92D8, 0x576A, - 0x92D9, 0x58F7, 0x92DA, 0x5B2C, 0x92DB, 0x7D2C, 0x92DC, 0x722A, - 0x92DD, 0x540A, 0x92DE, 0x91E3, 0x92DF, 0x9DB4, 0x92E0, 0x4EAD, - 0x92E1, 0x4F4E, 0x92E2, 0x505C, 0x92E3, 0x5075, 0x92E4, 0x5243, - 0x92E5, 0x8C9E, 0x92E6, 0x5448, 0x92E7, 0x5824, 0x92E8, 0x5B9A, - 0x92E9, 0x5E1D, 0x92EA, 0x5E95, 0x92EB, 0x5EAD, 0x92EC, 0x5EF7, - 0x92ED, 0x5F1F, 0x92EE, 0x608C, 0x92EF, 0x62B5, 0x92F0, 0x633A, - 0x92F1, 0x63D0, 0x92F2, 0x68AF, 0x92F3, 0x6C40, 0x92F4, 0x7887, - 0x92F5, 0x798E, 0x92F6, 0x7A0B, 0x92F7, 0x7DE0, 0x92F8, 0x8247, - 0x92F9, 0x8A02, 0x92FA, 0x8AE6, 0x92FB, 0x8E44, 0x92FC, 0x9013, - 0x9340, 0x90B8, 0x9341, 0x912D, 0x9342, 0x91D8, 0x9343, 0x9F0E, - 0x9344, 0x6CE5, 0x9345, 0x6458, 0x9346, 0x64E2, 0x9347, 0x6575, - 0x9348, 0x6EF4, 0x9349, 0x7684, 0x934A, 0x7B1B, 0x934B, 0x9069, - 0x934C, 0x93D1, 0x934D, 0x6EBA, 0x934E, 0x54F2, 0x934F, 0x5FB9, - 0x9350, 0x64A4, 0x9351, 0x8F4D, 0x9352, 0x8FED, 0x9353, 0x9244, - 0x9354, 0x5178, 0x9355, 0x586B, 0x9356, 0x5929, 0x9357, 0x5C55, - 0x9358, 0x5E97, 0x9359, 0x6DFB, 0x935A, 0x7E8F, 0x935B, 0x751C, - 0x935C, 0x8CBC, 0x935D, 0x8EE2, 0x935E, 0x985B, 0x935F, 0x70B9, - 0x9360, 0x4F1D, 0x9361, 0x6BBF, 0x9362, 0x6FB1, 0x9363, 0x7530, - 0x9364, 0x96FB, 0x9365, 0x514E, 0x9366, 0x5410, 0x9367, 0x5835, - 0x9368, 0x5857, 0x9369, 0x59AC, 0x936A, 0x5C60, 0x936B, 0x5F92, - 0x936C, 0x6597, 0x936D, 0x675C, 0x936E, 0x6E21, 0x936F, 0x767B, - 0x9370, 0x83DF, 0x9371, 0x8CED, 0x9372, 0x9014, 0x9373, 0x90FD, - 0x9374, 0x934D, 0x9375, 0x7825, 0x9376, 0x783A, 0x9377, 0x52AA, - 0x9378, 0x5EA6, 0x9379, 0x571F, 0x937A, 0x5974, 0x937B, 0x6012, - 0x937C, 0x5012, 0x937D, 0x515A, 0x937E, 0x51AC, 0x9380, 0x51CD, - 0x9381, 0x5200, 0x9382, 0x5510, 0x9383, 0x5854, 0x9384, 0x5858, - 0x9385, 0x5957, 0x9386, 0x5B95, 0x9387, 0x5CF6, 0x9388, 0x5D8B, - 0x9389, 0x60BC, 0x938A, 0x6295, 0x938B, 0x642D, 0x938C, 0x6771, - 0x938D, 0x6843, 0x938E, 0x68BC, 0x938F, 0x68DF, 0x9390, 0x76D7, - 0x9391, 0x6DD8, 0x9392, 0x6E6F, 0x9393, 0x6D9B, 0x9394, 0x706F, - 0x9395, 0x71C8, 0x9396, 0x5F53, 0x9397, 0x75D8, 0x9398, 0x7977, - 0x9399, 0x7B49, 0x939A, 0x7B54, 0x939B, 0x7B52, 0x939C, 0x7CD6, - 0x939D, 0x7D71, 0x939E, 0x5230, 0x939F, 0x8463, 0x93A0, 0x8569, - 0x93A1, 0x85E4, 0x93A2, 0x8A0E, 0x93A3, 0x8B04, 0x93A4, 0x8C46, - 0x93A5, 0x8E0F, 0x93A6, 0x9003, 0x93A7, 0x900F, 0x93A8, 0x9419, - 0x93A9, 0x9676, 0x93AA, 0x982D, 0x93AB, 0x9A30, 0x93AC, 0x95D8, - 0x93AD, 0x50CD, 0x93AE, 0x52D5, 0x93AF, 0x540C, 0x93B0, 0x5802, - 0x93B1, 0x5C0E, 0x93B2, 0x61A7, 0x93B3, 0x649E, 0x93B4, 0x6D1E, - 0x93B5, 0x77B3, 0x93B6, 0x7AE5, 0x93B7, 0x80F4, 0x93B8, 0x8404, - 0x93B9, 0x9053, 0x93BA, 0x9285, 0x93BB, 0x5CE0, 0x93BC, 0x9D07, - 0x93BD, 0x533F, 0x93BE, 0x5F97, 0x93BF, 0x5FB3, 0x93C0, 0x6D9C, - 0x93C1, 0x7279, 0x93C2, 0x7763, 0x93C3, 0x79BF, 0x93C4, 0x7BE4, - 0x93C5, 0x6BD2, 0x93C6, 0x72EC, 0x93C7, 0x8AAD, 0x93C8, 0x6803, - 0x93C9, 0x6A61, 0x93CA, 0x51F8, 0x93CB, 0x7A81, 0x93CC, 0x6934, - 0x93CD, 0x5C4A, 0x93CE, 0x9CF6, 0x93CF, 0x82EB, 0x93D0, 0x5BC5, - 0x93D1, 0x9149, 0x93D2, 0x701E, 0x93D3, 0x5678, 0x93D4, 0x5C6F, - 0x93D5, 0x60C7, 0x93D6, 0x6566, 0x93D7, 0x6C8C, 0x93D8, 0x8C5A, - 0x93D9, 0x9041, 0x93DA, 0x9813, 0x93DB, 0x5451, 0x93DC, 0x66C7, - 0x93DD, 0x920D, 0x93DE, 0x5948, 0x93DF, 0x90A3, 0x93E0, 0x5185, - 0x93E1, 0x4E4D, 0x93E2, 0x51EA, 0x93E3, 0x8599, 0x93E4, 0x8B0E, - 0x93E5, 0x7058, 0x93E6, 0x637A, 0x93E7, 0x934B, 0x93E8, 0x6962, - 0x93E9, 0x99B4, 0x93EA, 0x7E04, 0x93EB, 0x7577, 0x93EC, 0x5357, - 0x93ED, 0x6960, 0x93EE, 0x8EDF, 0x93EF, 0x96E3, 0x93F0, 0x6C5D, - 0x93F1, 0x4E8C, 0x93F2, 0x5C3C, 0x93F3, 0x5F10, 0x93F4, 0x8FE9, - 0x93F5, 0x5302, 0x93F6, 0x8CD1, 0x93F7, 0x8089, 0x93F8, 0x8679, - 0x93F9, 0x5EFF, 0x93FA, 0x65E5, 0x93FB, 0x4E73, 0x93FC, 0x5165, - 0x9440, 0x5982, 0x9441, 0x5C3F, 0x9442, 0x97EE, 0x9443, 0x4EFB, - 0x9444, 0x598A, 0x9445, 0x5FCD, 0x9446, 0x8A8D, 0x9447, 0x6FE1, - 0x9448, 0x79B0, 0x9449, 0x7962, 0x944A, 0x5BE7, 0x944B, 0x8471, - 0x944C, 0x732B, 0x944D, 0x71B1, 0x944E, 0x5E74, 0x944F, 0x5FF5, - 0x9450, 0x637B, 0x9451, 0x649A, 0x9452, 0x71C3, 0x9453, 0x7C98, - 0x9454, 0x4E43, 0x9455, 0x5EFC, 0x9456, 0x4E4B, 0x9457, 0x57DC, - 0x9458, 0x56A2, 0x9459, 0x60A9, 0x945A, 0x6FC3, 0x945B, 0x7D0D, - 0x945C, 0x80FD, 0x945D, 0x8133, 0x945E, 0x81BF, 0x945F, 0x8FB2, - 0x9460, 0x8997, 0x9461, 0x86A4, 0x9462, 0x5DF4, 0x9463, 0x628A, - 0x9464, 0x64AD, 0x9465, 0x8987, 0x9466, 0x6777, 0x9467, 0x6CE2, - 0x9468, 0x6D3E, 0x9469, 0x7436, 0x946A, 0x7834, 0x946B, 0x5A46, - 0x946C, 0x7F75, 0x946D, 0x82AD, 0x946E, 0x99AC, 0x946F, 0x4FF3, - 0x9470, 0x5EC3, 0x9471, 0x62DD, 0x9472, 0x6392, 0x9473, 0x6557, - 0x9474, 0x676F, 0x9475, 0x76C3, 0x9476, 0x724C, 0x9477, 0x80CC, - 0x9478, 0x80BA, 0x9479, 0x8F29, 0x947A, 0x914D, 0x947B, 0x500D, - 0x947C, 0x57F9, 0x947D, 0x5A92, 0x947E, 0x6885, 0x9480, 0x6973, - 0x9481, 0x7164, 0x9482, 0x72FD, 0x9483, 0x8CB7, 0x9484, 0x58F2, - 0x9485, 0x8CE0, 0x9486, 0x966A, 0x9487, 0x9019, 0x9488, 0x877F, - 0x9489, 0x79E4, 0x948A, 0x77E7, 0x948B, 0x8429, 0x948C, 0x4F2F, - 0x948D, 0x5265, 0x948E, 0x535A, 0x948F, 0x62CD, 0x9490, 0x67CF, - 0x9491, 0x6CCA, 0x9492, 0x767D, 0x9493, 0x7B94, 0x9494, 0x7C95, - 0x9495, 0x8236, 0x9496, 0x8584, 0x9497, 0x8FEB, 0x9498, 0x66DD, - 0x9499, 0x6F20, 0x949A, 0x7206, 0x949B, 0x7E1B, 0x949C, 0x83AB, - 0x949D, 0x99C1, 0x949E, 0x9EA6, 0x949F, 0x51FD, 0x94A0, 0x7BB1, - 0x94A1, 0x7872, 0x94A2, 0x7BB8, 0x94A3, 0x8087, 0x94A4, 0x7B48, - 0x94A5, 0x6AE8, 0x94A6, 0x5E61, 0x94A7, 0x808C, 0x94A8, 0x7551, - 0x94A9, 0x7560, 0x94AA, 0x516B, 0x94AB, 0x9262, 0x94AC, 0x6E8C, - 0x94AD, 0x767A, 0x94AE, 0x9197, 0x94AF, 0x9AEA, 0x94B0, 0x4F10, - 0x94B1, 0x7F70, 0x94B2, 0x629C, 0x94B3, 0x7B4F, 0x94B4, 0x95A5, - 0x94B5, 0x9CE9, 0x94B6, 0x567A, 0x94B7, 0x5859, 0x94B8, 0x86E4, - 0x94B9, 0x96BC, 0x94BA, 0x4F34, 0x94BB, 0x5224, 0x94BC, 0x534A, - 0x94BD, 0x53CD, 0x94BE, 0x53DB, 0x94BF, 0x5E06, 0x94C0, 0x642C, - 0x94C1, 0x6591, 0x94C2, 0x677F, 0x94C3, 0x6C3E, 0x94C4, 0x6C4E, - 0x94C5, 0x7248, 0x94C6, 0x72AF, 0x94C7, 0x73ED, 0x94C8, 0x7554, - 0x94C9, 0x7E41, 0x94CA, 0x822C, 0x94CB, 0x85E9, 0x94CC, 0x8CA9, - 0x94CD, 0x7BC4, 0x94CE, 0x91C6, 0x94CF, 0x7169, 0x94D0, 0x9812, - 0x94D1, 0x98EF, 0x94D2, 0x633D, 0x94D3, 0x6669, 0x94D4, 0x756A, - 0x94D5, 0x76E4, 0x94D6, 0x78D0, 0x94D7, 0x8543, 0x94D8, 0x86EE, - 0x94D9, 0x532A, 0x94DA, 0x5351, 0x94DB, 0x5426, 0x94DC, 0x5983, - 0x94DD, 0x5E87, 0x94DE, 0x5F7C, 0x94DF, 0x60B2, 0x94E0, 0x6249, - 0x94E1, 0x6279, 0x94E2, 0x62AB, 0x94E3, 0x6590, 0x94E4, 0x6BD4, - 0x94E5, 0x6CCC, 0x94E6, 0x75B2, 0x94E7, 0x76AE, 0x94E8, 0x7891, - 0x94E9, 0x79D8, 0x94EA, 0x7DCB, 0x94EB, 0x7F77, 0x94EC, 0x80A5, - 0x94ED, 0x88AB, 0x94EE, 0x8AB9, 0x94EF, 0x8CBB, 0x94F0, 0x907F, - 0x94F1, 0x975E, 0x94F2, 0x98DB, 0x94F3, 0x6A0B, 0x94F4, 0x7C38, - 0x94F5, 0x5099, 0x94F6, 0x5C3E, 0x94F7, 0x5FAE, 0x94F8, 0x6787, - 0x94F9, 0x6BD8, 0x94FA, 0x7435, 0x94FB, 0x7709, 0x94FC, 0x7F8E, - 0x9540, 0x9F3B, 0x9541, 0x67CA, 0x9542, 0x7A17, 0x9543, 0x5339, - 0x9544, 0x758B, 0x9545, 0x9AED, 0x9546, 0x5F66, 0x9547, 0x819D, - 0x9548, 0x83F1, 0x9549, 0x8098, 0x954A, 0x5F3C, 0x954B, 0x5FC5, - 0x954C, 0x7562, 0x954D, 0x7B46, 0x954E, 0x903C, 0x954F, 0x6867, - 0x9550, 0x59EB, 0x9551, 0x5A9B, 0x9552, 0x7D10, 0x9553, 0x767E, - 0x9554, 0x8B2C, 0x9555, 0x4FF5, 0x9556, 0x5F6A, 0x9557, 0x6A19, - 0x9558, 0x6C37, 0x9559, 0x6F02, 0x955A, 0x74E2, 0x955B, 0x7968, - 0x955C, 0x8868, 0x955D, 0x8A55, 0x955E, 0x8C79, 0x955F, 0x5EDF, - 0x9560, 0x63CF, 0x9561, 0x75C5, 0x9562, 0x79D2, 0x9563, 0x82D7, - 0x9564, 0x9328, 0x9565, 0x92F2, 0x9566, 0x849C, 0x9567, 0x86ED, - 0x9568, 0x9C2D, 0x9569, 0x54C1, 0x956A, 0x5F6C, 0x956B, 0x658C, - 0x956C, 0x6D5C, 0x956D, 0x7015, 0x956E, 0x8CA7, 0x956F, 0x8CD3, - 0x9570, 0x983B, 0x9571, 0x654F, 0x9572, 0x74F6, 0x9573, 0x4E0D, - 0x9574, 0x4ED8, 0x9575, 0x57E0, 0x9576, 0x592B, 0x9577, 0x5A66, - 0x9578, 0x5BCC, 0x9579, 0x51A8, 0x957A, 0x5E03, 0x957B, 0x5E9C, - 0x957C, 0x6016, 0x957D, 0x6276, 0x957E, 0x6577, 0x9580, 0x65A7, - 0x9581, 0x666E, 0x9582, 0x6D6E, 0x9583, 0x7236, 0x9584, 0x7B26, - 0x9585, 0x8150, 0x9586, 0x819A, 0x9587, 0x8299, 0x9588, 0x8B5C, - 0x9589, 0x8CA0, 0x958A, 0x8CE6, 0x958B, 0x8D74, 0x958C, 0x961C, - 0x958D, 0x9644, 0x958E, 0x4FAE, 0x958F, 0x64AB, 0x9590, 0x6B66, - 0x9591, 0x821E, 0x9592, 0x8461, 0x9593, 0x856A, 0x9594, 0x90E8, - 0x9595, 0x5C01, 0x9596, 0x6953, 0x9597, 0x98A8, 0x9598, 0x847A, - 0x9599, 0x8557, 0x959A, 0x4F0F, 0x959B, 0x526F, 0x959C, 0x5FA9, - 0x959D, 0x5E45, 0x959E, 0x670D, 0x959F, 0x798F, 0x95A0, 0x8179, - 0x95A1, 0x8907, 0x95A2, 0x8986, 0x95A3, 0x6DF5, 0x95A4, 0x5F17, - 0x95A5, 0x6255, 0x95A6, 0x6CB8, 0x95A7, 0x4ECF, 0x95A8, 0x7269, - 0x95A9, 0x9B92, 0x95AA, 0x5206, 0x95AB, 0x543B, 0x95AC, 0x5674, - 0x95AD, 0x58B3, 0x95AE, 0x61A4, 0x95AF, 0x626E, 0x95B0, 0x711A, - 0x95B1, 0x596E, 0x95B2, 0x7C89, 0x95B3, 0x7CDE, 0x95B4, 0x7D1B, - 0x95B5, 0x96F0, 0x95B6, 0x6587, 0x95B7, 0x805E, 0x95B8, 0x4E19, - 0x95B9, 0x4F75, 0x95BA, 0x5175, 0x95BB, 0x5840, 0x95BC, 0x5E63, - 0x95BD, 0x5E73, 0x95BE, 0x5F0A, 0x95BF, 0x67C4, 0x95C0, 0x4E26, - 0x95C1, 0x853D, 0x95C2, 0x9589, 0x95C3, 0x965B, 0x95C4, 0x7C73, - 0x95C5, 0x9801, 0x95C6, 0x50FB, 0x95C7, 0x58C1, 0x95C8, 0x7656, - 0x95C9, 0x78A7, 0x95CA, 0x5225, 0x95CB, 0x77A5, 0x95CC, 0x8511, - 0x95CD, 0x7B86, 0x95CE, 0x504F, 0x95CF, 0x5909, 0x95D0, 0x7247, - 0x95D1, 0x7BC7, 0x95D2, 0x7DE8, 0x95D3, 0x8FBA, 0x95D4, 0x8FD4, - 0x95D5, 0x904D, 0x95D6, 0x4FBF, 0x95D7, 0x52C9, 0x95D8, 0x5A29, - 0x95D9, 0x5F01, 0x95DA, 0x97AD, 0x95DB, 0x4FDD, 0x95DC, 0x8217, - 0x95DD, 0x92EA, 0x95DE, 0x5703, 0x95DF, 0x6355, 0x95E0, 0x6B69, - 0x95E1, 0x752B, 0x95E2, 0x88DC, 0x95E3, 0x8F14, 0x95E4, 0x7A42, - 0x95E5, 0x52DF, 0x95E6, 0x5893, 0x95E7, 0x6155, 0x95E8, 0x620A, - 0x95E9, 0x66AE, 0x95EA, 0x6BCD, 0x95EB, 0x7C3F, 0x95EC, 0x83E9, - 0x95ED, 0x5023, 0x95EE, 0x4FF8, 0x95EF, 0x5305, 0x95F0, 0x5446, - 0x95F1, 0x5831, 0x95F2, 0x5949, 0x95F3, 0x5B9D, 0x95F4, 0x5CF0, - 0x95F5, 0x5CEF, 0x95F6, 0x5D29, 0x95F7, 0x5E96, 0x95F8, 0x62B1, - 0x95F9, 0x6367, 0x95FA, 0x653E, 0x95FB, 0x65B9, 0x95FC, 0x670B, - 0x9640, 0x6CD5, 0x9641, 0x6CE1, 0x9642, 0x70F9, 0x9643, 0x7832, - 0x9644, 0x7E2B, 0x9645, 0x80DE, 0x9646, 0x82B3, 0x9647, 0x840C, - 0x9648, 0x84EC, 0x9649, 0x8702, 0x964A, 0x8912, 0x964B, 0x8A2A, - 0x964C, 0x8C4A, 0x964D, 0x90A6, 0x964E, 0x92D2, 0x964F, 0x98FD, - 0x9650, 0x9CF3, 0x9651, 0x9D6C, 0x9652, 0x4E4F, 0x9653, 0x4EA1, - 0x9654, 0x508D, 0x9655, 0x5256, 0x9656, 0x574A, 0x9657, 0x59A8, - 0x9658, 0x5E3D, 0x9659, 0x5FD8, 0x965A, 0x5FD9, 0x965B, 0x623F, - 0x965C, 0x66B4, 0x965D, 0x671B, 0x965E, 0x67D0, 0x965F, 0x68D2, - 0x9660, 0x5192, 0x9661, 0x7D21, 0x9662, 0x80AA, 0x9663, 0x81A8, - 0x9664, 0x8B00, 0x9665, 0x8C8C, 0x9666, 0x8CBF, 0x9667, 0x927E, - 0x9668, 0x9632, 0x9669, 0x5420, 0x966A, 0x982C, 0x966B, 0x5317, - 0x966C, 0x50D5, 0x966D, 0x535C, 0x966E, 0x58A8, 0x966F, 0x64B2, - 0x9670, 0x6734, 0x9671, 0x7267, 0x9672, 0x7766, 0x9673, 0x7A46, - 0x9674, 0x91E6, 0x9675, 0x52C3, 0x9676, 0x6CA1, 0x9677, 0x6B86, - 0x9678, 0x5800, 0x9679, 0x5E4C, 0x967A, 0x5954, 0x967B, 0x672C, - 0x967C, 0x7FFB, 0x967D, 0x51E1, 0x967E, 0x76C6, 0x9680, 0x6469, - 0x9681, 0x78E8, 0x9682, 0x9B54, 0x9683, 0x9EBB, 0x9684, 0x57CB, - 0x9685, 0x59B9, 0x9686, 0x6627, 0x9687, 0x679A, 0x9688, 0x6BCE, - 0x9689, 0x54E9, 0x968A, 0x69D9, 0x968B, 0x5E55, 0x968C, 0x819C, - 0x968D, 0x6795, 0x968E, 0x9BAA, 0x968F, 0x67FE, 0x9690, 0x9C52, - 0x9691, 0x685D, 0x9692, 0x4EA6, 0x9693, 0x4FE3, 0x9694, 0x53C8, - 0x9695, 0x62B9, 0x9696, 0x672B, 0x9697, 0x6CAB, 0x9698, 0x8FC4, - 0x9699, 0x4FAD, 0x969A, 0x7E6D, 0x969B, 0x9EBF, 0x969C, 0x4E07, - 0x969D, 0x6162, 0x969E, 0x6E80, 0x969F, 0x6F2B, 0x96A0, 0x8513, - 0x96A1, 0x5473, 0x96A2, 0x672A, 0x96A3, 0x9B45, 0x96A4, 0x5DF3, - 0x96A5, 0x7B95, 0x96A6, 0x5CAC, 0x96A7, 0x5BC6, 0x96A8, 0x871C, - 0x96A9, 0x6E4A, 0x96AA, 0x84D1, 0x96AB, 0x7A14, 0x96AC, 0x8108, - 0x96AD, 0x5999, 0x96AE, 0x7C8D, 0x96AF, 0x6C11, 0x96B0, 0x7720, - 0x96B1, 0x52D9, 0x96B2, 0x5922, 0x96B3, 0x7121, 0x96B4, 0x725F, - 0x96B5, 0x77DB, 0x96B6, 0x9727, 0x96B7, 0x9D61, 0x96B8, 0x690B, - 0x96B9, 0x5A7F, 0x96BA, 0x5A18, 0x96BB, 0x51A5, 0x96BC, 0x540D, - 0x96BD, 0x547D, 0x96BE, 0x660E, 0x96BF, 0x76DF, 0x96C0, 0x8FF7, - 0x96C1, 0x9298, 0x96C2, 0x9CF4, 0x96C3, 0x59EA, 0x96C4, 0x725D, - 0x96C5, 0x6EC5, 0x96C6, 0x514D, 0x96C7, 0x68C9, 0x96C8, 0x7DBF, - 0x96C9, 0x7DEC, 0x96CA, 0x9762, 0x96CB, 0x9EBA, 0x96CC, 0x6478, - 0x96CD, 0x6A21, 0x96CE, 0x8302, 0x96CF, 0x5984, 0x96D0, 0x5B5F, - 0x96D1, 0x6BDB, 0x96D2, 0x731B, 0x96D3, 0x76F2, 0x96D4, 0x7DB2, - 0x96D5, 0x8017, 0x96D6, 0x8499, 0x96D7, 0x5132, 0x96D8, 0x6728, - 0x96D9, 0x9ED9, 0x96DA, 0x76EE, 0x96DB, 0x6762, 0x96DC, 0x52FF, - 0x96DD, 0x9905, 0x96DE, 0x5C24, 0x96DF, 0x623B, 0x96E0, 0x7C7E, - 0x96E1, 0x8CB0, 0x96E2, 0x554F, 0x96E3, 0x60B6, 0x96E4, 0x7D0B, - 0x96E5, 0x9580, 0x96E6, 0x5301, 0x96E7, 0x4E5F, 0x96E8, 0x51B6, - 0x96E9, 0x591C, 0x96EA, 0x723A, 0x96EB, 0x8036, 0x96EC, 0x91CE, - 0x96ED, 0x5F25, 0x96EE, 0x77E2, 0x96EF, 0x5384, 0x96F0, 0x5F79, - 0x96F1, 0x7D04, 0x96F2, 0x85AC, 0x96F3, 0x8A33, 0x96F4, 0x8E8D, - 0x96F5, 0x9756, 0x96F6, 0x67F3, 0x96F7, 0x85AE, 0x96F8, 0x9453, - 0x96F9, 0x6109, 0x96FA, 0x6108, 0x96FB, 0x6CB9, 0x96FC, 0x7652, - 0x9740, 0x8AED, 0x9741, 0x8F38, 0x9742, 0x552F, 0x9743, 0x4F51, - 0x9744, 0x512A, 0x9745, 0x52C7, 0x9746, 0x53CB, 0x9747, 0x5BA5, - 0x9748, 0x5E7D, 0x9749, 0x60A0, 0x974A, 0x6182, 0x974B, 0x63D6, - 0x974C, 0x6709, 0x974D, 0x67DA, 0x974E, 0x6E67, 0x974F, 0x6D8C, - 0x9750, 0x7336, 0x9751, 0x7337, 0x9752, 0x7531, 0x9753, 0x7950, - 0x9754, 0x88D5, 0x9755, 0x8A98, 0x9756, 0x904A, 0x9757, 0x9091, - 0x9758, 0x90F5, 0x9759, 0x96C4, 0x975A, 0x878D, 0x975B, 0x5915, - 0x975C, 0x4E88, 0x975D, 0x4F59, 0x975E, 0x4E0E, 0x975F, 0x8A89, - 0x9760, 0x8F3F, 0x9761, 0x9810, 0x9762, 0x50AD, 0x9763, 0x5E7C, - 0x9764, 0x5996, 0x9765, 0x5BB9, 0x9766, 0x5EB8, 0x9767, 0x63DA, - 0x9768, 0x63FA, 0x9769, 0x64C1, 0x976A, 0x66DC, 0x976B, 0x694A, - 0x976C, 0x69D8, 0x976D, 0x6D0B, 0x976E, 0x6EB6, 0x976F, 0x7194, - 0x9770, 0x7528, 0x9771, 0x7AAF, 0x9772, 0x7F8A, 0x9773, 0x8000, - 0x9774, 0x8449, 0x9775, 0x84C9, 0x9776, 0x8981, 0x9777, 0x8B21, - 0x9778, 0x8E0A, 0x9779, 0x9065, 0x977A, 0x967D, 0x977B, 0x990A, - 0x977C, 0x617E, 0x977D, 0x6291, 0x977E, 0x6B32, 0x9780, 0x6C83, - 0x9781, 0x6D74, 0x9782, 0x7FCC, 0x9783, 0x7FFC, 0x9784, 0x6DC0, - 0x9785, 0x7F85, 0x9786, 0x87BA, 0x9787, 0x88F8, 0x9788, 0x6765, - 0x9789, 0x83B1, 0x978A, 0x983C, 0x978B, 0x96F7, 0x978C, 0x6D1B, - 0x978D, 0x7D61, 0x978E, 0x843D, 0x978F, 0x916A, 0x9790, 0x4E71, - 0x9791, 0x5375, 0x9792, 0x5D50, 0x9793, 0x6B04, 0x9794, 0x6FEB, - 0x9795, 0x85CD, 0x9796, 0x862D, 0x9797, 0x89A7, 0x9798, 0x5229, - 0x9799, 0x540F, 0x979A, 0x5C65, 0x979B, 0x674E, 0x979C, 0x68A8, - 0x979D, 0x7406, 0x979E, 0x7483, 0x979F, 0x75E2, 0x97A0, 0x88CF, - 0x97A1, 0x88E1, 0x97A2, 0x91CC, 0x97A3, 0x96E2, 0x97A4, 0x9678, - 0x97A5, 0x5F8B, 0x97A6, 0x7387, 0x97A7, 0x7ACB, 0x97A8, 0x844E, - 0x97A9, 0x63A0, 0x97AA, 0x7565, 0x97AB, 0x5289, 0x97AC, 0x6D41, - 0x97AD, 0x6E9C, 0x97AE, 0x7409, 0x97AF, 0x7559, 0x97B0, 0x786B, - 0x97B1, 0x7C92, 0x97B2, 0x9686, 0x97B3, 0x7ADC, 0x97B4, 0x9F8D, - 0x97B5, 0x4FB6, 0x97B6, 0x616E, 0x97B7, 0x65C5, 0x97B8, 0x865C, - 0x97B9, 0x4E86, 0x97BA, 0x4EAE, 0x97BB, 0x50DA, 0x97BC, 0x4E21, - 0x97BD, 0x51CC, 0x97BE, 0x5BEE, 0x97BF, 0x6599, 0x97C0, 0x6881, - 0x97C1, 0x6DBC, 0x97C2, 0x731F, 0x97C3, 0x7642, 0x97C4, 0x77AD, - 0x97C5, 0x7A1C, 0x97C6, 0x7CE7, 0x97C7, 0x826F, 0x97C8, 0x8AD2, - 0x97C9, 0x907C, 0x97CA, 0x91CF, 0x97CB, 0x9675, 0x97CC, 0x9818, - 0x97CD, 0x529B, 0x97CE, 0x7DD1, 0x97CF, 0x502B, 0x97D0, 0x5398, - 0x97D1, 0x6797, 0x97D2, 0x6DCB, 0x97D3, 0x71D0, 0x97D4, 0x7433, - 0x97D5, 0x81E8, 0x97D6, 0x8F2A, 0x97D7, 0x96A3, 0x97D8, 0x9C57, - 0x97D9, 0x9E9F, 0x97DA, 0x7460, 0x97DB, 0x5841, 0x97DC, 0x6D99, - 0x97DD, 0x7D2F, 0x97DE, 0x985E, 0x97DF, 0x4EE4, 0x97E0, 0x4F36, - 0x97E1, 0x4F8B, 0x97E2, 0x51B7, 0x97E3, 0x52B1, 0x97E4, 0x5DBA, - 0x97E5, 0x601C, 0x97E6, 0x73B2, 0x97E7, 0x793C, 0x97E8, 0x82D3, - 0x97E9, 0x9234, 0x97EA, 0x96B7, 0x97EB, 0x96F6, 0x97EC, 0x970A, - 0x97ED, 0x9E97, 0x97EE, 0x9F62, 0x97EF, 0x66A6, 0x97F0, 0x6B74, - 0x97F1, 0x5217, 0x97F2, 0x52A3, 0x97F3, 0x70C8, 0x97F4, 0x88C2, - 0x97F5, 0x5EC9, 0x97F6, 0x604B, 0x97F7, 0x6190, 0x97F8, 0x6F23, - 0x97F9, 0x7149, 0x97FA, 0x7C3E, 0x97FB, 0x7DF4, 0x97FC, 0x806F, - 0x9840, 0x84EE, 0x9841, 0x9023, 0x9842, 0x932C, 0x9843, 0x5442, - 0x9844, 0x9B6F, 0x9845, 0x6AD3, 0x9846, 0x7089, 0x9847, 0x8CC2, - 0x9848, 0x8DEF, 0x9849, 0x9732, 0x984A, 0x52B4, 0x984B, 0x5A41, - 0x984C, 0x5ECA, 0x984D, 0x5F04, 0x984E, 0x6717, 0x984F, 0x697C, - 0x9850, 0x6994, 0x9851, 0x6D6A, 0x9852, 0x6F0F, 0x9853, 0x7262, - 0x9854, 0x72FC, 0x9855, 0x7BED, 0x9856, 0x8001, 0x9857, 0x807E, - 0x9858, 0x874B, 0x9859, 0x90CE, 0x985A, 0x516D, 0x985B, 0x9E93, - 0x985C, 0x7984, 0x985D, 0x808B, 0x985E, 0x9332, 0x985F, 0x8AD6, - 0x9860, 0x502D, 0x9861, 0x548C, 0x9862, 0x8A71, 0x9863, 0x6B6A, - 0x9864, 0x8CC4, 0x9865, 0x8107, 0x9866, 0x60D1, 0x9867, 0x67A0, - 0x9868, 0x9DF2, 0x9869, 0x4E99, 0x986A, 0x4E98, 0x986B, 0x9C10, - 0x986C, 0x8A6B, 0x986D, 0x85C1, 0x986E, 0x8568, 0x986F, 0x6900, - 0x9870, 0x6E7E, 0x9871, 0x7897, 0x9872, 0x8155, 0x989F, 0x5F0C, - 0x98A0, 0x4E10, 0x98A1, 0x4E15, 0x98A2, 0x4E2A, 0x98A3, 0x4E31, - 0x98A4, 0x4E36, 0x98A5, 0x4E3C, 0x98A6, 0x4E3F, 0x98A7, 0x4E42, - 0x98A8, 0x4E56, 0x98A9, 0x4E58, 0x98AA, 0x4E82, 0x98AB, 0x4E85, - 0x98AC, 0x8C6B, 0x98AD, 0x4E8A, 0x98AE, 0x8212, 0x98AF, 0x5F0D, - 0x98B0, 0x4E8E, 0x98B1, 0x4E9E, 0x98B2, 0x4E9F, 0x98B3, 0x4EA0, - 0x98B4, 0x4EA2, 0x98B5, 0x4EB0, 0x98B6, 0x4EB3, 0x98B7, 0x4EB6, - 0x98B8, 0x4ECE, 0x98B9, 0x4ECD, 0x98BA, 0x4EC4, 0x98BB, 0x4EC6, - 0x98BC, 0x4EC2, 0x98BD, 0x4ED7, 0x98BE, 0x4EDE, 0x98BF, 0x4EED, - 0x98C0, 0x4EDF, 0x98C1, 0x4EF7, 0x98C2, 0x4F09, 0x98C3, 0x4F5A, - 0x98C4, 0x4F30, 0x98C5, 0x4F5B, 0x98C6, 0x4F5D, 0x98C7, 0x4F57, - 0x98C8, 0x4F47, 0x98C9, 0x4F76, 0x98CA, 0x4F88, 0x98CB, 0x4F8F, - 0x98CC, 0x4F98, 0x98CD, 0x4F7B, 0x98CE, 0x4F69, 0x98CF, 0x4F70, - 0x98D0, 0x4F91, 0x98D1, 0x4F6F, 0x98D2, 0x4F86, 0x98D3, 0x4F96, - 0x98D4, 0x5118, 0x98D5, 0x4FD4, 0x98D6, 0x4FDF, 0x98D7, 0x4FCE, - 0x98D8, 0x4FD8, 0x98D9, 0x4FDB, 0x98DA, 0x4FD1, 0x98DB, 0x4FDA, - 0x98DC, 0x4FD0, 0x98DD, 0x4FE4, 0x98DE, 0x4FE5, 0x98DF, 0x501A, - 0x98E0, 0x5028, 0x98E1, 0x5014, 0x98E2, 0x502A, 0x98E3, 0x5025, - 0x98E4, 0x5005, 0x98E5, 0x4F1C, 0x98E6, 0x4FF6, 0x98E7, 0x5021, - 0x98E8, 0x5029, 0x98E9, 0x502C, 0x98EA, 0x4FFE, 0x98EB, 0x4FEF, - 0x98EC, 0x5011, 0x98ED, 0x5006, 0x98EE, 0x5043, 0x98EF, 0x5047, - 0x98F0, 0x6703, 0x98F1, 0x5055, 0x98F2, 0x5050, 0x98F3, 0x5048, - 0x98F4, 0x505A, 0x98F5, 0x5056, 0x98F6, 0x506C, 0x98F7, 0x5078, - 0x98F8, 0x5080, 0x98F9, 0x509A, 0x98FA, 0x5085, 0x98FB, 0x50B4, - 0x98FC, 0x50B2, 0x9940, 0x50C9, 0x9941, 0x50CA, 0x9942, 0x50B3, - 0x9943, 0x50C2, 0x9944, 0x50D6, 0x9945, 0x50DE, 0x9946, 0x50E5, - 0x9947, 0x50ED, 0x9948, 0x50E3, 0x9949, 0x50EE, 0x994A, 0x50F9, - 0x994B, 0x50F5, 0x994C, 0x5109, 0x994D, 0x5101, 0x994E, 0x5102, - 0x994F, 0x5116, 0x9950, 0x5115, 0x9951, 0x5114, 0x9952, 0x511A, - 0x9953, 0x5121, 0x9954, 0x513A, 0x9955, 0x5137, 0x9956, 0x513C, - 0x9957, 0x513B, 0x9958, 0x513F, 0x9959, 0x5140, 0x995A, 0x5152, - 0x995B, 0x514C, 0x995C, 0x5154, 0x995D, 0x5162, 0x995E, 0x7AF8, - 0x995F, 0x5169, 0x9960, 0x516A, 0x9961, 0x516E, 0x9962, 0x5180, - 0x9963, 0x5182, 0x9964, 0x56D8, 0x9965, 0x518C, 0x9966, 0x5189, - 0x9967, 0x518F, 0x9968, 0x5191, 0x9969, 0x5193, 0x996A, 0x5195, - 0x996B, 0x5196, 0x996C, 0x51A4, 0x996D, 0x51A6, 0x996E, 0x51A2, - 0x996F, 0x51A9, 0x9970, 0x51AA, 0x9971, 0x51AB, 0x9972, 0x51B3, - 0x9973, 0x51B1, 0x9974, 0x51B2, 0x9975, 0x51B0, 0x9976, 0x51B5, - 0x9977, 0x51BD, 0x9978, 0x51C5, 0x9979, 0x51C9, 0x997A, 0x51DB, - 0x997B, 0x51E0, 0x997C, 0x8655, 0x997D, 0x51E9, 0x997E, 0x51ED, - 0x9980, 0x51F0, 0x9981, 0x51F5, 0x9982, 0x51FE, 0x9983, 0x5204, - 0x9984, 0x520B, 0x9985, 0x5214, 0x9986, 0x520E, 0x9987, 0x5227, - 0x9988, 0x522A, 0x9989, 0x522E, 0x998A, 0x5233, 0x998B, 0x5239, - 0x998C, 0x524F, 0x998D, 0x5244, 0x998E, 0x524B, 0x998F, 0x524C, - 0x9990, 0x525E, 0x9991, 0x5254, 0x9992, 0x526A, 0x9993, 0x5274, - 0x9994, 0x5269, 0x9995, 0x5273, 0x9996, 0x527F, 0x9997, 0x527D, - 0x9998, 0x528D, 0x9999, 0x5294, 0x999A, 0x5292, 0x999B, 0x5271, - 0x999C, 0x5288, 0x999D, 0x5291, 0x999E, 0x8FA8, 0x999F, 0x8FA7, - 0x99A0, 0x52AC, 0x99A1, 0x52AD, 0x99A2, 0x52BC, 0x99A3, 0x52B5, - 0x99A4, 0x52C1, 0x99A5, 0x52CD, 0x99A6, 0x52D7, 0x99A7, 0x52DE, - 0x99A8, 0x52E3, 0x99A9, 0x52E6, 0x99AA, 0x98ED, 0x99AB, 0x52E0, - 0x99AC, 0x52F3, 0x99AD, 0x52F5, 0x99AE, 0x52F8, 0x99AF, 0x52F9, - 0x99B0, 0x5306, 0x99B1, 0x5308, 0x99B2, 0x7538, 0x99B3, 0x530D, - 0x99B4, 0x5310, 0x99B5, 0x530F, 0x99B6, 0x5315, 0x99B7, 0x531A, - 0x99B8, 0x5323, 0x99B9, 0x532F, 0x99BA, 0x5331, 0x99BB, 0x5333, - 0x99BC, 0x5338, 0x99BD, 0x5340, 0x99BE, 0x5346, 0x99BF, 0x5345, - 0x99C0, 0x4E17, 0x99C1, 0x5349, 0x99C2, 0x534D, 0x99C3, 0x51D6, - 0x99C4, 0x535E, 0x99C5, 0x5369, 0x99C6, 0x536E, 0x99C7, 0x5918, - 0x99C8, 0x537B, 0x99C9, 0x5377, 0x99CA, 0x5382, 0x99CB, 0x5396, - 0x99CC, 0x53A0, 0x99CD, 0x53A6, 0x99CE, 0x53A5, 0x99CF, 0x53AE, - 0x99D0, 0x53B0, 0x99D1, 0x53B6, 0x99D2, 0x53C3, 0x99D3, 0x7C12, - 0x99D4, 0x96D9, 0x99D5, 0x53DF, 0x99D6, 0x66FC, 0x99D7, 0x71EE, - 0x99D8, 0x53EE, 0x99D9, 0x53E8, 0x99DA, 0x53ED, 0x99DB, 0x53FA, - 0x99DC, 0x5401, 0x99DD, 0x543D, 0x99DE, 0x5440, 0x99DF, 0x542C, - 0x99E0, 0x542D, 0x99E1, 0x543C, 0x99E2, 0x542E, 0x99E3, 0x5436, - 0x99E4, 0x5429, 0x99E5, 0x541D, 0x99E6, 0x544E, 0x99E7, 0x548F, - 0x99E8, 0x5475, 0x99E9, 0x548E, 0x99EA, 0x545F, 0x99EB, 0x5471, - 0x99EC, 0x5477, 0x99ED, 0x5470, 0x99EE, 0x5492, 0x99EF, 0x547B, - 0x99F0, 0x5480, 0x99F1, 0x5476, 0x99F2, 0x5484, 0x99F3, 0x5490, - 0x99F4, 0x5486, 0x99F5, 0x54C7, 0x99F6, 0x54A2, 0x99F7, 0x54B8, - 0x99F8, 0x54A5, 0x99F9, 0x54AC, 0x99FA, 0x54C4, 0x99FB, 0x54C8, - 0x99FC, 0x54A8, 0x9A40, 0x54AB, 0x9A41, 0x54C2, 0x9A42, 0x54A4, - 0x9A43, 0x54BE, 0x9A44, 0x54BC, 0x9A45, 0x54D8, 0x9A46, 0x54E5, - 0x9A47, 0x54E6, 0x9A48, 0x550F, 0x9A49, 0x5514, 0x9A4A, 0x54FD, - 0x9A4B, 0x54EE, 0x9A4C, 0x54ED, 0x9A4D, 0x54FA, 0x9A4E, 0x54E2, - 0x9A4F, 0x5539, 0x9A50, 0x5540, 0x9A51, 0x5563, 0x9A52, 0x554C, - 0x9A53, 0x552E, 0x9A54, 0x555C, 0x9A55, 0x5545, 0x9A56, 0x5556, - 0x9A57, 0x5557, 0x9A58, 0x5538, 0x9A59, 0x5533, 0x9A5A, 0x555D, - 0x9A5B, 0x5599, 0x9A5C, 0x5580, 0x9A5D, 0x54AF, 0x9A5E, 0x558A, - 0x9A5F, 0x559F, 0x9A60, 0x557B, 0x9A61, 0x557E, 0x9A62, 0x5598, - 0x9A63, 0x559E, 0x9A64, 0x55AE, 0x9A65, 0x557C, 0x9A66, 0x5583, - 0x9A67, 0x55A9, 0x9A68, 0x5587, 0x9A69, 0x55A8, 0x9A6A, 0x55DA, - 0x9A6B, 0x55C5, 0x9A6C, 0x55DF, 0x9A6D, 0x55C4, 0x9A6E, 0x55DC, - 0x9A6F, 0x55E4, 0x9A70, 0x55D4, 0x9A71, 0x5614, 0x9A72, 0x55F7, - 0x9A73, 0x5616, 0x9A74, 0x55FE, 0x9A75, 0x55FD, 0x9A76, 0x561B, - 0x9A77, 0x55F9, 0x9A78, 0x564E, 0x9A79, 0x5650, 0x9A7A, 0x71DF, - 0x9A7B, 0x5634, 0x9A7C, 0x5636, 0x9A7D, 0x5632, 0x9A7E, 0x5638, - 0x9A80, 0x566B, 0x9A81, 0x5664, 0x9A82, 0x562F, 0x9A83, 0x566C, - 0x9A84, 0x566A, 0x9A85, 0x5686, 0x9A86, 0x5680, 0x9A87, 0x568A, - 0x9A88, 0x56A0, 0x9A89, 0x5694, 0x9A8A, 0x568F, 0x9A8B, 0x56A5, - 0x9A8C, 0x56AE, 0x9A8D, 0x56B6, 0x9A8E, 0x56B4, 0x9A8F, 0x56C2, - 0x9A90, 0x56BC, 0x9A91, 0x56C1, 0x9A92, 0x56C3, 0x9A93, 0x56C0, - 0x9A94, 0x56C8, 0x9A95, 0x56CE, 0x9A96, 0x56D1, 0x9A97, 0x56D3, - 0x9A98, 0x56D7, 0x9A99, 0x56EE, 0x9A9A, 0x56F9, 0x9A9B, 0x5700, - 0x9A9C, 0x56FF, 0x9A9D, 0x5704, 0x9A9E, 0x5709, 0x9A9F, 0x5708, - 0x9AA0, 0x570B, 0x9AA1, 0x570D, 0x9AA2, 0x5713, 0x9AA3, 0x5718, - 0x9AA4, 0x5716, 0x9AA5, 0x55C7, 0x9AA6, 0x571C, 0x9AA7, 0x5726, - 0x9AA8, 0x5737, 0x9AA9, 0x5738, 0x9AAA, 0x574E, 0x9AAB, 0x573B, - 0x9AAC, 0x5740, 0x9AAD, 0x574F, 0x9AAE, 0x5769, 0x9AAF, 0x57C0, - 0x9AB0, 0x5788, 0x9AB1, 0x5761, 0x9AB2, 0x577F, 0x9AB3, 0x5789, - 0x9AB4, 0x5793, 0x9AB5, 0x57A0, 0x9AB6, 0x57B3, 0x9AB7, 0x57A4, - 0x9AB8, 0x57AA, 0x9AB9, 0x57B0, 0x9ABA, 0x57C3, 0x9ABB, 0x57C6, - 0x9ABC, 0x57D4, 0x9ABD, 0x57D2, 0x9ABE, 0x57D3, 0x9ABF, 0x580A, - 0x9AC0, 0x57D6, 0x9AC1, 0x57E3, 0x9AC2, 0x580B, 0x9AC3, 0x5819, - 0x9AC4, 0x581D, 0x9AC5, 0x5872, 0x9AC6, 0x5821, 0x9AC7, 0x5862, - 0x9AC8, 0x584B, 0x9AC9, 0x5870, 0x9ACA, 0x6BC0, 0x9ACB, 0x5852, - 0x9ACC, 0x583D, 0x9ACD, 0x5879, 0x9ACE, 0x5885, 0x9ACF, 0x58B9, - 0x9AD0, 0x589F, 0x9AD1, 0x58AB, 0x9AD2, 0x58BA, 0x9AD3, 0x58DE, - 0x9AD4, 0x58BB, 0x9AD5, 0x58B8, 0x9AD6, 0x58AE, 0x9AD7, 0x58C5, - 0x9AD8, 0x58D3, 0x9AD9, 0x58D1, 0x9ADA, 0x58D7, 0x9ADB, 0x58D9, - 0x9ADC, 0x58D8, 0x9ADD, 0x58E5, 0x9ADE, 0x58DC, 0x9ADF, 0x58E4, - 0x9AE0, 0x58DF, 0x9AE1, 0x58EF, 0x9AE2, 0x58FA, 0x9AE3, 0x58F9, - 0x9AE4, 0x58FB, 0x9AE5, 0x58FC, 0x9AE6, 0x58FD, 0x9AE7, 0x5902, - 0x9AE8, 0x590A, 0x9AE9, 0x5910, 0x9AEA, 0x591B, 0x9AEB, 0x68A6, - 0x9AEC, 0x5925, 0x9AED, 0x592C, 0x9AEE, 0x592D, 0x9AEF, 0x5932, - 0x9AF0, 0x5938, 0x9AF1, 0x593E, 0x9AF2, 0x7AD2, 0x9AF3, 0x5955, - 0x9AF4, 0x5950, 0x9AF5, 0x594E, 0x9AF6, 0x595A, 0x9AF7, 0x5958, - 0x9AF8, 0x5962, 0x9AF9, 0x5960, 0x9AFA, 0x5967, 0x9AFB, 0x596C, - 0x9AFC, 0x5969, 0x9B40, 0x5978, 0x9B41, 0x5981, 0x9B42, 0x599D, - 0x9B43, 0x4F5E, 0x9B44, 0x4FAB, 0x9B45, 0x59A3, 0x9B46, 0x59B2, - 0x9B47, 0x59C6, 0x9B48, 0x59E8, 0x9B49, 0x59DC, 0x9B4A, 0x598D, - 0x9B4B, 0x59D9, 0x9B4C, 0x59DA, 0x9B4D, 0x5A25, 0x9B4E, 0x5A1F, - 0x9B4F, 0x5A11, 0x9B50, 0x5A1C, 0x9B51, 0x5A09, 0x9B52, 0x5A1A, - 0x9B53, 0x5A40, 0x9B54, 0x5A6C, 0x9B55, 0x5A49, 0x9B56, 0x5A35, - 0x9B57, 0x5A36, 0x9B58, 0x5A62, 0x9B59, 0x5A6A, 0x9B5A, 0x5A9A, - 0x9B5B, 0x5ABC, 0x9B5C, 0x5ABE, 0x9B5D, 0x5ACB, 0x9B5E, 0x5AC2, - 0x9B5F, 0x5ABD, 0x9B60, 0x5AE3, 0x9B61, 0x5AD7, 0x9B62, 0x5AE6, - 0x9B63, 0x5AE9, 0x9B64, 0x5AD6, 0x9B65, 0x5AFA, 0x9B66, 0x5AFB, - 0x9B67, 0x5B0C, 0x9B68, 0x5B0B, 0x9B69, 0x5B16, 0x9B6A, 0x5B32, - 0x9B6B, 0x5AD0, 0x9B6C, 0x5B2A, 0x9B6D, 0x5B36, 0x9B6E, 0x5B3E, - 0x9B6F, 0x5B43, 0x9B70, 0x5B45, 0x9B71, 0x5B40, 0x9B72, 0x5B51, - 0x9B73, 0x5B55, 0x9B74, 0x5B5A, 0x9B75, 0x5B5B, 0x9B76, 0x5B65, - 0x9B77, 0x5B69, 0x9B78, 0x5B70, 0x9B79, 0x5B73, 0x9B7A, 0x5B75, - 0x9B7B, 0x5B78, 0x9B7C, 0x6588, 0x9B7D, 0x5B7A, 0x9B7E, 0x5B80, - 0x9B80, 0x5B83, 0x9B81, 0x5BA6, 0x9B82, 0x5BB8, 0x9B83, 0x5BC3, - 0x9B84, 0x5BC7, 0x9B85, 0x5BC9, 0x9B86, 0x5BD4, 0x9B87, 0x5BD0, - 0x9B88, 0x5BE4, 0x9B89, 0x5BE6, 0x9B8A, 0x5BE2, 0x9B8B, 0x5BDE, - 0x9B8C, 0x5BE5, 0x9B8D, 0x5BEB, 0x9B8E, 0x5BF0, 0x9B8F, 0x5BF6, - 0x9B90, 0x5BF3, 0x9B91, 0x5C05, 0x9B92, 0x5C07, 0x9B93, 0x5C08, - 0x9B94, 0x5C0D, 0x9B95, 0x5C13, 0x9B96, 0x5C20, 0x9B97, 0x5C22, - 0x9B98, 0x5C28, 0x9B99, 0x5C38, 0x9B9A, 0x5C39, 0x9B9B, 0x5C41, - 0x9B9C, 0x5C46, 0x9B9D, 0x5C4E, 0x9B9E, 0x5C53, 0x9B9F, 0x5C50, - 0x9BA0, 0x5C4F, 0x9BA1, 0x5B71, 0x9BA2, 0x5C6C, 0x9BA3, 0x5C6E, - 0x9BA4, 0x4E62, 0x9BA5, 0x5C76, 0x9BA6, 0x5C79, 0x9BA7, 0x5C8C, - 0x9BA8, 0x5C91, 0x9BA9, 0x5C94, 0x9BAA, 0x599B, 0x9BAB, 0x5CAB, - 0x9BAC, 0x5CBB, 0x9BAD, 0x5CB6, 0x9BAE, 0x5CBC, 0x9BAF, 0x5CB7, - 0x9BB0, 0x5CC5, 0x9BB1, 0x5CBE, 0x9BB2, 0x5CC7, 0x9BB3, 0x5CD9, - 0x9BB4, 0x5CE9, 0x9BB5, 0x5CFD, 0x9BB6, 0x5CFA, 0x9BB7, 0x5CED, - 0x9BB8, 0x5D8C, 0x9BB9, 0x5CEA, 0x9BBA, 0x5D0B, 0x9BBB, 0x5D15, - 0x9BBC, 0x5D17, 0x9BBD, 0x5D5C, 0x9BBE, 0x5D1F, 0x9BBF, 0x5D1B, - 0x9BC0, 0x5D11, 0x9BC1, 0x5D14, 0x9BC2, 0x5D22, 0x9BC3, 0x5D1A, - 0x9BC4, 0x5D19, 0x9BC5, 0x5D18, 0x9BC6, 0x5D4C, 0x9BC7, 0x5D52, - 0x9BC8, 0x5D4E, 0x9BC9, 0x5D4B, 0x9BCA, 0x5D6C, 0x9BCB, 0x5D73, - 0x9BCC, 0x5D76, 0x9BCD, 0x5D87, 0x9BCE, 0x5D84, 0x9BCF, 0x5D82, - 0x9BD0, 0x5DA2, 0x9BD1, 0x5D9D, 0x9BD2, 0x5DAC, 0x9BD3, 0x5DAE, - 0x9BD4, 0x5DBD, 0x9BD5, 0x5D90, 0x9BD6, 0x5DB7, 0x9BD7, 0x5DBC, - 0x9BD8, 0x5DC9, 0x9BD9, 0x5DCD, 0x9BDA, 0x5DD3, 0x9BDB, 0x5DD2, - 0x9BDC, 0x5DD6, 0x9BDD, 0x5DDB, 0x9BDE, 0x5DEB, 0x9BDF, 0x5DF2, - 0x9BE0, 0x5DF5, 0x9BE1, 0x5E0B, 0x9BE2, 0x5E1A, 0x9BE3, 0x5E19, - 0x9BE4, 0x5E11, 0x9BE5, 0x5E1B, 0x9BE6, 0x5E36, 0x9BE7, 0x5E37, - 0x9BE8, 0x5E44, 0x9BE9, 0x5E43, 0x9BEA, 0x5E40, 0x9BEB, 0x5E4E, - 0x9BEC, 0x5E57, 0x9BED, 0x5E54, 0x9BEE, 0x5E5F, 0x9BEF, 0x5E62, - 0x9BF0, 0x5E64, 0x9BF1, 0x5E47, 0x9BF2, 0x5E75, 0x9BF3, 0x5E76, - 0x9BF4, 0x5E7A, 0x9BF5, 0x9EBC, 0x9BF6, 0x5E7F, 0x9BF7, 0x5EA0, - 0x9BF8, 0x5EC1, 0x9BF9, 0x5EC2, 0x9BFA, 0x5EC8, 0x9BFB, 0x5ED0, - 0x9BFC, 0x5ECF, 0x9C40, 0x5ED6, 0x9C41, 0x5EE3, 0x9C42, 0x5EDD, - 0x9C43, 0x5EDA, 0x9C44, 0x5EDB, 0x9C45, 0x5EE2, 0x9C46, 0x5EE1, - 0x9C47, 0x5EE8, 0x9C48, 0x5EE9, 0x9C49, 0x5EEC, 0x9C4A, 0x5EF1, - 0x9C4B, 0x5EF3, 0x9C4C, 0x5EF0, 0x9C4D, 0x5EF4, 0x9C4E, 0x5EF8, - 0x9C4F, 0x5EFE, 0x9C50, 0x5F03, 0x9C51, 0x5F09, 0x9C52, 0x5F5D, - 0x9C53, 0x5F5C, 0x9C54, 0x5F0B, 0x9C55, 0x5F11, 0x9C56, 0x5F16, - 0x9C57, 0x5F29, 0x9C58, 0x5F2D, 0x9C59, 0x5F38, 0x9C5A, 0x5F41, - 0x9C5B, 0x5F48, 0x9C5C, 0x5F4C, 0x9C5D, 0x5F4E, 0x9C5E, 0x5F2F, - 0x9C5F, 0x5F51, 0x9C60, 0x5F56, 0x9C61, 0x5F57, 0x9C62, 0x5F59, - 0x9C63, 0x5F61, 0x9C64, 0x5F6D, 0x9C65, 0x5F73, 0x9C66, 0x5F77, - 0x9C67, 0x5F83, 0x9C68, 0x5F82, 0x9C69, 0x5F7F, 0x9C6A, 0x5F8A, - 0x9C6B, 0x5F88, 0x9C6C, 0x5F91, 0x9C6D, 0x5F87, 0x9C6E, 0x5F9E, - 0x9C6F, 0x5F99, 0x9C70, 0x5F98, 0x9C71, 0x5FA0, 0x9C72, 0x5FA8, - 0x9C73, 0x5FAD, 0x9C74, 0x5FBC, 0x9C75, 0x5FD6, 0x9C76, 0x5FFB, - 0x9C77, 0x5FE4, 0x9C78, 0x5FF8, 0x9C79, 0x5FF1, 0x9C7A, 0x5FDD, - 0x9C7B, 0x60B3, 0x9C7C, 0x5FFF, 0x9C7D, 0x6021, 0x9C7E, 0x6060, - 0x9C80, 0x6019, 0x9C81, 0x6010, 0x9C82, 0x6029, 0x9C83, 0x600E, - 0x9C84, 0x6031, 0x9C85, 0x601B, 0x9C86, 0x6015, 0x9C87, 0x602B, - 0x9C88, 0x6026, 0x9C89, 0x600F, 0x9C8A, 0x603A, 0x9C8B, 0x605A, - 0x9C8C, 0x6041, 0x9C8D, 0x606A, 0x9C8E, 0x6077, 0x9C8F, 0x605F, - 0x9C90, 0x604A, 0x9C91, 0x6046, 0x9C92, 0x604D, 0x9C93, 0x6063, - 0x9C94, 0x6043, 0x9C95, 0x6064, 0x9C96, 0x6042, 0x9C97, 0x606C, - 0x9C98, 0x606B, 0x9C99, 0x6059, 0x9C9A, 0x6081, 0x9C9B, 0x608D, - 0x9C9C, 0x60E7, 0x9C9D, 0x6083, 0x9C9E, 0x609A, 0x9C9F, 0x6084, - 0x9CA0, 0x609B, 0x9CA1, 0x6096, 0x9CA2, 0x6097, 0x9CA3, 0x6092, - 0x9CA4, 0x60A7, 0x9CA5, 0x608B, 0x9CA6, 0x60E1, 0x9CA7, 0x60B8, - 0x9CA8, 0x60E0, 0x9CA9, 0x60D3, 0x9CAA, 0x60B4, 0x9CAB, 0x5FF0, - 0x9CAC, 0x60BD, 0x9CAD, 0x60C6, 0x9CAE, 0x60B5, 0x9CAF, 0x60D8, - 0x9CB0, 0x614D, 0x9CB1, 0x6115, 0x9CB2, 0x6106, 0x9CB3, 0x60F6, - 0x9CB4, 0x60F7, 0x9CB5, 0x6100, 0x9CB6, 0x60F4, 0x9CB7, 0x60FA, - 0x9CB8, 0x6103, 0x9CB9, 0x6121, 0x9CBA, 0x60FB, 0x9CBB, 0x60F1, - 0x9CBC, 0x610D, 0x9CBD, 0x610E, 0x9CBE, 0x6147, 0x9CBF, 0x613E, - 0x9CC0, 0x6128, 0x9CC1, 0x6127, 0x9CC2, 0x614A, 0x9CC3, 0x613F, - 0x9CC4, 0x613C, 0x9CC5, 0x612C, 0x9CC6, 0x6134, 0x9CC7, 0x613D, - 0x9CC8, 0x6142, 0x9CC9, 0x6144, 0x9CCA, 0x6173, 0x9CCB, 0x6177, - 0x9CCC, 0x6158, 0x9CCD, 0x6159, 0x9CCE, 0x615A, 0x9CCF, 0x616B, - 0x9CD0, 0x6174, 0x9CD1, 0x616F, 0x9CD2, 0x6165, 0x9CD3, 0x6171, - 0x9CD4, 0x615F, 0x9CD5, 0x615D, 0x9CD6, 0x6153, 0x9CD7, 0x6175, - 0x9CD8, 0x6199, 0x9CD9, 0x6196, 0x9CDA, 0x6187, 0x9CDB, 0x61AC, - 0x9CDC, 0x6194, 0x9CDD, 0x619A, 0x9CDE, 0x618A, 0x9CDF, 0x6191, - 0x9CE0, 0x61AB, 0x9CE1, 0x61AE, 0x9CE2, 0x61CC, 0x9CE3, 0x61CA, - 0x9CE4, 0x61C9, 0x9CE5, 0x61F7, 0x9CE6, 0x61C8, 0x9CE7, 0x61C3, - 0x9CE8, 0x61C6, 0x9CE9, 0x61BA, 0x9CEA, 0x61CB, 0x9CEB, 0x7F79, - 0x9CEC, 0x61CD, 0x9CED, 0x61E6, 0x9CEE, 0x61E3, 0x9CEF, 0x61F6, - 0x9CF0, 0x61FA, 0x9CF1, 0x61F4, 0x9CF2, 0x61FF, 0x9CF3, 0x61FD, - 0x9CF4, 0x61FC, 0x9CF5, 0x61FE, 0x9CF6, 0x6200, 0x9CF7, 0x6208, - 0x9CF8, 0x6209, 0x9CF9, 0x620D, 0x9CFA, 0x620C, 0x9CFB, 0x6214, - 0x9CFC, 0x621B, 0x9D40, 0x621E, 0x9D41, 0x6221, 0x9D42, 0x622A, - 0x9D43, 0x622E, 0x9D44, 0x6230, 0x9D45, 0x6232, 0x9D46, 0x6233, - 0x9D47, 0x6241, 0x9D48, 0x624E, 0x9D49, 0x625E, 0x9D4A, 0x6263, - 0x9D4B, 0x625B, 0x9D4C, 0x6260, 0x9D4D, 0x6268, 0x9D4E, 0x627C, - 0x9D4F, 0x6282, 0x9D50, 0x6289, 0x9D51, 0x627E, 0x9D52, 0x6292, - 0x9D53, 0x6293, 0x9D54, 0x6296, 0x9D55, 0x62D4, 0x9D56, 0x6283, - 0x9D57, 0x6294, 0x9D58, 0x62D7, 0x9D59, 0x62D1, 0x9D5A, 0x62BB, - 0x9D5B, 0x62CF, 0x9D5C, 0x62FF, 0x9D5D, 0x62C6, 0x9D5E, 0x64D4, - 0x9D5F, 0x62C8, 0x9D60, 0x62DC, 0x9D61, 0x62CC, 0x9D62, 0x62CA, - 0x9D63, 0x62C2, 0x9D64, 0x62C7, 0x9D65, 0x629B, 0x9D66, 0x62C9, - 0x9D67, 0x630C, 0x9D68, 0x62EE, 0x9D69, 0x62F1, 0x9D6A, 0x6327, - 0x9D6B, 0x6302, 0x9D6C, 0x6308, 0x9D6D, 0x62EF, 0x9D6E, 0x62F5, - 0x9D6F, 0x6350, 0x9D70, 0x633E, 0x9D71, 0x634D, 0x9D72, 0x641C, - 0x9D73, 0x634F, 0x9D74, 0x6396, 0x9D75, 0x638E, 0x9D76, 0x6380, - 0x9D77, 0x63AB, 0x9D78, 0x6376, 0x9D79, 0x63A3, 0x9D7A, 0x638F, - 0x9D7B, 0x6389, 0x9D7C, 0x639F, 0x9D7D, 0x63B5, 0x9D7E, 0x636B, - 0x9D80, 0x6369, 0x9D81, 0x63BE, 0x9D82, 0x63E9, 0x9D83, 0x63C0, - 0x9D84, 0x63C6, 0x9D85, 0x63E3, 0x9D86, 0x63C9, 0x9D87, 0x63D2, - 0x9D88, 0x63F6, 0x9D89, 0x63C4, 0x9D8A, 0x6416, 0x9D8B, 0x6434, - 0x9D8C, 0x6406, 0x9D8D, 0x6413, 0x9D8E, 0x6426, 0x9D8F, 0x6436, - 0x9D90, 0x651D, 0x9D91, 0x6417, 0x9D92, 0x6428, 0x9D93, 0x640F, - 0x9D94, 0x6467, 0x9D95, 0x646F, 0x9D96, 0x6476, 0x9D97, 0x644E, - 0x9D98, 0x652A, 0x9D99, 0x6495, 0x9D9A, 0x6493, 0x9D9B, 0x64A5, - 0x9D9C, 0x64A9, 0x9D9D, 0x6488, 0x9D9E, 0x64BC, 0x9D9F, 0x64DA, - 0x9DA0, 0x64D2, 0x9DA1, 0x64C5, 0x9DA2, 0x64C7, 0x9DA3, 0x64BB, - 0x9DA4, 0x64D8, 0x9DA5, 0x64C2, 0x9DA6, 0x64F1, 0x9DA7, 0x64E7, - 0x9DA8, 0x8209, 0x9DA9, 0x64E0, 0x9DAA, 0x64E1, 0x9DAB, 0x62AC, - 0x9DAC, 0x64E3, 0x9DAD, 0x64EF, 0x9DAE, 0x652C, 0x9DAF, 0x64F6, - 0x9DB0, 0x64F4, 0x9DB1, 0x64F2, 0x9DB2, 0x64FA, 0x9DB3, 0x6500, - 0x9DB4, 0x64FD, 0x9DB5, 0x6518, 0x9DB6, 0x651C, 0x9DB7, 0x6505, - 0x9DB8, 0x6524, 0x9DB9, 0x6523, 0x9DBA, 0x652B, 0x9DBB, 0x6534, - 0x9DBC, 0x6535, 0x9DBD, 0x6537, 0x9DBE, 0x6536, 0x9DBF, 0x6538, - 0x9DC0, 0x754B, 0x9DC1, 0x6548, 0x9DC2, 0x6556, 0x9DC3, 0x6555, - 0x9DC4, 0x654D, 0x9DC5, 0x6558, 0x9DC6, 0x655E, 0x9DC7, 0x655D, - 0x9DC8, 0x6572, 0x9DC9, 0x6578, 0x9DCA, 0x6582, 0x9DCB, 0x6583, - 0x9DCC, 0x8B8A, 0x9DCD, 0x659B, 0x9DCE, 0x659F, 0x9DCF, 0x65AB, - 0x9DD0, 0x65B7, 0x9DD1, 0x65C3, 0x9DD2, 0x65C6, 0x9DD3, 0x65C1, - 0x9DD4, 0x65C4, 0x9DD5, 0x65CC, 0x9DD6, 0x65D2, 0x9DD7, 0x65DB, - 0x9DD8, 0x65D9, 0x9DD9, 0x65E0, 0x9DDA, 0x65E1, 0x9DDB, 0x65F1, - 0x9DDC, 0x6772, 0x9DDD, 0x660A, 0x9DDE, 0x6603, 0x9DDF, 0x65FB, - 0x9DE0, 0x6773, 0x9DE1, 0x6635, 0x9DE2, 0x6636, 0x9DE3, 0x6634, - 0x9DE4, 0x661C, 0x9DE5, 0x664F, 0x9DE6, 0x6644, 0x9DE7, 0x6649, - 0x9DE8, 0x6641, 0x9DE9, 0x665E, 0x9DEA, 0x665D, 0x9DEB, 0x6664, - 0x9DEC, 0x6667, 0x9DED, 0x6668, 0x9DEE, 0x665F, 0x9DEF, 0x6662, - 0x9DF0, 0x6670, 0x9DF1, 0x6683, 0x9DF2, 0x6688, 0x9DF3, 0x668E, - 0x9DF4, 0x6689, 0x9DF5, 0x6684, 0x9DF6, 0x6698, 0x9DF7, 0x669D, - 0x9DF8, 0x66C1, 0x9DF9, 0x66B9, 0x9DFA, 0x66C9, 0x9DFB, 0x66BE, - 0x9DFC, 0x66BC, 0x9E40, 0x66C4, 0x9E41, 0x66B8, 0x9E42, 0x66D6, - 0x9E43, 0x66DA, 0x9E44, 0x66E0, 0x9E45, 0x663F, 0x9E46, 0x66E6, - 0x9E47, 0x66E9, 0x9E48, 0x66F0, 0x9E49, 0x66F5, 0x9E4A, 0x66F7, - 0x9E4B, 0x670F, 0x9E4C, 0x6716, 0x9E4D, 0x671E, 0x9E4E, 0x6726, - 0x9E4F, 0x6727, 0x9E50, 0x9738, 0x9E51, 0x672E, 0x9E52, 0x673F, - 0x9E53, 0x6736, 0x9E54, 0x6741, 0x9E55, 0x6738, 0x9E56, 0x6737, - 0x9E57, 0x6746, 0x9E58, 0x675E, 0x9E59, 0x6760, 0x9E5A, 0x6759, - 0x9E5B, 0x6763, 0x9E5C, 0x6764, 0x9E5D, 0x6789, 0x9E5E, 0x6770, - 0x9E5F, 0x67A9, 0x9E60, 0x677C, 0x9E61, 0x676A, 0x9E62, 0x678C, - 0x9E63, 0x678B, 0x9E64, 0x67A6, 0x9E65, 0x67A1, 0x9E66, 0x6785, - 0x9E67, 0x67B7, 0x9E68, 0x67EF, 0x9E69, 0x67B4, 0x9E6A, 0x67EC, - 0x9E6B, 0x67B3, 0x9E6C, 0x67E9, 0x9E6D, 0x67B8, 0x9E6E, 0x67E4, - 0x9E6F, 0x67DE, 0x9E70, 0x67DD, 0x9E71, 0x67E2, 0x9E72, 0x67EE, - 0x9E73, 0x67B9, 0x9E74, 0x67CE, 0x9E75, 0x67C6, 0x9E76, 0x67E7, - 0x9E77, 0x6A9C, 0x9E78, 0x681E, 0x9E79, 0x6846, 0x9E7A, 0x6829, - 0x9E7B, 0x6840, 0x9E7C, 0x684D, 0x9E7D, 0x6832, 0x9E7E, 0x684E, - 0x9E80, 0x68B3, 0x9E81, 0x682B, 0x9E82, 0x6859, 0x9E83, 0x6863, - 0x9E84, 0x6877, 0x9E85, 0x687F, 0x9E86, 0x689F, 0x9E87, 0x688F, - 0x9E88, 0x68AD, 0x9E89, 0x6894, 0x9E8A, 0x689D, 0x9E8B, 0x689B, - 0x9E8C, 0x6883, 0x9E8D, 0x6AAE, 0x9E8E, 0x68B9, 0x9E8F, 0x6874, - 0x9E90, 0x68B5, 0x9E91, 0x68A0, 0x9E92, 0x68BA, 0x9E93, 0x690F, - 0x9E94, 0x688D, 0x9E95, 0x687E, 0x9E96, 0x6901, 0x9E97, 0x68CA, - 0x9E98, 0x6908, 0x9E99, 0x68D8, 0x9E9A, 0x6922, 0x9E9B, 0x6926, - 0x9E9C, 0x68E1, 0x9E9D, 0x690C, 0x9E9E, 0x68CD, 0x9E9F, 0x68D4, - 0x9EA0, 0x68E7, 0x9EA1, 0x68D5, 0x9EA2, 0x6936, 0x9EA3, 0x6912, - 0x9EA4, 0x6904, 0x9EA5, 0x68D7, 0x9EA6, 0x68E3, 0x9EA7, 0x6925, - 0x9EA8, 0x68F9, 0x9EA9, 0x68E0, 0x9EAA, 0x68EF, 0x9EAB, 0x6928, - 0x9EAC, 0x692A, 0x9EAD, 0x691A, 0x9EAE, 0x6923, 0x9EAF, 0x6921, - 0x9EB0, 0x68C6, 0x9EB1, 0x6979, 0x9EB2, 0x6977, 0x9EB3, 0x695C, - 0x9EB4, 0x6978, 0x9EB5, 0x696B, 0x9EB6, 0x6954, 0x9EB7, 0x697E, - 0x9EB8, 0x696E, 0x9EB9, 0x6939, 0x9EBA, 0x6974, 0x9EBB, 0x693D, - 0x9EBC, 0x6959, 0x9EBD, 0x6930, 0x9EBE, 0x6961, 0x9EBF, 0x695E, - 0x9EC0, 0x695D, 0x9EC1, 0x6981, 0x9EC2, 0x696A, 0x9EC3, 0x69B2, - 0x9EC4, 0x69AE, 0x9EC5, 0x69D0, 0x9EC6, 0x69BF, 0x9EC7, 0x69C1, - 0x9EC8, 0x69D3, 0x9EC9, 0x69BE, 0x9ECA, 0x69CE, 0x9ECB, 0x5BE8, - 0x9ECC, 0x69CA, 0x9ECD, 0x69DD, 0x9ECE, 0x69BB, 0x9ECF, 0x69C3, - 0x9ED0, 0x69A7, 0x9ED1, 0x6A2E, 0x9ED2, 0x6991, 0x9ED3, 0x69A0, - 0x9ED4, 0x699C, 0x9ED5, 0x6995, 0x9ED6, 0x69B4, 0x9ED7, 0x69DE, - 0x9ED8, 0x69E8, 0x9ED9, 0x6A02, 0x9EDA, 0x6A1B, 0x9EDB, 0x69FF, - 0x9EDC, 0x6B0A, 0x9EDD, 0x69F9, 0x9EDE, 0x69F2, 0x9EDF, 0x69E7, - 0x9EE0, 0x6A05, 0x9EE1, 0x69B1, 0x9EE2, 0x6A1E, 0x9EE3, 0x69ED, - 0x9EE4, 0x6A14, 0x9EE5, 0x69EB, 0x9EE6, 0x6A0A, 0x9EE7, 0x6A12, - 0x9EE8, 0x6AC1, 0x9EE9, 0x6A23, 0x9EEA, 0x6A13, 0x9EEB, 0x6A44, - 0x9EEC, 0x6A0C, 0x9EED, 0x6A72, 0x9EEE, 0x6A36, 0x9EEF, 0x6A78, - 0x9EF0, 0x6A47, 0x9EF1, 0x6A62, 0x9EF2, 0x6A59, 0x9EF3, 0x6A66, - 0x9EF4, 0x6A48, 0x9EF5, 0x6A38, 0x9EF6, 0x6A22, 0x9EF7, 0x6A90, - 0x9EF8, 0x6A8D, 0x9EF9, 0x6AA0, 0x9EFA, 0x6A84, 0x9EFB, 0x6AA2, - 0x9EFC, 0x6AA3, 0x9F40, 0x6A97, 0x9F41, 0x8617, 0x9F42, 0x6ABB, - 0x9F43, 0x6AC3, 0x9F44, 0x6AC2, 0x9F45, 0x6AB8, 0x9F46, 0x6AB3, - 0x9F47, 0x6AAC, 0x9F48, 0x6ADE, 0x9F49, 0x6AD1, 0x9F4A, 0x6ADF, - 0x9F4B, 0x6AAA, 0x9F4C, 0x6ADA, 0x9F4D, 0x6AEA, 0x9F4E, 0x6AFB, - 0x9F4F, 0x6B05, 0x9F50, 0x8616, 0x9F51, 0x6AFA, 0x9F52, 0x6B12, - 0x9F53, 0x6B16, 0x9F54, 0x9B31, 0x9F55, 0x6B1F, 0x9F56, 0x6B38, - 0x9F57, 0x6B37, 0x9F58, 0x76DC, 0x9F59, 0x6B39, 0x9F5A, 0x98EE, - 0x9F5B, 0x6B47, 0x9F5C, 0x6B43, 0x9F5D, 0x6B49, 0x9F5E, 0x6B50, - 0x9F5F, 0x6B59, 0x9F60, 0x6B54, 0x9F61, 0x6B5B, 0x9F62, 0x6B5F, - 0x9F63, 0x6B61, 0x9F64, 0x6B78, 0x9F65, 0x6B79, 0x9F66, 0x6B7F, - 0x9F67, 0x6B80, 0x9F68, 0x6B84, 0x9F69, 0x6B83, 0x9F6A, 0x6B8D, - 0x9F6B, 0x6B98, 0x9F6C, 0x6B95, 0x9F6D, 0x6B9E, 0x9F6E, 0x6BA4, - 0x9F6F, 0x6BAA, 0x9F70, 0x6BAB, 0x9F71, 0x6BAF, 0x9F72, 0x6BB2, - 0x9F73, 0x6BB1, 0x9F74, 0x6BB3, 0x9F75, 0x6BB7, 0x9F76, 0x6BBC, - 0x9F77, 0x6BC6, 0x9F78, 0x6BCB, 0x9F79, 0x6BD3, 0x9F7A, 0x6BDF, - 0x9F7B, 0x6BEC, 0x9F7C, 0x6BEB, 0x9F7D, 0x6BF3, 0x9F7E, 0x6BEF, - 0x9F80, 0x9EBE, 0x9F81, 0x6C08, 0x9F82, 0x6C13, 0x9F83, 0x6C14, - 0x9F84, 0x6C1B, 0x9F85, 0x6C24, 0x9F86, 0x6C23, 0x9F87, 0x6C5E, - 0x9F88, 0x6C55, 0x9F89, 0x6C62, 0x9F8A, 0x6C6A, 0x9F8B, 0x6C82, - 0x9F8C, 0x6C8D, 0x9F8D, 0x6C9A, 0x9F8E, 0x6C81, 0x9F8F, 0x6C9B, - 0x9F90, 0x6C7E, 0x9F91, 0x6C68, 0x9F92, 0x6C73, 0x9F93, 0x6C92, - 0x9F94, 0x6C90, 0x9F95, 0x6CC4, 0x9F96, 0x6CF1, 0x9F97, 0x6CD3, - 0x9F98, 0x6CBD, 0x9F99, 0x6CD7, 0x9F9A, 0x6CC5, 0x9F9B, 0x6CDD, - 0x9F9C, 0x6CAE, 0x9F9D, 0x6CB1, 0x9F9E, 0x6CBE, 0x9F9F, 0x6CBA, - 0x9FA0, 0x6CDB, 0x9FA1, 0x6CEF, 0x9FA2, 0x6CD9, 0x9FA3, 0x6CEA, - 0x9FA4, 0x6D1F, 0x9FA5, 0x884D, 0x9FA6, 0x6D36, 0x9FA7, 0x6D2B, - 0x9FA8, 0x6D3D, 0x9FA9, 0x6D38, 0x9FAA, 0x6D19, 0x9FAB, 0x6D35, - 0x9FAC, 0x6D33, 0x9FAD, 0x6D12, 0x9FAE, 0x6D0C, 0x9FAF, 0x6D63, - 0x9FB0, 0x6D93, 0x9FB1, 0x6D64, 0x9FB2, 0x6D5A, 0x9FB3, 0x6D79, - 0x9FB4, 0x6D59, 0x9FB5, 0x6D8E, 0x9FB6, 0x6D95, 0x9FB7, 0x6FE4, - 0x9FB8, 0x6D85, 0x9FB9, 0x6DF9, 0x9FBA, 0x6E15, 0x9FBB, 0x6E0A, - 0x9FBC, 0x6DB5, 0x9FBD, 0x6DC7, 0x9FBE, 0x6DE6, 0x9FBF, 0x6DB8, - 0x9FC0, 0x6DC6, 0x9FC1, 0x6DEC, 0x9FC2, 0x6DDE, 0x9FC3, 0x6DCC, - 0x9FC4, 0x6DE8, 0x9FC5, 0x6DD2, 0x9FC6, 0x6DC5, 0x9FC7, 0x6DFA, - 0x9FC8, 0x6DD9, 0x9FC9, 0x6DE4, 0x9FCA, 0x6DD5, 0x9FCB, 0x6DEA, - 0x9FCC, 0x6DEE, 0x9FCD, 0x6E2D, 0x9FCE, 0x6E6E, 0x9FCF, 0x6E2E, - 0x9FD0, 0x6E19, 0x9FD1, 0x6E72, 0x9FD2, 0x6E5F, 0x9FD3, 0x6E3E, - 0x9FD4, 0x6E23, 0x9FD5, 0x6E6B, 0x9FD6, 0x6E2B, 0x9FD7, 0x6E76, - 0x9FD8, 0x6E4D, 0x9FD9, 0x6E1F, 0x9FDA, 0x6E43, 0x9FDB, 0x6E3A, - 0x9FDC, 0x6E4E, 0x9FDD, 0x6E24, 0x9FDE, 0x6EFF, 0x9FDF, 0x6E1D, - 0x9FE0, 0x6E38, 0x9FE1, 0x6E82, 0x9FE2, 0x6EAA, 0x9FE3, 0x6E98, - 0x9FE4, 0x6EC9, 0x9FE5, 0x6EB7, 0x9FE6, 0x6ED3, 0x9FE7, 0x6EBD, - 0x9FE8, 0x6EAF, 0x9FE9, 0x6EC4, 0x9FEA, 0x6EB2, 0x9FEB, 0x6ED4, - 0x9FEC, 0x6ED5, 0x9FED, 0x6E8F, 0x9FEE, 0x6EA5, 0x9FEF, 0x6EC2, - 0x9FF0, 0x6E9F, 0x9FF1, 0x6F41, 0x9FF2, 0x6F11, 0x9FF3, 0x704C, - 0x9FF4, 0x6EEC, 0x9FF5, 0x6EF8, 0x9FF6, 0x6EFE, 0x9FF7, 0x6F3F, - 0x9FF8, 0x6EF2, 0x9FF9, 0x6F31, 0x9FFA, 0x6EEF, 0x9FFB, 0x6F32, - 0x9FFC, 0x6ECC, 0xE040, 0x6F3E, 0xE041, 0x6F13, 0xE042, 0x6EF7, - 0xE043, 0x6F86, 0xE044, 0x6F7A, 0xE045, 0x6F78, 0xE046, 0x6F81, - 0xE047, 0x6F80, 0xE048, 0x6F6F, 0xE049, 0x6F5B, 0xE04A, 0x6FF3, - 0xE04B, 0x6F6D, 0xE04C, 0x6F82, 0xE04D, 0x6F7C, 0xE04E, 0x6F58, - 0xE04F, 0x6F8E, 0xE050, 0x6F91, 0xE051, 0x6FC2, 0xE052, 0x6F66, - 0xE053, 0x6FB3, 0xE054, 0x6FA3, 0xE055, 0x6FA1, 0xE056, 0x6FA4, - 0xE057, 0x6FB9, 0xE058, 0x6FC6, 0xE059, 0x6FAA, 0xE05A, 0x6FDF, - 0xE05B, 0x6FD5, 0xE05C, 0x6FEC, 0xE05D, 0x6FD4, 0xE05E, 0x6FD8, - 0xE05F, 0x6FF1, 0xE060, 0x6FEE, 0xE061, 0x6FDB, 0xE062, 0x7009, - 0xE063, 0x700B, 0xE064, 0x6FFA, 0xE065, 0x7011, 0xE066, 0x7001, - 0xE067, 0x700F, 0xE068, 0x6FFE, 0xE069, 0x701B, 0xE06A, 0x701A, - 0xE06B, 0x6F74, 0xE06C, 0x701D, 0xE06D, 0x7018, 0xE06E, 0x701F, - 0xE06F, 0x7030, 0xE070, 0x703E, 0xE071, 0x7032, 0xE072, 0x7051, - 0xE073, 0x7063, 0xE074, 0x7099, 0xE075, 0x7092, 0xE076, 0x70AF, - 0xE077, 0x70F1, 0xE078, 0x70AC, 0xE079, 0x70B8, 0xE07A, 0x70B3, - 0xE07B, 0x70AE, 0xE07C, 0x70DF, 0xE07D, 0x70CB, 0xE07E, 0x70DD, - 0xE080, 0x70D9, 0xE081, 0x7109, 0xE082, 0x70FD, 0xE083, 0x711C, - 0xE084, 0x7119, 0xE085, 0x7165, 0xE086, 0x7155, 0xE087, 0x7188, - 0xE088, 0x7166, 0xE089, 0x7162, 0xE08A, 0x714C, 0xE08B, 0x7156, - 0xE08C, 0x716C, 0xE08D, 0x718F, 0xE08E, 0x71FB, 0xE08F, 0x7184, - 0xE090, 0x7195, 0xE091, 0x71A8, 0xE092, 0x71AC, 0xE093, 0x71D7, - 0xE094, 0x71B9, 0xE095, 0x71BE, 0xE096, 0x71D2, 0xE097, 0x71C9, - 0xE098, 0x71D4, 0xE099, 0x71CE, 0xE09A, 0x71E0, 0xE09B, 0x71EC, - 0xE09C, 0x71E7, 0xE09D, 0x71F5, 0xE09E, 0x71FC, 0xE09F, 0x71F9, - 0xE0A0, 0x71FF, 0xE0A1, 0x720D, 0xE0A2, 0x7210, 0xE0A3, 0x721B, - 0xE0A4, 0x7228, 0xE0A5, 0x722D, 0xE0A6, 0x722C, 0xE0A7, 0x7230, - 0xE0A8, 0x7232, 0xE0A9, 0x723B, 0xE0AA, 0x723C, 0xE0AB, 0x723F, - 0xE0AC, 0x7240, 0xE0AD, 0x7246, 0xE0AE, 0x724B, 0xE0AF, 0x7258, - 0xE0B0, 0x7274, 0xE0B1, 0x727E, 0xE0B2, 0x7282, 0xE0B3, 0x7281, - 0xE0B4, 0x7287, 0xE0B5, 0x7292, 0xE0B6, 0x7296, 0xE0B7, 0x72A2, - 0xE0B8, 0x72A7, 0xE0B9, 0x72B9, 0xE0BA, 0x72B2, 0xE0BB, 0x72C3, - 0xE0BC, 0x72C6, 0xE0BD, 0x72C4, 0xE0BE, 0x72CE, 0xE0BF, 0x72D2, - 0xE0C0, 0x72E2, 0xE0C1, 0x72E0, 0xE0C2, 0x72E1, 0xE0C3, 0x72F9, - 0xE0C4, 0x72F7, 0xE0C5, 0x500F, 0xE0C6, 0x7317, 0xE0C7, 0x730A, - 0xE0C8, 0x731C, 0xE0C9, 0x7316, 0xE0CA, 0x731D, 0xE0CB, 0x7334, - 0xE0CC, 0x732F, 0xE0CD, 0x7329, 0xE0CE, 0x7325, 0xE0CF, 0x733E, - 0xE0D0, 0x734E, 0xE0D1, 0x734F, 0xE0D2, 0x9ED8, 0xE0D3, 0x7357, - 0xE0D4, 0x736A, 0xE0D5, 0x7368, 0xE0D6, 0x7370, 0xE0D7, 0x7378, - 0xE0D8, 0x7375, 0xE0D9, 0x737B, 0xE0DA, 0x737A, 0xE0DB, 0x73C8, - 0xE0DC, 0x73B3, 0xE0DD, 0x73CE, 0xE0DE, 0x73BB, 0xE0DF, 0x73C0, - 0xE0E0, 0x73E5, 0xE0E1, 0x73EE, 0xE0E2, 0x73DE, 0xE0E3, 0x74A2, - 0xE0E4, 0x7405, 0xE0E5, 0x746F, 0xE0E6, 0x7425, 0xE0E7, 0x73F8, - 0xE0E8, 0x7432, 0xE0E9, 0x743A, 0xE0EA, 0x7455, 0xE0EB, 0x743F, - 0xE0EC, 0x745F, 0xE0ED, 0x7459, 0xE0EE, 0x7441, 0xE0EF, 0x745C, - 0xE0F0, 0x7469, 0xE0F1, 0x7470, 0xE0F2, 0x7463, 0xE0F3, 0x746A, - 0xE0F4, 0x7476, 0xE0F5, 0x747E, 0xE0F6, 0x748B, 0xE0F7, 0x749E, - 0xE0F8, 0x74A7, 0xE0F9, 0x74CA, 0xE0FA, 0x74CF, 0xE0FB, 0x74D4, - 0xE0FC, 0x73F1, 0xE140, 0x74E0, 0xE141, 0x74E3, 0xE142, 0x74E7, - 0xE143, 0x74E9, 0xE144, 0x74EE, 0xE145, 0x74F2, 0xE146, 0x74F0, - 0xE147, 0x74F1, 0xE148, 0x74F8, 0xE149, 0x74F7, 0xE14A, 0x7504, - 0xE14B, 0x7503, 0xE14C, 0x7505, 0xE14D, 0x750C, 0xE14E, 0x750E, - 0xE14F, 0x750D, 0xE150, 0x7515, 0xE151, 0x7513, 0xE152, 0x751E, - 0xE153, 0x7526, 0xE154, 0x752C, 0xE155, 0x753C, 0xE156, 0x7544, - 0xE157, 0x754D, 0xE158, 0x754A, 0xE159, 0x7549, 0xE15A, 0x755B, - 0xE15B, 0x7546, 0xE15C, 0x755A, 0xE15D, 0x7569, 0xE15E, 0x7564, - 0xE15F, 0x7567, 0xE160, 0x756B, 0xE161, 0x756D, 0xE162, 0x7578, - 0xE163, 0x7576, 0xE164, 0x7586, 0xE165, 0x7587, 0xE166, 0x7574, - 0xE167, 0x758A, 0xE168, 0x7589, 0xE169, 0x7582, 0xE16A, 0x7594, - 0xE16B, 0x759A, 0xE16C, 0x759D, 0xE16D, 0x75A5, 0xE16E, 0x75A3, - 0xE16F, 0x75C2, 0xE170, 0x75B3, 0xE171, 0x75C3, 0xE172, 0x75B5, - 0xE173, 0x75BD, 0xE174, 0x75B8, 0xE175, 0x75BC, 0xE176, 0x75B1, - 0xE177, 0x75CD, 0xE178, 0x75CA, 0xE179, 0x75D2, 0xE17A, 0x75D9, - 0xE17B, 0x75E3, 0xE17C, 0x75DE, 0xE17D, 0x75FE, 0xE17E, 0x75FF, - 0xE180, 0x75FC, 0xE181, 0x7601, 0xE182, 0x75F0, 0xE183, 0x75FA, - 0xE184, 0x75F2, 0xE185, 0x75F3, 0xE186, 0x760B, 0xE187, 0x760D, - 0xE188, 0x7609, 0xE189, 0x761F, 0xE18A, 0x7627, 0xE18B, 0x7620, - 0xE18C, 0x7621, 0xE18D, 0x7622, 0xE18E, 0x7624, 0xE18F, 0x7634, - 0xE190, 0x7630, 0xE191, 0x763B, 0xE192, 0x7647, 0xE193, 0x7648, - 0xE194, 0x7646, 0xE195, 0x765C, 0xE196, 0x7658, 0xE197, 0x7661, - 0xE198, 0x7662, 0xE199, 0x7668, 0xE19A, 0x7669, 0xE19B, 0x766A, - 0xE19C, 0x7667, 0xE19D, 0x766C, 0xE19E, 0x7670, 0xE19F, 0x7672, - 0xE1A0, 0x7676, 0xE1A1, 0x7678, 0xE1A2, 0x767C, 0xE1A3, 0x7680, - 0xE1A4, 0x7683, 0xE1A5, 0x7688, 0xE1A6, 0x768B, 0xE1A7, 0x768E, - 0xE1A8, 0x7696, 0xE1A9, 0x7693, 0xE1AA, 0x7699, 0xE1AB, 0x769A, - 0xE1AC, 0x76B0, 0xE1AD, 0x76B4, 0xE1AE, 0x76B8, 0xE1AF, 0x76B9, - 0xE1B0, 0x76BA, 0xE1B1, 0x76C2, 0xE1B2, 0x76CD, 0xE1B3, 0x76D6, - 0xE1B4, 0x76D2, 0xE1B5, 0x76DE, 0xE1B6, 0x76E1, 0xE1B7, 0x76E5, - 0xE1B8, 0x76E7, 0xE1B9, 0x76EA, 0xE1BA, 0x862F, 0xE1BB, 0x76FB, - 0xE1BC, 0x7708, 0xE1BD, 0x7707, 0xE1BE, 0x7704, 0xE1BF, 0x7729, - 0xE1C0, 0x7724, 0xE1C1, 0x771E, 0xE1C2, 0x7725, 0xE1C3, 0x7726, - 0xE1C4, 0x771B, 0xE1C5, 0x7737, 0xE1C6, 0x7738, 0xE1C7, 0x7747, - 0xE1C8, 0x775A, 0xE1C9, 0x7768, 0xE1CA, 0x776B, 0xE1CB, 0x775B, - 0xE1CC, 0x7765, 0xE1CD, 0x777F, 0xE1CE, 0x777E, 0xE1CF, 0x7779, - 0xE1D0, 0x778E, 0xE1D1, 0x778B, 0xE1D2, 0x7791, 0xE1D3, 0x77A0, - 0xE1D4, 0x779E, 0xE1D5, 0x77B0, 0xE1D6, 0x77B6, 0xE1D7, 0x77B9, - 0xE1D8, 0x77BF, 0xE1D9, 0x77BC, 0xE1DA, 0x77BD, 0xE1DB, 0x77BB, - 0xE1DC, 0x77C7, 0xE1DD, 0x77CD, 0xE1DE, 0x77D7, 0xE1DF, 0x77DA, - 0xE1E0, 0x77DC, 0xE1E1, 0x77E3, 0xE1E2, 0x77EE, 0xE1E3, 0x77FC, - 0xE1E4, 0x780C, 0xE1E5, 0x7812, 0xE1E6, 0x7926, 0xE1E7, 0x7820, - 0xE1E8, 0x792A, 0xE1E9, 0x7845, 0xE1EA, 0x788E, 0xE1EB, 0x7874, - 0xE1EC, 0x7886, 0xE1ED, 0x787C, 0xE1EE, 0x789A, 0xE1EF, 0x788C, - 0xE1F0, 0x78A3, 0xE1F1, 0x78B5, 0xE1F2, 0x78AA, 0xE1F3, 0x78AF, - 0xE1F4, 0x78D1, 0xE1F5, 0x78C6, 0xE1F6, 0x78CB, 0xE1F7, 0x78D4, - 0xE1F8, 0x78BE, 0xE1F9, 0x78BC, 0xE1FA, 0x78C5, 0xE1FB, 0x78CA, - 0xE1FC, 0x78EC, 0xE240, 0x78E7, 0xE241, 0x78DA, 0xE242, 0x78FD, - 0xE243, 0x78F4, 0xE244, 0x7907, 0xE245, 0x7912, 0xE246, 0x7911, - 0xE247, 0x7919, 0xE248, 0x792C, 0xE249, 0x792B, 0xE24A, 0x7940, - 0xE24B, 0x7960, 0xE24C, 0x7957, 0xE24D, 0x795F, 0xE24E, 0x795A, - 0xE24F, 0x7955, 0xE250, 0x7953, 0xE251, 0x797A, 0xE252, 0x797F, - 0xE253, 0x798A, 0xE254, 0x799D, 0xE255, 0x79A7, 0xE256, 0x9F4B, - 0xE257, 0x79AA, 0xE258, 0x79AE, 0xE259, 0x79B3, 0xE25A, 0x79B9, - 0xE25B, 0x79BA, 0xE25C, 0x79C9, 0xE25D, 0x79D5, 0xE25E, 0x79E7, - 0xE25F, 0x79EC, 0xE260, 0x79E1, 0xE261, 0x79E3, 0xE262, 0x7A08, - 0xE263, 0x7A0D, 0xE264, 0x7A18, 0xE265, 0x7A19, 0xE266, 0x7A20, - 0xE267, 0x7A1F, 0xE268, 0x7980, 0xE269, 0x7A31, 0xE26A, 0x7A3B, - 0xE26B, 0x7A3E, 0xE26C, 0x7A37, 0xE26D, 0x7A43, 0xE26E, 0x7A57, - 0xE26F, 0x7A49, 0xE270, 0x7A61, 0xE271, 0x7A62, 0xE272, 0x7A69, - 0xE273, 0x9F9D, 0xE274, 0x7A70, 0xE275, 0x7A79, 0xE276, 0x7A7D, - 0xE277, 0x7A88, 0xE278, 0x7A97, 0xE279, 0x7A95, 0xE27A, 0x7A98, - 0xE27B, 0x7A96, 0xE27C, 0x7AA9, 0xE27D, 0x7AC8, 0xE27E, 0x7AB0, - 0xE280, 0x7AB6, 0xE281, 0x7AC5, 0xE282, 0x7AC4, 0xE283, 0x7ABF, - 0xE284, 0x9083, 0xE285, 0x7AC7, 0xE286, 0x7ACA, 0xE287, 0x7ACD, - 0xE288, 0x7ACF, 0xE289, 0x7AD5, 0xE28A, 0x7AD3, 0xE28B, 0x7AD9, - 0xE28C, 0x7ADA, 0xE28D, 0x7ADD, 0xE28E, 0x7AE1, 0xE28F, 0x7AE2, - 0xE290, 0x7AE6, 0xE291, 0x7AED, 0xE292, 0x7AF0, 0xE293, 0x7B02, - 0xE294, 0x7B0F, 0xE295, 0x7B0A, 0xE296, 0x7B06, 0xE297, 0x7B33, - 0xE298, 0x7B18, 0xE299, 0x7B19, 0xE29A, 0x7B1E, 0xE29B, 0x7B35, - 0xE29C, 0x7B28, 0xE29D, 0x7B36, 0xE29E, 0x7B50, 0xE29F, 0x7B7A, - 0xE2A0, 0x7B04, 0xE2A1, 0x7B4D, 0xE2A2, 0x7B0B, 0xE2A3, 0x7B4C, - 0xE2A4, 0x7B45, 0xE2A5, 0x7B75, 0xE2A6, 0x7B65, 0xE2A7, 0x7B74, - 0xE2A8, 0x7B67, 0xE2A9, 0x7B70, 0xE2AA, 0x7B71, 0xE2AB, 0x7B6C, - 0xE2AC, 0x7B6E, 0xE2AD, 0x7B9D, 0xE2AE, 0x7B98, 0xE2AF, 0x7B9F, - 0xE2B0, 0x7B8D, 0xE2B1, 0x7B9C, 0xE2B2, 0x7B9A, 0xE2B3, 0x7B8B, - 0xE2B4, 0x7B92, 0xE2B5, 0x7B8F, 0xE2B6, 0x7B5D, 0xE2B7, 0x7B99, - 0xE2B8, 0x7BCB, 0xE2B9, 0x7BC1, 0xE2BA, 0x7BCC, 0xE2BB, 0x7BCF, - 0xE2BC, 0x7BB4, 0xE2BD, 0x7BC6, 0xE2BE, 0x7BDD, 0xE2BF, 0x7BE9, - 0xE2C0, 0x7C11, 0xE2C1, 0x7C14, 0xE2C2, 0x7BE6, 0xE2C3, 0x7BE5, - 0xE2C4, 0x7C60, 0xE2C5, 0x7C00, 0xE2C6, 0x7C07, 0xE2C7, 0x7C13, - 0xE2C8, 0x7BF3, 0xE2C9, 0x7BF7, 0xE2CA, 0x7C17, 0xE2CB, 0x7C0D, - 0xE2CC, 0x7BF6, 0xE2CD, 0x7C23, 0xE2CE, 0x7C27, 0xE2CF, 0x7C2A, - 0xE2D0, 0x7C1F, 0xE2D1, 0x7C37, 0xE2D2, 0x7C2B, 0xE2D3, 0x7C3D, - 0xE2D4, 0x7C4C, 0xE2D5, 0x7C43, 0xE2D6, 0x7C54, 0xE2D7, 0x7C4F, - 0xE2D8, 0x7C40, 0xE2D9, 0x7C50, 0xE2DA, 0x7C58, 0xE2DB, 0x7C5F, - 0xE2DC, 0x7C64, 0xE2DD, 0x7C56, 0xE2DE, 0x7C65, 0xE2DF, 0x7C6C, - 0xE2E0, 0x7C75, 0xE2E1, 0x7C83, 0xE2E2, 0x7C90, 0xE2E3, 0x7CA4, - 0xE2E4, 0x7CAD, 0xE2E5, 0x7CA2, 0xE2E6, 0x7CAB, 0xE2E7, 0x7CA1, - 0xE2E8, 0x7CA8, 0xE2E9, 0x7CB3, 0xE2EA, 0x7CB2, 0xE2EB, 0x7CB1, - 0xE2EC, 0x7CAE, 0xE2ED, 0x7CB9, 0xE2EE, 0x7CBD, 0xE2EF, 0x7CC0, - 0xE2F0, 0x7CC5, 0xE2F1, 0x7CC2, 0xE2F2, 0x7CD8, 0xE2F3, 0x7CD2, - 0xE2F4, 0x7CDC, 0xE2F5, 0x7CE2, 0xE2F6, 0x9B3B, 0xE2F7, 0x7CEF, - 0xE2F8, 0x7CF2, 0xE2F9, 0x7CF4, 0xE2FA, 0x7CF6, 0xE2FB, 0x7CFA, - 0xE2FC, 0x7D06, 0xE340, 0x7D02, 0xE341, 0x7D1C, 0xE342, 0x7D15, - 0xE343, 0x7D0A, 0xE344, 0x7D45, 0xE345, 0x7D4B, 0xE346, 0x7D2E, - 0xE347, 0x7D32, 0xE348, 0x7D3F, 0xE349, 0x7D35, 0xE34A, 0x7D46, - 0xE34B, 0x7D73, 0xE34C, 0x7D56, 0xE34D, 0x7D4E, 0xE34E, 0x7D72, - 0xE34F, 0x7D68, 0xE350, 0x7D6E, 0xE351, 0x7D4F, 0xE352, 0x7D63, - 0xE353, 0x7D93, 0xE354, 0x7D89, 0xE355, 0x7D5B, 0xE356, 0x7D8F, - 0xE357, 0x7D7D, 0xE358, 0x7D9B, 0xE359, 0x7DBA, 0xE35A, 0x7DAE, - 0xE35B, 0x7DA3, 0xE35C, 0x7DB5, 0xE35D, 0x7DC7, 0xE35E, 0x7DBD, - 0xE35F, 0x7DAB, 0xE360, 0x7E3D, 0xE361, 0x7DA2, 0xE362, 0x7DAF, - 0xE363, 0x7DDC, 0xE364, 0x7DB8, 0xE365, 0x7D9F, 0xE366, 0x7DB0, - 0xE367, 0x7DD8, 0xE368, 0x7DDD, 0xE369, 0x7DE4, 0xE36A, 0x7DDE, - 0xE36B, 0x7DFB, 0xE36C, 0x7DF2, 0xE36D, 0x7DE1, 0xE36E, 0x7E05, - 0xE36F, 0x7E0A, 0xE370, 0x7E23, 0xE371, 0x7E21, 0xE372, 0x7E12, - 0xE373, 0x7E31, 0xE374, 0x7E1F, 0xE375, 0x7E09, 0xE376, 0x7E0B, - 0xE377, 0x7E22, 0xE378, 0x7E46, 0xE379, 0x7E66, 0xE37A, 0x7E3B, - 0xE37B, 0x7E35, 0xE37C, 0x7E39, 0xE37D, 0x7E43, 0xE37E, 0x7E37, - 0xE380, 0x7E32, 0xE381, 0x7E3A, 0xE382, 0x7E67, 0xE383, 0x7E5D, - 0xE384, 0x7E56, 0xE385, 0x7E5E, 0xE386, 0x7E59, 0xE387, 0x7E5A, - 0xE388, 0x7E79, 0xE389, 0x7E6A, 0xE38A, 0x7E69, 0xE38B, 0x7E7C, - 0xE38C, 0x7E7B, 0xE38D, 0x7E83, 0xE38E, 0x7DD5, 0xE38F, 0x7E7D, - 0xE390, 0x8FAE, 0xE391, 0x7E7F, 0xE392, 0x7E88, 0xE393, 0x7E89, - 0xE394, 0x7E8C, 0xE395, 0x7E92, 0xE396, 0x7E90, 0xE397, 0x7E93, - 0xE398, 0x7E94, 0xE399, 0x7E96, 0xE39A, 0x7E8E, 0xE39B, 0x7E9B, - 0xE39C, 0x7E9C, 0xE39D, 0x7F38, 0xE39E, 0x7F3A, 0xE39F, 0x7F45, - 0xE3A0, 0x7F4C, 0xE3A1, 0x7F4D, 0xE3A2, 0x7F4E, 0xE3A3, 0x7F50, - 0xE3A4, 0x7F51, 0xE3A5, 0x7F55, 0xE3A6, 0x7F54, 0xE3A7, 0x7F58, - 0xE3A8, 0x7F5F, 0xE3A9, 0x7F60, 0xE3AA, 0x7F68, 0xE3AB, 0x7F69, - 0xE3AC, 0x7F67, 0xE3AD, 0x7F78, 0xE3AE, 0x7F82, 0xE3AF, 0x7F86, - 0xE3B0, 0x7F83, 0xE3B1, 0x7F88, 0xE3B2, 0x7F87, 0xE3B3, 0x7F8C, - 0xE3B4, 0x7F94, 0xE3B5, 0x7F9E, 0xE3B6, 0x7F9D, 0xE3B7, 0x7F9A, - 0xE3B8, 0x7FA3, 0xE3B9, 0x7FAF, 0xE3BA, 0x7FB2, 0xE3BB, 0x7FB9, - 0xE3BC, 0x7FAE, 0xE3BD, 0x7FB6, 0xE3BE, 0x7FB8, 0xE3BF, 0x8B71, - 0xE3C0, 0x7FC5, 0xE3C1, 0x7FC6, 0xE3C2, 0x7FCA, 0xE3C3, 0x7FD5, - 0xE3C4, 0x7FD4, 0xE3C5, 0x7FE1, 0xE3C6, 0x7FE6, 0xE3C7, 0x7FE9, - 0xE3C8, 0x7FF3, 0xE3C9, 0x7FF9, 0xE3CA, 0x98DC, 0xE3CB, 0x8006, - 0xE3CC, 0x8004, 0xE3CD, 0x800B, 0xE3CE, 0x8012, 0xE3CF, 0x8018, - 0xE3D0, 0x8019, 0xE3D1, 0x801C, 0xE3D2, 0x8021, 0xE3D3, 0x8028, - 0xE3D4, 0x803F, 0xE3D5, 0x803B, 0xE3D6, 0x804A, 0xE3D7, 0x8046, - 0xE3D8, 0x8052, 0xE3D9, 0x8058, 0xE3DA, 0x805A, 0xE3DB, 0x805F, - 0xE3DC, 0x8062, 0xE3DD, 0x8068, 0xE3DE, 0x8073, 0xE3DF, 0x8072, - 0xE3E0, 0x8070, 0xE3E1, 0x8076, 0xE3E2, 0x8079, 0xE3E3, 0x807D, - 0xE3E4, 0x807F, 0xE3E5, 0x8084, 0xE3E6, 0x8086, 0xE3E7, 0x8085, - 0xE3E8, 0x809B, 0xE3E9, 0x8093, 0xE3EA, 0x809A, 0xE3EB, 0x80AD, - 0xE3EC, 0x5190, 0xE3ED, 0x80AC, 0xE3EE, 0x80DB, 0xE3EF, 0x80E5, - 0xE3F0, 0x80D9, 0xE3F1, 0x80DD, 0xE3F2, 0x80C4, 0xE3F3, 0x80DA, - 0xE3F4, 0x80D6, 0xE3F5, 0x8109, 0xE3F6, 0x80EF, 0xE3F7, 0x80F1, - 0xE3F8, 0x811B, 0xE3F9, 0x8129, 0xE3FA, 0x8123, 0xE3FB, 0x812F, - 0xE3FC, 0x814B, 0xE440, 0x968B, 0xE441, 0x8146, 0xE442, 0x813E, - 0xE443, 0x8153, 0xE444, 0x8151, 0xE445, 0x80FC, 0xE446, 0x8171, - 0xE447, 0x816E, 0xE448, 0x8165, 0xE449, 0x8166, 0xE44A, 0x8174, - 0xE44B, 0x8183, 0xE44C, 0x8188, 0xE44D, 0x818A, 0xE44E, 0x8180, - 0xE44F, 0x8182, 0xE450, 0x81A0, 0xE451, 0x8195, 0xE452, 0x81A4, - 0xE453, 0x81A3, 0xE454, 0x815F, 0xE455, 0x8193, 0xE456, 0x81A9, - 0xE457, 0x81B0, 0xE458, 0x81B5, 0xE459, 0x81BE, 0xE45A, 0x81B8, - 0xE45B, 0x81BD, 0xE45C, 0x81C0, 0xE45D, 0x81C2, 0xE45E, 0x81BA, - 0xE45F, 0x81C9, 0xE460, 0x81CD, 0xE461, 0x81D1, 0xE462, 0x81D9, - 0xE463, 0x81D8, 0xE464, 0x81C8, 0xE465, 0x81DA, 0xE466, 0x81DF, - 0xE467, 0x81E0, 0xE468, 0x81E7, 0xE469, 0x81FA, 0xE46A, 0x81FB, - 0xE46B, 0x81FE, 0xE46C, 0x8201, 0xE46D, 0x8202, 0xE46E, 0x8205, - 0xE46F, 0x8207, 0xE470, 0x820A, 0xE471, 0x820D, 0xE472, 0x8210, - 0xE473, 0x8216, 0xE474, 0x8229, 0xE475, 0x822B, 0xE476, 0x8238, - 0xE477, 0x8233, 0xE478, 0x8240, 0xE479, 0x8259, 0xE47A, 0x8258, - 0xE47B, 0x825D, 0xE47C, 0x825A, 0xE47D, 0x825F, 0xE47E, 0x8264, - 0xE480, 0x8262, 0xE481, 0x8268, 0xE482, 0x826A, 0xE483, 0x826B, - 0xE484, 0x822E, 0xE485, 0x8271, 0xE486, 0x8277, 0xE487, 0x8278, - 0xE488, 0x827E, 0xE489, 0x828D, 0xE48A, 0x8292, 0xE48B, 0x82AB, - 0xE48C, 0x829F, 0xE48D, 0x82BB, 0xE48E, 0x82AC, 0xE48F, 0x82E1, - 0xE490, 0x82E3, 0xE491, 0x82DF, 0xE492, 0x82D2, 0xE493, 0x82F4, - 0xE494, 0x82F3, 0xE495, 0x82FA, 0xE496, 0x8393, 0xE497, 0x8303, - 0xE498, 0x82FB, 0xE499, 0x82F9, 0xE49A, 0x82DE, 0xE49B, 0x8306, - 0xE49C, 0x82DC, 0xE49D, 0x8309, 0xE49E, 0x82D9, 0xE49F, 0x8335, - 0xE4A0, 0x8334, 0xE4A1, 0x8316, 0xE4A2, 0x8332, 0xE4A3, 0x8331, - 0xE4A4, 0x8340, 0xE4A5, 0x8339, 0xE4A6, 0x8350, 0xE4A7, 0x8345, - 0xE4A8, 0x832F, 0xE4A9, 0x832B, 0xE4AA, 0x8317, 0xE4AB, 0x8318, - 0xE4AC, 0x8385, 0xE4AD, 0x839A, 0xE4AE, 0x83AA, 0xE4AF, 0x839F, - 0xE4B0, 0x83A2, 0xE4B1, 0x8396, 0xE4B2, 0x8323, 0xE4B3, 0x838E, - 0xE4B4, 0x8387, 0xE4B5, 0x838A, 0xE4B6, 0x837C, 0xE4B7, 0x83B5, - 0xE4B8, 0x8373, 0xE4B9, 0x8375, 0xE4BA, 0x83A0, 0xE4BB, 0x8389, - 0xE4BC, 0x83A8, 0xE4BD, 0x83F4, 0xE4BE, 0x8413, 0xE4BF, 0x83EB, - 0xE4C0, 0x83CE, 0xE4C1, 0x83FD, 0xE4C2, 0x8403, 0xE4C3, 0x83D8, - 0xE4C4, 0x840B, 0xE4C5, 0x83C1, 0xE4C6, 0x83F7, 0xE4C7, 0x8407, - 0xE4C8, 0x83E0, 0xE4C9, 0x83F2, 0xE4CA, 0x840D, 0xE4CB, 0x8422, - 0xE4CC, 0x8420, 0xE4CD, 0x83BD, 0xE4CE, 0x8438, 0xE4CF, 0x8506, - 0xE4D0, 0x83FB, 0xE4D1, 0x846D, 0xE4D2, 0x842A, 0xE4D3, 0x843C, - 0xE4D4, 0x855A, 0xE4D5, 0x8484, 0xE4D6, 0x8477, 0xE4D7, 0x846B, - 0xE4D8, 0x84AD, 0xE4D9, 0x846E, 0xE4DA, 0x8482, 0xE4DB, 0x8469, - 0xE4DC, 0x8446, 0xE4DD, 0x842C, 0xE4DE, 0x846F, 0xE4DF, 0x8479, - 0xE4E0, 0x8435, 0xE4E1, 0x84CA, 0xE4E2, 0x8462, 0xE4E3, 0x84B9, - 0xE4E4, 0x84BF, 0xE4E5, 0x849F, 0xE4E6, 0x84D9, 0xE4E7, 0x84CD, - 0xE4E8, 0x84BB, 0xE4E9, 0x84DA, 0xE4EA, 0x84D0, 0xE4EB, 0x84C1, - 0xE4EC, 0x84C6, 0xE4ED, 0x84D6, 0xE4EE, 0x84A1, 0xE4EF, 0x8521, - 0xE4F0, 0x84FF, 0xE4F1, 0x84F4, 0xE4F2, 0x8517, 0xE4F3, 0x8518, - 0xE4F4, 0x852C, 0xE4F5, 0x851F, 0xE4F6, 0x8515, 0xE4F7, 0x8514, - 0xE4F8, 0x84FC, 0xE4F9, 0x8540, 0xE4FA, 0x8563, 0xE4FB, 0x8558, - 0xE4FC, 0x8548, 0xE540, 0x8541, 0xE541, 0x8602, 0xE542, 0x854B, - 0xE543, 0x8555, 0xE544, 0x8580, 0xE545, 0x85A4, 0xE546, 0x8588, - 0xE547, 0x8591, 0xE548, 0x858A, 0xE549, 0x85A8, 0xE54A, 0x856D, - 0xE54B, 0x8594, 0xE54C, 0x859B, 0xE54D, 0x85EA, 0xE54E, 0x8587, - 0xE54F, 0x859C, 0xE550, 0x8577, 0xE551, 0x857E, 0xE552, 0x8590, - 0xE553, 0x85C9, 0xE554, 0x85BA, 0xE555, 0x85CF, 0xE556, 0x85B9, - 0xE557, 0x85D0, 0xE558, 0x85D5, 0xE559, 0x85DD, 0xE55A, 0x85E5, - 0xE55B, 0x85DC, 0xE55C, 0x85F9, 0xE55D, 0x860A, 0xE55E, 0x8613, - 0xE55F, 0x860B, 0xE560, 0x85FE, 0xE561, 0x85FA, 0xE562, 0x8606, - 0xE563, 0x8622, 0xE564, 0x861A, 0xE565, 0x8630, 0xE566, 0x863F, - 0xE567, 0x864D, 0xE568, 0x4E55, 0xE569, 0x8654, 0xE56A, 0x865F, - 0xE56B, 0x8667, 0xE56C, 0x8671, 0xE56D, 0x8693, 0xE56E, 0x86A3, - 0xE56F, 0x86A9, 0xE570, 0x86AA, 0xE571, 0x868B, 0xE572, 0x868C, - 0xE573, 0x86B6, 0xE574, 0x86AF, 0xE575, 0x86C4, 0xE576, 0x86C6, - 0xE577, 0x86B0, 0xE578, 0x86C9, 0xE579, 0x8823, 0xE57A, 0x86AB, - 0xE57B, 0x86D4, 0xE57C, 0x86DE, 0xE57D, 0x86E9, 0xE57E, 0x86EC, - 0xE580, 0x86DF, 0xE581, 0x86DB, 0xE582, 0x86EF, 0xE583, 0x8712, - 0xE584, 0x8706, 0xE585, 0x8708, 0xE586, 0x8700, 0xE587, 0x8703, - 0xE588, 0x86FB, 0xE589, 0x8711, 0xE58A, 0x8709, 0xE58B, 0x870D, - 0xE58C, 0x86F9, 0xE58D, 0x870A, 0xE58E, 0x8734, 0xE58F, 0x873F, - 0xE590, 0x8737, 0xE591, 0x873B, 0xE592, 0x8725, 0xE593, 0x8729, - 0xE594, 0x871A, 0xE595, 0x8760, 0xE596, 0x875F, 0xE597, 0x8778, - 0xE598, 0x874C, 0xE599, 0x874E, 0xE59A, 0x8774, 0xE59B, 0x8757, - 0xE59C, 0x8768, 0xE59D, 0x876E, 0xE59E, 0x8759, 0xE59F, 0x8753, - 0xE5A0, 0x8763, 0xE5A1, 0x876A, 0xE5A2, 0x8805, 0xE5A3, 0x87A2, - 0xE5A4, 0x879F, 0xE5A5, 0x8782, 0xE5A6, 0x87AF, 0xE5A7, 0x87CB, - 0xE5A8, 0x87BD, 0xE5A9, 0x87C0, 0xE5AA, 0x87D0, 0xE5AB, 0x96D6, - 0xE5AC, 0x87AB, 0xE5AD, 0x87C4, 0xE5AE, 0x87B3, 0xE5AF, 0x87C7, - 0xE5B0, 0x87C6, 0xE5B1, 0x87BB, 0xE5B2, 0x87EF, 0xE5B3, 0x87F2, - 0xE5B4, 0x87E0, 0xE5B5, 0x880F, 0xE5B6, 0x880D, 0xE5B7, 0x87FE, - 0xE5B8, 0x87F6, 0xE5B9, 0x87F7, 0xE5BA, 0x880E, 0xE5BB, 0x87D2, - 0xE5BC, 0x8811, 0xE5BD, 0x8816, 0xE5BE, 0x8815, 0xE5BF, 0x8822, - 0xE5C0, 0x8821, 0xE5C1, 0x8831, 0xE5C2, 0x8836, 0xE5C3, 0x8839, - 0xE5C4, 0x8827, 0xE5C5, 0x883B, 0xE5C6, 0x8844, 0xE5C7, 0x8842, - 0xE5C8, 0x8852, 0xE5C9, 0x8859, 0xE5CA, 0x885E, 0xE5CB, 0x8862, - 0xE5CC, 0x886B, 0xE5CD, 0x8881, 0xE5CE, 0x887E, 0xE5CF, 0x889E, - 0xE5D0, 0x8875, 0xE5D1, 0x887D, 0xE5D2, 0x88B5, 0xE5D3, 0x8872, - 0xE5D4, 0x8882, 0xE5D5, 0x8897, 0xE5D6, 0x8892, 0xE5D7, 0x88AE, - 0xE5D8, 0x8899, 0xE5D9, 0x88A2, 0xE5DA, 0x888D, 0xE5DB, 0x88A4, - 0xE5DC, 0x88B0, 0xE5DD, 0x88BF, 0xE5DE, 0x88B1, 0xE5DF, 0x88C3, - 0xE5E0, 0x88C4, 0xE5E1, 0x88D4, 0xE5E2, 0x88D8, 0xE5E3, 0x88D9, - 0xE5E4, 0x88DD, 0xE5E5, 0x88F9, 0xE5E6, 0x8902, 0xE5E7, 0x88FC, - 0xE5E8, 0x88F4, 0xE5E9, 0x88E8, 0xE5EA, 0x88F2, 0xE5EB, 0x8904, - 0xE5EC, 0x890C, 0xE5ED, 0x890A, 0xE5EE, 0x8913, 0xE5EF, 0x8943, - 0xE5F0, 0x891E, 0xE5F1, 0x8925, 0xE5F2, 0x892A, 0xE5F3, 0x892B, - 0xE5F4, 0x8941, 0xE5F5, 0x8944, 0xE5F6, 0x893B, 0xE5F7, 0x8936, - 0xE5F8, 0x8938, 0xE5F9, 0x894C, 0xE5FA, 0x891D, 0xE5FB, 0x8960, - 0xE5FC, 0x895E, 0xE640, 0x8966, 0xE641, 0x8964, 0xE642, 0x896D, - 0xE643, 0x896A, 0xE644, 0x896F, 0xE645, 0x8974, 0xE646, 0x8977, - 0xE647, 0x897E, 0xE648, 0x8983, 0xE649, 0x8988, 0xE64A, 0x898A, - 0xE64B, 0x8993, 0xE64C, 0x8998, 0xE64D, 0x89A1, 0xE64E, 0x89A9, - 0xE64F, 0x89A6, 0xE650, 0x89AC, 0xE651, 0x89AF, 0xE652, 0x89B2, - 0xE653, 0x89BA, 0xE654, 0x89BD, 0xE655, 0x89BF, 0xE656, 0x89C0, - 0xE657, 0x89DA, 0xE658, 0x89DC, 0xE659, 0x89DD, 0xE65A, 0x89E7, - 0xE65B, 0x89F4, 0xE65C, 0x89F8, 0xE65D, 0x8A03, 0xE65E, 0x8A16, - 0xE65F, 0x8A10, 0xE660, 0x8A0C, 0xE661, 0x8A1B, 0xE662, 0x8A1D, - 0xE663, 0x8A25, 0xE664, 0x8A36, 0xE665, 0x8A41, 0xE666, 0x8A5B, - 0xE667, 0x8A52, 0xE668, 0x8A46, 0xE669, 0x8A48, 0xE66A, 0x8A7C, - 0xE66B, 0x8A6D, 0xE66C, 0x8A6C, 0xE66D, 0x8A62, 0xE66E, 0x8A85, - 0xE66F, 0x8A82, 0xE670, 0x8A84, 0xE671, 0x8AA8, 0xE672, 0x8AA1, - 0xE673, 0x8A91, 0xE674, 0x8AA5, 0xE675, 0x8AA6, 0xE676, 0x8A9A, - 0xE677, 0x8AA3, 0xE678, 0x8AC4, 0xE679, 0x8ACD, 0xE67A, 0x8AC2, - 0xE67B, 0x8ADA, 0xE67C, 0x8AEB, 0xE67D, 0x8AF3, 0xE67E, 0x8AE7, - 0xE680, 0x8AE4, 0xE681, 0x8AF1, 0xE682, 0x8B14, 0xE683, 0x8AE0, - 0xE684, 0x8AE2, 0xE685, 0x8AF7, 0xE686, 0x8ADE, 0xE687, 0x8ADB, - 0xE688, 0x8B0C, 0xE689, 0x8B07, 0xE68A, 0x8B1A, 0xE68B, 0x8AE1, - 0xE68C, 0x8B16, 0xE68D, 0x8B10, 0xE68E, 0x8B17, 0xE68F, 0x8B20, - 0xE690, 0x8B33, 0xE691, 0x97AB, 0xE692, 0x8B26, 0xE693, 0x8B2B, - 0xE694, 0x8B3E, 0xE695, 0x8B28, 0xE696, 0x8B41, 0xE697, 0x8B4C, - 0xE698, 0x8B4F, 0xE699, 0x8B4E, 0xE69A, 0x8B49, 0xE69B, 0x8B56, - 0xE69C, 0x8B5B, 0xE69D, 0x8B5A, 0xE69E, 0x8B6B, 0xE69F, 0x8B5F, - 0xE6A0, 0x8B6C, 0xE6A1, 0x8B6F, 0xE6A2, 0x8B74, 0xE6A3, 0x8B7D, - 0xE6A4, 0x8B80, 0xE6A5, 0x8B8C, 0xE6A6, 0x8B8E, 0xE6A7, 0x8B92, - 0xE6A8, 0x8B93, 0xE6A9, 0x8B96, 0xE6AA, 0x8B99, 0xE6AB, 0x8B9A, - 0xE6AC, 0x8C3A, 0xE6AD, 0x8C41, 0xE6AE, 0x8C3F, 0xE6AF, 0x8C48, - 0xE6B0, 0x8C4C, 0xE6B1, 0x8C4E, 0xE6B2, 0x8C50, 0xE6B3, 0x8C55, - 0xE6B4, 0x8C62, 0xE6B5, 0x8C6C, 0xE6B6, 0x8C78, 0xE6B7, 0x8C7A, - 0xE6B8, 0x8C82, 0xE6B9, 0x8C89, 0xE6BA, 0x8C85, 0xE6BB, 0x8C8A, - 0xE6BC, 0x8C8D, 0xE6BD, 0x8C8E, 0xE6BE, 0x8C94, 0xE6BF, 0x8C7C, - 0xE6C0, 0x8C98, 0xE6C1, 0x621D, 0xE6C2, 0x8CAD, 0xE6C3, 0x8CAA, - 0xE6C4, 0x8CBD, 0xE6C5, 0x8CB2, 0xE6C6, 0x8CB3, 0xE6C7, 0x8CAE, - 0xE6C8, 0x8CB6, 0xE6C9, 0x8CC8, 0xE6CA, 0x8CC1, 0xE6CB, 0x8CE4, - 0xE6CC, 0x8CE3, 0xE6CD, 0x8CDA, 0xE6CE, 0x8CFD, 0xE6CF, 0x8CFA, - 0xE6D0, 0x8CFB, 0xE6D1, 0x8D04, 0xE6D2, 0x8D05, 0xE6D3, 0x8D0A, - 0xE6D4, 0x8D07, 0xE6D5, 0x8D0F, 0xE6D6, 0x8D0D, 0xE6D7, 0x8D10, - 0xE6D8, 0x9F4E, 0xE6D9, 0x8D13, 0xE6DA, 0x8CCD, 0xE6DB, 0x8D14, - 0xE6DC, 0x8D16, 0xE6DD, 0x8D67, 0xE6DE, 0x8D6D, 0xE6DF, 0x8D71, - 0xE6E0, 0x8D73, 0xE6E1, 0x8D81, 0xE6E2, 0x8D99, 0xE6E3, 0x8DC2, - 0xE6E4, 0x8DBE, 0xE6E5, 0x8DBA, 0xE6E6, 0x8DCF, 0xE6E7, 0x8DDA, - 0xE6E8, 0x8DD6, 0xE6E9, 0x8DCC, 0xE6EA, 0x8DDB, 0xE6EB, 0x8DCB, - 0xE6EC, 0x8DEA, 0xE6ED, 0x8DEB, 0xE6EE, 0x8DDF, 0xE6EF, 0x8DE3, - 0xE6F0, 0x8DFC, 0xE6F1, 0x8E08, 0xE6F2, 0x8E09, 0xE6F3, 0x8DFF, - 0xE6F4, 0x8E1D, 0xE6F5, 0x8E1E, 0xE6F6, 0x8E10, 0xE6F7, 0x8E1F, - 0xE6F8, 0x8E42, 0xE6F9, 0x8E35, 0xE6FA, 0x8E30, 0xE6FB, 0x8E34, - 0xE6FC, 0x8E4A, 0xE740, 0x8E47, 0xE741, 0x8E49, 0xE742, 0x8E4C, - 0xE743, 0x8E50, 0xE744, 0x8E48, 0xE745, 0x8E59, 0xE746, 0x8E64, - 0xE747, 0x8E60, 0xE748, 0x8E2A, 0xE749, 0x8E63, 0xE74A, 0x8E55, - 0xE74B, 0x8E76, 0xE74C, 0x8E72, 0xE74D, 0x8E7C, 0xE74E, 0x8E81, - 0xE74F, 0x8E87, 0xE750, 0x8E85, 0xE751, 0x8E84, 0xE752, 0x8E8B, - 0xE753, 0x8E8A, 0xE754, 0x8E93, 0xE755, 0x8E91, 0xE756, 0x8E94, - 0xE757, 0x8E99, 0xE758, 0x8EAA, 0xE759, 0x8EA1, 0xE75A, 0x8EAC, - 0xE75B, 0x8EB0, 0xE75C, 0x8EC6, 0xE75D, 0x8EB1, 0xE75E, 0x8EBE, - 0xE75F, 0x8EC5, 0xE760, 0x8EC8, 0xE761, 0x8ECB, 0xE762, 0x8EDB, - 0xE763, 0x8EE3, 0xE764, 0x8EFC, 0xE765, 0x8EFB, 0xE766, 0x8EEB, - 0xE767, 0x8EFE, 0xE768, 0x8F0A, 0xE769, 0x8F05, 0xE76A, 0x8F15, - 0xE76B, 0x8F12, 0xE76C, 0x8F19, 0xE76D, 0x8F13, 0xE76E, 0x8F1C, - 0xE76F, 0x8F1F, 0xE770, 0x8F1B, 0xE771, 0x8F0C, 0xE772, 0x8F26, - 0xE773, 0x8F33, 0xE774, 0x8F3B, 0xE775, 0x8F39, 0xE776, 0x8F45, - 0xE777, 0x8F42, 0xE778, 0x8F3E, 0xE779, 0x8F4C, 0xE77A, 0x8F49, - 0xE77B, 0x8F46, 0xE77C, 0x8F4E, 0xE77D, 0x8F57, 0xE77E, 0x8F5C, - 0xE780, 0x8F62, 0xE781, 0x8F63, 0xE782, 0x8F64, 0xE783, 0x8F9C, - 0xE784, 0x8F9F, 0xE785, 0x8FA3, 0xE786, 0x8FAD, 0xE787, 0x8FAF, - 0xE788, 0x8FB7, 0xE789, 0x8FDA, 0xE78A, 0x8FE5, 0xE78B, 0x8FE2, - 0xE78C, 0x8FEA, 0xE78D, 0x8FEF, 0xE78E, 0x9087, 0xE78F, 0x8FF4, - 0xE790, 0x9005, 0xE791, 0x8FF9, 0xE792, 0x8FFA, 0xE793, 0x9011, - 0xE794, 0x9015, 0xE795, 0x9021, 0xE796, 0x900D, 0xE797, 0x901E, - 0xE798, 0x9016, 0xE799, 0x900B, 0xE79A, 0x9027, 0xE79B, 0x9036, - 0xE79C, 0x9035, 0xE79D, 0x9039, 0xE79E, 0x8FF8, 0xE79F, 0x904F, - 0xE7A0, 0x9050, 0xE7A1, 0x9051, 0xE7A2, 0x9052, 0xE7A3, 0x900E, - 0xE7A4, 0x9049, 0xE7A5, 0x903E, 0xE7A6, 0x9056, 0xE7A7, 0x9058, - 0xE7A8, 0x905E, 0xE7A9, 0x9068, 0xE7AA, 0x906F, 0xE7AB, 0x9076, - 0xE7AC, 0x96A8, 0xE7AD, 0x9072, 0xE7AE, 0x9082, 0xE7AF, 0x907D, - 0xE7B0, 0x9081, 0xE7B1, 0x9080, 0xE7B2, 0x908A, 0xE7B3, 0x9089, - 0xE7B4, 0x908F, 0xE7B5, 0x90A8, 0xE7B6, 0x90AF, 0xE7B7, 0x90B1, - 0xE7B8, 0x90B5, 0xE7B9, 0x90E2, 0xE7BA, 0x90E4, 0xE7BB, 0x6248, - 0xE7BC, 0x90DB, 0xE7BD, 0x9102, 0xE7BE, 0x9112, 0xE7BF, 0x9119, - 0xE7C0, 0x9132, 0xE7C1, 0x9130, 0xE7C2, 0x914A, 0xE7C3, 0x9156, - 0xE7C4, 0x9158, 0xE7C5, 0x9163, 0xE7C6, 0x9165, 0xE7C7, 0x9169, - 0xE7C8, 0x9173, 0xE7C9, 0x9172, 0xE7CA, 0x918B, 0xE7CB, 0x9189, - 0xE7CC, 0x9182, 0xE7CD, 0x91A2, 0xE7CE, 0x91AB, 0xE7CF, 0x91AF, - 0xE7D0, 0x91AA, 0xE7D1, 0x91B5, 0xE7D2, 0x91B4, 0xE7D3, 0x91BA, - 0xE7D4, 0x91C0, 0xE7D5, 0x91C1, 0xE7D6, 0x91C9, 0xE7D7, 0x91CB, - 0xE7D8, 0x91D0, 0xE7D9, 0x91D6, 0xE7DA, 0x91DF, 0xE7DB, 0x91E1, - 0xE7DC, 0x91DB, 0xE7DD, 0x91FC, 0xE7DE, 0x91F5, 0xE7DF, 0x91F6, - 0xE7E0, 0x921E, 0xE7E1, 0x91FF, 0xE7E2, 0x9214, 0xE7E3, 0x922C, - 0xE7E4, 0x9215, 0xE7E5, 0x9211, 0xE7E6, 0x925E, 0xE7E7, 0x9257, - 0xE7E8, 0x9245, 0xE7E9, 0x9249, 0xE7EA, 0x9264, 0xE7EB, 0x9248, - 0xE7EC, 0x9295, 0xE7ED, 0x923F, 0xE7EE, 0x924B, 0xE7EF, 0x9250, - 0xE7F0, 0x929C, 0xE7F1, 0x9296, 0xE7F2, 0x9293, 0xE7F3, 0x929B, - 0xE7F4, 0x925A, 0xE7F5, 0x92CF, 0xE7F6, 0x92B9, 0xE7F7, 0x92B7, - 0xE7F8, 0x92E9, 0xE7F9, 0x930F, 0xE7FA, 0x92FA, 0xE7FB, 0x9344, - 0xE7FC, 0x932E, 0xE840, 0x9319, 0xE841, 0x9322, 0xE842, 0x931A, - 0xE843, 0x9323, 0xE844, 0x933A, 0xE845, 0x9335, 0xE846, 0x933B, - 0xE847, 0x935C, 0xE848, 0x9360, 0xE849, 0x937C, 0xE84A, 0x936E, - 0xE84B, 0x9356, 0xE84C, 0x93B0, 0xE84D, 0x93AC, 0xE84E, 0x93AD, - 0xE84F, 0x9394, 0xE850, 0x93B9, 0xE851, 0x93D6, 0xE852, 0x93D7, - 0xE853, 0x93E8, 0xE854, 0x93E5, 0xE855, 0x93D8, 0xE856, 0x93C3, - 0xE857, 0x93DD, 0xE858, 0x93D0, 0xE859, 0x93C8, 0xE85A, 0x93E4, - 0xE85B, 0x941A, 0xE85C, 0x9414, 0xE85D, 0x9413, 0xE85E, 0x9403, - 0xE85F, 0x9407, 0xE860, 0x9410, 0xE861, 0x9436, 0xE862, 0x942B, - 0xE863, 0x9435, 0xE864, 0x9421, 0xE865, 0x943A, 0xE866, 0x9441, - 0xE867, 0x9452, 0xE868, 0x9444, 0xE869, 0x945B, 0xE86A, 0x9460, - 0xE86B, 0x9462, 0xE86C, 0x945E, 0xE86D, 0x946A, 0xE86E, 0x9229, - 0xE86F, 0x9470, 0xE870, 0x9475, 0xE871, 0x9477, 0xE872, 0x947D, - 0xE873, 0x945A, 0xE874, 0x947C, 0xE875, 0x947E, 0xE876, 0x9481, - 0xE877, 0x947F, 0xE878, 0x9582, 0xE879, 0x9587, 0xE87A, 0x958A, - 0xE87B, 0x9594, 0xE87C, 0x9596, 0xE87D, 0x9598, 0xE87E, 0x9599, - 0xE880, 0x95A0, 0xE881, 0x95A8, 0xE882, 0x95A7, 0xE883, 0x95AD, - 0xE884, 0x95BC, 0xE885, 0x95BB, 0xE886, 0x95B9, 0xE887, 0x95BE, - 0xE888, 0x95CA, 0xE889, 0x6FF6, 0xE88A, 0x95C3, 0xE88B, 0x95CD, - 0xE88C, 0x95CC, 0xE88D, 0x95D5, 0xE88E, 0x95D4, 0xE88F, 0x95D6, - 0xE890, 0x95DC, 0xE891, 0x95E1, 0xE892, 0x95E5, 0xE893, 0x95E2, - 0xE894, 0x9621, 0xE895, 0x9628, 0xE896, 0x962E, 0xE897, 0x962F, - 0xE898, 0x9642, 0xE899, 0x964C, 0xE89A, 0x964F, 0xE89B, 0x964B, - 0xE89C, 0x9677, 0xE89D, 0x965C, 0xE89E, 0x965E, 0xE89F, 0x965D, - 0xE8A0, 0x965F, 0xE8A1, 0x9666, 0xE8A2, 0x9672, 0xE8A3, 0x966C, - 0xE8A4, 0x968D, 0xE8A5, 0x9698, 0xE8A6, 0x9695, 0xE8A7, 0x9697, - 0xE8A8, 0x96AA, 0xE8A9, 0x96A7, 0xE8AA, 0x96B1, 0xE8AB, 0x96B2, - 0xE8AC, 0x96B0, 0xE8AD, 0x96B4, 0xE8AE, 0x96B6, 0xE8AF, 0x96B8, - 0xE8B0, 0x96B9, 0xE8B1, 0x96CE, 0xE8B2, 0x96CB, 0xE8B3, 0x96C9, - 0xE8B4, 0x96CD, 0xE8B5, 0x894D, 0xE8B6, 0x96DC, 0xE8B7, 0x970D, - 0xE8B8, 0x96D5, 0xE8B9, 0x96F9, 0xE8BA, 0x9704, 0xE8BB, 0x9706, - 0xE8BC, 0x9708, 0xE8BD, 0x9713, 0xE8BE, 0x970E, 0xE8BF, 0x9711, - 0xE8C0, 0x970F, 0xE8C1, 0x9716, 0xE8C2, 0x9719, 0xE8C3, 0x9724, - 0xE8C4, 0x972A, 0xE8C5, 0x9730, 0xE8C6, 0x9739, 0xE8C7, 0x973D, - 0xE8C8, 0x973E, 0xE8C9, 0x9744, 0xE8CA, 0x9746, 0xE8CB, 0x9748, - 0xE8CC, 0x9742, 0xE8CD, 0x9749, 0xE8CE, 0x975C, 0xE8CF, 0x9760, - 0xE8D0, 0x9764, 0xE8D1, 0x9766, 0xE8D2, 0x9768, 0xE8D3, 0x52D2, - 0xE8D4, 0x976B, 0xE8D5, 0x9771, 0xE8D6, 0x9779, 0xE8D7, 0x9785, - 0xE8D8, 0x977C, 0xE8D9, 0x9781, 0xE8DA, 0x977A, 0xE8DB, 0x9786, - 0xE8DC, 0x978B, 0xE8DD, 0x978F, 0xE8DE, 0x9790, 0xE8DF, 0x979C, - 0xE8E0, 0x97A8, 0xE8E1, 0x97A6, 0xE8E2, 0x97A3, 0xE8E3, 0x97B3, - 0xE8E4, 0x97B4, 0xE8E5, 0x97C3, 0xE8E6, 0x97C6, 0xE8E7, 0x97C8, - 0xE8E8, 0x97CB, 0xE8E9, 0x97DC, 0xE8EA, 0x97ED, 0xE8EB, 0x9F4F, - 0xE8EC, 0x97F2, 0xE8ED, 0x7ADF, 0xE8EE, 0x97F6, 0xE8EF, 0x97F5, - 0xE8F0, 0x980F, 0xE8F1, 0x980C, 0xE8F2, 0x9838, 0xE8F3, 0x9824, - 0xE8F4, 0x9821, 0xE8F5, 0x9837, 0xE8F6, 0x983D, 0xE8F7, 0x9846, - 0xE8F8, 0x984F, 0xE8F9, 0x984B, 0xE8FA, 0x986B, 0xE8FB, 0x986F, - 0xE8FC, 0x9870, 0xE940, 0x9871, 0xE941, 0x9874, 0xE942, 0x9873, - 0xE943, 0x98AA, 0xE944, 0x98AF, 0xE945, 0x98B1, 0xE946, 0x98B6, - 0xE947, 0x98C4, 0xE948, 0x98C3, 0xE949, 0x98C6, 0xE94A, 0x98E9, - 0xE94B, 0x98EB, 0xE94C, 0x9903, 0xE94D, 0x9909, 0xE94E, 0x9912, - 0xE94F, 0x9914, 0xE950, 0x9918, 0xE951, 0x9921, 0xE952, 0x991D, - 0xE953, 0x991E, 0xE954, 0x9924, 0xE955, 0x9920, 0xE956, 0x992C, - 0xE957, 0x992E, 0xE958, 0x993D, 0xE959, 0x993E, 0xE95A, 0x9942, - 0xE95B, 0x9949, 0xE95C, 0x9945, 0xE95D, 0x9950, 0xE95E, 0x994B, - 0xE95F, 0x9951, 0xE960, 0x9952, 0xE961, 0x994C, 0xE962, 0x9955, - 0xE963, 0x9997, 0xE964, 0x9998, 0xE965, 0x99A5, 0xE966, 0x99AD, - 0xE967, 0x99AE, 0xE968, 0x99BC, 0xE969, 0x99DF, 0xE96A, 0x99DB, - 0xE96B, 0x99DD, 0xE96C, 0x99D8, 0xE96D, 0x99D1, 0xE96E, 0x99ED, - 0xE96F, 0x99EE, 0xE970, 0x99F1, 0xE971, 0x99F2, 0xE972, 0x99FB, - 0xE973, 0x99F8, 0xE974, 0x9A01, 0xE975, 0x9A0F, 0xE976, 0x9A05, - 0xE977, 0x99E2, 0xE978, 0x9A19, 0xE979, 0x9A2B, 0xE97A, 0x9A37, - 0xE97B, 0x9A45, 0xE97C, 0x9A42, 0xE97D, 0x9A40, 0xE97E, 0x9A43, - 0xE980, 0x9A3E, 0xE981, 0x9A55, 0xE982, 0x9A4D, 0xE983, 0x9A5B, - 0xE984, 0x9A57, 0xE985, 0x9A5F, 0xE986, 0x9A62, 0xE987, 0x9A65, - 0xE988, 0x9A64, 0xE989, 0x9A69, 0xE98A, 0x9A6B, 0xE98B, 0x9A6A, - 0xE98C, 0x9AAD, 0xE98D, 0x9AB0, 0xE98E, 0x9ABC, 0xE98F, 0x9AC0, - 0xE990, 0x9ACF, 0xE991, 0x9AD1, 0xE992, 0x9AD3, 0xE993, 0x9AD4, - 0xE994, 0x9ADE, 0xE995, 0x9ADF, 0xE996, 0x9AE2, 0xE997, 0x9AE3, - 0xE998, 0x9AE6, 0xE999, 0x9AEF, 0xE99A, 0x9AEB, 0xE99B, 0x9AEE, - 0xE99C, 0x9AF4, 0xE99D, 0x9AF1, 0xE99E, 0x9AF7, 0xE99F, 0x9AFB, - 0xE9A0, 0x9B06, 0xE9A1, 0x9B18, 0xE9A2, 0x9B1A, 0xE9A3, 0x9B1F, - 0xE9A4, 0x9B22, 0xE9A5, 0x9B23, 0xE9A6, 0x9B25, 0xE9A7, 0x9B27, - 0xE9A8, 0x9B28, 0xE9A9, 0x9B29, 0xE9AA, 0x9B2A, 0xE9AB, 0x9B2E, - 0xE9AC, 0x9B2F, 0xE9AD, 0x9B32, 0xE9AE, 0x9B44, 0xE9AF, 0x9B43, - 0xE9B0, 0x9B4F, 0xE9B1, 0x9B4D, 0xE9B2, 0x9B4E, 0xE9B3, 0x9B51, - 0xE9B4, 0x9B58, 0xE9B5, 0x9B74, 0xE9B6, 0x9B93, 0xE9B7, 0x9B83, - 0xE9B8, 0x9B91, 0xE9B9, 0x9B96, 0xE9BA, 0x9B97, 0xE9BB, 0x9B9F, - 0xE9BC, 0x9BA0, 0xE9BD, 0x9BA8, 0xE9BE, 0x9BB4, 0xE9BF, 0x9BC0, - 0xE9C0, 0x9BCA, 0xE9C1, 0x9BB9, 0xE9C2, 0x9BC6, 0xE9C3, 0x9BCF, - 0xE9C4, 0x9BD1, 0xE9C5, 0x9BD2, 0xE9C6, 0x9BE3, 0xE9C7, 0x9BE2, - 0xE9C8, 0x9BE4, 0xE9C9, 0x9BD4, 0xE9CA, 0x9BE1, 0xE9CB, 0x9C3A, - 0xE9CC, 0x9BF2, 0xE9CD, 0x9BF1, 0xE9CE, 0x9BF0, 0xE9CF, 0x9C15, - 0xE9D0, 0x9C14, 0xE9D1, 0x9C09, 0xE9D2, 0x9C13, 0xE9D3, 0x9C0C, - 0xE9D4, 0x9C06, 0xE9D5, 0x9C08, 0xE9D6, 0x9C12, 0xE9D7, 0x9C0A, - 0xE9D8, 0x9C04, 0xE9D9, 0x9C2E, 0xE9DA, 0x9C1B, 0xE9DB, 0x9C25, - 0xE9DC, 0x9C24, 0xE9DD, 0x9C21, 0xE9DE, 0x9C30, 0xE9DF, 0x9C47, - 0xE9E0, 0x9C32, 0xE9E1, 0x9C46, 0xE9E2, 0x9C3E, 0xE9E3, 0x9C5A, - 0xE9E4, 0x9C60, 0xE9E5, 0x9C67, 0xE9E6, 0x9C76, 0xE9E7, 0x9C78, - 0xE9E8, 0x9CE7, 0xE9E9, 0x9CEC, 0xE9EA, 0x9CF0, 0xE9EB, 0x9D09, - 0xE9EC, 0x9D08, 0xE9ED, 0x9CEB, 0xE9EE, 0x9D03, 0xE9EF, 0x9D06, - 0xE9F0, 0x9D2A, 0xE9F1, 0x9D26, 0xE9F2, 0x9DAF, 0xE9F3, 0x9D23, - 0xE9F4, 0x9D1F, 0xE9F5, 0x9D44, 0xE9F6, 0x9D15, 0xE9F7, 0x9D12, - 0xE9F8, 0x9D41, 0xE9F9, 0x9D3F, 0xE9FA, 0x9D3E, 0xE9FB, 0x9D46, - 0xE9FC, 0x9D48, 0xEA40, 0x9D5D, 0xEA41, 0x9D5E, 0xEA42, 0x9D64, - 0xEA43, 0x9D51, 0xEA44, 0x9D50, 0xEA45, 0x9D59, 0xEA46, 0x9D72, - 0xEA47, 0x9D89, 0xEA48, 0x9D87, 0xEA49, 0x9DAB, 0xEA4A, 0x9D6F, - 0xEA4B, 0x9D7A, 0xEA4C, 0x9D9A, 0xEA4D, 0x9DA4, 0xEA4E, 0x9DA9, - 0xEA4F, 0x9DB2, 0xEA50, 0x9DC4, 0xEA51, 0x9DC1, 0xEA52, 0x9DBB, - 0xEA53, 0x9DB8, 0xEA54, 0x9DBA, 0xEA55, 0x9DC6, 0xEA56, 0x9DCF, - 0xEA57, 0x9DC2, 0xEA58, 0x9DD9, 0xEA59, 0x9DD3, 0xEA5A, 0x9DF8, - 0xEA5B, 0x9DE6, 0xEA5C, 0x9DED, 0xEA5D, 0x9DEF, 0xEA5E, 0x9DFD, - 0xEA5F, 0x9E1A, 0xEA60, 0x9E1B, 0xEA61, 0x9E1E, 0xEA62, 0x9E75, - 0xEA63, 0x9E79, 0xEA64, 0x9E7D, 0xEA65, 0x9E81, 0xEA66, 0x9E88, - 0xEA67, 0x9E8B, 0xEA68, 0x9E8C, 0xEA69, 0x9E92, 0xEA6A, 0x9E95, - 0xEA6B, 0x9E91, 0xEA6C, 0x9E9D, 0xEA6D, 0x9EA5, 0xEA6E, 0x9EA9, - 0xEA6F, 0x9EB8, 0xEA70, 0x9EAA, 0xEA71, 0x9EAD, 0xEA72, 0x9761, - 0xEA73, 0x9ECC, 0xEA74, 0x9ECE, 0xEA75, 0x9ECF, 0xEA76, 0x9ED0, - 0xEA77, 0x9ED4, 0xEA78, 0x9EDC, 0xEA79, 0x9EDE, 0xEA7A, 0x9EDD, - 0xEA7B, 0x9EE0, 0xEA7C, 0x9EE5, 0xEA7D, 0x9EE8, 0xEA7E, 0x9EEF, - 0xEA80, 0x9EF4, 0xEA81, 0x9EF6, 0xEA82, 0x9EF7, 0xEA83, 0x9EF9, - 0xEA84, 0x9EFB, 0xEA85, 0x9EFC, 0xEA86, 0x9EFD, 0xEA87, 0x9F07, - 0xEA88, 0x9F08, 0xEA89, 0x76B7, 0xEA8A, 0x9F15, 0xEA8B, 0x9F21, - 0xEA8C, 0x9F2C, 0xEA8D, 0x9F3E, 0xEA8E, 0x9F4A, 0xEA8F, 0x9F52, - 0xEA90, 0x9F54, 0xEA91, 0x9F63, 0xEA92, 0x9F5F, 0xEA93, 0x9F60, - 0xEA94, 0x9F61, 0xEA95, 0x9F66, 0xEA96, 0x9F67, 0xEA97, 0x9F6C, - 0xEA98, 0x9F6A, 0xEA99, 0x9F77, 0xEA9A, 0x9F72, 0xEA9B, 0x9F76, - 0xEA9C, 0x9F95, 0xEA9D, 0x9F9C, 0xEA9E, 0x9FA0, 0xEA9F, 0x582F, - 0xEAA0, 0x69C7, 0xEAA1, 0x9059, 0xEAA2, 0x7464, 0xEAA3, 0x51DC, - 0xEAA4, 0x7199, 0xFA40, 0x2170, 0xFA41, 0x2171, 0xFA42, 0x2172, - 0xFA43, 0x2173, 0xFA44, 0x2174, 0xFA45, 0x2175, 0xFA46, 0x2176, - 0xFA47, 0x2177, 0xFA48, 0x2178, 0xFA49, 0x2179, 0xFA55, 0xFFE4, - 0xFA56, 0xFF07, 0xFA57, 0xFF02, 0xFA5C, 0x7E8A, 0xFA5D, 0x891C, - 0xFA5E, 0x9348, 0xFA5F, 0x9288, 0xFA60, 0x84DC, 0xFA61, 0x4FC9, - 0xFA62, 0x70BB, 0xFA63, 0x6631, 0xFA64, 0x68C8, 0xFA65, 0x92F9, - 0xFA66, 0x66FB, 0xFA67, 0x5F45, 0xFA68, 0x4E28, 0xFA69, 0x4EE1, - 0xFA6A, 0x4EFC, 0xFA6B, 0x4F00, 0xFA6C, 0x4F03, 0xFA6D, 0x4F39, - 0xFA6E, 0x4F56, 0xFA6F, 0x4F92, 0xFA70, 0x4F8A, 0xFA71, 0x4F9A, - 0xFA72, 0x4F94, 0xFA73, 0x4FCD, 0xFA74, 0x5040, 0xFA75, 0x5022, - 0xFA76, 0x4FFF, 0xFA77, 0x501E, 0xFA78, 0x5046, 0xFA79, 0x5070, - 0xFA7A, 0x5042, 0xFA7B, 0x5094, 0xFA7C, 0x50F4, 0xFA7D, 0x50D8, - 0xFA7E, 0x514A, 0xFA80, 0x5164, 0xFA81, 0x519D, 0xFA82, 0x51BE, - 0xFA83, 0x51EC, 0xFA84, 0x5215, 0xFA85, 0x529C, 0xFA86, 0x52A6, - 0xFA87, 0x52C0, 0xFA88, 0x52DB, 0xFA89, 0x5300, 0xFA8A, 0x5307, - 0xFA8B, 0x5324, 0xFA8C, 0x5372, 0xFA8D, 0x5393, 0xFA8E, 0x53B2, - 0xFA8F, 0x53DD, 0xFA90, 0xFA0E, 0xFA91, 0x549C, 0xFA92, 0x548A, - 0xFA93, 0x54A9, 0xFA94, 0x54FF, 0xFA95, 0x5586, 0xFA96, 0x5759, - 0xFA97, 0x5765, 0xFA98, 0x57AC, 0xFA99, 0x57C8, 0xFA9A, 0x57C7, - 0xFA9B, 0xFA0F, 0xFA9C, 0xFA10, 0xFA9D, 0x589E, 0xFA9E, 0x58B2, - 0xFA9F, 0x590B, 0xFAA0, 0x5953, 0xFAA1, 0x595B, 0xFAA2, 0x595D, - 0xFAA3, 0x5963, 0xFAA4, 0x59A4, 0xFAA5, 0x59BA, 0xFAA6, 0x5B56, - 0xFAA7, 0x5BC0, 0xFAA8, 0x752F, 0xFAA9, 0x5BD8, 0xFAAA, 0x5BEC, - 0xFAAB, 0x5C1E, 0xFAAC, 0x5CA6, 0xFAAD, 0x5CBA, 0xFAAE, 0x5CF5, - 0xFAAF, 0x5D27, 0xFAB0, 0x5D53, 0xFAB1, 0xFA11, 0xFAB2, 0x5D42, - 0xFAB3, 0x5D6D, 0xFAB4, 0x5DB8, 0xFAB5, 0x5DB9, 0xFAB6, 0x5DD0, - 0xFAB7, 0x5F21, 0xFAB8, 0x5F34, 0xFAB9, 0x5F67, 0xFABA, 0x5FB7, - 0xFABB, 0x5FDE, 0xFABC, 0x605D, 0xFABD, 0x6085, 0xFABE, 0x608A, - 0xFABF, 0x60DE, 0xFAC0, 0x60D5, 0xFAC1, 0x6120, 0xFAC2, 0x60F2, - 0xFAC3, 0x6111, 0xFAC4, 0x6137, 0xFAC5, 0x6130, 0xFAC6, 0x6198, - 0xFAC7, 0x6213, 0xFAC8, 0x62A6, 0xFAC9, 0x63F5, 0xFACA, 0x6460, - 0xFACB, 0x649D, 0xFACC, 0x64CE, 0xFACD, 0x654E, 0xFACE, 0x6600, - 0xFACF, 0x6615, 0xFAD0, 0x663B, 0xFAD1, 0x6609, 0xFAD2, 0x662E, - 0xFAD3, 0x661E, 0xFAD4, 0x6624, 0xFAD5, 0x6665, 0xFAD6, 0x6657, - 0xFAD7, 0x6659, 0xFAD8, 0xFA12, 0xFAD9, 0x6673, 0xFADA, 0x6699, - 0xFADB, 0x66A0, 0xFADC, 0x66B2, 0xFADD, 0x66BF, 0xFADE, 0x66FA, - 0xFADF, 0x670E, 0xFAE0, 0xF929, 0xFAE1, 0x6766, 0xFAE2, 0x67BB, - 0xFAE3, 0x6852, 0xFAE4, 0x67C0, 0xFAE5, 0x6801, 0xFAE6, 0x6844, - 0xFAE7, 0x68CF, 0xFAE8, 0xFA13, 0xFAE9, 0x6968, 0xFAEA, 0xFA14, - 0xFAEB, 0x6998, 0xFAEC, 0x69E2, 0xFAED, 0x6A30, 0xFAEE, 0x6A6B, - 0xFAEF, 0x6A46, 0xFAF0, 0x6A73, 0xFAF1, 0x6A7E, 0xFAF2, 0x6AE2, - 0xFAF3, 0x6AE4, 0xFAF4, 0x6BD6, 0xFAF5, 0x6C3F, 0xFAF6, 0x6C5C, - 0xFAF7, 0x6C86, 0xFAF8, 0x6C6F, 0xFAF9, 0x6CDA, 0xFAFA, 0x6D04, - 0xFAFB, 0x6D87, 0xFAFC, 0x6D6F, 0xFB40, 0x6D96, 0xFB41, 0x6DAC, - 0xFB42, 0x6DCF, 0xFB43, 0x6DF8, 0xFB44, 0x6DF2, 0xFB45, 0x6DFC, - 0xFB46, 0x6E39, 0xFB47, 0x6E5C, 0xFB48, 0x6E27, 0xFB49, 0x6E3C, - 0xFB4A, 0x6EBF, 0xFB4B, 0x6F88, 0xFB4C, 0x6FB5, 0xFB4D, 0x6FF5, - 0xFB4E, 0x7005, 0xFB4F, 0x7007, 0xFB50, 0x7028, 0xFB51, 0x7085, - 0xFB52, 0x70AB, 0xFB53, 0x710F, 0xFB54, 0x7104, 0xFB55, 0x715C, - 0xFB56, 0x7146, 0xFB57, 0x7147, 0xFB58, 0xFA15, 0xFB59, 0x71C1, - 0xFB5A, 0x71FE, 0xFB5B, 0x72B1, 0xFB5C, 0x72BE, 0xFB5D, 0x7324, - 0xFB5E, 0xFA16, 0xFB5F, 0x7377, 0xFB60, 0x73BD, 0xFB61, 0x73C9, - 0xFB62, 0x73D6, 0xFB63, 0x73E3, 0xFB64, 0x73D2, 0xFB65, 0x7407, - 0xFB66, 0x73F5, 0xFB67, 0x7426, 0xFB68, 0x742A, 0xFB69, 0x7429, - 0xFB6A, 0x742E, 0xFB6B, 0x7462, 0xFB6C, 0x7489, 0xFB6D, 0x749F, - 0xFB6E, 0x7501, 0xFB6F, 0x756F, 0xFB70, 0x7682, 0xFB71, 0x769C, - 0xFB72, 0x769E, 0xFB73, 0x769B, 0xFB74, 0x76A6, 0xFB75, 0xFA17, - 0xFB76, 0x7746, 0xFB77, 0x52AF, 0xFB78, 0x7821, 0xFB79, 0x784E, - 0xFB7A, 0x7864, 0xFB7B, 0x787A, 0xFB7C, 0x7930, 0xFB7D, 0xFA18, - 0xFB7E, 0xFA19, 0xFB80, 0xFA1A, 0xFB81, 0x7994, 0xFB82, 0xFA1B, - 0xFB83, 0x799B, 0xFB84, 0x7AD1, 0xFB85, 0x7AE7, 0xFB86, 0xFA1C, - 0xFB87, 0x7AEB, 0xFB88, 0x7B9E, 0xFB89, 0xFA1D, 0xFB8A, 0x7D48, - 0xFB8B, 0x7D5C, 0xFB8C, 0x7DB7, 0xFB8D, 0x7DA0, 0xFB8E, 0x7DD6, - 0xFB8F, 0x7E52, 0xFB90, 0x7F47, 0xFB91, 0x7FA1, 0xFB92, 0xFA1E, - 0xFB93, 0x8301, 0xFB94, 0x8362, 0xFB95, 0x837F, 0xFB96, 0x83C7, - 0xFB97, 0x83F6, 0xFB98, 0x8448, 0xFB99, 0x84B4, 0xFB9A, 0x8553, - 0xFB9B, 0x8559, 0xFB9C, 0x856B, 0xFB9D, 0xFA1F, 0xFB9E, 0x85B0, - 0xFB9F, 0xFA20, 0xFBA0, 0xFA21, 0xFBA1, 0x8807, 0xFBA2, 0x88F5, - 0xFBA3, 0x8A12, 0xFBA4, 0x8A37, 0xFBA5, 0x8A79, 0xFBA6, 0x8AA7, - 0xFBA7, 0x8ABE, 0xFBA8, 0x8ADF, 0xFBA9, 0xFA22, 0xFBAA, 0x8AF6, - 0xFBAB, 0x8B53, 0xFBAC, 0x8B7F, 0xFBAD, 0x8CF0, 0xFBAE, 0x8CF4, - 0xFBAF, 0x8D12, 0xFBB0, 0x8D76, 0xFBB1, 0xFA23, 0xFBB2, 0x8ECF, - 0xFBB3, 0xFA24, 0xFBB4, 0xFA25, 0xFBB5, 0x9067, 0xFBB6, 0x90DE, - 0xFBB7, 0xFA26, 0xFBB8, 0x9115, 0xFBB9, 0x9127, 0xFBBA, 0x91DA, - 0xFBBB, 0x91D7, 0xFBBC, 0x91DE, 0xFBBD, 0x91ED, 0xFBBE, 0x91EE, - 0xFBBF, 0x91E4, 0xFBC0, 0x91E5, 0xFBC1, 0x9206, 0xFBC2, 0x9210, - 0xFBC3, 0x920A, 0xFBC4, 0x923A, 0xFBC5, 0x9240, 0xFBC6, 0x923C, - 0xFBC7, 0x924E, 0xFBC8, 0x9259, 0xFBC9, 0x9251, 0xFBCA, 0x9239, - 0xFBCB, 0x9267, 0xFBCC, 0x92A7, 0xFBCD, 0x9277, 0xFBCE, 0x9278, - 0xFBCF, 0x92E7, 0xFBD0, 0x92D7, 0xFBD1, 0x92D9, 0xFBD2, 0x92D0, - 0xFBD3, 0xFA27, 0xFBD4, 0x92D5, 0xFBD5, 0x92E0, 0xFBD6, 0x92D3, - 0xFBD7, 0x9325, 0xFBD8, 0x9321, 0xFBD9, 0x92FB, 0xFBDA, 0xFA28, - 0xFBDB, 0x931E, 0xFBDC, 0x92FF, 0xFBDD, 0x931D, 0xFBDE, 0x9302, - 0xFBDF, 0x9370, 0xFBE0, 0x9357, 0xFBE1, 0x93A4, 0xFBE2, 0x93C6, - 0xFBE3, 0x93DE, 0xFBE4, 0x93F8, 0xFBE5, 0x9431, 0xFBE6, 0x9445, - 0xFBE7, 0x9448, 0xFBE8, 0x9592, 0xFBE9, 0xF9DC, 0xFBEA, 0xFA29, - 0xFBEB, 0x969D, 0xFBEC, 0x96AF, 0xFBED, 0x9733, 0xFBEE, 0x973B, - 0xFBEF, 0x9743, 0xFBF0, 0x974D, 0xFBF1, 0x974F, 0xFBF2, 0x9751, - 0xFBF3, 0x9755, 0xFBF4, 0x9857, 0xFBF5, 0x9865, 0xFBF6, 0xFA2A, - 0xFBF7, 0xFA2B, 0xFBF8, 0x9927, 0xFBF9, 0xFA2C, 0xFBFA, 0x999E, - 0xFBFB, 0x9A4E, 0xFBFC, 0x9AD9, 0xFC40, 0x9ADC, 0xFC41, 0x9B75, - 0xFC42, 0x9B72, 0xFC43, 0x9B8F, 0xFC44, 0x9BB1, 0xFC45, 0x9BBB, - 0xFC46, 0x9C00, 0xFC47, 0x9D70, 0xFC48, 0x9D6B, 0xFC49, 0xFA2D, - 0xFC4A, 0x9E19, 0xFC4B, 0x9ED1, 0, 0 -}; -#endif - - - -WCHAR ff_convert ( /* Converted code, 0 means conversion error */ - WCHAR src, /* Character code to be converted */ - UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */ -) -{ - const WCHAR *p; - WCHAR c; - int i, n, li, hi; - - - if (src <= 0x80) { /* ASCII */ - c = src; - } else { -#if !_TINY_TABLE - if (dir) { /* OEMCP to unicode */ - p = sjis2uni; - hi = sizeof(sjis2uni) / 4 - 1; - } else { /* Unicode to OEMCP */ - p = uni2sjis; - hi = sizeof(uni2sjis) / 4 - 1; - } - li = 0; - for (n = 16; n; n--) { - i = li + (hi - li) / 2; - if (src == p[i * 2]) break; - if (src > p[i * 2]) - li = i; - else - hi = i; - } - c = n ? p[i * 2 + 1] : 0; -#else - if (dir) { /* OEMCP to unicode (Incremental search)*/ - p = &uni2sjis[1]; - do { - c = *p; - p += 2; - } while (c && c != src); - p -= 3; - c = *p; - } else { /* Unicode to OEMCP */ - li = 0; hi = sizeof(uni2sjis) / 4 - 1; - for (n = 16; n; n--) { - i = li + (hi - li) / 2; - if (src == uni2sjis[i * 2]) break; - if (src > uni2sjis[i * 2]) - li = i; - else - hi = i; - } - c = n ? uni2sjis[i * 2 + 1] : 0; - } -#endif - } - - return c; -} - -WCHAR ff_wtoupper(WCHAR chr) -{ - if(chr >= 'a' && chr <= 'z') - return (chr - 32); - else - return chr; -} - -#endif diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/test_patterns/test.txt b/21_m1284p_WIZNET_TFTP_client_FATFS/test_patterns/test.txt deleted file mode 100644 index cf56d00..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/test_patterns/test.txt +++ /dev/null @@ -1,6 +0,0 @@ -#1 Hello to TFTP server! -#2 Hello to TFTP server again! -#3 It works! -#4 New string for test.. -#5 Bumped :)) - diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/test_patterns/tftpd32.ini b/21_m1284p_WIZNET_TFTP_client_FATFS/test_patterns/tftpd32.ini deleted file mode 100644 index 4ab9df8..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/test_patterns/tftpd32.ini +++ /dev/null @@ -1,40 +0,0 @@ -[DHCP] -Lease_NumLeases=0 -[TFTPD32] -BaseDirectory=. -TftpPort=69 -Hide=0 -WinSize=0 -Negociate=1 -PXECompatibility=0 -DirText=1 -ShowProgressBar=1 -Timeout=3 -MaxRetransmit=6 -SecurityLevel=1 -UnixStrings=1 -Beep=0 -VirtualRoot=0 -MD5=0 -LocalIP= -Services=1 -TftpLogFile= -SaveSyslogFile= -PipeSyslogMsg=0 -LowestUDPPort=0 -HighestUDPPort=0 -MulticastPort=0 -MulticastAddress= -PersistantLeases=1 -DHCP Ping=1 -DHCP LocalIP= -Max Simultaneous Transfers=100 -UseEventLog=0 -Console Password=tftpd32 -Support for port Option=0 -UseEventLog=0 -Keep transfer Gui=5 -Ignore ack for last TFTP packet=0 -Enable IPv6=0 -UnicastBOOTP=0 -DHCP Double Answer=0 diff --git a/21_m1284p_WIZNET_TFTP_client_FATFS/uart_extd.c b/21_m1284p_WIZNET_TFTP_client_FATFS/uart_extd.c deleted file mode 100644 index f4ad484..0000000 --- a/21_m1284p_WIZNET_TFTP_client_FATFS/uart_extd.c +++ /dev/null @@ -1,706 +0,0 @@ -/* - * Modified for different BUFFER_SIZE for UART0 && UART1 - * see below: UART0_RX_BUFFER_SIZE/UART1_RX_BUFFER_SIZE && UART0_TX_BUFFER_SIZE/UART1_TX_BUFFER_SIZE - * Ibragimov M. 7/03/2015 -*/ -/************************************************************************* -Title: Interrupt UART library with receive/transmit circular buffers -Author: Peter Fleury http://jump.to/fleury -File: $Id: uart.c,v 1.12 2014/01/08 21:58:12 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher -Hardware: any AVR with built-in UART, -License: GNU General Public License - -DESCRIPTION: - An interrupt is generated when the UART has finished transmitting or - receiving a byte. The interrupt handling routines use circular buffers - for buffering received and transmitted data. - - The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE variables define - the buffer size in bytes. Note that these variables must be a - power of 2. - -USAGE: - Refere to the header file uart.h for a description of the routines. - See also example test_uart.c. - -NOTES: - Based on Atmel Application Note AVR306 - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -*************************************************************************/ -#include -#include -#include -#include "uart_extd.h" - - -/* - * constants and macros - */ - -/* size of RX0/TX0 buffers */ -#define UART0_RX_BUFFER_MASK ( UART0_RX_BUFFER_SIZE - 1) -#define UART0_TX_BUFFER_MASK ( UART0_TX_BUFFER_SIZE - 1) - -#if ( UART0_RX_BUFFER_SIZE & UART0_RX_BUFFER_MASK ) -#error RX0 buffer size is not a power of 2 -#endif -#if ( UART0_TX_BUFFER_SIZE & UART0_TX_BUFFER_MASK ) -#error TX0 buffer size is not a power of 2 -#endif - -/* size of RX1/TX1 buffers */ -#define UART1_RX_BUFFER_MASK ( UART1_RX_BUFFER_SIZE - 1) -#define UART1_TX_BUFFER_MASK ( UART1_TX_BUFFER_SIZE - 1) - -#if ( UART1_RX_BUFFER_SIZE & UART1_RX_BUFFER_MASK ) -#error RX1 buffer size is not a power of 2 -#endif -#if ( UART1_TX_BUFFER_SIZE & UART1_TX_BUFFER_MASK ) -#error TX1 buffer size is not a power of 2 -#endif - - -#if defined(__AVR_AT90S2313__) \ - || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ - || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ - || defined(__AVR_ATmega103__) - /* old AVR classic or ATmega103 with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS USR - #define UART0_CONTROL UCR - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) - /* old AVR classic with one UART */ - #define AT90_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ - || defined(__AVR_ATmega323__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega163__) - /* ATmega163 with one UART */ - #define ATMEGA_UART - #define UART0_RECEIVE_INTERRUPT UART_RX_vect - #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega162__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect - #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega161__) - /* ATmega with UART */ - #error "AVR ATmega161 currently not supported by this libaray !" -#elif defined(__AVR_ATmega169__) - /* ATmega with one USART */ - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ - || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATtiny2313__) - #define ATMEGA_USART - #define UART0_RECEIVE_INTERRUPT USART_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect - #define UART0_STATUS UCSRA - #define UART0_CONTROL UCSRB - #define UART0_DATA UDR - #define UART0_UDRIE UDRIE -#elif defined(__AVR_ATmega329__) || \ - defined(__AVR_ATmega649__) || \ - defined(__AVR_ATmega325__) || \ - defined(__AVR_ATmega645__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) -/* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATmega644__) - /* ATmega with one USART */ - #define ATMEGA_USART0 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 -#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - /* ATmega with two USART */ - #define ATMEGA_USART0 - #define ATMEGA_USART1 - #define UART0_RECEIVE_INTERRUPT USART0_RX_vect - #define UART1_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect - #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR0A - #define UART0_CONTROL UCSR0B - #define UART0_DATA UDR0 - #define UART0_UDRIE UDRIE0 - #define UART1_STATUS UCSR1A - #define UART1_CONTROL UCSR1B - #define UART1_DATA UDR1 - #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) - /* AT90USBxx with one USART */ - #define AT90USB_USART - #define UART0_RECEIVE_INTERRUPT USART1_RX_vect - #define UART0_TRANSMIT_INTERRUPT USART1_UDRE_vect - #define UART0_STATUS UCSR1A - #define UART0_CONTROL UCSR1B - #define UART0_DATA UDR1 - #define UART0_UDRIE UDRIE1 -#else - #error "no UART definition for MCU available" -#endif - - -/* - * module global variables - */ -static volatile unsigned char UART_TxBuf[UART0_TX_BUFFER_SIZE]; -static volatile unsigned char UART_RxBuf[UART0_RX_BUFFER_SIZE]; -static volatile unsigned char UART_TxHead; -static volatile unsigned char UART_TxTail; -static volatile unsigned char UART_RxHead; -static volatile unsigned char UART_RxTail; -static volatile unsigned char UART_LastRxError; - -#if defined( ATMEGA_USART1 ) -static volatile unsigned char UART1_TxBuf[UART1_TX_BUFFER_SIZE]; -static volatile unsigned char UART1_RxBuf[UART1_RX_BUFFER_SIZE]; -static volatile unsigned char UART1_TxHead; -static volatile unsigned char UART1_TxTail; -static volatile unsigned char UART1_RxHead; -static volatile unsigned char UART1_RxTail; -static volatile unsigned char UART1_LastRxError; -#endif - - - -ISR (UART0_RECEIVE_INTERRUPT) -/************************************************************************* -Function: UART Receive Complete interrupt -Purpose: called when the UART has received a character -**************************************************************************/ -{ - unsigned char tmphead; - unsigned char data; - unsigned char usr; - unsigned char lastRxError; - - - /* read UART status register and UART data register */ - usr = UART0_STATUS; - data = UART0_DATA; - - /* */ -#if defined( AT90_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( ATMEGA_USART0 ) - lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); -#elif defined ( ATMEGA_UART ) - lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); -#elif defined( AT90USB_USART ) - lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) ); -#endif - - /* calculate buffer index */ - tmphead = ( UART_RxHead + 1) & UART0_RX_BUFFER_MASK; - - if ( tmphead == UART_RxTail ) { - /* error: receive buffer overflow */ - lastRxError = UART_BUFFER_OVERFLOW >> 8; - }else{ - /* store new index */ - UART_RxHead = tmphead; - /* store received data in buffer */ - UART_RxBuf[tmphead] = data; - } - UART_LastRxError |= lastRxError; -} - - -ISR (UART0_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART Data Register Empty interrupt -Purpose: called when the UART is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART_TxHead != UART_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART_TxTail + 1) & UART0_TX_BUFFER_MASK; - UART_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART0_CONTROL &= ~_BV(UART0_UDRIE); - } -} - - -/************************************************************************* -Function: uart_init() -Purpose: initialize UART and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart_init(unsigned int baudrate) -{ - UART_TxHead = 0; - UART_TxTail = 0; - UART_RxHead = 0; - UART_RxTail = 0; - -#if defined( AT90_UART ) - /* set baud rate */ - UBRR = (unsigned char)baudrate; - - /* enable UART receiver and transmmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); - -#elif defined (ATMEGA_USART) - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART0_STATUS = (1<>8); - UBRRL = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR0L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE0)|(1<>8); - UBRR = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE)|(1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable UART receiver and transmitter and receive complete interrupt */ - UART0_CONTROL = _BV(RXCIE1)|(1<> 8; - }else{ - /* store new index */ - UART1_RxHead = tmphead; - /* store received data in buffer */ - UART1_RxBuf[tmphead] = data; - } - UART1_LastRxError |= lastRxError; -} - - -ISR(UART1_TRANSMIT_INTERRUPT) -/************************************************************************* -Function: UART1 Data Register Empty interrupt -Purpose: called when the UART1 is ready to transmit the next byte -**************************************************************************/ -{ - unsigned char tmptail; - - - if ( UART1_TxHead != UART1_TxTail) { - /* calculate and store new buffer index */ - tmptail = (UART1_TxTail + 1) & UART1_TX_BUFFER_MASK; - UART1_TxTail = tmptail; - /* get one byte from buffer and write it to UART */ - UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ - }else{ - /* tx buffer empty, disable UDRE interrupt */ - UART1_CONTROL &= ~_BV(UART1_UDRIE); - } -} - - -/************************************************************************* -Function: uart1_init() -Purpose: initialize UART1 and set baudrate -Input: baudrate using macro UART_BAUD_SELECT() -Returns: none -**************************************************************************/ -void uart1_init(unsigned int baudrate) -{ - UART1_TxHead = 0; - UART1_TxTail = 0; - UART1_RxHead = 0; - UART1_RxTail = 0; - - - /* Set baud rate */ - if ( baudrate & 0x8000 ) - { - UART1_STATUS = (1<>8); - UBRR1L = (unsigned char) baudrate; - - /* Enable USART receiver and transmitter and receive complete interrupt */ - UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury -File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ -Software: AVR-GCC 4.1, AVR Libc 1.4 -Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz -License: GNU General Public License -Usage: see Doxygen manual - -LICENSE: - Copyright (C) 2006 Peter Fleury - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -************************************************************************/ - -/** - * @defgroup pfleury_uart UART Library - * @code #include @endcode - * - * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. - * - * This library can be used to transmit and receive data through the built in UART. - * - * An interrupt is generated when the UART has finished transmitting or - * receiving a byte. The interrupt handling routines use circular buffers - * for buffering received and transmitted data. - * - * The UART0[1]_RX_BUFFER_SIZE and UART0[1]_TX_BUFFER_SIZE constants define - * the size of the circular buffers in bytes. Note that these constants must be a power of 2. - * You may need to adapt this constants to your target and your application by adding - * CDEFS += -DUART0[1]_RX_BUFFER_SIZE=nn -DUART0[1]_RX_BUFFER_SIZE=nn to your Makefile. - * - * @note Based on Atmel Application Note AVR306 - * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - */ - -/**@{*/ - - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - - -/* -** constants and macros -*/ - -/** @brief UART Baudrate Expression - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) - -/** @brief UART Baudrate Expression for ATmega double speed mode - * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz - * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 - */ -#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) - - -/** Size of the circular receive buffer UART0, must be power of 2 */ -#ifndef UART0_RX_BUFFER_SIZE -#define UART0_RX_BUFFER_SIZE 32 -#endif -/** Size of the circular transmit buffer UART0, must be power of 2 */ -#ifndef UART0_TX_BUFFER_SIZE -#define UART0_TX_BUFFER_SIZE 32 -#endif - -/** Size of the circular receive buffer UART1, must be power of 2 */ -#ifndef UART1_RX_BUFFER_SIZE -#define UART1_RX_BUFFER_SIZE 128 -#endif -/** Size of the circular transmit buffer UART1, must be power of 2 */ -#ifndef UART1_TX_BUFFER_SIZE -#define UART1_TX_BUFFER_SIZE 128 -#endif - -/* test if the size of the circular buffers fits into SRAM */ -#if ( (UART0_RX_BUFFER_SIZE+UART0_TX_BUFFER_SIZE+UART1_RX_BUFFER_SIZE+UART1_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) -#error "size of UART0[1]_RX_BUFFER_SIZE + UART0[1]_TX_BUFFER_SIZE larger than size of SRAM" -#endif - -/* -** high byte error return code of uart_getc() -*/ -#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ -#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ -#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ -#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ -#define UART_NO_DATA 0x0100 /* no receive data available */ - - -/* -** function prototypes -*/ - -/** - @brief Initialize UART and set baudrate - @param baudrate Specify baudrate using macro UART_BAUD_SELECT() - @return none -*/ -extern void uart_init(unsigned int baudrate); - - -/** - * @brief Get received byte from ringbuffer - * - * Returns in the lower byte the received character and in the - * higher byte the last receive error. - * UART_NO_DATA is returned when no data is available. - * - * @param void - * @return lower byte: received byte from ringbuffer - * @return higher byte: last receive status - * - \b 0 successfully received data from UART - * - \b UART_NO_DATA - *
no receive data available - * - \b UART_BUFFER_OVERFLOW - *
Receive ringbuffer overflow. - * We are not reading the receive buffer fast enough, - * one or more received character have been dropped - * - \b UART_OVERRUN_ERROR - *
Overrun condition by UART. - * A character already present in the UART UDR register was - * not read by the interrupt handler before the next character arrived, - * one or more received characters have been dropped. - * - \b UART_FRAME_ERROR - *
Framing Error by UART - */ -extern unsigned int uart_getc(void); - - -/** - * @brief Put byte to ringbuffer for transmitting via UART - * @param data byte to be transmitted - * @return none - */ -extern void uart_putc(unsigned char data); - - -/** - * @brief Put string to ringbuffer for transmitting via UART - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s string to be transmitted - * @return none - */ -extern void uart_puts(const char *s ); - - -/** - * @brief Put string from program memory to ringbuffer for transmitting via UART. - * - * The string is buffered by the uart library in a circular buffer - * and one character at a time is transmitted to the UART using interrupts. - * Blocks if it can not write the whole string into the circular buffer. - * - * @param s program memory string to be transmitted - * @return none - * @see uart_puts_P - */ -extern void uart_puts_p(const char *s ); - -/** - * @brief Macro to automatically put a string constant into program memory - */ -#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) - - - -/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ -extern void uart1_init(unsigned int baudrate); -/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */ -extern unsigned int uart1_getc(void); -/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */ -extern void uart1_putc(unsigned char data); -/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */ -extern void uart1_puts(const char *s ); -/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */ -extern void uart1_puts_p(const char *s ); -/** @brief Macro to automatically put a string constant into program memory */ -#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s)) - -/**@}*/ - - -#endif // UART_H - diff --git a/KiCad_M644_breakout_v1.2d/.gitignore b/KiCad_M644_breakout_v1.2d/.gitignore deleted file mode 100644 index 95e2b38..0000000 --- a/KiCad_M644_breakout_v1.2d/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.bak -*.bck -*.raw -*.log -*.dcm -*.kicad_pcb-bak -*autosave* diff --git a/KiCad_M644_breakout_v1.2d/3d_terminal_blocks/300_2_5.wrl b/KiCad_M644_breakout_v1.2d/3d_terminal_blocks/300_2_5.wrl deleted file mode 100644 index a477d28..0000000 --- a/KiCad_M644_breakout_v1.2d/3d_terminal_blocks/300_2_5.wrl +++ /dev/null @@ -1,10047 +0,0 @@ -#VRML V2.0 utf8 - - -Shape { - appearance DEF A1109421936 Appearance { - material Material { - diffuseColor 0.338824 0.338824 0.338824 - specularColor 0.451765 0.451765 0.451765 - emissiveColor 0.282353 0.282353 0.282353 - ambientIntensity 0.5 - shininess 0.8 - transparency 0 - } - } - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 0.270903 -1.62864, - 3.95698 0.270903 -1.62864, - 3.95698 0.270903 -1.52864, - 6.45698 0.270903 -1.52864 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 0.270903 -1.62864, - 3.95698 0.220903 -1.62864, - 3.95698 0.220903 -1.52864, - 3.95698 0.270903 -1.52864 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 0.270903 -1.52864, - 3.95698 0.220903 -1.52864, - 6.45698 0.220903 -1.52864, - 6.45698 0.270903 -1.52864 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 0.270903 -1.62864, - 6.45698 0.270903 -1.62864, - 6.45698 0.220903 -1.62864, - 3.95698 0.220903 -1.62864 - ] - } - normal Normal { - vector [ - -0 -0 -1, - -0 -0 -1, - -0 -0 -1, - -0 -0 -1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 0.220903 -1.62864, - 6.45698 0.270903 -1.62864, - 6.45698 0.270903 -1.52864, - 6.45698 0.220903 -1.52864 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 0.0890008 -1.55007, - 6.45698 0.138928 -1.60426, - 6.45698 0.208635 -1.62814, - 6.45698 0.220903 -1.62864, - 3.95698 0.220903 -1.62864, - 3.95698 0.149476 -1.61055, - 3.95698 0.0952841 -1.56062, - 3.95698 0.0714053 -1.49091, - 3.95698 0.0709029 -1.47864, - 6.45698 0.0709029 -1.47864 - ] - } - normal Normal { - vector [ - 0 -0.879347 -0.476182, - 0 -0.546502 -0.837458, - 0 -0.0817826 -0.99665, - 0 0 -1, - 0 0 -1, - 0 -0.476182 -0.879347, - 0 -0.837458 -0.546502, - 0 -0.99665 -0.0817826, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016 - ] - } - coordIndex [ - 4, 3, 5, -1, - 5, 3, 2, -1, - 5, 2, 1, -1, - 5, 1, 6, -1, - 6, 1, 0, -1, - 6, 0, 7, -1, - 7, 0, 8, -1, - 8, 0, 9, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 0.0709029 -1.47864, - 3.95698 0.0709029 2.52136, - 3.95698 0.170903 2.52136, - 3.95698 0.170903 -1.47864 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 0.170903 -1.47864, - 3.95698 0.170903 -1.47864, - 3.95698 0.170903 2.52136, - 6.45698 0.170903 2.52136 - ] - } - normal Normal { - vector [ - 0 1 -3.82859e-016, - 0 1 -3.82859e-016, - 0 1 -3.82859e-016, - 0 1 -3.82859e-016 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 0.0709029 -1.47864, - 6.45698 0.0709029 -1.47864, - 6.45698 0.0709029 2.52136, - 3.95698 0.0709029 2.52136 - ] - } - normal Normal { - vector [ - -0 -1 3.82859e-016, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 0.220903 -1.52864, - 6.45698 0.185548 -1.514, - 6.45698 0.170903 -1.47864, - 6.45698 0.0709029 -1.47864, - 6.45698 0.0890008 -1.55007, - 6.45698 0.138928 -1.60426, - 6.45698 0.208635 -1.62814, - 6.45698 0.220903 -1.62864 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 1, -1, - 6, 1, 5, -1, - 5, 1, 2, -1, - 5, 2, 4, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 0.170903 -1.47864, - 6.45698 0.170903 -1.47864, - 6.45698 0.185548 -1.514, - 6.45698 0.220903 -1.52864, - 3.95698 0.220903 -1.52864, - 3.95698 0.185547 -1.514 - ] - } - normal Normal { - vector [ - -0 1 -3.82859e-016, - -0 1 -3.82859e-016, - -0 0.707103 0.70711, - -0 -0 1, - -0 -0 1, - -0 0.70711 0.707103 - ] - } - coordIndex [ - 0, 1, 2, -1, - 0, 2, 5, -1, - 5, 2, 3, -1, - 5, 3, 4, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 0.170903 -1.47864, - 3.95698 0.185547 -1.514, - 3.95698 0.220903 -1.52864, - 3.95698 0.220903 -1.62864, - 3.95698 0.149476 -1.61055, - 3.95698 0.0952841 -1.56062, - 3.95698 0.0714053 -1.49091, - 3.95698 0.0709029 -1.47864 - ] - } - normal Normal { - vector [ - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 5, -1, - 5, 0, 1, -1, - 5, 1, 4, -1, - 4, 1, 2, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 0.0709029 2.52136, - 6.45698 0.0709029 -1.47864, - 6.45698 0.170903 -1.47864, - 6.45698 0.170903 2.52136 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance DEF A1914361957 Appearance { - material Material { - diffuseColor 1 1 1 - specularColor 1 1 1 - emissiveColor 0.5 0.5 0.5 - ambientIntensity 1 - shininess 1 - transparency 0 - } - } - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 -2.06424 3.42441, - 3.95698 -2.06424 3.42441, - 3.95698 -4.84287 0.547053, - 6.45698 -4.84287 0.547053 - ] - } - normal Normal { - vector [ - -0 -0.71934 0.694658, - -0 -0.71934 0.694658, - -0 -0.71934 0.694658, - -0 -0.71934 0.694658 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 -1.84083 3.4875, - 6.45698 -1.66934 3.59287, - 6.45698 -1.48264 3.66809, - 6.45698 -1.286 3.71105, - 6.45698 -1.08494 3.72054, - 6.45698 -0.885127 3.69629, - 6.45698 -0.692176 3.63899, - 6.45698 -0.511518 3.55024, - 6.45698 -0.348235 3.43254, - 6.45698 -0.206922 3.28921, - 6.45698 -0.0915539 3.12427, - 6.45698 -0.00537666 2.94237, - 6.45698 0.049185 2.74863, - 6.45698 0.0705961 2.54849, - 6.45698 0.0709029 2.52136, - 3.95698 0.0709029 2.52136, - 3.95698 0.054022 2.72193, - 3.95698 0.00385449 2.91686, - 3.95698 -0.0781883 3.10066, - 3.95698 -0.189798 3.26816, - 3.95698 -0.327835 3.41465, - 3.95698 -0.488415 3.53601, - 3.95698 -0.66702 3.62882, - 3.95698 -0.858626 3.69048, - 3.95698 -1.05784 3.71924, - 3.95698 -1.25906 3.7143, - 3.95698 -1.45662 3.67579, - 3.95698 -1.64497 3.60481, - 3.95698 -1.81881 3.50334, - 3.95698 -1.97324 3.37425, - 3.95698 -1.9923 3.35495, - 6.45698 -1.9923 3.35495 - ] - } - normal Normal { - vector [ - -0 0.593113 -0.805119, - -0 0.4502 -0.892928, - -0 0.29462 -0.955615, - -0 0.130751 -0.991415, - -0 -0.0367965 -0.999323, - -0 -0.203309 -0.979115, - -0 -0.364101 -0.931359, - -0 -0.514649 -0.857401, - -0 -0.650718 -0.759319, - -0 -0.768479 -0.639875, - -0 -0.864619 -0.502427, - -0 -0.936434 -0.350845, - -0 -0.981902 -0.189391, - -0 -0.999744 -0.0226084, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016, - -0 -0.985933 -0.167143, - -0 -0.944126 -0.329584, - -0 -0.875757 -0.482751, - -0 -0.782749 -0.622337, - -0 -0.667719 -0.744414, - -0 -0.533902 -0.845546, - -0 -0.385064 -0.92289, - -0 -0.225393 -0.974268, - -0 -0.0593801 -0.998235, - -0 0.108303 -0.994118, - -0 0.27294 -0.962031, - -0 0.429897 -0.902878, - -0 0.574759 -0.818323, - -0 0.703451 -0.710744, - -0 0.71934 -0.694658, - -0 0.71934 -0.694658 - ] - } - coordIndex [ - 31, 30, 0, -1, - 0, 30, 29, -1, - 0, 29, 28, -1, - 0, 28, 1, -1, - 1, 28, 27, -1, - 1, 27, 2, -1, - 2, 27, 26, -1, - 2, 26, 3, -1, - 3, 26, 25, -1, - 3, 25, 4, -1, - 4, 25, 24, -1, - 4, 24, 5, -1, - 5, 24, 23, -1, - 5, 23, 6, -1, - 6, 23, 22, -1, - 6, 22, 7, -1, - 7, 22, 21, -1, - 7, 21, 8, -1, - 8, 21, 20, -1, - 8, 20, 9, -1, - 9, 20, 19, -1, - 9, 19, 10, -1, - 10, 19, 18, -1, - 10, 18, 11, -1, - 11, 18, 17, -1, - 11, 17, 12, -1, - 12, 17, 16, -1, - 12, 16, 13, -1, - 13, 16, 14, -1, - 14, 16, 15, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 -4.77094 0.477588, - 6.45698 -4.77094 0.477588, - 6.45698 -4.84287 0.547053, - 3.95698 -4.84287 0.547053 - ] - } - normal Normal { - vector [ - 0 -0.694658 -0.71934, - 0 -0.694658 -0.71934, - 0 -0.694658 -0.71934, - 0 -0.694658 -0.71934 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 -2.06424 3.42441, - 3.95698 -1.92155 3.5519, - 3.95698 -1.74836 3.66439, - 3.95698 -1.55954 3.74803, - 3.95698 -1.35986 3.80071, - 3.95698 -1.15436 3.82111, - 3.95698 -0.94822 3.80871, - 3.95698 -0.746645 3.76383, - 3.95698 -0.554721 3.68759, - 3.95698 -0.377291 3.58192, - 3.95698 -0.218834 3.44948, - 3.95698 -0.0833466 3.29363, - 3.95698 0.0257508 3.11829, - 3.95698 0.105706 2.92788, - 3.95698 0.1545 2.72722, - 3.95698 0.170903 2.52136, - 3.95698 0.0709029 2.52136, - 3.95698 0.054022 2.72193, - 3.95698 0.00385449 2.91686, - 3.95698 -0.0781883 3.10066, - 3.95698 -0.189798 3.26816, - 3.95698 -0.327835 3.41465, - 3.95698 -0.488415 3.53601, - 3.95698 -0.66702 3.62882, - 3.95698 -0.858626 3.69048, - 3.95698 -1.05784 3.71924, - 3.95698 -1.25906 3.7143, - 3.95698 -1.45662 3.67579, - 3.95698 -1.64497 3.60481, - 3.95698 -1.81881 3.50334, - 3.95698 -1.97324 3.37425, - 3.95698 -1.9923 3.35495 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 31, 0, 30, -1, - 30, 0, 29, -1, - 29, 0, 1, -1, - 29, 1, 28, -1, - 28, 1, 2, -1, - 28, 2, 27, -1, - 27, 2, 3, -1, - 27, 3, 26, -1, - 26, 3, 4, -1, - 26, 4, 25, -1, - 25, 4, 5, -1, - 25, 5, 24, -1, - 24, 5, 6, -1, - 24, 6, 23, -1, - 23, 6, 7, -1, - 23, 7, 22, -1, - 22, 7, 8, -1, - 22, 8, 21, -1, - 21, 8, 9, -1, - 21, 9, 20, -1, - 20, 9, 10, -1, - 20, 10, 19, -1, - 19, 10, 11, -1, - 19, 11, 18, -1, - 18, 11, 12, -1, - 18, 12, 17, -1, - 17, 12, 13, -1, - 17, 13, 16, -1, - 16, 13, 14, -1, - 16, 14, 15, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 -2.06424 3.42441, - 6.45698 -2.06424 3.42441, - 6.45698 -1.90944 3.5611, - 6.45698 -1.73494 3.67155, - 6.45698 -1.54516 3.75298, - 6.45698 -1.34488 3.80332, - 6.45698 -1.13915 3.82132, - 6.45698 -0.933174 3.80651, - 6.45698 -0.732138 3.75927, - 6.45698 -0.541119 3.68079, - 6.45698 -0.364938 3.57305, - 6.45698 -0.20804 3.43877, - 6.45698 -0.074385 3.28135, - 6.45698 0.032654 3.10474, - 6.45698 0.110376 2.91341, - 6.45698 0.15682 2.71219, - 6.45698 0.170903 2.52136, - 3.95698 0.170903 2.52136, - 3.95698 0.1545 2.72722, - 3.95698 0.105706 2.92788, - 3.95698 0.0257508 3.11829, - 3.95698 -0.0833466 3.29363, - 3.95698 -0.218834 3.44948, - 3.95698 -0.377291 3.58192, - 3.95698 -0.554721 3.68759, - 3.95698 -0.746645 3.76383, - 3.95698 -0.94822 3.80871, - 3.95698 -1.15436 3.82111, - 3.95698 -1.35986 3.80071, - 3.95698 -1.55954 3.74803, - 3.95698 -1.74836 3.66439, - 3.95698 -1.92155 3.5519 - ] - } - normal Normal { - vector [ - 0 -0.71934 0.694658, - 0 -0.71934 0.694658, - 0 -0.600262 0.799804, - 0 -0.466036 0.884766, - 0 -0.32005 0.947401, - 0 -0.165988 0.986128, - 0 -0.00773643 0.99997, - 0 0.15071 0.988578, - 0 0.305353 0.952239, - 0 0.452291 0.89187, - 0 0.587815 0.808995, - 0 0.708506 0.705705, - 0 0.811317 0.584606, - 0 0.893655 0.448755, - 0 0.953441 0.30158, - 0 0.989167 0.146794, - 0 1 -3.82859e-016, - 0 1 -3.82859e-016, - 0 0.987382 0.158354, - 0 0.949848 0.312711, - 0 0.888345 0.459177, - 0 0.804424 0.594056, - 0 0.700203 0.713944, - 0 0.578312 0.815816, - 0 0.441828 0.8971, - 0 0.294194 0.955746, - 0 0.139137 0.990273, - 0 -0.0194324 0.999811, - 0 -0.177511 0.984119, - 0 -0.33111 0.943592, - 0 -0.476353 0.879254, - 0 -0.609576 0.792728 - ] - } - coordIndex [ - 16, 17, 18, -1, - 16, 18, 15, -1, - 15, 18, 14, -1, - 14, 18, 19, -1, - 14, 19, 13, -1, - 13, 19, 20, -1, - 13, 20, 12, -1, - 12, 20, 21, -1, - 12, 21, 11, -1, - 11, 21, 22, -1, - 11, 22, 10, -1, - 10, 22, 23, -1, - 10, 23, 9, -1, - 9, 23, 24, -1, - 9, 24, 8, -1, - 8, 24, 25, -1, - 8, 25, 7, -1, - 7, 25, 26, -1, - 7, 26, 6, -1, - 6, 26, 27, -1, - 6, 27, 5, -1, - 5, 27, 28, -1, - 5, 28, 4, -1, - 4, 28, 29, -1, - 4, 29, 3, -1, - 3, 29, 30, -1, - 3, 30, 2, -1, - 2, 30, 31, -1, - 2, 31, 0, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 -1.9923 3.35495, - 3.95698 -4.77094 0.477588, - 3.95698 -4.84287 0.547053, - 3.95698 -2.06424 3.42441 - ] - } - normal Normal { - vector [ - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.95698 -1.9923 3.35495, - 6.45698 -1.9923 3.35495, - 6.45698 -4.77094 0.477588, - 3.95698 -4.77094 0.477588 - ] - } - normal Normal { - vector [ - 0 0.71934 -0.694658, - 0 0.71934 -0.694658, - 0 0.71934 -0.694658, - 0 0.71934 -0.694658 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 0.170903 2.52136, - 6.45698 0.15682 2.71219, - 6.45698 0.110376 2.91341, - 6.45698 0.032654 3.10474, - 6.45698 -0.074385 3.28135, - 6.45698 -0.20804 3.43877, - 6.45698 -0.364938 3.57305, - 6.45698 -0.541119 3.68079, - 6.45698 -0.732138 3.75927, - 6.45698 -0.933174 3.80651, - 6.45698 -1.13915 3.82132, - 6.45698 -1.34488 3.80332, - 6.45698 -1.54516 3.75298, - 6.45698 -1.73494 3.67155, - 6.45698 -1.90944 3.5611, - 6.45698 -2.06424 3.42441, - 6.45698 -1.9923 3.35495, - 6.45698 -1.84083 3.4875, - 6.45698 -1.66934 3.59287, - 6.45698 -1.48264 3.66809, - 6.45698 -1.286 3.71105, - 6.45698 -1.08494 3.72054, - 6.45698 -0.885127 3.69629, - 6.45698 -0.692176 3.63899, - 6.45698 -0.511518 3.55024, - 6.45698 -0.348235 3.43254, - 6.45698 -0.206922 3.28921, - 6.45698 -0.0915539 3.12427, - 6.45698 -0.00537666 2.94237, - 6.45698 0.049185 2.74863, - 6.45698 0.0705961 2.54849, - 6.45698 0.0709029 2.52136 - ] - } - normal Normal { - vector [ - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0 - ] - } - coordIndex [ - 31, 0, 30, -1, - 30, 0, 1, -1, - 30, 1, 29, -1, - 29, 1, 2, -1, - 29, 2, 28, -1, - 28, 2, 3, -1, - 28, 3, 27, -1, - 27, 3, 4, -1, - 27, 4, 26, -1, - 26, 4, 5, -1, - 26, 5, 25, -1, - 25, 5, 6, -1, - 25, 6, 24, -1, - 24, 6, 7, -1, - 24, 7, 23, -1, - 23, 7, 8, -1, - 23, 8, 22, -1, - 22, 8, 9, -1, - 22, 9, 21, -1, - 21, 9, 10, -1, - 21, 10, 20, -1, - 20, 10, 11, -1, - 20, 11, 19, -1, - 19, 11, 12, -1, - 19, 12, 18, -1, - 18, 12, 13, -1, - 18, 13, 17, -1, - 17, 13, 14, -1, - 17, 14, 16, -1, - 16, 14, 15, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.45698 -4.77094 0.477588, - 6.45698 -1.9923 3.35495, - 6.45698 -2.06424 3.42441, - 6.45698 -4.84287 0.547053 - ] - } - normal Normal { - vector [ - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance DEF A4266473842 Appearance { - material Material { - diffuseColor 0 0 1 - specularColor 0 0 1 - emissiveColor 0 0 0.5 - ambientIntensity 1 - shininess 1 - transparency 0 - } - } - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 4.60774 -7.0291 0.571357, - 4.60774 -7.0291 4.57136, - 2.70861 -7.0291 4.57136, - 2.70861 -7.0291 -2.08452, - 3.30861 -7.0291 -2.08452, - 3.30861 -7.0291 -2.68452, - 2.70861 -7.0291 -2.68452, - 2.70861 -7.0291 -4.42864, - 7.70861 -7.0291 -4.42864, - 7.70861 -7.0291 4.57136, - 5.79989 -7.0291 4.57136, - 5.79989 -7.0291 0.668089, - 5.80039 -7.0291 0.665012, - 5.80588 -7.0291 0.524089, - 5.77832 -7.0291 0.385777, - 5.71924 -7.0291 0.257719, - 5.6319 -7.0291 0.146988, - 5.52113 -7.0291 0.0597029, - 5.39304 -7.0291 0.000686212, - 5.25471 -7.0291 -0.0268015, - 5.11379 -7.0291 -0.0212421, - 4.97806 -7.0291 0.0170575, - 4.85502 -7.0291 0.0859814, - 4.75147 -7.0291 0.181722, - 4.67312 -7.0291 0.298989, - 4.62431 -7.0291 0.431304 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 1, 2, 0, -1, - 0, 2, 25, -1, - 25, 2, 3, -1, - 25, 3, 24, -1, - 24, 3, 4, -1, - 24, 4, 23, -1, - 23, 4, 5, -1, - 23, 5, 22, -1, - 22, 5, 7, -1, - 7, 5, 6, -1, - 7, 8, 22, -1, - 22, 8, 21, -1, - 21, 8, 20, -1, - 20, 8, 19, -1, - 19, 8, 18, -1, - 18, 8, 17, -1, - 17, 8, 16, -1, - 16, 8, 15, -1, - 15, 8, 14, -1, - 14, 8, 13, -1, - 13, 8, 9, -1, - 13, 9, 12, -1, - 12, 9, 10, -1, - 12, 10, 11, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.70861 0.470903 -2.08452, - 2.70861 -7.0291 -2.08452, - 2.70861 -7.0291 4.57136, - 2.70861 0.470903 4.57136, - 2.70861 0.470903 3.97136, - 2.70861 5.4709 2.37136, - 2.70861 5.4709 -4.42864, - 2.70861 -7.0291 -4.42864, - 2.70861 -7.0291 -2.68452, - 2.70861 0.470903 -2.68452 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 1, 2, 0, -1, - 0, 2, 3, -1, - 0, 3, 9, -1, - 9, 3, 4, -1, - 9, 4, 5, -1, - 9, 5, 6, -1, - 9, 6, 8, -1, - 8, 6, 7, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70861 5.4709 -4.42864, - 7.70861 -7.0291 -4.42864, - 2.70861 -7.0291 -4.42864, - 2.70861 5.4709 -4.42864 - ] - } - normal Normal { - vector [ - -0 -0 -1, - -0 -0 -1, - -0 -0 -1, - -0 -0 -1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.70861 5.4709 2.37136, - 7.70861 5.4709 2.37136, - 7.70861 5.4709 -4.42864, - 2.70861 5.4709 -4.42864, - 7.30774 5.4709 0.0415655, - 7.29165 5.4709 0.301008, - 7.24268 5.4709 0.56022, - 7.16161 5.4709 0.811248, - 7.04969 5.4709 1.05013, - 6.90872 5.4709 1.2731, - 6.7409 5.4709 1.47663, - 6.54889 5.4709 1.65752, - 6.33572 5.4709 1.81291, - 6.10474 5.4709 1.94035, - 5.85962 5.4709 2.03783, - 5.6042 5.4709 2.1038, - 5.34253 5.4709 2.13724, - 5.07873 5.4709 2.1376, - 4.81697 5.4709 2.10489, - 4.56138 5.4709 2.03962, - 4.31598 5.4709 1.94282, - 4.08466 5.4709 1.81602, - 3.87106 5.4709 1.66122, - 3.67855 5.4709 1.48086, - 3.51017 5.4709 1.27779, - 3.36858 5.4709 1.05521, - 3.25601 5.4709 0.816639, - 3.17424 5.4709 0.565835, - 3.12455 5.4709 0.306758, - 3.10774 5.4709 0.0434976, - 3.12407 5.4709 -0.219794, - 3.17327 5.4709 -0.478961, - 3.25458 5.4709 -0.729915, - 3.36671 5.4709 -0.968695, - 3.5079 5.4709 -1.19153, - 3.6759 5.4709 -1.39491, - 3.86808 5.4709 -1.57563, - 4.08139 5.4709 -1.73082, - 4.31249 5.4709 -1.85804, - 4.5577 5.4709 -1.95529, - 4.81318 5.4709 -2.02103, - 5.07488 5.4709 -2.05423, - 5.33867 5.4709 -2.05435, - 5.60041 5.4709 -2.0214, - 5.85594 5.4709 -1.95589, - 6.10125 5.4709 -1.85887, - 6.33245 5.4709 -1.73185, - 6.54591 5.4709 -1.57686, - 6.73826 5.4709 -1.39632, - 6.90645 5.4709 -1.1931, - 7.04784 5.4709 -0.970388, - 7.16019 5.4709 -0.731712, - 7.24173 5.4709 -0.480833, - 7.29117 5.4709 -0.221711, - 5.70774 5.4709 -3.52149, - 5.70712 5.4709 -3.49665, - 5.68399 5.4709 -3.36924, - 5.62892 5.4709 -3.25203, - 5.54559 5.4709 -3.1529, - 5.4396 5.4709 -3.0785, - 5.31805 5.4709 -3.03381, - 5.18911 5.4709 -3.02184, - 5.06141 5.4709 -3.04338, - 4.94353 5.4709 -3.097, - 4.84338 5.4709 -3.17909, - 4.76766 5.4709 -3.28415, - 4.72147 5.4709 -3.40513, - 4.70789 5.4709 -3.53392, - 4.72785 5.4709 -3.66187, - 4.78 5.4709 -3.78041, - 4.86084 5.4709 -3.88157, - 4.96495 5.4709 -3.95859, - 5.08534 5.4709 -4.00628, - 5.21395 5.4709 -4.02145, - 5.34214 5.4709 -4.00309, - 5.46132 5.4709 -3.95242, - 5.56348 5.4709 -3.87284, - 5.64178 5.4709 -3.7697, - 5.69097 5.4709 -3.6499 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 77, 2, 76, -1, - 76, 2, 75, -1, - 75, 2, 74, -1, - 74, 2, 73, -1, - 73, 2, 72, -1, - 72, 2, 3, -1, - 72, 3, 71, -1, - 71, 3, 70, -1, - 70, 3, 69, -1, - 23, 0, 22, -1, - 22, 0, 21, -1, - 21, 0, 20, -1, - 20, 0, 19, -1, - 19, 0, 18, -1, - 18, 0, 17, -1, - 23, 24, 0, -1, - 0, 24, 25, -1, - 0, 25, 26, -1, - 0, 26, 27, -1, - 0, 27, 28, -1, - 0, 28, 3, -1, - 3, 28, 29, -1, - 3, 29, 30, -1, - 3, 30, 31, -1, - 3, 31, 32, -1, - 3, 32, 33, -1, - 3, 33, 69, -1, - 69, 33, 34, -1, - 69, 34, 68, -1, - 68, 34, 35, -1, - 68, 35, 67, -1, - 67, 35, 36, -1, - 67, 36, 66, -1, - 66, 36, 37, -1, - 66, 37, 65, -1, - 65, 37, 38, -1, - 65, 38, 64, -1, - 64, 38, 39, -1, - 64, 39, 63, -1, - 63, 39, 40, -1, - 63, 40, 62, -1, - 62, 40, 41, -1, - 62, 41, 61, -1, - 61, 41, 42, -1, - 61, 42, 60, -1, - 60, 42, 43, -1, - 60, 43, 59, -1, - 59, 43, 44, -1, - 59, 44, 58, -1, - 58, 44, 45, -1, - 58, 45, 57, -1, - 57, 45, 46, -1, - 57, 46, 56, -1, - 56, 46, 47, -1, - 56, 47, 55, -1, - 55, 47, 48, -1, - 55, 48, 54, -1, - 54, 48, 49, -1, - 54, 49, 78, -1, - 78, 49, 50, -1, - 78, 50, 77, -1, - 77, 50, 2, -1, - 2, 50, 51, -1, - 2, 51, 52, -1, - 2, 52, 53, -1, - 2, 53, 1, -1, - 1, 53, 4, -1, - 9, 1, 8, -1, - 8, 1, 7, -1, - 7, 1, 6, -1, - 6, 1, 5, -1, - 5, 1, 4, -1, - 9, 10, 1, -1, - 1, 10, 11, -1, - 1, 11, 12, -1, - 1, 12, 13, -1, - 1, 13, 14, -1, - 1, 14, 15, -1, - 1, 15, 16, -1, - 1, 16, 0, -1, - 0, 16, 17, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 4.60774 -7.0291 4.57136, - 4.60774 -6.8291 4.57136, - 2.80861 -6.8291 4.57136, - 2.80861 0.270903 4.57136, - 7.60861 0.270903 4.57136, - 7.60861 -6.8291 4.57136, - 5.79989 -6.8291 4.57136, - 5.79989 -7.0291 4.57136, - 7.70861 -7.0291 4.57136, - 7.70861 0.470903 4.57136, - 2.70861 0.470903 4.57136, - 2.70861 -7.0291 4.57136 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 0, 1, 11, -1, - 11, 1, 2, -1, - 11, 2, 10, -1, - 10, 2, 3, -1, - 10, 3, 9, -1, - 9, 3, 4, -1, - 9, 4, 8, -1, - 8, 4, 5, -1, - 8, 5, 7, -1, - 7, 5, 6, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70861 5.4709 2.37136, - 7.70861 0.470903 3.97136, - 7.70861 0.470903 4.57136, - 7.70861 -7.0291 4.57136, - 7.70861 -7.0291 -4.42864, - 7.70861 5.4709 -4.42864 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 5, 0, 4, -1, - 4, 0, 1, -1, - 4, 1, 3, -1, - 3, 1, 2, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.70861 0.470903 3.97136, - 2.70861 0.470903 4.57136, - 7.70861 0.470903 4.57136, - 7.70861 0.470903 3.97136 - ] - } - normal Normal { - vector [ - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70861 5.4709 2.37136, - 2.70861 5.4709 2.37136, - 2.70861 0.470903 3.97136, - 7.70861 0.470903 3.97136 - ] - } - normal Normal { - vector [ - 0 0.304776 0.952424, - 0 0.304776 0.952424, - 0 0.304776 0.952424, - 0 0.304776 0.952424 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.80861 0.270903 4.57136, - 2.80861 -6.8291 4.57136, - 2.80861 -6.8291 -1.62864, - 2.80861 0.270903 -1.62864 - ] - } - normal Normal { - vector [ - 1 -0 -0, - 1 -0 -0, - 1 -0 -0, - 1 -0 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 4.60774 -6.8291 4.57136, - 4.60774 -6.8291 0.571357, - 4.62431 -6.8291 0.431304, - 4.67312 -6.8291 0.298989, - 4.75147 -6.8291 0.181722, - 4.85502 -6.8291 0.0859814, - 4.97806 -6.8291 0.0170575, - 5.11379 -6.8291 -0.0212421, - 5.25471 -6.8291 -0.0268015, - 5.39304 -6.8291 0.000686212, - 5.52113 -6.8291 0.0597029, - 5.6319 -6.8291 0.146988, - 5.71924 -6.8291 0.257719, - 5.77832 -6.8291 0.385777, - 5.80588 -6.8291 0.524089, - 5.80039 -6.8291 0.665012, - 5.79989 -6.8291 0.668089, - 5.79989 -6.8291 4.57136, - 7.60861 -6.8291 4.57136, - 7.60861 -6.8291 -1.62864, - 2.80861 -6.8291 -1.62864, - 2.80861 -6.8291 4.57136 - ] - } - normal Normal { - vector [ - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0 - ] - } - coordIndex [ - 21, 0, 20, -1, - 20, 0, 1, -1, - 20, 1, 2, -1, - 20, 2, 3, -1, - 20, 3, 4, -1, - 20, 4, 5, -1, - 20, 5, 19, -1, - 19, 5, 6, -1, - 19, 6, 7, -1, - 9, 19, 8, -1, - 8, 19, 7, -1, - 9, 10, 19, -1, - 19, 10, 11, -1, - 19, 11, 12, -1, - 19, 12, 13, -1, - 19, 13, 18, -1, - 18, 13, 14, -1, - 18, 14, 17, -1, - 17, 14, 15, -1, - 17, 15, 16, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.60861 -6.8291 4.57136, - 7.60861 0.270903 4.57136, - 7.60861 0.270903 -1.62864, - 7.60861 -6.8291 -1.62864 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -1 -0 -0, - -1 -0 -0, - -1 -0 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.55861 -6.7791 2.37136, - 7.55861 0.120903 2.37136, - 2.85861 0.120903 2.37136, - 2.85861 -6.7791 2.37136, - 6.70774 -3.94071 2.37136, - 6.70751 -3.9668 2.37136, - 6.68698 -4.18942 2.37136, - 6.63358 -4.40652 2.37136, - 6.54851 -4.61328 2.37136, - 6.43365 -4.80509 2.37136, - 6.29156 -4.9777 2.37136, - 6.12539 -5.12727 2.37136, - 5.93883 -5.25048 2.37136, - 5.73604 -5.3446 2.37136, - 5.52151 -5.40753 2.37136, - 5.3 -5.43787 2.37136, - 5.07645 -5.43495 2.37136, - 4.85582 -5.39884 2.37136, - 4.643 -5.33034 2.37136, - 4.44273 -5.23096 2.37136, - 4.25945 -5.10293 2.37136, - 4.09724 -4.94907 2.37136, - 3.9597 -4.77281 2.37136, - 3.84989 -4.57807 2.37136, - 3.77024 -4.36917 2.37136, - 3.72252 -4.15075 2.37136, - 3.7078 -3.92767 2.37136, - 3.7264 -3.70487 2.37136, - 3.7779 -3.48731 2.37136, - 3.86118 -3.27983 2.37136, - 3.97436 -3.08703 2.37136, - 4.11495 -2.91319 2.37136, - 4.27981 -2.76218 2.37136, - 4.46528 -2.63735 2.37136, - 4.66725 -2.54147 2.37136, - 4.88123 -2.47668 2.37136, - 5.10246 -2.44441 2.37136, - 5.32603 -2.44538 2.37136, - 5.54697 -2.47957 2.37136, - 5.76037 -2.54622 2.37136, - 5.9615 -2.64385 2.37136, - 6.14589 -2.77029 2.37136, - 6.30943 -2.92273 2.37136, - 6.4485 -3.09778 2.37136, - 6.56 -3.29156 2.37136, - 6.64147 -3.49976 2.37136, - 6.69108 -3.71776 2.37136 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 5, -1, - 5, 0, 4, -1, - 7, 8, 0, -1, - 0, 8, 9, -1, - 0, 9, 10, -1, - 0, 10, 11, -1, - 0, 11, 12, -1, - 0, 12, 3, -1, - 3, 12, 13, -1, - 3, 13, 14, -1, - 40, 1, 39, -1, - 39, 1, 38, -1, - 38, 1, 37, -1, - 37, 1, 36, -1, - 36, 1, 35, -1, - 35, 1, 34, -1, - 34, 1, 33, -1, - 40, 41, 1, -1, - 1, 41, 42, -1, - 1, 42, 43, -1, - 1, 43, 44, -1, - 1, 44, 45, -1, - 1, 45, 0, -1, - 0, 45, 46, -1, - 0, 46, 4, -1, - 27, 2, 26, -1, - 26, 2, 25, -1, - 25, 2, 3, -1, - 25, 3, 24, -1, - 24, 3, 23, -1, - 23, 3, 22, -1, - 22, 3, 21, -1, - 21, 3, 20, -1, - 20, 3, 19, -1, - 19, 3, 18, -1, - 18, 3, 17, -1, - 17, 3, 16, -1, - 16, 3, 15, -1, - 15, 3, 14, -1, - 27, 28, 2, -1, - 2, 28, 29, -1, - 2, 29, 30, -1, - 2, 30, 31, -1, - 2, 31, 32, -1, - 2, 32, 1, -1, - 1, 32, 33, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.60861 0.270903 4.57136, - 2.80861 0.270903 4.57136, - 2.80861 0.270903 -1.62864, - 7.60861 0.270903 -1.62864 - ] - } - normal Normal { - vector [ - -0 -1 0, - -0 -1 0, - -0 -1 0, - -0 -1 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.70774 -3.94071 -1.62864, - 6.69108 -3.71776 -1.62864, - 6.64147 -3.49976 -1.62864, - 6.56 -3.29156 -1.62864, - 6.4485 -3.09778 -1.62864, - 6.30943 -2.92273 -1.62864, - 6.14589 -2.77029 -1.62864, - 5.9615 -2.64385 -1.62864, - 5.76037 -2.54622 -1.62864, - 5.54697 -2.47957 -1.62864, - 5.32603 -2.44538 -1.62864, - 5.10246 -2.44441 -1.62864, - 4.88123 -2.47668 -1.62864, - 4.66725 -2.54147 -1.62864, - 4.46528 -2.63735 -1.62864, - 4.27981 -2.76218 -1.62864, - 4.11495 -2.91319 -1.62864, - 3.97436 -3.08703 -1.62864, - 3.86118 -3.27983 -1.62864, - 3.7779 -3.48731 -1.62864, - 3.7264 -3.70487 -1.62864, - 3.7078 -3.92767 -1.62864, - 3.72252 -4.15075 -1.62864, - 3.77024 -4.36917 -1.62864, - 3.84989 -4.57807 -1.62864, - 3.9597 -4.77281 -1.62864, - 4.09724 -4.94907 -1.62864, - 4.25945 -5.10293 -1.62864, - 4.44273 -5.23096 -1.62864, - 4.643 -5.33034 -1.62864, - 4.85582 -5.39884 -1.62864, - 5.07645 -5.43495 -1.62864, - 5.3 -5.43787 -1.62864, - 5.52151 -5.40753 -1.62864, - 5.73604 -5.3446 -1.62864, - 5.93883 -5.25048 -1.62864, - 6.12539 -5.12727 -1.62864, - 6.29156 -4.9777 -1.62864, - 6.43365 -4.80509 -1.62864, - 6.54851 -4.61328 -1.62864, - 6.63358 -4.40652 -1.62864, - 6.68698 -4.18942 -1.62864, - 6.70751 -3.9668 -1.62864 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 42, 0, 41, -1, - 41, 0, 40, -1, - 40, 0, 1, -1, - 40, 1, 39, -1, - 39, 1, 2, -1, - 39, 2, 38, -1, - 38, 2, 3, -1, - 38, 3, 37, -1, - 37, 3, 4, -1, - 37, 4, 36, -1, - 36, 4, 5, -1, - 36, 5, 35, -1, - 35, 5, 6, -1, - 35, 6, 34, -1, - 34, 6, 7, -1, - 34, 7, 33, -1, - 33, 7, 8, -1, - 33, 8, 32, -1, - 32, 8, 9, -1, - 32, 9, 31, -1, - 31, 9, 10, -1, - 31, 10, 30, -1, - 30, 10, 11, -1, - 30, 11, 29, -1, - 29, 11, 12, -1, - 29, 12, 28, -1, - 28, 12, 13, -1, - 28, 13, 27, -1, - 27, 13, 14, -1, - 27, 14, 26, -1, - 26, 14, 15, -1, - 26, 15, 25, -1, - 25, 15, 16, -1, - 25, 16, 24, -1, - 24, 16, 17, -1, - 24, 17, 23, -1, - 23, 17, 18, -1, - 23, 18, 22, -1, - 22, 18, 19, -1, - 22, 19, 21, -1, - 21, 19, 20, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 6.70774 -3.94071 -1.62864, - 6.69108 -3.71776 -1.62864, - 6.64147 -3.49976 -1.62864, - 6.56 -3.29156 -1.62864, - 6.4485 -3.09778 -1.62864, - 6.30943 -2.92273 -1.62864, - 6.14589 -2.77029 -1.62864, - 5.9615 -2.64385 -1.62864, - 5.76037 -2.54622 -1.62864, - 5.54697 -2.47957 -1.62864, - 5.32603 -2.44538 -1.62864, - 5.10246 -2.44441 -1.62864, - 4.88123 -2.47668 -1.62864, - 4.66725 -2.54147 -1.62864, - 4.46528 -2.63735 -1.62864, - 4.27981 -2.76218 -1.62864, - 4.11495 -2.91319 -1.62864, - 3.97436 -3.08703 -1.62864, - 3.86118 -3.27983 -1.62864, - 3.7779 -3.48731 -1.62864, - 3.7264 -3.70487 -1.62864, - 3.7078 -3.92767 -1.62864, - 3.72252 -4.15075 -1.62864, - 3.77024 -4.36917 -1.62864, - 3.84989 -4.57807 -1.62864, - 3.9597 -4.77281 -1.62864, - 4.09724 -4.94907 -1.62864, - 4.25945 -5.10293 -1.62864, - 4.44273 -5.23096 -1.62864, - 4.643 -5.33034 -1.62864, - 4.85582 -5.39884 -1.62864, - 5.07645 -5.43495 -1.62864, - 5.3 -5.43787 -1.62864, - 5.52151 -5.40753 -1.62864, - 5.73604 -5.3446 -1.62864, - 5.93883 -5.25048 -1.62864, - 6.12539 -5.12727 -1.62864, - 6.29156 -4.9777 -1.62864, - 6.43365 -4.80509 -1.62864, - 6.54851 -4.61328 -1.62864, - 6.63358 -4.40652 -1.62864, - 6.68698 -4.18942 -1.62864, - 6.70751 -3.9668 -1.62864, - 6.70774 -3.94071 -1.62864, - 6.70774 -3.94071 2.37136, - 6.70751 -3.9668 2.37136, - 6.68698 -4.18942 2.37136, - 6.63358 -4.40652 2.37136, - 6.54851 -4.61328 2.37136, - 6.43365 -4.80509 2.37136, - 6.29156 -4.9777 2.37136, - 6.12539 -5.12727 2.37136, - 5.93883 -5.25048 2.37136, - 5.73604 -5.3446 2.37136, - 5.52151 -5.40753 2.37136, - 5.3 -5.43787 2.37136, - 5.07645 -5.43495 2.37136, - 4.85582 -5.39884 2.37136, - 4.643 -5.33034 2.37136, - 4.44273 -5.23096 2.37136, - 4.25945 -5.10293 2.37136, - 4.09724 -4.94907 2.37136, - 3.9597 -4.77281 2.37136, - 3.84989 -4.57807 2.37136, - 3.77024 -4.36917 2.37136, - 3.72252 -4.15075 2.37136, - 3.7078 -3.92767 2.37136, - 3.7264 -3.70487 2.37136, - 3.7779 -3.48731 2.37136, - 3.86118 -3.27983 2.37136, - 3.97436 -3.08703 2.37136, - 4.11495 -2.91319 2.37136, - 4.27981 -2.76218 2.37136, - 4.46528 -2.63735 2.37136, - 4.66725 -2.54147 2.37136, - 4.88123 -2.47668 2.37136, - 5.10246 -2.44441 2.37136, - 5.32603 -2.44538 2.37136, - 5.54697 -2.47957 2.37136, - 5.76037 -2.54622 2.37136, - 5.9615 -2.64385 2.37136, - 6.14589 -2.77029 2.37136, - 6.30943 -2.92273 2.37136, - 6.4485 -3.09778 2.37136, - 6.56 -3.29156 2.37136, - 6.64147 -3.49976 2.37136, - 6.69108 -3.71776 2.37136, - 6.70774 -3.94071 2.37136 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.988892 -0.148633 -0, - -0.955817 -0.293964 -0, - -0.901507 -0.432764 -0, - -0.827171 -0.561951 -0, - -0.734459 -0.678653 -0, - -0.62543 -0.78028 -0, - -0.502508 -0.864572 -0, - -0.368423 -0.929658 -0, - -0.226153 -0.974092 -0, - -0.078859 -0.996886 -0, - 0.0701868 -0.997534 -0, - 0.217673 -0.976022 -0, - 0.360324 -0.932827 -0, - 0.494971 -0.86891 -0, - 0.618621 -0.785689 -0, - 0.728529 -0.685015 -0, - 0.822253 -0.569123 -0, - 0.89771 -0.440587 -0, - 0.953224 -0.302265 -0, - 0.987563 -0.157227 -0, - 0.999962 -0.00869623 -0, - 0.990148 0.140028 0, - 0.958337 0.285641 0, - 0.905237 0.424908 0, - 0.832026 0.554736 0, - 0.740333 0.672241 0, - 0.632192 0.774812 0, - 0.510008 0.86017 0, - 0.376493 0.926419 0, - 0.234615 0.972088 0, - 0.0875251 0.996162 0, - -0.0615094 0.998106 -0, - -0.209178 0.977878 -0, - -0.352199 0.935925 -0, - -0.487396 0.873181 -0, - -0.611765 0.791039 -0, - -0.722545 0.691324 -0, - -0.817272 0.576252 -0, - -0.893844 0.448377 -0, - -0.950559 0.310543 -0, - -0.986158 0.165809 -0, - -0.999849 0.0173918 -0, - -1 2.44921e-016 -0, - -1 2.44921e-016 -0, - -0.999849 0.0173918 -0, - -0.986158 0.165809 -0, - -0.950559 0.310543 -0, - -0.893844 0.448377 -0, - -0.817272 0.576252 -0, - -0.722545 0.691324 -0, - -0.611765 0.791039 -0, - -0.487396 0.873181 -0, - -0.352199 0.935925 -0, - -0.209178 0.977878 -0, - -0.0615094 0.998106 -0, - 0.0875251 0.996162 0, - 0.234615 0.972088 0, - 0.376493 0.926419 0, - 0.510008 0.86017 0, - 0.632192 0.774812 0, - 0.740333 0.672241 0, - 0.832026 0.554736 0, - 0.905237 0.424908 0, - 0.958337 0.285641 0, - 0.990148 0.140028 0, - 0.999962 -0.00869623 -0, - 0.987563 -0.157227 -0, - 0.953224 -0.302265 -0, - 0.89771 -0.440587 -0, - 0.822253 -0.569123 -0, - 0.728529 -0.685015 -0, - 0.618621 -0.785689 -0, - 0.494971 -0.86891 -0, - 0.360324 -0.932827 -0, - 0.217673 -0.976022 -0, - 0.0701868 -0.997534 -0, - -0.078859 -0.996886 -0, - -0.226153 -0.974092 -0, - -0.368423 -0.929658 -0, - -0.502508 -0.864572 -0, - -0.62543 -0.78028 -0, - -0.734459 -0.678653 -0, - -0.827171 -0.561951 -0, - -0.901507 -0.432764 -0, - -0.955817 -0.293964 -0, - -0.988892 -0.148633 -0, - -1 -0 -0 - ] - } - coordIndex [ - 45, 44, 43, -1, - 45, 43, 42, -1, - 45, 42, 46, -1, - 46, 42, 41, -1, - 46, 41, 47, -1, - 47, 41, 40, -1, - 47, 40, 48, -1, - 48, 40, 39, -1, - 48, 39, 49, -1, - 49, 39, 38, -1, - 49, 38, 50, -1, - 50, 38, 37, -1, - 50, 37, 51, -1, - 51, 37, 36, -1, - 51, 36, 52, -1, - 52, 36, 35, -1, - 52, 35, 53, -1, - 53, 35, 34, -1, - 53, 34, 54, -1, - 54, 34, 33, -1, - 54, 33, 55, -1, - 55, 33, 32, -1, - 55, 32, 56, -1, - 56, 32, 31, -1, - 56, 31, 57, -1, - 57, 31, 30, -1, - 57, 30, 58, -1, - 58, 30, 29, -1, - 58, 29, 59, -1, - 59, 29, 28, -1, - 59, 28, 60, -1, - 60, 28, 27, -1, - 60, 27, 61, -1, - 61, 27, 26, -1, - 61, 26, 62, -1, - 62, 26, 25, -1, - 62, 25, 63, -1, - 63, 25, 24, -1, - 63, 24, 64, -1, - 64, 24, 23, -1, - 64, 23, 65, -1, - 65, 23, 22, -1, - 65, 22, 66, -1, - 66, 22, 21, -1, - 66, 21, 67, -1, - 67, 21, 20, -1, - 67, 20, 68, -1, - 68, 20, 19, -1, - 68, 19, 69, -1, - 69, 19, 18, -1, - 69, 18, 70, -1, - 70, 18, 17, -1, - 70, 17, 71, -1, - 71, 17, 16, -1, - 71, 16, 72, -1, - 72, 16, 15, -1, - 72, 15, 73, -1, - 73, 15, 14, -1, - 73, 14, 74, -1, - 74, 14, 13, -1, - 74, 13, 75, -1, - 75, 13, 12, -1, - 75, 12, 76, -1, - 76, 12, 11, -1, - 76, 11, 77, -1, - 77, 11, 10, -1, - 77, 10, 78, -1, - 78, 10, 9, -1, - 78, 9, 79, -1, - 79, 9, 8, -1, - 79, 8, 80, -1, - 80, 8, 7, -1, - 80, 7, 81, -1, - 81, 7, 6, -1, - 81, 6, 82, -1, - 82, 6, 5, -1, - 82, 5, 83, -1, - 83, 5, 4, -1, - 83, 4, 84, -1, - 84, 4, 3, -1, - 84, 3, 85, -1, - 85, 3, 2, -1, - 85, 2, 86, -1, - 86, 2, 1, -1, - 86, 1, 87, -1, - 87, 1, 0, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.60861 0.270903 -1.62864, - 2.80861 0.270903 -1.62864, - 2.80861 -6.8291 -1.62864, - 7.60861 -6.8291 -1.62864, - 7.55861 0.120903 -1.62864, - 7.55861 -6.7791 -1.62864, - 2.85861 -6.7791 -1.62864, - 2.85861 0.120903 -1.62864 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 5, 6, 2, -1, - 2, 6, 1, -1, - 1, 6, 7, -1, - 1, 7, 0, -1, - 0, 7, 4, -1, - 0, 4, 3, -1, - 3, 4, 5, -1, - 3, 5, 2, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.55861 -6.7791 2.37136, - 2.85861 -6.7791 2.37136, - 2.85861 -6.7791 -1.62864, - 7.55861 -6.7791 -1.62864, - 5.80774 -6.7791 0.571357, - 5.79577 -6.7791 0.452085, - 5.75209 -6.7791 0.319009, - 5.67876 -6.7791 0.199684, - 5.57976 -6.7791 0.100611, - 5.46049 -6.7791 0.0271893, - 5.32745 -6.7791 -0.016581, - 5.18788 -6.7791 -0.0283145, - 5.0494 -6.7791 -0.00737186, - 4.91954 -6.7791 0.0451055, - 4.80539 -6.7791 0.126258, - 4.71316 -6.7791 0.231665, - 4.64788 -6.7791 0.355581, - 4.61311 -6.7791 0.491254, - 4.61074 -6.7791 0.631293, - 4.6409 -6.7791 0.768065, - 4.70195 -6.7791 0.894119, - 4.79056 -6.7791 1.00259, - 4.9019 -6.7791 1.08755, - 5.0299 -6.7791 1.1444, - 5.1676 -6.7791 1.17001, - 5.30748 -6.7791 1.16301, - 5.44193 -6.7791 1.12377, - 5.56362 -6.7791 1.05442, - 5.66591 -6.7791 0.958755, - 5.74324 -6.7791 0.84198, - 5.79139 -6.7791 0.710458 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 11, 12, 2, -1, - 2, 12, 13, -1, - 2, 13, 14, -1, - 2, 14, 15, -1, - 2, 15, 1, -1, - 1, 15, 16, -1, - 1, 16, 17, -1, - 1, 17, 18, -1, - 1, 18, 19, -1, - 1, 19, 20, -1, - 1, 20, 21, -1, - 1, 21, 22, -1, - 1, 22, 0, -1, - 0, 22, 23, -1, - 0, 23, 24, -1, - 0, 24, 25, -1, - 0, 25, 26, -1, - 0, 26, 27, -1, - 0, 27, 28, -1, - 0, 28, 3, -1, - 3, 28, 29, -1, - 11, 2, 10, -1, - 10, 2, 9, -1, - 9, 2, 8, -1, - 8, 2, 3, -1, - 8, 3, 7, -1, - 7, 3, 6, -1, - 6, 3, 5, -1, - 5, 3, 4, -1, - 4, 3, 30, -1, - 30, 3, 29, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.85861 0.120903 2.37136, - 7.55861 0.120903 2.37136, - 7.55861 0.120903 -1.62864, - 2.85861 0.120903 -1.62864 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.55861 0.120903 2.37136, - 7.55861 -6.7791 2.37136, - 7.55861 -6.7791 -1.62864, - 7.55861 0.120903 -1.62864 - ] - } - normal Normal { - vector [ - 1 3.9968e-013 -0, - 1 3.9968e-013 -0, - 1 3.9968e-013 -0, - 1 3.9968e-013 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.85861 -6.7791 2.37136, - 2.85861 0.120903 2.37136, - 2.85861 0.120903 -1.62864, - 2.85861 -6.7791 -1.62864 - ] - } - normal Normal { - vector [ - -1 1.28979e-013 0, - -1 1.28979e-013 0, - -1 1.28979e-013 0, - -1 1.28979e-013 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 5.70774 3.4709 -3.52149, - 5.69097 3.4709 -3.6499, - 5.64178 3.4709 -3.7697, - 5.56348 3.4709 -3.87284, - 5.46132 3.4709 -3.95242, - 5.34214 3.4709 -4.00309, - 5.21395 3.4709 -4.02145, - 5.08534 3.4709 -4.00628, - 4.96495 3.4709 -3.95859, - 4.86084 3.4709 -3.88157, - 4.78 3.4709 -3.78041, - 4.72785 3.4709 -3.66187, - 4.70789 3.4709 -3.53392, - 4.72147 3.4709 -3.40513, - 4.76766 3.4709 -3.28415, - 4.84338 3.4709 -3.17909, - 4.94353 3.4709 -3.097, - 5.06141 3.4709 -3.04338, - 5.18911 3.4709 -3.02184, - 5.31805 3.4709 -3.03381, - 5.4396 3.4709 -3.0785, - 5.54559 3.4709 -3.1529, - 5.62892 3.4709 -3.25203, - 5.68399 3.4709 -3.36924, - 5.70712 3.4709 -3.49665, - 5.70774 3.4709 -3.52149, - 5.70774 5.4709 -3.52149, - 5.70712 5.4709 -3.49665, - 5.68399 5.4709 -3.36924, - 5.62892 5.4709 -3.25203, - 5.54559 5.4709 -3.1529, - 5.4396 5.4709 -3.0785, - 5.31805 5.4709 -3.03381, - 5.18911 5.4709 -3.02184, - 5.06141 5.4709 -3.04338, - 4.94353 5.4709 -3.097, - 4.84338 5.4709 -3.17909, - 4.76766 5.4709 -3.28415, - 4.72147 5.4709 -3.40513, - 4.70789 5.4709 -3.53392, - 4.72785 5.4709 -3.66187, - 4.78 5.4709 -3.78041, - 4.86084 5.4709 -3.88157, - 4.96495 5.4709 -3.95859, - 5.08534 5.4709 -4.00628, - 5.21395 5.4709 -4.02145, - 5.34214 5.4709 -4.00309, - 5.46132 5.4709 -3.95242, - 5.56348 5.4709 -3.87284, - 5.64178 5.4709 -3.7697, - 5.69097 5.4709 -3.6499, - 5.70774 5.4709 -3.52149 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.96646 -0 0.256818, - -0.868089 -0 0.496409, - -0.711486 -0 0.7027, - -0.507156 -0 0.861854, - -0.268806 -0 0.963194, - -0.012424 -0 0.999923, - 0.244791 -0 0.969576, - 0.485586 -0 0.874189, - 0.693807 -0 0.720161, - 0.855487 -0 0.517824, - 0.95978 -0 0.280752, - 0.999691 -0 0.024846, - 0.972542 0 -0.232726, - 0.880154 0 -0.474687, - 0.728725 0 -0.684806, - 0.528413 0 -0.848987, - 0.292654 0 -0.956218, - 0.0372642 0 -0.999305, - -0.220626 -0 -0.975359, - -0.463716 -0 -0.885984, - -0.675699 -0 -0.737177, - -0.842357 -0 -0.53892, - -0.952509 -0 -0.304512, - -0.998765 -0 -0.0496767, - -1 -0 -2.44921e-016, - -1 -0 -2.44921e-016, - -0.998765 -0 -0.0496767, - -0.952509 -0 -0.304512, - -0.842357 -0 -0.53892, - -0.675699 -0 -0.737177, - -0.463716 -0 -0.885984, - -0.220626 -0 -0.975359, - 0.0372642 0 -0.999305, - 0.292654 0 -0.956218, - 0.528413 0 -0.848987, - 0.728725 0 -0.684806, - 0.880154 0 -0.474687, - 0.972542 0 -0.232726, - 0.999691 -0 0.024846, - 0.95978 -0 0.280752, - 0.855487 -0 0.517824, - 0.693807 -0 0.720161, - 0.485586 -0 0.874189, - 0.244791 -0 0.969576, - -0.012424 -0 0.999923, - -0.268806 -0 0.963194, - -0.507156 -0 0.861854, - -0.711486 -0 0.7027, - -0.868089 -0 0.496409, - -0.96646 -0 0.256818, - -1 -0 -0 - ] - } - coordIndex [ - 27, 26, 25, -1, - 27, 25, 24, -1, - 27, 24, 28, -1, - 28, 24, 23, -1, - 28, 23, 29, -1, - 29, 23, 22, -1, - 29, 22, 30, -1, - 30, 22, 21, -1, - 30, 21, 31, -1, - 31, 21, 20, -1, - 31, 20, 32, -1, - 32, 20, 19, -1, - 32, 19, 33, -1, - 33, 19, 18, -1, - 33, 18, 34, -1, - 34, 18, 17, -1, - 34, 17, 35, -1, - 35, 17, 16, -1, - 35, 16, 36, -1, - 36, 16, 15, -1, - 36, 15, 37, -1, - 37, 15, 14, -1, - 37, 14, 38, -1, - 38, 14, 13, -1, - 38, 13, 39, -1, - 39, 13, 12, -1, - 39, 12, 40, -1, - 40, 12, 11, -1, - 40, 11, 41, -1, - 41, 11, 10, -1, - 41, 10, 42, -1, - 42, 10, 9, -1, - 42, 9, 43, -1, - 43, 9, 8, -1, - 43, 8, 44, -1, - 44, 8, 7, -1, - 44, 7, 45, -1, - 45, 7, 6, -1, - 45, 6, 46, -1, - 46, 6, 5, -1, - 46, 5, 47, -1, - 47, 5, 4, -1, - 47, 4, 48, -1, - 48, 4, 3, -1, - 48, 3, 49, -1, - 49, 3, 2, -1, - 49, 2, 50, -1, - 50, 2, 1, -1, - 50, 1, 51, -1, - 51, 1, 0, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.30774 3.4709 0.0415655, - 7.29117 3.4709 -0.221711, - 7.24173 3.4709 -0.480833, - 7.16019 3.4709 -0.731712, - 7.04784 3.4709 -0.970388, - 6.90645 3.4709 -1.1931, - 6.73826 3.4709 -1.39632, - 6.54591 3.4709 -1.57686, - 6.33245 3.4709 -1.73185, - 6.10125 3.4709 -1.85887, - 5.85594 3.4709 -1.95589, - 5.60041 3.4709 -2.0214, - 5.33867 3.4709 -2.05435, - 5.07488 3.4709 -2.05423, - 4.81318 3.4709 -2.02103, - 4.5577 3.4709 -1.95529, - 4.31249 3.4709 -1.85804, - 4.08139 3.4709 -1.73082, - 3.86808 3.4709 -1.57563, - 3.6759 3.4709 -1.39491, - 3.5079 3.4709 -1.19153, - 3.36671 3.4709 -0.968695, - 3.25458 3.4709 -0.729915, - 3.17327 3.4709 -0.478961, - 3.12407 3.4709 -0.219794, - 3.10774 3.4709 0.0434976, - 3.12455 3.4709 0.306758, - 3.17424 3.4709 0.565835, - 3.25601 3.4709 0.816639, - 3.36858 3.4709 1.05521, - 3.51017 3.4709 1.27779, - 3.67855 3.4709 1.48086, - 3.87106 3.4709 1.66122, - 4.08466 3.4709 1.81602, - 4.31598 3.4709 1.94282, - 4.56138 3.4709 2.03962, - 4.81697 3.4709 2.10489, - 5.07873 3.4709 2.1376, - 5.34253 3.4709 2.13724, - 5.6042 3.4709 2.1038, - 5.85962 3.4709 2.03783, - 6.10474 3.4709 1.94035, - 6.33572 3.4709 1.81291, - 6.54889 3.4709 1.65752, - 6.7409 3.4709 1.47663, - 6.90872 3.4709 1.2731, - 7.04969 3.4709 1.05013, - 7.16161 3.4709 0.811248, - 7.24268 3.4709 0.56022, - 7.29165 3.4709 0.301008, - 7.26955 3.4709 0.0415655, - 7.26015 3.4709 0.238245, - 7.21904 3.4709 0.495165, - 7.14589 3.4709 0.744862, - 7.04188 3.4709 0.983359, - 6.90867 3.4709 1.20686, - 6.74836 3.4709 1.4118, - 6.56352 3.4709 1.59492, - 6.35709 3.4709 1.7533, - 6.13236 3.4709 1.88443, - 5.8929 3.4709 1.9862, - 5.64253 3.4709 2.05701, - 5.38524 3.4709 2.09572, - 5.12512 3.4709 2.10172, - 4.86631 3.4709 2.07491, - 4.61295 3.4709 2.01572, - 4.36905 3.4709 1.92509, - 4.13851 3.4709 1.80446, - 3.925 3.4709 1.65577, - 3.73192 3.4709 1.48136, - 3.56234 3.4709 1.28403, - 3.41896 3.4709 1.06691, - 3.30407 3.4709 0.833456, - 3.21949 3.4709 0.587396, - 3.16658 3.4709 0.332644, - 3.14617 3.4709 0.0732561, - 3.1586 3.4709 -0.186637, - 3.20366 3.4709 -0.442895, - 3.28063 3.4709 -0.691438, - 3.38829 3.4709 -0.928309, - 3.52493 3.4709 -1.14973, - 3.68836 3.4709 -1.35219, - 3.87599 3.4709 -1.53244, - 4.08483 3.4709 -1.68764, - 4.31155 3.4709 -1.81529, - 4.55255 3.4709 -1.91337, - 4.80398 3.4709 -1.98032, - 5.06184 3.4709 -2.01508, - 5.32202 3.4709 -2.01708, - 5.58038 3.4709 -1.98629, - 5.83281 3.4709 -1.92321, - 6.07528 3.4709 -1.82884, - 6.30394 3.4709 -1.70469, - 6.51514 3.4709 -1.55273, - 6.70552 3.4709 -1.37538, - 6.87205 3.4709 -1.17546, - 7.01207 3.4709 -0.95616, - 7.12336 3.4709 -0.720972, - 7.20414 3.4709 -0.473641, - 7.25313 3.4709 -0.218106 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 49, 0, 48, -1, - 48, 0, 1, -1, - 48, 1, 51, -1, - 51, 1, 50, -1, - 50, 1, 99, -1, - 51, 52, 48, -1, - 48, 52, 47, -1, - 47, 52, 53, -1, - 47, 53, 46, -1, - 46, 53, 54, -1, - 46, 54, 45, -1, - 45, 54, 55, -1, - 45, 55, 44, -1, - 44, 55, 56, -1, - 44, 56, 43, -1, - 43, 56, 57, -1, - 43, 57, 42, -1, - 42, 57, 58, -1, - 42, 58, 41, -1, - 41, 58, 59, -1, - 41, 59, 40, -1, - 40, 59, 60, -1, - 40, 60, 39, -1, - 39, 60, 61, -1, - 39, 61, 38, -1, - 38, 61, 62, -1, - 38, 62, 37, -1, - 37, 62, 63, -1, - 37, 63, 36, -1, - 36, 63, 64, -1, - 36, 64, 35, -1, - 35, 64, 65, -1, - 35, 65, 34, -1, - 34, 65, 66, -1, - 34, 66, 33, -1, - 33, 66, 67, -1, - 33, 67, 32, -1, - 32, 67, 68, -1, - 32, 68, 31, -1, - 31, 68, 69, -1, - 31, 69, 30, -1, - 30, 69, 70, -1, - 30, 70, 29, -1, - 29, 70, 71, -1, - 29, 71, 28, -1, - 28, 71, 72, -1, - 28, 72, 27, -1, - 27, 72, 73, -1, - 27, 73, 26, -1, - 26, 73, 74, -1, - 26, 74, 25, -1, - 25, 74, 75, -1, - 25, 75, 24, -1, - 24, 75, 76, -1, - 24, 76, 23, -1, - 23, 76, 77, -1, - 23, 77, 22, -1, - 22, 77, 78, -1, - 22, 78, 21, -1, - 21, 78, 79, -1, - 21, 79, 20, -1, - 20, 79, 80, -1, - 20, 80, 19, -1, - 19, 80, 81, -1, - 19, 81, 18, -1, - 18, 81, 82, -1, - 18, 82, 17, -1, - 17, 82, 83, -1, - 17, 83, 16, -1, - 16, 83, 84, -1, - 16, 84, 15, -1, - 15, 84, 85, -1, - 15, 85, 14, -1, - 14, 85, 86, -1, - 14, 86, 13, -1, - 13, 86, 87, -1, - 13, 87, 12, -1, - 12, 87, 88, -1, - 12, 88, 11, -1, - 11, 88, 89, -1, - 11, 89, 10, -1, - 10, 89, 90, -1, - 10, 90, 9, -1, - 9, 90, 91, -1, - 9, 91, 8, -1, - 8, 91, 92, -1, - 8, 92, 7, -1, - 7, 92, 93, -1, - 7, 93, 6, -1, - 6, 93, 94, -1, - 6, 94, 5, -1, - 5, 94, 95, -1, - 5, 95, 4, -1, - 4, 95, 96, -1, - 4, 96, 3, -1, - 3, 96, 97, -1, - 3, 97, 2, -1, - 2, 97, 98, -1, - 2, 98, 1, -1, - 1, 98, 99, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 5.70774 3.4709 -3.52149, - 5.69097 3.4709 -3.6499, - 5.64178 3.4709 -3.7697, - 5.56348 3.4709 -3.87284, - 5.46132 3.4709 -3.95242, - 5.34214 3.4709 -4.00309, - 5.21395 3.4709 -4.02145, - 5.08534 3.4709 -4.00628, - 4.96495 3.4709 -3.95859, - 4.86084 3.4709 -3.88157, - 4.78 3.4709 -3.78041, - 4.72785 3.4709 -3.66187, - 4.70789 3.4709 -3.53392, - 4.72147 3.4709 -3.40513, - 4.76766 3.4709 -3.28415, - 4.84338 3.4709 -3.17909, - 4.94353 3.4709 -3.097, - 5.06141 3.4709 -3.04338, - 5.18911 3.4709 -3.02184, - 5.31805 3.4709 -3.03381, - 5.4396 3.4709 -3.0785, - 5.54559 3.4709 -3.1529, - 5.62892 3.4709 -3.25203, - 5.68399 3.4709 -3.36924, - 5.70712 3.4709 -3.49665 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 24, 0, 23, -1, - 23, 0, 1, -1, - 23, 1, 22, -1, - 22, 1, 2, -1, - 22, 2, 21, -1, - 21, 2, 3, -1, - 21, 3, 20, -1, - 20, 3, 4, -1, - 20, 4, 19, -1, - 19, 4, 5, -1, - 19, 5, 18, -1, - 18, 5, 6, -1, - 18, 6, 17, -1, - 17, 6, 7, -1, - 17, 7, 16, -1, - 16, 7, 8, -1, - 16, 8, 15, -1, - 15, 8, 9, -1, - 15, 9, 14, -1, - 14, 9, 10, -1, - 14, 10, 13, -1, - 13, 10, 11, -1, - 13, 11, 12, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.30774 3.4709 0.0415655, - 7.29117 3.4709 -0.221711, - 7.24173 3.4709 -0.480833, - 7.16019 3.4709 -0.731712, - 7.04784 3.4709 -0.970388, - 6.90645 3.4709 -1.1931, - 6.73826 3.4709 -1.39632, - 6.54591 3.4709 -1.57686, - 6.33245 3.4709 -1.73185, - 6.10125 3.4709 -1.85887, - 5.85594 3.4709 -1.95589, - 5.60041 3.4709 -2.0214, - 5.33867 3.4709 -2.05435, - 5.07488 3.4709 -2.05423, - 4.81318 3.4709 -2.02103, - 4.5577 3.4709 -1.95529, - 4.31249 3.4709 -1.85804, - 4.08139 3.4709 -1.73082, - 3.86808 3.4709 -1.57563, - 3.6759 3.4709 -1.39491, - 3.5079 3.4709 -1.19153, - 3.36671 3.4709 -0.968695, - 3.25458 3.4709 -0.729915, - 3.17327 3.4709 -0.478961, - 3.12407 3.4709 -0.219794, - 3.10774 3.4709 0.0434976, - 3.12455 3.4709 0.306758, - 3.17424 3.4709 0.565835, - 3.25601 3.4709 0.816639, - 3.36858 3.4709 1.05521, - 3.51017 3.4709 1.27779, - 3.67855 3.4709 1.48086, - 3.87106 3.4709 1.66122, - 4.08466 3.4709 1.81602, - 4.31598 3.4709 1.94282, - 4.56138 3.4709 2.03962, - 4.81697 3.4709 2.10489, - 5.07873 3.4709 2.1376, - 5.34253 3.4709 2.13724, - 5.6042 3.4709 2.1038, - 5.85962 3.4709 2.03783, - 6.10474 3.4709 1.94035, - 6.33572 3.4709 1.81291, - 6.54889 3.4709 1.65752, - 6.7409 3.4709 1.47663, - 6.90872 3.4709 1.2731, - 7.04969 3.4709 1.05013, - 7.16161 3.4709 0.811248, - 7.24268 3.4709 0.56022, - 7.29165 3.4709 0.301008, - 7.30774 3.4709 0.0415655, - 7.30774 5.4709 0.0415655, - 7.29165 5.4709 0.301008, - 7.24268 5.4709 0.56022, - 7.16161 5.4709 0.811248, - 7.04969 5.4709 1.05013, - 6.90872 5.4709 1.2731, - 6.7409 5.4709 1.47663, - 6.54889 5.4709 1.65752, - 6.33572 5.4709 1.81291, - 6.10474 5.4709 1.94035, - 5.85962 5.4709 2.03783, - 5.6042 5.4709 2.1038, - 5.34253 5.4709 2.13724, - 5.07873 5.4709 2.1376, - 4.81697 5.4709 2.10489, - 4.56138 5.4709 2.03962, - 4.31598 5.4709 1.94282, - 4.08466 5.4709 1.81602, - 3.87106 5.4709 1.66122, - 3.67855 5.4709 1.48086, - 3.51017 5.4709 1.27779, - 3.36858 5.4709 1.05521, - 3.25601 5.4709 0.816639, - 3.17424 5.4709 0.565835, - 3.12455 5.4709 0.306758, - 3.10774 5.4709 0.0434976, - 3.12407 5.4709 -0.219794, - 3.17327 5.4709 -0.478961, - 3.25458 5.4709 -0.729915, - 3.36671 5.4709 -0.968695, - 3.5079 5.4709 -1.19153, - 3.6759 5.4709 -1.39491, - 3.86808 5.4709 -1.57563, - 4.08139 5.4709 -1.73082, - 4.31249 5.4709 -1.85804, - 4.5577 5.4709 -1.95529, - 4.81318 5.4709 -2.02103, - 5.07488 5.4709 -2.05423, - 5.33867 5.4709 -2.05435, - 5.60041 5.4709 -2.0214, - 5.85594 5.4709 -1.95589, - 6.10125 5.4709 -1.85887, - 6.33245 5.4709 -1.73185, - 6.54591 5.4709 -1.57686, - 6.73826 5.4709 -1.39632, - 6.90645 5.4709 -1.1931, - 7.04784 5.4709 -0.970388, - 7.16019 5.4709 -0.731712, - 7.24173 5.4709 -0.480833, - 7.29117 5.4709 -0.221711, - 7.30774 5.4709 0.0415655 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.99211 -0 0.12537, - -0.968565 -0 0.248761, - -0.929736 -0 0.368227, - -0.876236 -0 0.481883, - -0.808909 -0 0.587934, - -0.728817 -0 0.684708, - -0.637225 -0 0.770677, - -0.535578 -0 0.844486, - -0.42548 -0 0.904968, - -0.308667 -0 0.95117, - -0.186984 -0 0.982363, - -0.0623498 -0 0.998054, - 0.063268 -0 0.997997, - 0.187887 -0 0.982191, - 0.309542 -0 0.950886, - 0.426312 -0 0.904576, - 0.536355 -0 0.843993, - 0.637934 -0 0.770091, - 0.729447 -0 0.684037, - 0.809449 -0 0.58719, - 0.876679 -0 0.481076, - 0.930074 -0 0.367372, - 0.968793 -0 0.24787, - 0.992225 -0 0.124457, - 1 0 -0.000920056, - 0.991994 0 -0.126282, - 0.968336 0 -0.249652, - 0.929397 0 -0.369082, - 0.875792 0 -0.482689, - 0.808368 0 -0.588678, - 0.728187 0 -0.685378, - 0.636516 0 -0.771263, - 0.534801 0 -0.844978, - 0.424647 0 -0.905359, - 0.307792 0 -0.951454, - 0.18608 0 -0.982535, - 0.0614315 0 -0.998111, - -0.0641862 -0 -0.997938, - -0.188791 -0 -0.982017, - -0.310417 -0 -0.950601, - -0.427144 -0 -0.904184, - -0.537131 -0 -0.843499, - -0.638643 -0 -0.769504, - -0.730076 -0 -0.683366, - -0.809989 -0 -0.586445, - -0.877121 -0 -0.480269, - -0.930412 -0 -0.366516, - -0.969021 -0 -0.246978, - -0.992339 -0 -0.123544, - -1 -0 -2.44921e-016, - -1 -0 -2.44921e-016, - -0.992339 -0 -0.123544, - -0.969021 -0 -0.246978, - -0.930412 -0 -0.366516, - -0.877121 -0 -0.480269, - -0.809989 -0 -0.586445, - -0.730076 -0 -0.683366, - -0.638643 -0 -0.769504, - -0.537131 -0 -0.843499, - -0.427144 -0 -0.904184, - -0.310417 -0 -0.950601, - -0.188791 -0 -0.982017, - -0.0641862 -0 -0.997938, - 0.0614315 0 -0.998111, - 0.18608 0 -0.982535, - 0.307792 0 -0.951454, - 0.424647 0 -0.905359, - 0.534801 0 -0.844978, - 0.636516 0 -0.771263, - 0.728187 0 -0.685378, - 0.808368 0 -0.588678, - 0.875792 0 -0.482689, - 0.929397 0 -0.369082, - 0.968336 0 -0.249652, - 0.991994 0 -0.126282, - 1 0 -0.000920056, - 0.992225 -0 0.124457, - 0.968793 -0 0.24787, - 0.930074 -0 0.367372, - 0.876679 -0 0.481076, - 0.809449 -0 0.58719, - 0.729447 -0 0.684037, - 0.637934 -0 0.770091, - 0.536355 -0 0.843993, - 0.426312 -0 0.904576, - 0.309542 -0 0.950886, - 0.187887 -0 0.982191, - 0.063268 -0 0.997997, - -0.0623498 -0 0.998054, - -0.186984 -0 0.982363, - -0.308667 -0 0.95117, - -0.42548 -0 0.904968, - -0.535578 -0 0.844486, - -0.637225 -0 0.770677, - -0.728817 -0 0.684708, - -0.808909 -0 0.587934, - -0.876236 -0 0.481883, - -0.929736 -0 0.368227, - -0.968565 -0 0.248761, - -0.99211 -0 0.12537, - -1 -0 -0 - ] - } - coordIndex [ - 52, 51, 50, -1, - 52, 50, 49, -1, - 52, 49, 53, -1, - 53, 49, 48, -1, - 53, 48, 54, -1, - 54, 48, 47, -1, - 54, 47, 55, -1, - 55, 47, 46, -1, - 55, 46, 56, -1, - 56, 46, 45, -1, - 56, 45, 57, -1, - 57, 45, 44, -1, - 57, 44, 58, -1, - 58, 44, 43, -1, - 58, 43, 59, -1, - 59, 43, 42, -1, - 59, 42, 60, -1, - 60, 42, 41, -1, - 60, 41, 61, -1, - 61, 41, 40, -1, - 61, 40, 62, -1, - 62, 40, 39, -1, - 62, 39, 63, -1, - 63, 39, 38, -1, - 63, 38, 64, -1, - 64, 38, 37, -1, - 64, 37, 65, -1, - 65, 37, 36, -1, - 65, 36, 66, -1, - 66, 36, 35, -1, - 66, 35, 67, -1, - 67, 35, 34, -1, - 67, 34, 68, -1, - 68, 34, 33, -1, - 68, 33, 69, -1, - 69, 33, 32, -1, - 69, 32, 70, -1, - 70, 32, 31, -1, - 70, 31, 71, -1, - 71, 31, 30, -1, - 71, 30, 72, -1, - 72, 30, 29, -1, - 72, 29, 73, -1, - 73, 29, 28, -1, - 73, 28, 74, -1, - 74, 28, 27, -1, - 74, 27, 75, -1, - 75, 27, 26, -1, - 75, 26, 76, -1, - 76, 26, 25, -1, - 76, 25, 77, -1, - 77, 25, 24, -1, - 77, 24, 78, -1, - 78, 24, 23, -1, - 78, 23, 79, -1, - 79, 23, 22, -1, - 79, 22, 80, -1, - 80, 22, 21, -1, - 80, 21, 81, -1, - 81, 21, 20, -1, - 81, 20, 82, -1, - 82, 20, 19, -1, - 82, 19, 83, -1, - 83, 19, 18, -1, - 83, 18, 84, -1, - 84, 18, 17, -1, - 84, 17, 85, -1, - 85, 17, 16, -1, - 85, 16, 86, -1, - 86, 16, 15, -1, - 86, 15, 87, -1, - 87, 15, 14, -1, - 87, 14, 88, -1, - 88, 14, 13, -1, - 88, 13, 89, -1, - 89, 13, 12, -1, - 89, 12, 90, -1, - 90, 12, 11, -1, - 90, 11, 91, -1, - 91, 11, 10, -1, - 91, 10, 92, -1, - 92, 10, 9, -1, - 92, 9, 93, -1, - 93, 9, 8, -1, - 93, 8, 94, -1, - 94, 8, 7, -1, - 94, 7, 95, -1, - 95, 7, 6, -1, - 95, 6, 96, -1, - 96, 6, 5, -1, - 96, 5, 97, -1, - 97, 5, 4, -1, - 97, 4, 98, -1, - 98, 4, 3, -1, - 98, 3, 99, -1, - 99, 3, 2, -1, - 99, 2, 100, -1, - 100, 2, 1, -1, - 100, 1, 101, -1, - 101, 1, 0, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.18271 4.4709 -0.550522, - 3.21424 4.4709 0.567875, - 3.29628 4.4709 0.814469, - 3.40869 4.4709 1.04878, - 3.54969 4.4709 1.26709, - 3.71703 4.4709 1.46593, - 3.90805 4.4709 1.64215, - 4.11972 4.4709 1.79293, - 4.34868 4.4709 1.91588, - 4.59128 4.4709 2.00906, - 4.84368 4.4709 2.07098, - 5.10186 4.4709 2.10065, - 5.36173 4.4709 2.09762, - 5.61915 4.4709 2.06191, - 5.87003 4.4709 1.99411, - 6.11039 4.4709 1.89528, - 6.33641 4.4709 1.76701, - 6.5445 4.4709 1.61132, - 6.73135 4.4709 1.43069, - 6.89399 4.4709 1.22799, - 7.02985 4.4709 1.00644, - 7.13675 4.4709 0.769566, - 7.213 4.4709 0.521122, - 7.2574 4.4709 0.265058, - 7.26955 4.4709 0.0415655, - 7.25053 4.4709 -0.237861, - 7.19381 4.4709 -0.512132 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 26, 0, 25, -1, - 25, 0, 24, -1, - 24, 0, 1, -1, - 24, 1, 23, -1, - 23, 1, 2, -1, - 23, 2, 22, -1, - 22, 2, 3, -1, - 22, 3, 21, -1, - 21, 3, 4, -1, - 21, 4, 20, -1, - 20, 4, 5, -1, - 20, 5, 19, -1, - 19, 5, 6, -1, - 19, 6, 18, -1, - 18, 6, 7, -1, - 18, 7, 17, -1, - 17, 7, 8, -1, - 17, 8, 16, -1, - 16, 8, 9, -1, - 16, 9, 15, -1, - 15, 9, 10, -1, - 15, 10, 14, -1, - 14, 10, 11, -1, - 14, 11, 13, -1, - 13, 11, 12, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.17262 4.4709 0.372253, - 7.11605 4.4709 -0.739087, - 7.002 4.4709 -0.974153, - 6.85914 4.4709 -1.19291, - 6.68977 4.4709 -1.39184, - 6.4966 4.4709 -1.56776, - 6.28273 4.4709 -1.71783, - 6.05159 4.4709 -1.83965, - 5.80691 4.4709 -1.93126, - 5.55261 4.4709 -1.9912, - 5.29277 4.4709 -2.01849, - 5.03156 4.4709 -2.0127, - 4.77318 4.4709 -1.97393, - 4.52178 4.4709 -1.90279, - 4.2814 4.4709 -1.80043, - 4.05589 4.4709 -1.66849, - 3.84888 4.4709 -1.5091, - 3.66368 4.4709 -1.3248, - 3.50328 4.4709 -1.11856, - 3.37025 4.4709 -0.893692, - 3.26673 4.4709 -0.653807, - 3.19438 4.4709 -0.402755, - 3.15435 4.4709 -0.144569, - 3.1473 4.4709 0.116606 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 23, 0, 22, -1, - 22, 0, 21, -1, - 21, 0, 1, -1, - 21, 1, 20, -1, - 20, 1, 2, -1, - 20, 2, 19, -1, - 19, 2, 3, -1, - 19, 3, 18, -1, - 18, 3, 4, -1, - 18, 4, 17, -1, - 17, 4, 5, -1, - 17, 5, 16, -1, - 16, 5, 6, -1, - 16, 6, 15, -1, - 15, 6, 7, -1, - 15, 7, 14, -1, - 14, 7, 8, -1, - 14, 8, 13, -1, - 13, 8, 9, -1, - 13, 9, 12, -1, - 12, 9, 10, -1, - 12, 10, 11, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.21424 4.4709 0.567875, - 3.17262 4.4709 0.372253, - 3.1473 4.4709 0.116606, - 3.15435 4.4709 -0.144569, - 3.19438 4.4709 -0.402755, - 3.26673 4.4709 -0.653807, - 3.37025 4.4709 -0.893692, - 3.50328 4.4709 -1.11856, - 3.66368 4.4709 -1.3248, - 3.84888 4.4709 -1.5091, - 4.05589 4.4709 -1.66849, - 4.2814 4.4709 -1.80043, - 4.52178 4.4709 -1.90279, - 4.77318 4.4709 -1.97393, - 5.03156 4.4709 -2.0127, - 5.29277 4.4709 -2.01849, - 5.55261 4.4709 -1.9912, - 5.80691 4.4709 -1.93126, - 6.05159 4.4709 -1.83965, - 6.28273 4.4709 -1.71783, - 6.4966 4.4709 -1.56776, - 6.68977 4.4709 -1.39184, - 6.85914 4.4709 -1.19291, - 7.002 4.4709 -0.974153, - 7.11605 4.4709 -0.739087, - 7.18271 4.4709 -0.550522, - 7.19381 4.4709 -0.512132, - 7.25053 4.4709 -0.237861, - 7.26955 4.4709 0.0415655, - 7.26955 3.4709 0.0415655, - 7.25313 3.4709 -0.218106, - 7.20414 3.4709 -0.473641, - 7.12336 3.4709 -0.720972, - 7.01207 3.4709 -0.95616, - 6.87205 3.4709 -1.17546, - 6.70552 3.4709 -1.37538, - 6.51514 3.4709 -1.55273, - 6.30394 3.4709 -1.70469, - 6.07528 3.4709 -1.82884, - 5.83281 3.4709 -1.92321, - 5.58038 3.4709 -1.98629, - 5.32202 3.4709 -2.01708, - 5.06184 3.4709 -2.01508, - 4.80398 3.4709 -1.98032, - 4.55255 3.4709 -1.91337, - 4.31155 3.4709 -1.81529, - 4.08483 3.4709 -1.68764, - 3.87599 3.4709 -1.53244, - 3.68836 3.4709 -1.35219, - 3.52493 3.4709 -1.14973, - 3.38829 3.4709 -0.928309, - 3.28063 3.4709 -0.691438, - 3.20366 3.4709 -0.442895, - 3.1586 3.4709 -0.186637, - 3.14617 3.4709 0.0732561, - 3.16658 3.4709 0.332644, - 3.21949 3.4709 0.587396, - 3.30407 3.4709 0.833456, - 3.41896 3.4709 1.06691, - 3.56234 3.4709 1.28403, - 3.73192 3.4709 1.48136, - 3.925 3.4709 1.65577, - 4.13851 3.4709 1.80446, - 4.36905 3.4709 1.92509, - 4.61295 3.4709 2.01572, - 4.86631 3.4709 2.07491, - 5.12512 3.4709 2.10172, - 5.38524 3.4709 2.09572, - 5.64253 3.4709 2.05701, - 5.8929 3.4709 1.9862, - 6.13236 3.4709 1.88443, - 6.35709 3.4709 1.7533, - 6.56352 3.4709 1.59492, - 6.74836 3.4709 1.4118, - 6.90867 3.4709 1.20686, - 7.04188 3.4709 0.983359, - 7.14589 3.4709 0.744862, - 7.21904 3.4709 0.495165, - 7.26015 3.4709 0.238245, - 7.26955 3.4709 0.0415655, - 7.26955 4.4709 0.0415655, - 7.2574 4.4709 0.265058, - 7.213 4.4709 0.521122, - 7.13675 4.4709 0.769566, - 7.02985 4.4709 1.00644, - 6.89399 4.4709 1.22799, - 6.73135 4.4709 1.43069, - 6.5445 4.4709 1.61132, - 6.33641 4.4709 1.76701, - 6.11039 4.4709 1.89528, - 5.87003 4.4709 1.99411, - 5.61915 4.4709 2.06191, - 5.36173 4.4709 2.09762, - 5.10186 4.4709 2.10065, - 4.84368 4.4709 2.07098, - 4.59128 4.4709 2.00906, - 4.34868 4.4709 1.91588, - 4.11972 4.4709 1.79293, - 3.90805 4.4709 1.64215, - 3.71703 4.4709 1.46593, - 3.54969 4.4709 1.26709, - 3.40869 4.4709 1.04878, - 3.29628 4.4709 0.814469 - ] - } - normal Normal { - vector [ - -0.966871 -0 0.255266, - -0.987054 -0 0.160387, - -0.999337 -0 0.0363957, - -0.995917 0 -0.0902771, - -0.976504 0 -0.2155, - -0.94141 0 -0.337263, - -0.8912 0 -0.45361, - -0.826679 0 -0.562673, - -0.748884 0 -0.662701, - -0.659063 0 -0.752087, - -0.558659 0 -0.829397, - -0.449285 0 -0.893389, - -0.332696 0 -0.943034, - -0.210764 0 -0.977537, - -0.0854487 0 -0.996343, - 0.0412392 0 -0.999149, - 0.167265 0 -0.985912, - 0.290605 0 -0.956843, - 0.409278 0 -0.91241, - 0.521379 0 -0.853325, - 0.625108 0 -0.780538, - 0.7188 0 -0.695217, - 0.800949 0 -0.598733, - 0.870237 0 -0.492634, - 0.92555 0 -0.378625, - 0.95788 0 -0.287169, - 0.963266 0 -0.268549, - 0.990774 0 -0.135525, - 1 0 0, - 1 0 0, - 0.992037 0 -0.125943, - 0.968277 0 -0.249881, - 0.929096 0 -0.369839, - 0.875119 0 -0.483907, - 0.807206 0 -0.59027, - 0.726438 0 -0.687232, - 0.634102 0 -0.773249, - 0.531667 0 -0.846953, - 0.420766 0 -0.907169, - 0.303164 0 -0.952938, - 0.180734 0 -0.983532, - 0.0554254 0 -0.998463, - -0.0707655 0 -0.997493, - -0.195829 0 -0.980638, - -0.317775 0 -0.948166, - -0.43466 0 -0.900595, - -0.544622 0 -0.838681, - -0.645912 0 -0.763412, - -0.736915 0 -0.675985, - -0.816183 0 -0.577793, - -0.882454 0 -0.470399, - -0.934671 0 -0.355515, - -0.972003 0 -0.234969, - -0.993856 0 -0.11068, - -0.999882 -0 0.0153703, - -0.989985 -0 0.141176, - -0.964321 -0 0.264734, - -0.923302 -0 0.384076, - -0.867578 -0 0.497301, - -0.798038 -0 0.602607, - -0.71579 -0 0.698316, - -0.622142 -0 0.782904, - -0.518587 -0 0.855025, - -0.406773 -0 0.913529, - -0.288481 -0 0.957486, - -0.165595 -0 0.986194, - -0.0400722 -0 0.999197, - 0.0860889 0 0.996287, - 0.210879 0 0.977512, - 0.332311 0 0.94317, - 0.448451 0 0.893808, - 0.557449 0 0.830211, - 0.65757 0 0.753394, - 0.747218 0 0.664578, - 0.824968 0 0.56518, - 0.88958 0 0.45678, - 0.940025 0 0.341107, - 0.9755 0 0.220001, - 0.99544 0 0.0953915, - 1 0 2.44921e-016, - 1 0 2.44921e-016, - 0.994108 0 0.108396, - 0.972575 0 0.23259, - 0.93559 0 0.353088, - 0.883741 0 0.467977, - 0.817851 0 0.57543, - 0.738967 0 0.673741, - 0.648343 0 0.761348, - 0.547419 0 0.836859, - 0.437797 0 0.899074, - 0.321219 0 0.947005, - 0.199538 0 0.97989, - 0.0746869 0 0.997207, - -0.0513509 -0 0.998681, - -0.176573 -0 0.984288, - -0.298989 -0 0.954256, - -0.416656 -0 0.909064, - -0.527702 -0 0.849429, - -0.630365 -0 0.776299, - -0.723013 -0 0.690835, - -0.804173 -0 0.594395, - -0.872558 -0 0.488511, - -0.927079 -0 0.374867 - ] - } - coordIndex [ - 28, 29, 30, -1, - 28, 30, 27, -1, - 27, 30, 31, -1, - 27, 31, 26, -1, - 26, 31, 32, -1, - 26, 32, 25, -1, - 25, 32, 24, -1, - 24, 32, 33, -1, - 24, 33, 23, -1, - 23, 33, 34, -1, - 23, 34, 22, -1, - 22, 34, 35, -1, - 22, 35, 21, -1, - 21, 35, 36, -1, - 21, 36, 20, -1, - 20, 36, 37, -1, - 20, 37, 19, -1, - 19, 37, 38, -1, - 19, 38, 18, -1, - 18, 38, 39, -1, - 18, 39, 17, -1, - 17, 39, 40, -1, - 17, 40, 16, -1, - 16, 40, 41, -1, - 16, 41, 15, -1, - 15, 41, 42, -1, - 15, 42, 14, -1, - 14, 42, 43, -1, - 14, 43, 13, -1, - 13, 43, 44, -1, - 13, 44, 12, -1, - 12, 44, 45, -1, - 12, 45, 11, -1, - 11, 45, 46, -1, - 11, 46, 10, -1, - 10, 46, 47, -1, - 10, 47, 9, -1, - 9, 47, 48, -1, - 9, 48, 8, -1, - 8, 48, 49, -1, - 8, 49, 7, -1, - 7, 49, 50, -1, - 7, 50, 6, -1, - 6, 50, 51, -1, - 6, 51, 5, -1, - 5, 51, 52, -1, - 5, 52, 4, -1, - 4, 52, 53, -1, - 4, 53, 3, -1, - 3, 53, 54, -1, - 3, 54, 2, -1, - 2, 54, 55, -1, - 2, 55, 1, -1, - 1, 55, 56, -1, - 1, 56, 0, -1, - 0, 56, 102, -1, - 102, 56, 57, -1, - 102, 57, 101, -1, - 101, 57, 58, -1, - 101, 58, 100, -1, - 100, 58, 59, -1, - 100, 59, 99, -1, - 99, 59, 60, -1, - 99, 60, 98, -1, - 98, 60, 61, -1, - 98, 61, 97, -1, - 97, 61, 62, -1, - 97, 62, 96, -1, - 96, 62, 63, -1, - 96, 63, 95, -1, - 95, 63, 64, -1, - 95, 64, 94, -1, - 94, 64, 65, -1, - 94, 65, 93, -1, - 93, 65, 66, -1, - 93, 66, 92, -1, - 92, 66, 67, -1, - 92, 67, 91, -1, - 91, 67, 68, -1, - 91, 68, 90, -1, - 90, 68, 69, -1, - 90, 69, 89, -1, - 89, 69, 70, -1, - 89, 70, 88, -1, - 88, 70, 71, -1, - 88, 71, 87, -1, - 87, 71, 72, -1, - 87, 72, 86, -1, - 86, 72, 73, -1, - 86, 73, 85, -1, - 85, 73, 74, -1, - 85, 74, 84, -1, - 84, 74, 75, -1, - 84, 75, 83, -1, - 83, 75, 76, -1, - 83, 76, 82, -1, - 82, 76, 77, -1, - 82, 77, 81, -1, - 81, 77, 78, -1, - 81, 78, 79, -1, - 81, 79, 80, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.21424 4.4709 0.567875, - 7.18271 4.4709 -0.550522, - 7.17273 4.24277 -0.555989, - 7.1387 3.46962 -0.574449, - 7.0942 2.4709 -0.59814, - 3.26486 2.4709 0.481047, - 3.23927 3.46962 0.524493, - 3.21989 4.24277 0.558006 - ] - } - normal Normal { - vector [ - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 5, -1, - 5, 0, 1, -1, - 5, 1, 4, -1, - 4, 1, 2, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.07406 2.4709 -0.654693, - 3.2525 2.4709 0.422304, - 3.26486 2.4709 0.481047, - 7.0942 2.4709 -0.59814 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.11605 4.4709 -0.739087, - 3.17262 4.4709 0.372253, - 3.1819 4.23614 0.378155, - 3.21245 3.46759 0.397429, - 3.2525 2.4709 0.422304, - 7.07406 2.4709 -0.654693, - 7.09523 3.46759 -0.696817, - 7.11122 4.23614 -0.729208 - ] - } - normal Normal { - vector [ - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 1, -1, - 6, 1, 5, -1, - 5, 1, 2, -1, - 5, 2, 4, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.17273 4.24277 -0.555989, - 7.1387 3.46962 -0.574449, - 7.0942 2.4709 -0.59814, - 7.07406 2.4709 -0.654693, - 7.09523 3.46759 -0.696817, - 7.11122 4.23614 -0.729208, - 7.11605 4.4709 -0.739087, - 7.18271 4.4709 -0.550522 - ] - } - normal Normal { - vector [ - -0.956157 0.0348995 0.290767, - -0.952115 0.0348995 0.303743, - -0.946454 0.0348995 0.320947, - -0.936353 0.0348995 0.34932, - -0.930709 0.0348995 0.364092, - -0.926328 0.0348995 0.375097, - -0.924986 0.0348995 0.378394, - -0.957296 0.0348995 0.286994 - ] - } - coordIndex [ - 1, 0, 7, -1, - 1, 7, 2, -1, - 2, 7, 3, -1, - 3, 7, 6, -1, - 3, 6, 4, -1, - 4, 6, 5, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.1819 4.23614 0.378155, - 3.21245 3.46759 0.397429, - 3.2525 2.4709 0.422304, - 3.26486 2.4709 0.481047, - 3.23927 3.46962 0.524493, - 3.21989 4.24277 0.558006, - 3.21424 4.4709 0.567875, - 3.17262 4.4709 0.372253 - ] - } - normal Normal { - vector [ - 0.985876 0.0348995 -0.163802, - 0.983865 0.0348995 -0.175474, - 0.980965 0.0348995 -0.191021, - 0.974764 0.0348995 -0.220492, - 0.970608 0.0348995 -0.238121, - 0.96728 0.0348995 -0.251298, - 0.966282 0.0348995 -0.255111, - 0.986453 0.0348995 -0.160289 - ] - } - coordIndex [ - 1, 0, 7, -1, - 1, 7, 2, -1, - 2, 7, 3, -1, - 3, 7, 6, -1, - 3, 6, 4, -1, - 4, 6, 5, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.70861 0.470903 -2.68452, - 2.70861 -7.0291 -2.68452, - 3.30861 -7.0291 -2.68452, - 3.30861 0.470903 -2.68452 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 3.30861 -7.0291 -2.68452, - 3.30861 -7.0291 -2.08452, - 3.30861 0.470903 -2.08452, - 3.30861 0.470903 -2.68452 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.70861 0.470903 -2.08452, - 2.70861 0.470903 -2.68452, - 3.30861 0.470903 -2.68452, - 3.30861 0.470903 -2.08452 - ] - } - normal Normal { - vector [ - -0 -1 -0, - -0 -1 -0, - -0 -1 -0, - -0 -1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 2.70861 -7.0291 -2.08452, - 2.70861 0.470903 -2.08452, - 3.30861 0.470903 -2.08452, - 3.30861 -7.0291 -2.08452 - ] - } - normal Normal { - vector [ - -0 0 -1, - -0 0 -1, - -0 0 -1, - -0 0 -1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 5.70774 -11.4291 0.571357, - 5.69097 -11.4291 0.699766, - 5.64178 -11.4291 0.819562, - 5.56348 -11.4291 0.922707, - 5.46132 -11.4291 1.00228, - 5.34214 -11.4291 1.05295, - 5.21395 -11.4291 1.07132, - 5.08534 -11.4291 1.05614, - 4.96495 -11.4291 1.00845, - 4.86084 -11.4291 0.931438, - 4.78 -11.4291 0.830269, - 4.72785 -11.4291 0.711733, - 4.70789 -11.4291 0.58378, - 4.72147 -11.4291 0.454994, - 4.76766 -11.4291 0.334013, - 4.84338 -11.4291 0.228954, - 4.94353 -11.4291 0.146863, - 5.06141 -11.4291 0.0932475, - 5.18911 -11.4291 0.071704, - 5.31805 -11.4291 0.0836773, - 5.4396 -11.4291 0.128365, - 5.54559 -11.4291 0.202768, - 5.62892 -11.4291 0.301897, - 5.68399 -11.4291 0.419101, - 5.70712 -11.4291 0.546518 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 24, 0, 23, -1, - 23, 0, 22, -1, - 22, 0, 1, -1, - 22, 1, 21, -1, - 21, 1, 2, -1, - 21, 2, 20, -1, - 20, 2, 3, -1, - 20, 3, 19, -1, - 19, 3, 4, -1, - 19, 4, 18, -1, - 18, 4, 5, -1, - 18, 5, 17, -1, - 17, 5, 6, -1, - 17, 6, 16, -1, - 16, 6, 7, -1, - 16, 7, 15, -1, - 15, 7, 8, -1, - 15, 8, 14, -1, - 14, 8, 9, -1, - 14, 9, 13, -1, - 13, 9, 10, -1, - 13, 10, 12, -1, - 12, 10, 11, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 5.70774 -6.4291 0.571357, - 5.70774 -11.4291 0.571357, - 5.70712 -11.4291 0.546518, - 5.68399 -11.4291 0.419101, - 5.62892 -11.4291 0.301897, - 5.54559 -11.4291 0.202768, - 5.4396 -11.4291 0.128365, - 5.31805 -11.4291 0.0836773, - 5.18911 -11.4291 0.071704, - 5.06141 -11.4291 0.0932475, - 4.94353 -11.4291 0.146863, - 4.84338 -11.4291 0.228954, - 4.76766 -11.4291 0.334013, - 4.72147 -11.4291 0.454994, - 4.70789 -11.4291 0.58378, - 4.72785 -11.4291 0.711733, - 4.78 -11.4291 0.830269, - 4.86084 -11.4291 0.931438, - 4.96495 -11.4291 1.00845, - 5.08534 -11.4291 1.05614, - 5.21395 -11.4291 1.07132, - 5.34214 -11.4291 1.05295, - 5.46132 -11.4291 1.00228, - 5.56348 -11.4291 0.922707, - 5.64178 -11.4291 0.819562, - 5.69097 -11.4291 0.699766, - 5.70774 -11.4291 0.571357, - 5.70774 -6.4291 0.571357, - 5.69097 -6.4291 0.699766, - 5.64178 -6.4291 0.819562, - 5.56348 -6.4291 0.922707, - 5.46132 -6.4291 1.00228, - 5.34214 -6.4291 1.05295, - 5.21395 -6.4291 1.07132, - 5.08534 -6.4291 1.05614, - 4.96495 -6.4291 1.00845, - 4.86084 -6.4291 0.931438, - 4.78 -6.4291 0.830269, - 4.72785 -6.4291 0.711733, - 4.70789 -6.4291 0.58378, - 4.72147 -6.4291 0.454994, - 4.76766 -6.4291 0.334013, - 4.84338 -6.4291 0.228954, - 4.94353 -6.4291 0.146863, - 5.06141 -6.4291 0.0932475, - 5.18911 -6.4291 0.071704, - 5.31805 -6.4291 0.0836773, - 5.4396 -6.4291 0.128365, - 5.54559 -6.4291 0.202768, - 5.62892 -6.4291 0.301897, - 5.68399 -6.4291 0.419101, - 5.70712 -6.4291 0.546518 - ] - } - normal Normal { - vector [ - 1 0 -2.44921e-016, - 1 0 -2.44921e-016, - 0.998765 0 -0.0496767, - 0.952509 0 -0.304512, - 0.842357 0 -0.53892, - 0.675699 0 -0.737177, - 0.463716 0 -0.885984, - 0.220626 0 -0.975359, - -0.0372642 -0 -0.999305, - -0.292654 -0 -0.956218, - -0.528413 -0 -0.848987, - -0.728725 -0 -0.684806, - -0.880154 -0 -0.474687, - -0.972542 -0 -0.232726, - -0.999691 0 0.024846, - -0.95978 0 0.280752, - -0.855487 0 0.517824, - -0.693807 0 0.720161, - -0.485586 0 0.874189, - -0.244791 0 0.969576, - 0.012424 0 0.999923, - 0.268806 0 0.963194, - 0.507156 0 0.861854, - 0.711486 0 0.7027, - 0.868089 0 0.496409, - 0.96646 0 0.256818, - 1 0 0, - 1 0 0, - 0.96646 0 0.256818, - 0.868089 0 0.496409, - 0.711486 0 0.7027, - 0.507156 0 0.861854, - 0.268806 0 0.963194, - 0.012424 0 0.999923, - -0.244791 0 0.969576, - -0.485586 0 0.874189, - -0.693807 0 0.720161, - -0.855487 0 0.517824, - -0.95978 0 0.280752, - -0.999691 0 0.024846, - -0.972542 -0 -0.232726, - -0.880154 -0 -0.474687, - -0.728725 -0 -0.684806, - -0.528413 -0 -0.848987, - -0.292654 -0 -0.956218, - -0.0372642 -0 -0.999305, - 0.220626 0 -0.975359, - 0.463716 0 -0.885984, - 0.675699 0 -0.737177, - 0.842357 0 -0.53892, - 0.952509 0 -0.304512, - 0.998765 0 -0.0496767 - ] - } - coordIndex [ - 0, 1, 2, -1, - 0, 2, 51, -1, - 51, 2, 3, -1, - 51, 3, 50, -1, - 50, 3, 4, -1, - 50, 4, 49, -1, - 49, 4, 5, -1, - 49, 5, 48, -1, - 48, 5, 6, -1, - 48, 6, 47, -1, - 47, 6, 7, -1, - 47, 7, 46, -1, - 46, 7, 8, -1, - 46, 8, 45, -1, - 45, 8, 9, -1, - 45, 9, 44, -1, - 44, 9, 10, -1, - 44, 10, 43, -1, - 43, 10, 11, -1, - 43, 11, 42, -1, - 42, 11, 12, -1, - 42, 12, 41, -1, - 41, 12, 13, -1, - 41, 13, 40, -1, - 40, 13, 14, -1, - 40, 14, 39, -1, - 39, 14, 15, -1, - 39, 15, 38, -1, - 38, 15, 16, -1, - 38, 16, 37, -1, - 37, 16, 17, -1, - 37, 17, 36, -1, - 36, 17, 18, -1, - 36, 18, 35, -1, - 35, 18, 19, -1, - 35, 19, 34, -1, - 34, 19, 20, -1, - 34, 20, 33, -1, - 33, 20, 21, -1, - 33, 21, 32, -1, - 32, 21, 22, -1, - 32, 22, 31, -1, - 31, 22, 23, -1, - 31, 23, 30, -1, - 30, 23, 24, -1, - 30, 24, 29, -1, - 29, 24, 25, -1, - 29, 25, 28, -1, - 28, 25, 26, -1, - 28, 26, 27, -1 - ] - } -} -Shape { - appearance DEF A2735237687 Appearance { - material Material { - diffuseColor 0.6 0.6 0.6 - specularColor 0.8 0.8 0.8 - emissiveColor 0.5 0.5 0.5 - ambientIntensity 0.5 - shininess 0.8 - transparency 0 - } - } - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 5.80774 -6.4291 0.571357, - 5.79139 -6.4291 0.710458, - 5.74324 -6.4291 0.84198, - 5.66591 -6.4291 0.958755, - 5.56362 -6.4291 1.05442, - 5.44193 -6.4291 1.12377, - 5.30748 -6.4291 1.16301, - 5.1676 -6.4291 1.17001, - 5.0299 -6.4291 1.1444, - 4.9019 -6.4291 1.08755, - 4.79056 -6.4291 1.00259, - 4.70195 -6.4291 0.894119, - 4.6409 -6.4291 0.768065, - 4.61074 -6.4291 0.631293, - 4.61311 -6.4291 0.491254, - 4.64788 -6.4291 0.355581, - 4.71316 -6.4291 0.231665, - 4.80539 -6.4291 0.126258, - 4.91954 -6.4291 0.0451055, - 5.0494 -6.4291 -0.00737186, - 5.18788 -6.4291 -0.0283145, - 5.32745 -6.4291 -0.016581, - 5.46049 -6.4291 0.0271893, - 5.57976 -6.4291 0.100611, - 5.67876 -6.4291 0.199684, - 5.75209 -6.4291 0.319009, - 5.79577 -6.4291 0.452085, - 5.80774 -6.4291 0.571357, - 5.80774 -6.7791 0.571357, - 5.79577 -6.7791 0.452085, - 5.75209 -6.7791 0.319009, - 5.67876 -6.7791 0.199684, - 5.57976 -6.7791 0.100611, - 5.46049 -6.7791 0.0271893, - 5.32745 -6.7791 -0.016581, - 5.18788 -6.7791 -0.0283145, - 5.0494 -6.7791 -0.00737186, - 4.91954 -6.7791 0.0451055, - 4.80539 -6.7791 0.126258, - 4.71316 -6.7791 0.231665, - 4.64788 -6.7791 0.355581, - 4.61311 -6.7791 0.491254, - 4.61074 -6.7791 0.631293, - 4.6409 -6.7791 0.768065, - 4.70195 -6.7791 0.894119, - 4.79056 -6.7791 1.00259, - 4.9019 -6.7791 1.08755, - 5.0299 -6.7791 1.1444, - 5.1676 -6.7791 1.17001, - 5.30748 -6.7791 1.16301, - 5.44193 -6.7791 1.12377, - 5.56362 -6.7791 1.05442, - 5.66591 -6.7791 0.958755, - 5.74324 -6.7791 0.84198, - 5.79139 -6.7791 0.710458, - 5.80774 -6.7791 0.571357 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.972755 -0 -0.231835, - -0.892505 -0 -0.451038, - -0.763622 -0 -0.645664, - -0.593129 -0 -0.805107, - -0.390317 -0 -0.92068, - -0.166237 -0 -0.986086, - 0.066902 -0 -0.99776, - 0.296395 -0 -0.955065, - 0.509738 -0 -0.86033, - 0.695305 -0 -0.718715, - 0.842985 -0 -0.537937, - 0.944731 -0 -0.327847, - 0.994998 -0 -0.0998931, - 0.991048 0 0.133504, - 0.933096 0 0.359627, - 0.8243 0 0.566154, - 0.670587 0 0.741831, - 0.480335 0 0.877085, - 0.263908 0 0.964548, - 0.033102 0 0.999452, - -0.199508 -0 0.979896, - -0.421247 -0 0.906946, - -0.620032 -0 0.784576, - -0.785032 -0 0.619455, - -0.907256 -0 0.42058, - -0.980043 -0 0.198787, - -1 -0 2.44921e-016, - -1 -0 2.44921e-016, - -0.980043 -0 0.198787, - -0.907256 -0 0.42058, - -0.785032 -0 0.619455, - -0.620032 -0 0.784576, - -0.421247 -0 0.906946, - -0.199508 -0 0.979896, - 0.033102 0 0.999452, - 0.263908 0 0.964548, - 0.480335 0 0.877085, - 0.670587 0 0.741831, - 0.8243 0 0.566154, - 0.933096 0 0.359627, - 0.991048 0 0.133504, - 0.994998 -0 -0.0998931, - 0.944731 -0 -0.327847, - 0.842985 -0 -0.537937, - 0.695305 -0 -0.718715, - 0.509738 -0 -0.86033, - 0.296395 -0 -0.955065, - 0.066902 -0 -0.99776, - -0.166237 -0 -0.986086, - -0.390317 -0 -0.92068, - -0.593129 -0 -0.805107, - -0.763622 -0 -0.645664, - -0.892505 -0 -0.451038, - -0.972755 -0 -0.231835, - -1 -0 -0 - ] - } - coordIndex [ - 0, 55, 1, -1, - 1, 55, 54, -1, - 1, 54, 2, -1, - 2, 54, 53, -1, - 2, 53, 3, -1, - 3, 53, 52, -1, - 3, 52, 4, -1, - 4, 52, 51, -1, - 4, 51, 5, -1, - 5, 51, 50, -1, - 5, 50, 6, -1, - 6, 50, 49, -1, - 6, 49, 7, -1, - 7, 49, 48, -1, - 7, 48, 8, -1, - 8, 48, 47, -1, - 8, 47, 9, -1, - 9, 47, 46, -1, - 9, 46, 10, -1, - 10, 46, 45, -1, - 10, 45, 11, -1, - 11, 45, 44, -1, - 11, 44, 12, -1, - 12, 44, 43, -1, - 12, 43, 13, -1, - 13, 43, 42, -1, - 13, 42, 14, -1, - 14, 42, 41, -1, - 14, 41, 15, -1, - 15, 41, 40, -1, - 15, 40, 16, -1, - 16, 40, 39, -1, - 16, 39, 17, -1, - 17, 39, 38, -1, - 17, 38, 18, -1, - 18, 38, 37, -1, - 18, 37, 19, -1, - 19, 37, 36, -1, - 19, 36, 20, -1, - 20, 36, 35, -1, - 20, 35, 21, -1, - 21, 35, 34, -1, - 21, 34, 22, -1, - 22, 34, 33, -1, - 22, 33, 23, -1, - 23, 33, 32, -1, - 23, 32, 24, -1, - 24, 32, 31, -1, - 24, 31, 25, -1, - 25, 31, 30, -1, - 25, 30, 26, -1, - 26, 30, 29, -1, - 26, 29, 27, -1, - 27, 29, 28, -1 - ] - } -} -Shape { - appearance USE A2735237687 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 4.62431 -6.8291 0.431304, - 4.67312 -6.8291 0.298989, - 4.75147 -6.8291 0.181722, - 4.85502 -6.8291 0.0859814, - 4.97806 -6.8291 0.0170575, - 5.11379 -6.8291 -0.0212421, - 5.25471 -6.8291 -0.0268015, - 5.39304 -6.8291 0.000686212, - 5.52113 -6.8291 0.0597029, - 5.6319 -6.8291 0.146988, - 5.71924 -6.8291 0.257719, - 5.77832 -6.8291 0.385777, - 5.80588 -6.8291 0.524089, - 5.80039 -6.8291 0.665012, - 5.79989 -6.8291 0.668089, - 5.79989 -7.0291 0.668089, - 5.80039 -7.0291 0.665012, - 5.80588 -7.0291 0.524089, - 5.77832 -7.0291 0.385777, - 5.71924 -7.0291 0.257719, - 5.6319 -7.0291 0.146988, - 5.52113 -7.0291 0.0597029, - 5.39304 -7.0291 0.000686212, - 5.25471 -7.0291 -0.0268015, - 5.11379 -7.0291 -0.0212421, - 4.97806 -7.0291 0.0170575, - 4.85502 -7.0291 0.0859814, - 4.75147 -7.0291 0.181722, - 4.67312 -7.0291 0.298989, - 4.62431 -7.0291 0.431304, - 4.60774 -7.0291 0.571357, - 4.60774 -6.8291 0.571357 - ] - } - normal Normal { - vector [ - 0.972376 0 0.233421, - 0.891029 0 0.453946, - 0.760454 0 0.649392, - 0.587865 0 0.808959, - 0.382798 0 0.923832, - 0.156581 0 0.987665, - -0.0782864 -0 0.996931, - -0.308829 -0 0.951118, - -0.522309 -0 0.852757, - -0.706932 -0 0.707282, - -0.852498 -0 0.522731, - -0.950965 -0 0.309299, - -0.996892 -0 0.0787798, - -0.987742 -0 -0.156092, - -0.986918 -0 -0.161221, - -0.986918 -0 -0.161221, - -0.987742 -0 -0.156092, - -0.996892 -0 0.0787798, - -0.950965 -0 0.309299, - -0.852498 -0 0.522731, - -0.706932 -0 0.707282, - -0.522309 -0 0.852757, - -0.308829 -0 0.951118, - -0.0782864 -0 0.996931, - 0.156581 0 0.987665, - 0.382798 0 0.923832, - 0.587865 0 0.808959, - 0.760454 0 0.649392, - 0.891029 0 0.453946, - 0.972376 0 0.233421, - 1 -0 -1.22461e-016, - 1 -0 -1.22461e-016 - ] - } - coordIndex [ - 16, 15, 14, -1, - 16, 14, 13, -1, - 16, 13, 17, -1, - 17, 13, 12, -1, - 17, 12, 18, -1, - 18, 12, 11, -1, - 18, 11, 19, -1, - 19, 11, 10, -1, - 19, 10, 20, -1, - 20, 10, 9, -1, - 20, 9, 21, -1, - 21, 9, 8, -1, - 21, 8, 22, -1, - 22, 8, 7, -1, - 22, 7, 23, -1, - 23, 7, 6, -1, - 23, 6, 24, -1, - 24, 6, 5, -1, - 24, 5, 25, -1, - 25, 5, 4, -1, - 25, 4, 26, -1, - 26, 4, 3, -1, - 26, 3, 27, -1, - 27, 3, 2, -1, - 27, 2, 28, -1, - 28, 2, 1, -1, - 28, 1, 29, -1, - 29, 1, 0, -1, - 29, 0, 30, -1, - 30, 0, 31, -1 - ] - } -} -Shape { - appearance USE A2735237687 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 5.80774 -6.4291 0.571357, - 5.79139 -6.4291 0.710458, - 5.74324 -6.4291 0.84198, - 5.66591 -6.4291 0.958755, - 5.56362 -6.4291 1.05442, - 5.44193 -6.4291 1.12377, - 5.30748 -6.4291 1.16301, - 5.1676 -6.4291 1.17001, - 5.0299 -6.4291 1.1444, - 4.9019 -6.4291 1.08755, - 4.79056 -6.4291 1.00259, - 4.70195 -6.4291 0.894119, - 4.6409 -6.4291 0.768065, - 4.61074 -6.4291 0.631293, - 4.61311 -6.4291 0.491254, - 4.64788 -6.4291 0.355581, - 4.71316 -6.4291 0.231665, - 4.80539 -6.4291 0.126258, - 4.91954 -6.4291 0.0451055, - 5.0494 -6.4291 -0.00737186, - 5.18788 -6.4291 -0.0283145, - 5.32745 -6.4291 -0.016581, - 5.46049 -6.4291 0.0271893, - 5.57976 -6.4291 0.100611, - 5.67876 -6.4291 0.199684, - 5.75209 -6.4291 0.319009, - 5.79577 -6.4291 0.452085, - 5.70774 -6.4291 0.571357, - 5.70712 -6.4291 0.546518, - 5.68399 -6.4291 0.419101, - 5.62892 -6.4291 0.301897, - 5.54559 -6.4291 0.202768, - 5.4396 -6.4291 0.128365, - 5.31805 -6.4291 0.0836773, - 5.18911 -6.4291 0.071704, - 5.06141 -6.4291 0.0932475, - 4.94353 -6.4291 0.146863, - 4.84338 -6.4291 0.228954, - 4.76766 -6.4291 0.334013, - 4.72147 -6.4291 0.454994, - 4.70789 -6.4291 0.58378, - 4.72785 -6.4291 0.711733, - 4.78 -6.4291 0.830269, - 4.86084 -6.4291 0.931438, - 4.96495 -6.4291 1.00845, - 5.08534 -6.4291 1.05614, - 5.21395 -6.4291 1.07132, - 5.34214 -6.4291 1.05295, - 5.46132 -6.4291 1.00228, - 5.56348 -6.4291 0.922707, - 5.64178 -6.4291 0.819562, - 5.69097 -6.4291 0.699766 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 26, 0, 25, -1, - 25, 0, 1, -1, - 25, 1, 24, -1, - 24, 1, 2, -1, - 24, 2, 28, -1, - 24, 28, 29, -1, - 24, 29, 23, -1, - 23, 29, 30, -1, - 23, 30, 22, -1, - 22, 30, 31, -1, - 22, 31, 21, -1, - 21, 31, 32, -1, - 21, 32, 20, -1, - 20, 32, 33, -1, - 20, 33, 19, -1, - 19, 33, 34, -1, - 19, 34, 18, -1, - 18, 34, 35, -1, - 18, 35, 17, -1, - 17, 35, 36, -1, - 17, 36, 16, -1, - 16, 36, 37, -1, - 16, 37, 15, -1, - 15, 37, 38, -1, - 15, 38, 14, -1, - 14, 38, 39, -1, - 14, 39, 13, -1, - 13, 39, 40, -1, - 13, 40, 12, -1, - 12, 40, 41, -1, - 12, 41, 11, -1, - 11, 41, 42, -1, - 11, 42, 10, -1, - 10, 42, 43, -1, - 10, 43, 9, -1, - 9, 43, 44, -1, - 9, 44, 8, -1, - 8, 44, 45, -1, - 8, 45, 7, -1, - 7, 45, 46, -1, - 7, 46, 6, -1, - 6, 46, 47, -1, - 6, 47, 5, -1, - 5, 47, 48, -1, - 5, 48, 4, -1, - 4, 48, 49, -1, - 4, 49, 3, -1, - 3, 49, 50, -1, - 3, 50, 2, -1, - 2, 50, 51, -1, - 2, 51, 27, -1, - 2, 27, 28, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 4.60774 -7.0291 4.57136, - 4.60774 -7.0291 0.571357, - 4.60774 -6.8291 0.571357, - 4.60774 -6.8291 4.57136 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 5.79989 -7.0291 0.668089, - 5.79989 -7.0291 4.57136, - 5.79989 -6.8291 4.57136, - 5.79989 -6.8291 0.668089 - ] - } - normal Normal { - vector [ - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 0.270857 -1.6287, - 8.95709 0.270857 -1.6287, - 8.95709 0.270857 -1.5287, - 11.4571 0.270857 -1.5287 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 0.270857 -1.6287, - 8.95709 0.220857 -1.6287, - 8.95709 0.220857 -1.5287, - 8.95709 0.270857 -1.5287 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 0.270857 -1.5287, - 8.95709 0.220857 -1.5287, - 11.4571 0.220857 -1.5287, - 11.4571 0.270857 -1.5287 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 0.270857 -1.6287, - 11.4571 0.270857 -1.6287, - 11.4571 0.220857 -1.6287, - 8.95709 0.220857 -1.6287 - ] - } - normal Normal { - vector [ - -0 -0 -1, - -0 -0 -1, - -0 -0 -1, - -0 -0 -1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 0.220857 -1.6287, - 11.4571 0.270857 -1.6287, - 11.4571 0.270857 -1.5287, - 11.4571 0.220857 -1.5287 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 0.0889552 -1.55013, - 11.4571 0.138882 -1.60432, - 11.4571 0.20859 -1.6282, - 11.4571 0.220857 -1.6287, - 8.95709 0.220857 -1.6287, - 8.95709 0.14943 -1.6106, - 8.95709 0.0952385 -1.56067, - 8.95709 0.0713597 -1.49097, - 8.95709 0.0708572 -1.4787, - 11.4571 0.0708572 -1.4787 - ] - } - normal Normal { - vector [ - 0 -0.879347 -0.476182, - 0 -0.546502 -0.837458, - 0 -0.0817826 -0.99665, - 0 0 -1, - 0 0 -1, - 0 -0.476182 -0.879347, - 0 -0.837458 -0.546502, - 0 -0.99665 -0.0817826, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016 - ] - } - coordIndex [ - 4, 3, 5, -1, - 5, 3, 2, -1, - 5, 2, 1, -1, - 5, 1, 6, -1, - 6, 1, 0, -1, - 6, 0, 7, -1, - 7, 0, 8, -1, - 8, 0, 9, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 0.0708572 -1.4787, - 8.95709 0.0708572 2.5213, - 8.95709 0.170857 2.5213, - 8.95709 0.170857 -1.4787 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 0.170857 -1.4787, - 8.95709 0.170857 -1.4787, - 8.95709 0.170857 2.5213, - 11.4571 0.170857 2.5213 - ] - } - normal Normal { - vector [ - 0 1 -3.82859e-016, - 0 1 -3.82859e-016, - 0 1 -3.82859e-016, - 0 1 -3.82859e-016 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 0.0708572 -1.4787, - 11.4571 0.0708572 -1.4787, - 11.4571 0.0708572 2.5213, - 8.95709 0.0708572 2.5213 - ] - } - normal Normal { - vector [ - -0 -1 3.82859e-016, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 0.220857 -1.5287, - 11.4571 0.185502 -1.51405, - 11.4571 0.170857 -1.4787, - 11.4571 0.0708572 -1.4787, - 11.4571 0.0889552 -1.55013, - 11.4571 0.138882 -1.60432, - 11.4571 0.20859 -1.6282, - 11.4571 0.220857 -1.6287 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 1, -1, - 6, 1, 5, -1, - 5, 1, 2, -1, - 5, 2, 4, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 0.170857 -1.4787, - 11.4571 0.170857 -1.4787, - 11.4571 0.185502 -1.51405, - 11.4571 0.220857 -1.5287, - 8.95709 0.220857 -1.5287, - 8.95709 0.185502 -1.51405 - ] - } - normal Normal { - vector [ - -0 1 -3.82859e-016, - -0 1 -3.82859e-016, - -0 0.707103 0.70711, - -0 -0 1, - -0 -0 1, - -0 0.70711 0.707103 - ] - } - coordIndex [ - 0, 1, 2, -1, - 0, 2, 5, -1, - 5, 2, 3, -1, - 5, 3, 4, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 0.170857 -1.4787, - 8.95709 0.185502 -1.51405, - 8.95709 0.220857 -1.5287, - 8.95709 0.220857 -1.6287, - 8.95709 0.14943 -1.6106, - 8.95709 0.0952385 -1.56067, - 8.95709 0.0713597 -1.49097, - 8.95709 0.0708572 -1.4787 - ] - } - normal Normal { - vector [ - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 5, -1, - 5, 0, 1, -1, - 5, 1, 4, -1, - 4, 1, 2, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 0.0708572 2.5213, - 11.4571 0.0708572 -1.4787, - 11.4571 0.170857 -1.4787, - 11.4571 0.170857 2.5213 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 -2.06428 3.42436, - 8.95709 -2.06428 3.42436, - 8.95709 -4.84292 0.546998, - 11.4571 -4.84292 0.546998 - ] - } - normal Normal { - vector [ - -0 -0.71934 0.694658, - -0 -0.71934 0.694658, - -0 -0.71934 0.694658, - -0 -0.71934 0.694658 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 -1.84088 3.48744, - 11.4571 -1.66938 3.59281, - 11.4571 -1.48269 3.66804, - 11.4571 -1.28604 3.711, - 11.4571 -1.08499 3.72049, - 11.4571 -0.885172 3.69624, - 11.4571 -0.692222 3.63893, - 11.4571 -0.511564 3.55018, - 11.4571 -0.348281 3.43248, - 11.4571 -0.206968 3.28915, - 11.4571 -0.0915995 3.12421, - 11.4571 -0.00542229 2.94231, - 11.4571 0.0491394 2.74857, - 11.4571 0.0705505 2.54843, - 11.4571 0.0708572 2.5213, - 8.95709 0.0708572 2.5213, - 8.95709 0.0539764 2.72187, - 8.95709 0.00380886 2.9168, - 8.95709 -0.0782339 3.1006, - 8.95709 -0.189844 3.26811, - 8.95709 -0.32788 3.4146, - 8.95709 -0.48846 3.53596, - 8.95709 -0.667066 3.62877, - 8.95709 -0.858671 3.69042, - 8.95709 -1.05789 3.71918, - 8.95709 -1.25911 3.71424, - 8.95709 -1.45667 3.67574, - 8.95709 -1.64502 3.60475, - 8.95709 -1.81885 3.50329, - 8.95709 -1.97328 3.37419, - 8.95709 -1.99235 3.35489, - 11.4571 -1.99235 3.35489 - ] - } - normal Normal { - vector [ - -0 0.593113 -0.805119, - -0 0.4502 -0.892928, - -0 0.29462 -0.955615, - -0 0.130751 -0.991415, - -0 -0.0367965 -0.999323, - -0 -0.203309 -0.979115, - -0 -0.364101 -0.931359, - -0 -0.514649 -0.857401, - -0 -0.650718 -0.759319, - -0 -0.768479 -0.639875, - -0 -0.864619 -0.502427, - -0 -0.936434 -0.350845, - -0 -0.981902 -0.189391, - -0 -0.999744 -0.0226084, - -0 -1 3.82859e-016, - -0 -1 3.82859e-016, - -0 -0.985933 -0.167143, - -0 -0.944126 -0.329584, - -0 -0.875757 -0.482751, - -0 -0.782749 -0.622337, - -0 -0.667719 -0.744414, - -0 -0.533902 -0.845546, - -0 -0.385064 -0.92289, - -0 -0.225393 -0.974268, - -0 -0.0593801 -0.998235, - -0 0.108303 -0.994118, - -0 0.27294 -0.962031, - -0 0.429897 -0.902878, - -0 0.574759 -0.818323, - -0 0.703451 -0.710744, - -0 0.71934 -0.694658, - -0 0.71934 -0.694658 - ] - } - coordIndex [ - 31, 30, 0, -1, - 0, 30, 29, -1, - 0, 29, 28, -1, - 0, 28, 1, -1, - 1, 28, 27, -1, - 1, 27, 2, -1, - 2, 27, 26, -1, - 2, 26, 3, -1, - 3, 26, 25, -1, - 3, 25, 4, -1, - 4, 25, 24, -1, - 4, 24, 5, -1, - 5, 24, 23, -1, - 5, 23, 6, -1, - 6, 23, 22, -1, - 6, 22, 7, -1, - 7, 22, 21, -1, - 7, 21, 8, -1, - 8, 21, 20, -1, - 8, 20, 9, -1, - 9, 20, 19, -1, - 9, 19, 10, -1, - 10, 19, 18, -1, - 10, 18, 11, -1, - 11, 18, 17, -1, - 11, 17, 12, -1, - 12, 17, 16, -1, - 12, 16, 13, -1, - 13, 16, 14, -1, - 14, 16, 15, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 -4.77098 0.477532, - 11.4571 -4.77098 0.477532, - 11.4571 -4.84292 0.546998, - 8.95709 -4.84292 0.546998 - ] - } - normal Normal { - vector [ - 0 -0.694658 -0.71934, - 0 -0.694658 -0.71934, - 0 -0.694658 -0.71934, - 0 -0.694658 -0.71934 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 -2.06428 3.42436, - 8.95709 -1.92159 3.55185, - 8.95709 -1.7484 3.66433, - 8.95709 -1.55959 3.74797, - 8.95709 -1.35991 3.80066, - 8.95709 -1.1544 3.82106, - 8.95709 -0.948265 3.80866, - 8.95709 -0.74669 3.76377, - 8.95709 -0.554766 3.68753, - 8.95709 -0.377337 3.58186, - 8.95709 -0.218879 3.44943, - 8.95709 -0.0833923 3.29357, - 8.95709 0.0257052 3.11823, - 8.95709 0.10566 2.92783, - 8.95709 0.154454 2.72716, - 8.95709 0.170857 2.5213, - 8.95709 0.0708572 2.5213, - 8.95709 0.0539764 2.72187, - 8.95709 0.00380886 2.9168, - 8.95709 -0.0782339 3.1006, - 8.95709 -0.189844 3.26811, - 8.95709 -0.32788 3.4146, - 8.95709 -0.48846 3.53596, - 8.95709 -0.667066 3.62877, - 8.95709 -0.858671 3.69042, - 8.95709 -1.05789 3.71918, - 8.95709 -1.25911 3.71424, - 8.95709 -1.45667 3.67574, - 8.95709 -1.64502 3.60475, - 8.95709 -1.81885 3.50329, - 8.95709 -1.97328 3.37419, - 8.95709 -1.99235 3.35489 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 31, 0, 30, -1, - 30, 0, 29, -1, - 29, 0, 1, -1, - 29, 1, 28, -1, - 28, 1, 2, -1, - 28, 2, 27, -1, - 27, 2, 3, -1, - 27, 3, 26, -1, - 26, 3, 4, -1, - 26, 4, 25, -1, - 25, 4, 5, -1, - 25, 5, 24, -1, - 24, 5, 6, -1, - 24, 6, 23, -1, - 23, 6, 7, -1, - 23, 7, 22, -1, - 22, 7, 8, -1, - 22, 8, 21, -1, - 21, 8, 9, -1, - 21, 9, 20, -1, - 20, 9, 10, -1, - 20, 10, 19, -1, - 19, 10, 11, -1, - 19, 11, 18, -1, - 18, 11, 12, -1, - 18, 12, 17, -1, - 17, 12, 13, -1, - 17, 13, 16, -1, - 16, 13, 14, -1, - 16, 14, 15, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 -2.06428 3.42436, - 11.4571 -2.06428 3.42436, - 11.4571 -1.90948 3.56105, - 11.4571 -1.73499 3.6715, - 11.4571 -1.54521 3.75292, - 11.4571 -1.34493 3.80327, - 11.4571 -1.1392 3.82126, - 11.4571 -0.93322 3.80645, - 11.4571 -0.732183 3.75921, - 11.4571 -0.541164 3.68073, - 11.4571 -0.364983 3.57299, - 11.4571 -0.208085 3.43872, - 11.4571 -0.0744306 3.28129, - 11.4571 0.0326083 3.10468, - 11.4571 0.110331 2.91335, - 11.4571 0.156775 2.71213, - 11.4571 0.170857 2.5213, - 8.95709 0.170857 2.5213, - 8.95709 0.154454 2.72716, - 8.95709 0.10566 2.92783, - 8.95709 0.0257052 3.11823, - 8.95709 -0.0833923 3.29357, - 8.95709 -0.218879 3.44943, - 8.95709 -0.377337 3.58186, - 8.95709 -0.554766 3.68753, - 8.95709 -0.74669 3.76377, - 8.95709 -0.948265 3.80866, - 8.95709 -1.1544 3.82106, - 8.95709 -1.35991 3.80066, - 8.95709 -1.55959 3.74797, - 8.95709 -1.7484 3.66433, - 8.95709 -1.92159 3.55185 - ] - } - normal Normal { - vector [ - 0 -0.71934 0.694658, - 0 -0.71934 0.694658, - 0 -0.600262 0.799804, - 0 -0.466036 0.884766, - 0 -0.32005 0.947401, - 0 -0.165988 0.986128, - 0 -0.00773643 0.99997, - 0 0.15071 0.988578, - 0 0.305353 0.952239, - 0 0.452291 0.89187, - 0 0.587815 0.808995, - 0 0.708506 0.705705, - 0 0.811317 0.584606, - 0 0.893655 0.448755, - 0 0.953441 0.30158, - 0 0.989167 0.146794, - 0 1 -3.82859e-016, - 0 1 -3.82859e-016, - 0 0.987382 0.158354, - 0 0.949848 0.312711, - 0 0.888345 0.459177, - 0 0.804424 0.594056, - 0 0.700203 0.713944, - 0 0.578312 0.815816, - 0 0.441828 0.8971, - 0 0.294194 0.955746, - 0 0.139137 0.990273, - 0 -0.0194324 0.999811, - 0 -0.177511 0.984119, - 0 -0.33111 0.943592, - 0 -0.476353 0.879254, - 0 -0.609576 0.792728 - ] - } - coordIndex [ - 16, 17, 18, -1, - 16, 18, 15, -1, - 15, 18, 14, -1, - 14, 18, 19, -1, - 14, 19, 13, -1, - 13, 19, 20, -1, - 13, 20, 12, -1, - 12, 20, 21, -1, - 12, 21, 11, -1, - 11, 21, 22, -1, - 11, 22, 10, -1, - 10, 22, 23, -1, - 10, 23, 9, -1, - 9, 23, 24, -1, - 9, 24, 8, -1, - 8, 24, 25, -1, - 8, 25, 7, -1, - 7, 25, 26, -1, - 7, 26, 6, -1, - 6, 26, 27, -1, - 6, 27, 5, -1, - 5, 27, 28, -1, - 5, 28, 4, -1, - 4, 28, 29, -1, - 4, 29, 3, -1, - 3, 29, 30, -1, - 3, 30, 2, -1, - 2, 30, 31, -1, - 2, 31, 0, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 -1.99235 3.35489, - 8.95709 -4.77098 0.477532, - 8.95709 -4.84292 0.546998, - 8.95709 -2.06428 3.42436 - ] - } - normal Normal { - vector [ - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.95709 -1.99235 3.35489, - 11.4571 -1.99235 3.35489, - 11.4571 -4.77098 0.477532, - 8.95709 -4.77098 0.477532 - ] - } - normal Normal { - vector [ - 0 0.71934 -0.694658, - 0 0.71934 -0.694658, - 0 0.71934 -0.694658, - 0 0.71934 -0.694658 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 0.170857 2.5213, - 11.4571 0.156775 2.71213, - 11.4571 0.110331 2.91335, - 11.4571 0.0326083 3.10468, - 11.4571 -0.0744306 3.28129, - 11.4571 -0.208085 3.43872, - 11.4571 -0.364983 3.57299, - 11.4571 -0.541164 3.68073, - 11.4571 -0.732183 3.75921, - 11.4571 -0.93322 3.80645, - 11.4571 -1.1392 3.82126, - 11.4571 -1.34493 3.80327, - 11.4571 -1.54521 3.75292, - 11.4571 -1.73499 3.6715, - 11.4571 -1.90948 3.56105, - 11.4571 -2.06428 3.42436, - 11.4571 -1.99235 3.35489, - 11.4571 -1.84088 3.48744, - 11.4571 -1.66938 3.59281, - 11.4571 -1.48269 3.66804, - 11.4571 -1.28604 3.711, - 11.4571 -1.08499 3.72049, - 11.4571 -0.885172 3.69624, - 11.4571 -0.692222 3.63893, - 11.4571 -0.511564 3.55018, - 11.4571 -0.348281 3.43248, - 11.4571 -0.206968 3.28915, - 11.4571 -0.0915995 3.12421, - 11.4571 -0.00542229 2.94231, - 11.4571 0.0491394 2.74857, - 11.4571 0.0705505 2.54843, - 11.4571 0.0708572 2.5213 - ] - } - normal Normal { - vector [ - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0 - ] - } - coordIndex [ - 31, 0, 30, -1, - 30, 0, 1, -1, - 30, 1, 29, -1, - 29, 1, 2, -1, - 29, 2, 28, -1, - 28, 2, 3, -1, - 28, 3, 27, -1, - 27, 3, 4, -1, - 27, 4, 26, -1, - 26, 4, 5, -1, - 26, 5, 25, -1, - 25, 5, 6, -1, - 25, 6, 24, -1, - 24, 6, 7, -1, - 24, 7, 23, -1, - 23, 7, 8, -1, - 23, 8, 22, -1, - 22, 8, 9, -1, - 22, 9, 21, -1, - 21, 9, 10, -1, - 21, 10, 20, -1, - 20, 10, 11, -1, - 20, 11, 19, -1, - 19, 11, 12, -1, - 19, 12, 18, -1, - 18, 12, 13, -1, - 18, 13, 17, -1, - 17, 13, 14, -1, - 17, 14, 16, -1, - 16, 14, 15, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.4571 -4.77098 0.477532, - 11.4571 -1.99235 3.35489, - 11.4571 -2.06428 3.42436, - 11.4571 -4.84292 0.546998 - ] - } - normal Normal { - vector [ - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 9.60785 -7.02914 0.571301, - 9.60785 -7.02914 4.5713, - 7.70873 -7.02914 4.5713, - 7.70873 -7.02914 -2.08457, - 8.30873 -7.02914 -2.08457, - 8.30873 -7.02914 -2.68457, - 7.70873 -7.02914 -2.68457, - 7.70873 -7.02914 -4.4287, - 12.7087 -7.02914 -4.4287, - 12.7087 -7.02914 4.5713, - 10.8 -7.02914 4.5713, - 10.8 -7.02914 0.668033, - 10.8005 -7.02914 0.664957, - 10.806 -7.02914 0.524033, - 10.7784 -7.02914 0.385721, - 10.7194 -7.02914 0.257663, - 10.632 -7.02914 0.146932, - 10.5212 -7.02914 0.0596471, - 10.3932 -7.02914 0.000630445, - 10.2548 -7.02914 -0.0268573, - 10.1139 -7.02914 -0.0212979, - 9.97818 -7.02914 0.0170017, - 9.85514 -7.02914 0.0859256, - 9.75158 -7.02914 0.181666, - 9.67324 -7.02914 0.298933, - 9.62443 -7.02914 0.431248 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 1, 2, 0, -1, - 0, 2, 25, -1, - 25, 2, 3, -1, - 25, 3, 24, -1, - 24, 3, 4, -1, - 24, 4, 23, -1, - 23, 4, 5, -1, - 23, 5, 22, -1, - 22, 5, 7, -1, - 7, 5, 6, -1, - 7, 8, 22, -1, - 22, 8, 21, -1, - 21, 8, 20, -1, - 20, 8, 19, -1, - 19, 8, 18, -1, - 18, 8, 17, -1, - 17, 8, 16, -1, - 16, 8, 15, -1, - 15, 8, 14, -1, - 14, 8, 13, -1, - 13, 8, 9, -1, - 13, 9, 12, -1, - 12, 9, 10, -1, - 12, 10, 11, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70873 0.470857 -2.08457, - 7.70873 -7.02914 -2.08457, - 7.70873 -7.02914 4.5713, - 7.70873 0.470857 4.5713, - 7.70873 0.470857 3.9713, - 7.70873 5.47086 2.3713, - 7.70873 5.47086 -4.4287, - 7.70873 -7.02914 -4.4287, - 7.70873 -7.02914 -2.68457, - 7.70873 0.470857 -2.68457 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 1, 2, 0, -1, - 0, 2, 3, -1, - 0, 3, 9, -1, - 9, 3, 4, -1, - 9, 4, 5, -1, - 9, 5, 6, -1, - 9, 6, 8, -1, - 8, 6, 7, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 5.47086 -4.4287, - 12.7087 -7.02914 -4.4287, - 7.70873 -7.02914 -4.4287, - 7.70873 5.47086 -4.4287 - ] - } - normal Normal { - vector [ - -0 -0 -1, - -0 -0 -1, - -0 -0 -1, - -0 -0 -1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70873 5.47086 2.3713, - 12.7087 5.47086 2.3713, - 12.7087 5.47086 -4.4287, - 7.70873 5.47086 -4.4287, - 12.3079 5.47086 0.0415097, - 12.2918 5.47086 0.300952, - 12.2428 5.47086 0.560165, - 12.1617 5.47086 0.811193, - 12.0498 5.47086 1.05008, - 11.9088 5.47086 1.27304, - 11.741 5.47086 1.47658, - 11.549 5.47086 1.65747, - 11.3358 5.47086 1.81286, - 11.1049 5.47086 1.9403, - 10.8597 5.47086 2.03777, - 10.6043 5.47086 2.10375, - 10.3426 5.47086 2.13718, - 10.0788 5.47086 2.13754, - 9.81709 5.47086 2.10483, - 9.56149 5.47086 2.03956, - 9.3161 5.47086 1.94276, - 9.08477 5.47086 1.81596, - 8.87117 5.47086 1.66116, - 8.67866 5.47086 1.4808, - 8.51028 5.47086 1.27773, - 8.36869 5.47086 1.05516, - 8.25612 5.47086 0.816583, - 8.17435 5.47086 0.565779, - 8.12467 5.47086 0.306703, - 8.10786 5.47086 0.0434418, - 8.12418 5.47086 -0.21985, - 8.17339 5.47086 -0.479017, - 8.2547 5.47086 -0.729971, - 8.36683 5.47086 -0.968751, - 8.50801 5.47086 -1.19159, - 8.67602 5.47086 -1.39497, - 8.86819 5.47086 -1.57568, - 9.08151 5.47086 -1.73087, - 9.3126 5.47086 -1.8581, - 9.55782 5.47086 -1.95535, - 9.81329 5.47086 -2.02109, - 10.075 5.47086 -2.05428, - 10.3388 5.47086 -2.0544, - 10.6005 5.47086 -2.02145, - 10.8561 5.47086 -1.95595, - 11.1014 5.47086 -1.85892, - 11.3326 5.47086 -1.73191, - 11.546 5.47086 -1.57691, - 11.7384 5.47086 -1.39638, - 11.9066 5.47086 -1.19315, - 12.0479 5.47086 -0.970444, - 12.1603 5.47086 -0.731768, - 12.2418 5.47086 -0.480889, - 12.2913 5.47086 -0.221767, - 10.7079 5.47086 -3.52155, - 10.7072 5.47086 -3.49671, - 10.6841 5.47086 -3.36929, - 10.629 5.47086 -3.25209, - 10.5457 5.47086 -3.15296, - 10.4397 5.47086 -3.07856, - 10.3182 5.47086 -3.03387, - 10.1892 5.47086 -3.0219, - 10.0615 5.47086 -3.04344, - 9.94365 5.47086 -3.09706, - 9.84349 5.47086 -3.17915, - 9.76778 5.47086 -3.28421, - 9.72158 5.47086 -3.40519, - 9.70801 5.47086 -3.53397, - 9.72796 5.47086 -3.66192, - 9.78011 5.47086 -3.78046, - 9.86095 5.47086 -3.88163, - 9.96506 5.47086 -3.95864, - 10.0855 5.47086 -4.00634, - 10.2141 5.47086 -4.02151, - 10.3423 5.47086 -4.00315, - 10.4614 5.47086 -3.95248, - 10.5636 5.47086 -3.8729, - 10.6419 5.47086 -3.76975, - 10.6911 5.47086 -3.64996 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 77, 2, 76, -1, - 76, 2, 75, -1, - 75, 2, 74, -1, - 74, 2, 73, -1, - 73, 2, 72, -1, - 72, 2, 3, -1, - 72, 3, 71, -1, - 71, 3, 70, -1, - 70, 3, 69, -1, - 23, 0, 22, -1, - 22, 0, 21, -1, - 21, 0, 20, -1, - 20, 0, 19, -1, - 19, 0, 18, -1, - 18, 0, 17, -1, - 23, 24, 0, -1, - 0, 24, 25, -1, - 0, 25, 26, -1, - 0, 26, 27, -1, - 0, 27, 28, -1, - 0, 28, 3, -1, - 3, 28, 29, -1, - 3, 29, 30, -1, - 3, 30, 31, -1, - 3, 31, 32, -1, - 3, 32, 33, -1, - 3, 33, 69, -1, - 69, 33, 34, -1, - 69, 34, 68, -1, - 68, 34, 35, -1, - 68, 35, 67, -1, - 67, 35, 36, -1, - 67, 36, 66, -1, - 66, 36, 37, -1, - 66, 37, 65, -1, - 65, 37, 38, -1, - 65, 38, 64, -1, - 64, 38, 39, -1, - 64, 39, 63, -1, - 63, 39, 40, -1, - 63, 40, 62, -1, - 62, 40, 41, -1, - 62, 41, 61, -1, - 61, 41, 42, -1, - 61, 42, 60, -1, - 60, 42, 43, -1, - 60, 43, 59, -1, - 59, 43, 44, -1, - 59, 44, 58, -1, - 58, 44, 45, -1, - 58, 45, 57, -1, - 57, 45, 46, -1, - 57, 46, 56, -1, - 56, 46, 47, -1, - 56, 47, 55, -1, - 55, 47, 48, -1, - 55, 48, 54, -1, - 54, 48, 49, -1, - 54, 49, 78, -1, - 78, 49, 50, -1, - 78, 50, 77, -1, - 77, 50, 2, -1, - 2, 50, 51, -1, - 2, 51, 52, -1, - 2, 52, 53, -1, - 2, 53, 1, -1, - 1, 53, 4, -1, - 9, 1, 8, -1, - 8, 1, 7, -1, - 7, 1, 6, -1, - 6, 1, 5, -1, - 5, 1, 4, -1, - 9, 10, 1, -1, - 1, 10, 11, -1, - 1, 11, 12, -1, - 1, 12, 13, -1, - 1, 13, 14, -1, - 1, 14, 15, -1, - 1, 15, 16, -1, - 1, 16, 0, -1, - 0, 16, 17, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 9.60785 -7.02914 4.5713, - 9.60785 -6.82914 4.5713, - 7.80873 -6.82914 4.5713, - 7.80873 0.270857 4.5713, - 12.6087 0.270857 4.5713, - 12.6087 -6.82914 4.5713, - 10.8 -6.82914 4.5713, - 10.8 -7.02914 4.5713, - 12.7087 -7.02914 4.5713, - 12.7087 0.470857 4.5713, - 7.70873 0.470857 4.5713, - 7.70873 -7.02914 4.5713 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 0, 1, 11, -1, - 11, 1, 2, -1, - 11, 2, 10, -1, - 10, 2, 3, -1, - 10, 3, 9, -1, - 9, 3, 4, -1, - 9, 4, 8, -1, - 8, 4, 5, -1, - 8, 5, 7, -1, - 7, 5, 6, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 5.47086 2.3713, - 12.7087 0.470857 3.9713, - 12.7087 0.470857 4.5713, - 12.7087 -7.02914 4.5713, - 12.7087 -7.02914 -4.4287, - 12.7087 5.47086 -4.4287 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 5, 0, 4, -1, - 4, 0, 1, -1, - 4, 1, 3, -1, - 3, 1, 2, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70873 0.470857 3.9713, - 7.70873 0.470857 4.5713, - 12.7087 0.470857 4.5713, - 12.7087 0.470857 3.9713 - ] - } - normal Normal { - vector [ - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 5.47086 2.3713, - 7.70873 5.47086 2.3713, - 7.70873 0.470857 3.9713, - 12.7087 0.470857 3.9713 - ] - } - normal Normal { - vector [ - 0 0.304776 0.952424, - 0 0.304776 0.952424, - 0 0.304776 0.952424, - 0 0.304776 0.952424 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.80873 0.270857 4.5713, - 7.80873 -6.82914 4.5713, - 7.80873 -6.82914 -1.6287, - 7.80873 0.270857 -1.6287 - ] - } - normal Normal { - vector [ - 1 -0 -0, - 1 -0 -0, - 1 -0 -0, - 1 -0 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 9.60785 -6.82914 4.5713, - 9.60785 -6.82914 0.571301, - 9.62443 -6.82914 0.431248, - 9.67324 -6.82914 0.298933, - 9.75158 -6.82914 0.181666, - 9.85514 -6.82914 0.0859256, - 9.97818 -6.82914 0.0170017, - 10.1139 -6.82914 -0.0212979, - 10.2548 -6.82914 -0.0268573, - 10.3932 -6.82914 0.000630445, - 10.5212 -6.82914 0.0596471, - 10.632 -6.82914 0.146932, - 10.7194 -6.82914 0.257663, - 10.7784 -6.82914 0.385721, - 10.806 -6.82914 0.524033, - 10.8005 -6.82914 0.664957, - 10.8 -6.82914 0.668033, - 10.8 -6.82914 4.5713, - 12.6087 -6.82914 4.5713, - 12.6087 -6.82914 -1.6287, - 7.80873 -6.82914 -1.6287, - 7.80873 -6.82914 4.5713 - ] - } - normal Normal { - vector [ - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0, - -0 1 -0 - ] - } - coordIndex [ - 21, 0, 20, -1, - 20, 0, 1, -1, - 20, 1, 2, -1, - 20, 2, 3, -1, - 20, 3, 4, -1, - 20, 4, 5, -1, - 20, 5, 19, -1, - 19, 5, 6, -1, - 19, 6, 7, -1, - 9, 19, 8, -1, - 8, 19, 7, -1, - 9, 10, 19, -1, - 19, 10, 11, -1, - 19, 11, 12, -1, - 19, 12, 13, -1, - 19, 13, 18, -1, - 18, 13, 14, -1, - 18, 14, 17, -1, - 17, 14, 15, -1, - 17, 15, 16, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.6087 -6.82914 4.5713, - 12.6087 0.270857 4.5713, - 12.6087 0.270857 -1.6287, - 12.6087 -6.82914 -1.6287 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -1 -0 -0, - -1 -0 -0, - -1 -0 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.5587 -6.77914 2.3713, - 12.5587 0.120857 2.3713, - 7.85873 0.120857 2.3713, - 7.85873 -6.77914 2.3713, - 11.7079 -3.94076 2.3713, - 11.7076 -3.96684 2.3713, - 11.6871 -4.18947 2.3713, - 11.6337 -4.40657 2.3713, - 11.5486 -4.61332 2.3713, - 11.4338 -4.80513 2.3713, - 11.2917 -4.97774 2.3713, - 11.1255 -5.12731 2.3713, - 10.9389 -5.25053 2.3713, - 10.7362 -5.34464 2.3713, - 10.5216 -5.40757 2.3713, - 10.3001 -5.43792 2.3713, - 10.0766 -5.435 2.3713, - 9.85593 -5.39889 2.3713, - 9.64311 -5.33038 2.3713, - 9.44284 -5.23101 2.3713, - 9.25957 -5.10297 2.3713, - 9.09736 -4.94912 2.3713, - 8.95982 -4.77286 2.3713, - 8.85 -4.57812 2.3713, - 8.77035 -4.36922 2.3713, - 8.72263 -4.1508 2.3713, - 8.70791 -3.92771 2.3713, - 8.72651 -3.70492 2.3713, - 8.77802 -3.48736 2.3713, - 8.86129 -3.27987 2.3713, - 8.97448 -3.08707 2.3713, - 9.11506 -2.91323 2.3713, - 9.27992 -2.76222 2.3713, - 9.4654 -2.63739 2.3713, - 9.66737 -2.54152 2.3713, - 9.88134 -2.47672 2.3713, - 10.1026 -2.44445 2.3713, - 10.3261 -2.44543 2.3713, - 10.5471 -2.47962 2.3713, - 10.7605 -2.54627 2.3713, - 10.9616 -2.6439 2.3713, - 11.146 -2.77034 2.3713, - 11.3095 -2.92278 2.3713, - 11.4486 -3.09783 2.3713, - 11.5601 -3.29161 2.3713, - 11.6416 -3.49981 2.3713, - 11.6912 -3.71781 2.3713 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 5, -1, - 5, 0, 4, -1, - 7, 8, 0, -1, - 0, 8, 9, -1, - 0, 9, 10, -1, - 0, 10, 11, -1, - 0, 11, 12, -1, - 0, 12, 3, -1, - 3, 12, 13, -1, - 3, 13, 14, -1, - 40, 1, 39, -1, - 39, 1, 38, -1, - 38, 1, 37, -1, - 37, 1, 36, -1, - 36, 1, 35, -1, - 35, 1, 34, -1, - 34, 1, 33, -1, - 40, 41, 1, -1, - 1, 41, 42, -1, - 1, 42, 43, -1, - 1, 43, 44, -1, - 1, 44, 45, -1, - 1, 45, 0, -1, - 0, 45, 46, -1, - 0, 46, 4, -1, - 27, 2, 26, -1, - 26, 2, 25, -1, - 25, 2, 3, -1, - 25, 3, 24, -1, - 24, 3, 23, -1, - 23, 3, 22, -1, - 22, 3, 21, -1, - 21, 3, 20, -1, - 20, 3, 19, -1, - 19, 3, 18, -1, - 18, 3, 17, -1, - 17, 3, 16, -1, - 16, 3, 15, -1, - 15, 3, 14, -1, - 27, 28, 2, -1, - 2, 28, 29, -1, - 2, 29, 30, -1, - 2, 30, 31, -1, - 2, 31, 32, -1, - 2, 32, 1, -1, - 1, 32, 33, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.6087 0.270857 4.5713, - 7.80873 0.270857 4.5713, - 7.80873 0.270857 -1.6287, - 12.6087 0.270857 -1.6287 - ] - } - normal Normal { - vector [ - -0 -1 0, - -0 -1 0, - -0 -1 0, - -0 -1 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.7079 -3.94076 -1.6287, - 11.6912 -3.71781 -1.6287, - 11.6416 -3.49981 -1.6287, - 11.5601 -3.29161 -1.6287, - 11.4486 -3.09783 -1.6287, - 11.3095 -2.92278 -1.6287, - 11.146 -2.77034 -1.6287, - 10.9616 -2.6439 -1.6287, - 10.7605 -2.54627 -1.6287, - 10.5471 -2.47962 -1.6287, - 10.3261 -2.44543 -1.6287, - 10.1026 -2.44445 -1.6287, - 9.88134 -2.47672 -1.6287, - 9.66737 -2.54152 -1.6287, - 9.4654 -2.63739 -1.6287, - 9.27992 -2.76222 -1.6287, - 9.11506 -2.91323 -1.6287, - 8.97448 -3.08707 -1.6287, - 8.86129 -3.27987 -1.6287, - 8.77802 -3.48736 -1.6287, - 8.72651 -3.70492 -1.6287, - 8.70791 -3.92771 -1.6287, - 8.72263 -4.1508 -1.6287, - 8.77035 -4.36922 -1.6287, - 8.85 -4.57812 -1.6287, - 8.95982 -4.77286 -1.6287, - 9.09736 -4.94912 -1.6287, - 9.25957 -5.10297 -1.6287, - 9.44284 -5.23101 -1.6287, - 9.64311 -5.33038 -1.6287, - 9.85593 -5.39889 -1.6287, - 10.0766 -5.435 -1.6287, - 10.3001 -5.43792 -1.6287, - 10.5216 -5.40757 -1.6287, - 10.7362 -5.34464 -1.6287, - 10.9389 -5.25053 -1.6287, - 11.1255 -5.12731 -1.6287, - 11.2917 -4.97774 -1.6287, - 11.4338 -4.80513 -1.6287, - 11.5486 -4.61332 -1.6287, - 11.6337 -4.40657 -1.6287, - 11.6871 -4.18947 -1.6287, - 11.7076 -3.96684 -1.6287 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 42, 0, 41, -1, - 41, 0, 40, -1, - 40, 0, 1, -1, - 40, 1, 39, -1, - 39, 1, 2, -1, - 39, 2, 38, -1, - 38, 2, 3, -1, - 38, 3, 37, -1, - 37, 3, 4, -1, - 37, 4, 36, -1, - 36, 4, 5, -1, - 36, 5, 35, -1, - 35, 5, 6, -1, - 35, 6, 34, -1, - 34, 6, 7, -1, - 34, 7, 33, -1, - 33, 7, 8, -1, - 33, 8, 32, -1, - 32, 8, 9, -1, - 32, 9, 31, -1, - 31, 9, 10, -1, - 31, 10, 30, -1, - 30, 10, 11, -1, - 30, 11, 29, -1, - 29, 11, 12, -1, - 29, 12, 28, -1, - 28, 12, 13, -1, - 28, 13, 27, -1, - 27, 13, 14, -1, - 27, 14, 26, -1, - 26, 14, 15, -1, - 26, 15, 25, -1, - 25, 15, 16, -1, - 25, 16, 24, -1, - 24, 16, 17, -1, - 24, 17, 23, -1, - 23, 17, 18, -1, - 23, 18, 22, -1, - 22, 18, 19, -1, - 22, 19, 21, -1, - 21, 19, 20, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 11.7079 -3.94076 -1.6287, - 11.6912 -3.71781 -1.6287, - 11.6416 -3.49981 -1.6287, - 11.5601 -3.29161 -1.6287, - 11.4486 -3.09783 -1.6287, - 11.3095 -2.92278 -1.6287, - 11.146 -2.77034 -1.6287, - 10.9616 -2.6439 -1.6287, - 10.7605 -2.54627 -1.6287, - 10.5471 -2.47962 -1.6287, - 10.3261 -2.44543 -1.6287, - 10.1026 -2.44445 -1.6287, - 9.88134 -2.47672 -1.6287, - 9.66737 -2.54152 -1.6287, - 9.4654 -2.63739 -1.6287, - 9.27992 -2.76222 -1.6287, - 9.11506 -2.91323 -1.6287, - 8.97448 -3.08707 -1.6287, - 8.86129 -3.27987 -1.6287, - 8.77802 -3.48736 -1.6287, - 8.72651 -3.70492 -1.6287, - 8.70791 -3.92771 -1.6287, - 8.72263 -4.1508 -1.6287, - 8.77035 -4.36922 -1.6287, - 8.85 -4.57812 -1.6287, - 8.95982 -4.77286 -1.6287, - 9.09736 -4.94912 -1.6287, - 9.25957 -5.10297 -1.6287, - 9.44284 -5.23101 -1.6287, - 9.64311 -5.33038 -1.6287, - 9.85593 -5.39889 -1.6287, - 10.0766 -5.435 -1.6287, - 10.3001 -5.43792 -1.6287, - 10.5216 -5.40757 -1.6287, - 10.7362 -5.34464 -1.6287, - 10.9389 -5.25053 -1.6287, - 11.1255 -5.12731 -1.6287, - 11.2917 -4.97774 -1.6287, - 11.4338 -4.80513 -1.6287, - 11.5486 -4.61332 -1.6287, - 11.6337 -4.40657 -1.6287, - 11.6871 -4.18947 -1.6287, - 11.7076 -3.96684 -1.6287, - 11.7079 -3.94076 -1.6287, - 11.7079 -3.94076 2.3713, - 11.7076 -3.96684 2.3713, - 11.6871 -4.18947 2.3713, - 11.6337 -4.40657 2.3713, - 11.5486 -4.61332 2.3713, - 11.4338 -4.80513 2.3713, - 11.2917 -4.97774 2.3713, - 11.1255 -5.12731 2.3713, - 10.9389 -5.25053 2.3713, - 10.7362 -5.34464 2.3713, - 10.5216 -5.40757 2.3713, - 10.3001 -5.43792 2.3713, - 10.0766 -5.435 2.3713, - 9.85593 -5.39889 2.3713, - 9.64311 -5.33038 2.3713, - 9.44284 -5.23101 2.3713, - 9.25957 -5.10297 2.3713, - 9.09736 -4.94912 2.3713, - 8.95982 -4.77286 2.3713, - 8.85 -4.57812 2.3713, - 8.77035 -4.36922 2.3713, - 8.72263 -4.1508 2.3713, - 8.70791 -3.92771 2.3713, - 8.72651 -3.70492 2.3713, - 8.77802 -3.48736 2.3713, - 8.86129 -3.27987 2.3713, - 8.97448 -3.08707 2.3713, - 9.11506 -2.91323 2.3713, - 9.27992 -2.76222 2.3713, - 9.4654 -2.63739 2.3713, - 9.66737 -2.54152 2.3713, - 9.88134 -2.47672 2.3713, - 10.1026 -2.44445 2.3713, - 10.3261 -2.44543 2.3713, - 10.5471 -2.47962 2.3713, - 10.7605 -2.54627 2.3713, - 10.9616 -2.6439 2.3713, - 11.146 -2.77034 2.3713, - 11.3095 -2.92278 2.3713, - 11.4486 -3.09783 2.3713, - 11.5601 -3.29161 2.3713, - 11.6416 -3.49981 2.3713, - 11.6912 -3.71781 2.3713, - 11.7079 -3.94076 2.3713 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.988892 -0.148633 -0, - -0.955817 -0.293964 -0, - -0.901507 -0.432764 -0, - -0.827171 -0.561951 -0, - -0.734459 -0.678653 -0, - -0.62543 -0.78028 -0, - -0.502508 -0.864572 -0, - -0.368423 -0.929658 -0, - -0.226153 -0.974092 -0, - -0.078859 -0.996886 -0, - 0.0701868 -0.997534 -0, - 0.217673 -0.976022 -0, - 0.360324 -0.932827 -0, - 0.494971 -0.86891 -0, - 0.618621 -0.785689 -0, - 0.728529 -0.685015 -0, - 0.822253 -0.569123 -0, - 0.89771 -0.440587 -0, - 0.953224 -0.302265 -0, - 0.987563 -0.157227 -0, - 0.999962 -0.00869623 -0, - 0.990148 0.140028 0, - 0.958337 0.285641 0, - 0.905237 0.424908 0, - 0.832026 0.554736 0, - 0.740333 0.672241 0, - 0.632192 0.774812 0, - 0.510008 0.86017 0, - 0.376493 0.926419 0, - 0.234615 0.972088 0, - 0.0875251 0.996162 0, - -0.0615094 0.998106 -0, - -0.209178 0.977878 -0, - -0.352199 0.935925 -0, - -0.487396 0.873181 -0, - -0.611765 0.791039 -0, - -0.722545 0.691324 -0, - -0.817272 0.576252 -0, - -0.893844 0.448377 -0, - -0.950559 0.310543 -0, - -0.986158 0.165809 -0, - -0.999849 0.0173918 -0, - -1 2.44921e-016 -0, - -1 2.44921e-016 -0, - -0.999849 0.0173918 -0, - -0.986158 0.165809 -0, - -0.950559 0.310543 -0, - -0.893844 0.448377 -0, - -0.817272 0.576252 -0, - -0.722545 0.691324 -0, - -0.611765 0.791039 -0, - -0.487396 0.873181 -0, - -0.352199 0.935925 -0, - -0.209178 0.977878 -0, - -0.0615094 0.998106 -0, - 0.0875251 0.996162 0, - 0.234615 0.972088 0, - 0.376493 0.926419 0, - 0.510008 0.86017 0, - 0.632192 0.774812 0, - 0.740333 0.672241 0, - 0.832026 0.554736 0, - 0.905237 0.424908 0, - 0.958337 0.285641 0, - 0.990148 0.140028 0, - 0.999962 -0.00869623 -0, - 0.987563 -0.157227 -0, - 0.953224 -0.302265 -0, - 0.89771 -0.440587 -0, - 0.822253 -0.569123 -0, - 0.728529 -0.685015 -0, - 0.618621 -0.785689 -0, - 0.494971 -0.86891 -0, - 0.360324 -0.932827 -0, - 0.217673 -0.976022 -0, - 0.0701868 -0.997534 -0, - -0.078859 -0.996886 -0, - -0.226153 -0.974092 -0, - -0.368423 -0.929658 -0, - -0.502508 -0.864572 -0, - -0.62543 -0.78028 -0, - -0.734459 -0.678653 -0, - -0.827171 -0.561951 -0, - -0.901507 -0.432764 -0, - -0.955817 -0.293964 -0, - -0.988892 -0.148633 -0, - -1 -0 -0 - ] - } - coordIndex [ - 45, 44, 43, -1, - 45, 43, 42, -1, - 45, 42, 46, -1, - 46, 42, 41, -1, - 46, 41, 47, -1, - 47, 41, 40, -1, - 47, 40, 48, -1, - 48, 40, 39, -1, - 48, 39, 49, -1, - 49, 39, 38, -1, - 49, 38, 50, -1, - 50, 38, 37, -1, - 50, 37, 51, -1, - 51, 37, 36, -1, - 51, 36, 52, -1, - 52, 36, 35, -1, - 52, 35, 53, -1, - 53, 35, 34, -1, - 53, 34, 54, -1, - 54, 34, 33, -1, - 54, 33, 55, -1, - 55, 33, 32, -1, - 55, 32, 56, -1, - 56, 32, 31, -1, - 56, 31, 57, -1, - 57, 31, 30, -1, - 57, 30, 58, -1, - 58, 30, 29, -1, - 58, 29, 59, -1, - 59, 29, 28, -1, - 59, 28, 60, -1, - 60, 28, 27, -1, - 60, 27, 61, -1, - 61, 27, 26, -1, - 61, 26, 62, -1, - 62, 26, 25, -1, - 62, 25, 63, -1, - 63, 25, 24, -1, - 63, 24, 64, -1, - 64, 24, 23, -1, - 64, 23, 65, -1, - 65, 23, 22, -1, - 65, 22, 66, -1, - 66, 22, 21, -1, - 66, 21, 67, -1, - 67, 21, 20, -1, - 67, 20, 68, -1, - 68, 20, 19, -1, - 68, 19, 69, -1, - 69, 19, 18, -1, - 69, 18, 70, -1, - 70, 18, 17, -1, - 70, 17, 71, -1, - 71, 17, 16, -1, - 71, 16, 72, -1, - 72, 16, 15, -1, - 72, 15, 73, -1, - 73, 15, 14, -1, - 73, 14, 74, -1, - 74, 14, 13, -1, - 74, 13, 75, -1, - 75, 13, 12, -1, - 75, 12, 76, -1, - 76, 12, 11, -1, - 76, 11, 77, -1, - 77, 11, 10, -1, - 77, 10, 78, -1, - 78, 10, 9, -1, - 78, 9, 79, -1, - 79, 9, 8, -1, - 79, 8, 80, -1, - 80, 8, 7, -1, - 80, 7, 81, -1, - 81, 7, 6, -1, - 81, 6, 82, -1, - 82, 6, 5, -1, - 82, 5, 83, -1, - 83, 5, 4, -1, - 83, 4, 84, -1, - 84, 4, 3, -1, - 84, 3, 85, -1, - 85, 3, 2, -1, - 85, 2, 86, -1, - 86, 2, 1, -1, - 86, 1, 87, -1, - 87, 1, 0, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.6087 0.270857 -1.6287, - 7.80873 0.270857 -1.6287, - 7.80873 -6.82914 -1.6287, - 12.6087 -6.82914 -1.6287, - 12.5587 0.120857 -1.6287, - 12.5587 -6.77914 -1.6287, - 7.85873 -6.77914 -1.6287, - 7.85873 0.120857 -1.6287 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 5, 6, 2, -1, - 2, 6, 1, -1, - 1, 6, 7, -1, - 1, 7, 0, -1, - 0, 7, 4, -1, - 0, 4, 3, -1, - 3, 4, 5, -1, - 3, 5, 2, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.5587 -6.77914 2.3713, - 7.85873 -6.77914 2.3713, - 7.85873 -6.77914 -1.6287, - 12.5587 -6.77914 -1.6287, - 10.8079 -6.77914 0.571301, - 10.7959 -6.77914 0.452029, - 10.7522 -6.77914 0.318953, - 10.6789 -6.77914 0.199628, - 10.5799 -6.77914 0.100555, - 10.4606 -6.77914 0.0271335, - 10.3276 -6.77914 -0.0166368, - 10.188 -6.77914 -0.0283703, - 10.0495 -6.77914 -0.00742763, - 9.91965 -6.77914 0.0450497, - 9.8055 -6.77914 0.126203, - 9.71327 -6.77914 0.231609, - 9.648 -6.77914 0.355525, - 9.61323 -6.77914 0.491199, - 9.61086 -6.77914 0.631237, - 9.64102 -6.77914 0.768009, - 9.70206 -6.77914 0.894064, - 9.79067 -6.77914 1.00253, - 9.90201 -6.77914 1.0875, - 10.03 -6.77914 1.14434, - 10.1677 -6.77914 1.16996, - 10.3076 -6.77914 1.16295, - 10.442 -6.77914 1.12371, - 10.5637 -6.77914 1.05437, - 10.666 -6.77914 0.958699, - 10.7434 -6.77914 0.841924, - 10.7915 -6.77914 0.710402 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 11, 12, 2, -1, - 2, 12, 13, -1, - 2, 13, 14, -1, - 2, 14, 15, -1, - 2, 15, 1, -1, - 1, 15, 16, -1, - 1, 16, 17, -1, - 1, 17, 18, -1, - 1, 18, 19, -1, - 1, 19, 20, -1, - 1, 20, 21, -1, - 1, 21, 22, -1, - 1, 22, 0, -1, - 0, 22, 23, -1, - 0, 23, 24, -1, - 0, 24, 25, -1, - 0, 25, 26, -1, - 0, 26, 27, -1, - 0, 27, 28, -1, - 0, 28, 3, -1, - 3, 28, 29, -1, - 11, 2, 10, -1, - 10, 2, 9, -1, - 9, 2, 8, -1, - 8, 2, 3, -1, - 8, 3, 7, -1, - 7, 3, 6, -1, - 6, 3, 5, -1, - 5, 3, 4, -1, - 4, 3, 30, -1, - 30, 3, 29, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.85873 0.120857 2.3713, - 12.5587 0.120857 2.3713, - 12.5587 0.120857 -1.6287, - 7.85873 0.120857 -1.6287 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.5587 0.120857 2.3713, - 12.5587 -6.77914 2.3713, - 12.5587 -6.77914 -1.6287, - 12.5587 0.120857 -1.6287 - ] - } - normal Normal { - vector [ - 1 3.9968e-013 -0, - 1 3.9968e-013 -0, - 1 3.9968e-013 -0, - 1 3.9968e-013 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.85873 -6.77914 2.3713, - 7.85873 0.120857 2.3713, - 7.85873 0.120857 -1.6287, - 7.85873 -6.77914 -1.6287 - ] - } - normal Normal { - vector [ - -1 1.28979e-013 0, - -1 1.28979e-013 0, - -1 1.28979e-013 0, - -1 1.28979e-013 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 10.7079 3.47086 -3.52155, - 10.6911 3.47086 -3.64996, - 10.6419 3.47086 -3.76975, - 10.5636 3.47086 -3.8729, - 10.4614 3.47086 -3.95248, - 10.3423 3.47086 -4.00315, - 10.2141 3.47086 -4.02151, - 10.0855 3.47086 -4.00634, - 9.96506 3.47086 -3.95864, - 9.86095 3.47086 -3.88163, - 9.78011 3.47086 -3.78046, - 9.72796 3.47086 -3.66192, - 9.70801 3.47086 -3.53397, - 9.72158 3.47086 -3.40519, - 9.76778 3.47086 -3.28421, - 9.84349 3.47086 -3.17915, - 9.94365 3.47086 -3.09706, - 10.0615 3.47086 -3.04344, - 10.1892 3.47086 -3.0219, - 10.3182 3.47086 -3.03387, - 10.4397 3.47086 -3.07856, - 10.5457 3.47086 -3.15296, - 10.629 3.47086 -3.25209, - 10.6841 3.47086 -3.36929, - 10.7072 3.47086 -3.49671, - 10.7079 3.47086 -3.52155, - 10.7079 5.47086 -3.52155, - 10.7072 5.47086 -3.49671, - 10.6841 5.47086 -3.36929, - 10.629 5.47086 -3.25209, - 10.5457 5.47086 -3.15296, - 10.4397 5.47086 -3.07856, - 10.3182 5.47086 -3.03387, - 10.1892 5.47086 -3.0219, - 10.0615 5.47086 -3.04344, - 9.94365 5.47086 -3.09706, - 9.84349 5.47086 -3.17915, - 9.76778 5.47086 -3.28421, - 9.72158 5.47086 -3.40519, - 9.70801 5.47086 -3.53397, - 9.72796 5.47086 -3.66192, - 9.78011 5.47086 -3.78046, - 9.86095 5.47086 -3.88163, - 9.96506 5.47086 -3.95864, - 10.0855 5.47086 -4.00634, - 10.2141 5.47086 -4.02151, - 10.3423 5.47086 -4.00315, - 10.4614 5.47086 -3.95248, - 10.5636 5.47086 -3.8729, - 10.6419 5.47086 -3.76975, - 10.6911 5.47086 -3.64996, - 10.7079 5.47086 -3.52155 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.96646 -0 0.256818, - -0.868089 -0 0.496409, - -0.711486 -0 0.7027, - -0.507156 -0 0.861854, - -0.268806 -0 0.963194, - -0.012424 -0 0.999923, - 0.244791 -0 0.969576, - 0.485586 -0 0.874189, - 0.693807 -0 0.720161, - 0.855487 -0 0.517824, - 0.95978 -0 0.280752, - 0.999691 -0 0.024846, - 0.972542 0 -0.232726, - 0.880154 0 -0.474687, - 0.728725 0 -0.684806, - 0.528413 0 -0.848987, - 0.292654 0 -0.956218, - 0.0372642 0 -0.999305, - -0.220626 -0 -0.975359, - -0.463716 -0 -0.885984, - -0.675699 -0 -0.737177, - -0.842357 -0 -0.53892, - -0.952509 -0 -0.304512, - -0.998765 -0 -0.0496767, - -1 -0 -2.44921e-016, - -1 -0 -2.44921e-016, - -0.998765 -0 -0.0496767, - -0.952509 -0 -0.304512, - -0.842357 -0 -0.53892, - -0.675699 -0 -0.737177, - -0.463716 -0 -0.885984, - -0.220626 -0 -0.975359, - 0.0372642 0 -0.999305, - 0.292654 0 -0.956218, - 0.528413 0 -0.848987, - 0.728725 0 -0.684806, - 0.880154 0 -0.474687, - 0.972542 0 -0.232726, - 0.999691 -0 0.024846, - 0.95978 -0 0.280752, - 0.855487 -0 0.517824, - 0.693807 -0 0.720161, - 0.485586 -0 0.874189, - 0.244791 -0 0.969576, - -0.012424 -0 0.999923, - -0.268806 -0 0.963194, - -0.507156 -0 0.861854, - -0.711486 -0 0.7027, - -0.868089 -0 0.496409, - -0.96646 -0 0.256818, - -1 -0 -0 - ] - } - coordIndex [ - 27, 26, 25, -1, - 27, 25, 24, -1, - 27, 24, 28, -1, - 28, 24, 23, -1, - 28, 23, 29, -1, - 29, 23, 22, -1, - 29, 22, 30, -1, - 30, 22, 21, -1, - 30, 21, 31, -1, - 31, 21, 20, -1, - 31, 20, 32, -1, - 32, 20, 19, -1, - 32, 19, 33, -1, - 33, 19, 18, -1, - 33, 18, 34, -1, - 34, 18, 17, -1, - 34, 17, 35, -1, - 35, 17, 16, -1, - 35, 16, 36, -1, - 36, 16, 15, -1, - 36, 15, 37, -1, - 37, 15, 14, -1, - 37, 14, 38, -1, - 38, 14, 13, -1, - 38, 13, 39, -1, - 39, 13, 12, -1, - 39, 12, 40, -1, - 40, 12, 11, -1, - 40, 11, 41, -1, - 41, 11, 10, -1, - 41, 10, 42, -1, - 42, 10, 9, -1, - 42, 9, 43, -1, - 43, 9, 8, -1, - 43, 8, 44, -1, - 44, 8, 7, -1, - 44, 7, 45, -1, - 45, 7, 6, -1, - 45, 6, 46, -1, - 46, 6, 5, -1, - 46, 5, 47, -1, - 47, 5, 4, -1, - 47, 4, 48, -1, - 48, 4, 3, -1, - 48, 3, 49, -1, - 49, 3, 2, -1, - 49, 2, 50, -1, - 50, 2, 1, -1, - 50, 1, 51, -1, - 51, 1, 0, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.3079 3.47086 0.0415097, - 12.2913 3.47086 -0.221767, - 12.2418 3.47086 -0.480889, - 12.1603 3.47086 -0.731768, - 12.0479 3.47086 -0.970444, - 11.9066 3.47086 -1.19315, - 11.7384 3.47086 -1.39638, - 11.546 3.47086 -1.57691, - 11.3326 3.47086 -1.73191, - 11.1014 3.47086 -1.85892, - 10.8561 3.47086 -1.95595, - 10.6005 3.47086 -2.02145, - 10.3388 3.47086 -2.0544, - 10.075 3.47086 -2.05428, - 9.81329 3.47086 -2.02109, - 9.55782 3.47086 -1.95535, - 9.3126 3.47086 -1.8581, - 9.08151 3.47086 -1.73087, - 8.86819 3.47086 -1.57568, - 8.67602 3.47086 -1.39497, - 8.50801 3.47086 -1.19159, - 8.36683 3.47086 -0.968751, - 8.2547 3.47086 -0.729971, - 8.17339 3.47086 -0.479017, - 8.12418 3.47086 -0.21985, - 8.10786 3.47086 0.0434418, - 8.12467 3.47086 0.306703, - 8.17435 3.47086 0.565779, - 8.25612 3.47086 0.816583, - 8.36869 3.47086 1.05516, - 8.51028 3.47086 1.27773, - 8.67866 3.47086 1.4808, - 8.87117 3.47086 1.66116, - 9.08477 3.47086 1.81596, - 9.3161 3.47086 1.94276, - 9.56149 3.47086 2.03956, - 9.81709 3.47086 2.10483, - 10.0788 3.47086 2.13754, - 10.3426 3.47086 2.13718, - 10.6043 3.47086 2.10375, - 10.8597 3.47086 2.03777, - 11.1049 3.47086 1.9403, - 11.3358 3.47086 1.81286, - 11.549 3.47086 1.65747, - 11.741 3.47086 1.47658, - 11.9088 3.47086 1.27304, - 12.0498 3.47086 1.05008, - 12.1617 3.47086 0.811193, - 12.2428 3.47086 0.560165, - 12.2918 3.47086 0.300952, - 12.2697 3.47086 0.0415097, - 12.2603 3.47086 0.238189, - 12.2191 3.47086 0.49511, - 12.146 3.47086 0.744806, - 12.042 3.47086 0.983304, - 11.9088 3.47086 1.2068, - 11.7485 3.47086 1.41174, - 11.5636 3.47086 1.59486, - 11.3572 3.47086 1.75325, - 11.1325 3.47086 1.88437, - 10.893 3.47086 1.98615, - 10.6426 3.47086 2.05695, - 10.3854 3.47086 2.09566, - 10.1252 3.47086 2.10166, - 9.86643 3.47086 2.07485, - 9.61306 3.47086 2.01566, - 9.36917 3.47086 1.92503, - 9.13863 3.47086 1.80441, - 8.92512 3.47086 1.65571, - 8.73203 3.47086 1.4813, - 8.56245 3.47086 1.28397, - 8.41907 3.47086 1.06685, - 8.30418 3.47086 0.8334, - 8.21961 3.47086 0.58734, - 8.1667 3.47086 0.332588, - 8.14629 3.47086 0.0732003, - 8.15871 3.47086 -0.186693, - 8.20377 3.47086 -0.442951, - 8.28074 3.47086 -0.691494, - 8.3884 3.47086 -0.928364, - 8.52504 3.47086 -1.14979, - 8.68848 3.47086 -1.35224, - 8.87611 3.47086 -1.5325, - 9.08495 3.47086 -1.68769, - 9.31167 3.47086 -1.81535, - 9.55266 3.47086 -1.91343, - 9.80409 3.47086 -1.98038, - 10.0619 3.47086 -2.01513, - 10.3221 3.47086 -2.01713, - 10.5805 3.47086 -1.98635, - 10.8329 3.47086 -1.92327, - 11.0754 3.47086 -1.8289, - 11.3041 3.47086 -1.70475, - 11.5153 3.47086 -1.55278, - 11.7056 3.47086 -1.37543, - 11.8722 3.47086 -1.17551, - 12.0122 3.47086 -0.956215, - 12.1235 3.47086 -0.721028, - 12.2043 3.47086 -0.473697, - 12.2532 3.47086 -0.218162 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 49, 0, 48, -1, - 48, 0, 1, -1, - 48, 1, 51, -1, - 51, 1, 50, -1, - 50, 1, 99, -1, - 51, 52, 48, -1, - 48, 52, 47, -1, - 47, 52, 53, -1, - 47, 53, 46, -1, - 46, 53, 54, -1, - 46, 54, 45, -1, - 45, 54, 55, -1, - 45, 55, 44, -1, - 44, 55, 56, -1, - 44, 56, 43, -1, - 43, 56, 57, -1, - 43, 57, 42, -1, - 42, 57, 58, -1, - 42, 58, 41, -1, - 41, 58, 59, -1, - 41, 59, 40, -1, - 40, 59, 60, -1, - 40, 60, 39, -1, - 39, 60, 61, -1, - 39, 61, 38, -1, - 38, 61, 62, -1, - 38, 62, 37, -1, - 37, 62, 63, -1, - 37, 63, 36, -1, - 36, 63, 64, -1, - 36, 64, 35, -1, - 35, 64, 65, -1, - 35, 65, 34, -1, - 34, 65, 66, -1, - 34, 66, 33, -1, - 33, 66, 67, -1, - 33, 67, 32, -1, - 32, 67, 68, -1, - 32, 68, 31, -1, - 31, 68, 69, -1, - 31, 69, 30, -1, - 30, 69, 70, -1, - 30, 70, 29, -1, - 29, 70, 71, -1, - 29, 71, 28, -1, - 28, 71, 72, -1, - 28, 72, 27, -1, - 27, 72, 73, -1, - 27, 73, 26, -1, - 26, 73, 74, -1, - 26, 74, 25, -1, - 25, 74, 75, -1, - 25, 75, 24, -1, - 24, 75, 76, -1, - 24, 76, 23, -1, - 23, 76, 77, -1, - 23, 77, 22, -1, - 22, 77, 78, -1, - 22, 78, 21, -1, - 21, 78, 79, -1, - 21, 79, 20, -1, - 20, 79, 80, -1, - 20, 80, 19, -1, - 19, 80, 81, -1, - 19, 81, 18, -1, - 18, 81, 82, -1, - 18, 82, 17, -1, - 17, 82, 83, -1, - 17, 83, 16, -1, - 16, 83, 84, -1, - 16, 84, 15, -1, - 15, 84, 85, -1, - 15, 85, 14, -1, - 14, 85, 86, -1, - 14, 86, 13, -1, - 13, 86, 87, -1, - 13, 87, 12, -1, - 12, 87, 88, -1, - 12, 88, 11, -1, - 11, 88, 89, -1, - 11, 89, 10, -1, - 10, 89, 90, -1, - 10, 90, 9, -1, - 9, 90, 91, -1, - 9, 91, 8, -1, - 8, 91, 92, -1, - 8, 92, 7, -1, - 7, 92, 93, -1, - 7, 93, 6, -1, - 6, 93, 94, -1, - 6, 94, 5, -1, - 5, 94, 95, -1, - 5, 95, 4, -1, - 4, 95, 96, -1, - 4, 96, 3, -1, - 3, 96, 97, -1, - 3, 97, 2, -1, - 2, 97, 98, -1, - 2, 98, 1, -1, - 1, 98, 99, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 10.7079 3.47086 -3.52155, - 10.6911 3.47086 -3.64996, - 10.6419 3.47086 -3.76975, - 10.5636 3.47086 -3.8729, - 10.4614 3.47086 -3.95248, - 10.3423 3.47086 -4.00315, - 10.2141 3.47086 -4.02151, - 10.0855 3.47086 -4.00634, - 9.96506 3.47086 -3.95864, - 9.86095 3.47086 -3.88163, - 9.78011 3.47086 -3.78046, - 9.72796 3.47086 -3.66192, - 9.70801 3.47086 -3.53397, - 9.72158 3.47086 -3.40519, - 9.76778 3.47086 -3.28421, - 9.84349 3.47086 -3.17915, - 9.94365 3.47086 -3.09706, - 10.0615 3.47086 -3.04344, - 10.1892 3.47086 -3.0219, - 10.3182 3.47086 -3.03387, - 10.4397 3.47086 -3.07856, - 10.5457 3.47086 -3.15296, - 10.629 3.47086 -3.25209, - 10.6841 3.47086 -3.36929, - 10.7072 3.47086 -3.49671 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 24, 0, 23, -1, - 23, 0, 1, -1, - 23, 1, 22, -1, - 22, 1, 2, -1, - 22, 2, 21, -1, - 21, 2, 3, -1, - 21, 3, 20, -1, - 20, 3, 4, -1, - 20, 4, 19, -1, - 19, 4, 5, -1, - 19, 5, 18, -1, - 18, 5, 6, -1, - 18, 6, 17, -1, - 17, 6, 7, -1, - 17, 7, 16, -1, - 16, 7, 8, -1, - 16, 8, 15, -1, - 15, 8, 9, -1, - 15, 9, 14, -1, - 14, 9, 10, -1, - 14, 10, 13, -1, - 13, 10, 11, -1, - 13, 11, 12, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.3079 3.47086 0.0415097, - 12.2913 3.47086 -0.221767, - 12.2418 3.47086 -0.480889, - 12.1603 3.47086 -0.731768, - 12.0479 3.47086 -0.970444, - 11.9066 3.47086 -1.19315, - 11.7384 3.47086 -1.39638, - 11.546 3.47086 -1.57691, - 11.3326 3.47086 -1.73191, - 11.1014 3.47086 -1.85892, - 10.8561 3.47086 -1.95595, - 10.6005 3.47086 -2.02145, - 10.3388 3.47086 -2.0544, - 10.075 3.47086 -2.05428, - 9.81329 3.47086 -2.02109, - 9.55782 3.47086 -1.95535, - 9.3126 3.47086 -1.8581, - 9.08151 3.47086 -1.73087, - 8.86819 3.47086 -1.57568, - 8.67602 3.47086 -1.39497, - 8.50801 3.47086 -1.19159, - 8.36683 3.47086 -0.968751, - 8.2547 3.47086 -0.729971, - 8.17339 3.47086 -0.479017, - 8.12418 3.47086 -0.21985, - 8.10786 3.47086 0.0434418, - 8.12467 3.47086 0.306703, - 8.17435 3.47086 0.565779, - 8.25612 3.47086 0.816583, - 8.36869 3.47086 1.05516, - 8.51028 3.47086 1.27773, - 8.67866 3.47086 1.4808, - 8.87117 3.47086 1.66116, - 9.08477 3.47086 1.81596, - 9.3161 3.47086 1.94276, - 9.56149 3.47086 2.03956, - 9.81709 3.47086 2.10483, - 10.0788 3.47086 2.13754, - 10.3426 3.47086 2.13718, - 10.6043 3.47086 2.10375, - 10.8597 3.47086 2.03777, - 11.1049 3.47086 1.9403, - 11.3358 3.47086 1.81286, - 11.549 3.47086 1.65747, - 11.741 3.47086 1.47658, - 11.9088 3.47086 1.27304, - 12.0498 3.47086 1.05008, - 12.1617 3.47086 0.811193, - 12.2428 3.47086 0.560165, - 12.2918 3.47086 0.300952, - 12.3079 3.47086 0.0415097, - 12.3079 5.47086 0.0415097, - 12.2918 5.47086 0.300952, - 12.2428 5.47086 0.560165, - 12.1617 5.47086 0.811193, - 12.0498 5.47086 1.05008, - 11.9088 5.47086 1.27304, - 11.741 5.47086 1.47658, - 11.549 5.47086 1.65747, - 11.3358 5.47086 1.81286, - 11.1049 5.47086 1.9403, - 10.8597 5.47086 2.03777, - 10.6043 5.47086 2.10375, - 10.3426 5.47086 2.13718, - 10.0788 5.47086 2.13754, - 9.81709 5.47086 2.10483, - 9.56149 5.47086 2.03956, - 9.3161 5.47086 1.94276, - 9.08477 5.47086 1.81596, - 8.87117 5.47086 1.66116, - 8.67866 5.47086 1.4808, - 8.51028 5.47086 1.27773, - 8.36869 5.47086 1.05516, - 8.25612 5.47086 0.816583, - 8.17435 5.47086 0.565779, - 8.12467 5.47086 0.306703, - 8.10786 5.47086 0.0434418, - 8.12418 5.47086 -0.21985, - 8.17339 5.47086 -0.479017, - 8.2547 5.47086 -0.729971, - 8.36683 5.47086 -0.968751, - 8.50801 5.47086 -1.19159, - 8.67602 5.47086 -1.39497, - 8.86819 5.47086 -1.57568, - 9.08151 5.47086 -1.73087, - 9.3126 5.47086 -1.8581, - 9.55782 5.47086 -1.95535, - 9.81329 5.47086 -2.02109, - 10.075 5.47086 -2.05428, - 10.3388 5.47086 -2.0544, - 10.6005 5.47086 -2.02145, - 10.8561 5.47086 -1.95595, - 11.1014 5.47086 -1.85892, - 11.3326 5.47086 -1.73191, - 11.546 5.47086 -1.57691, - 11.7384 5.47086 -1.39638, - 11.9066 5.47086 -1.19315, - 12.0479 5.47086 -0.970444, - 12.1603 5.47086 -0.731768, - 12.2418 5.47086 -0.480889, - 12.2913 5.47086 -0.221767, - 12.3079 5.47086 0.0415097 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.99211 -0 0.12537, - -0.968565 -0 0.248761, - -0.929736 -0 0.368227, - -0.876236 -0 0.481883, - -0.808909 -0 0.587934, - -0.728817 -0 0.684708, - -0.637225 -0 0.770677, - -0.535578 -0 0.844486, - -0.42548 -0 0.904968, - -0.308667 -0 0.95117, - -0.186984 -0 0.982363, - -0.0623498 -0 0.998054, - 0.063268 -0 0.997997, - 0.187887 -0 0.982191, - 0.309542 -0 0.950886, - 0.426312 -0 0.904576, - 0.536355 -0 0.843993, - 0.637934 -0 0.770091, - 0.729447 -0 0.684037, - 0.809449 -0 0.58719, - 0.876679 -0 0.481076, - 0.930074 -0 0.367372, - 0.968793 -0 0.24787, - 0.992225 -0 0.124457, - 1 0 -0.000920056, - 0.991994 0 -0.126282, - 0.968336 0 -0.249652, - 0.929397 0 -0.369082, - 0.875792 0 -0.482689, - 0.808368 0 -0.588678, - 0.728187 0 -0.685378, - 0.636516 0 -0.771263, - 0.534801 0 -0.844978, - 0.424647 0 -0.905359, - 0.307792 0 -0.951454, - 0.18608 0 -0.982535, - 0.0614315 0 -0.998111, - -0.0641862 -0 -0.997938, - -0.188791 -0 -0.982017, - -0.310417 -0 -0.950601, - -0.427144 -0 -0.904184, - -0.537131 -0 -0.843499, - -0.638643 -0 -0.769504, - -0.730076 -0 -0.683366, - -0.809989 -0 -0.586445, - -0.877121 -0 -0.480269, - -0.930412 -0 -0.366516, - -0.969021 -0 -0.246978, - -0.992339 -0 -0.123544, - -1 -0 -2.44921e-016, - -1 -0 -2.44921e-016, - -0.992339 -0 -0.123544, - -0.969021 -0 -0.246978, - -0.930412 -0 -0.366516, - -0.877121 -0 -0.480269, - -0.809989 -0 -0.586445, - -0.730076 -0 -0.683366, - -0.638643 -0 -0.769504, - -0.537131 -0 -0.843499, - -0.427144 -0 -0.904184, - -0.310417 -0 -0.950601, - -0.188791 -0 -0.982017, - -0.0641862 -0 -0.997938, - 0.0614315 0 -0.998111, - 0.18608 0 -0.982535, - 0.307792 0 -0.951454, - 0.424647 0 -0.905359, - 0.534801 0 -0.844978, - 0.636516 0 -0.771263, - 0.728187 0 -0.685378, - 0.808368 0 -0.588678, - 0.875792 0 -0.482689, - 0.929397 0 -0.369082, - 0.968336 0 -0.249652, - 0.991994 0 -0.126282, - 1 0 -0.000920056, - 0.992225 -0 0.124457, - 0.968793 -0 0.24787, - 0.930074 -0 0.367372, - 0.876679 -0 0.481076, - 0.809449 -0 0.58719, - 0.729447 -0 0.684037, - 0.637934 -0 0.770091, - 0.536355 -0 0.843993, - 0.426312 -0 0.904576, - 0.309542 -0 0.950886, - 0.187887 -0 0.982191, - 0.063268 -0 0.997997, - -0.0623498 -0 0.998054, - -0.186984 -0 0.982363, - -0.308667 -0 0.95117, - -0.42548 -0 0.904968, - -0.535578 -0 0.844486, - -0.637225 -0 0.770677, - -0.728817 -0 0.684708, - -0.808909 -0 0.587934, - -0.876236 -0 0.481883, - -0.929736 -0 0.368227, - -0.968565 -0 0.248761, - -0.99211 -0 0.12537, - -1 -0 -0 - ] - } - coordIndex [ - 52, 51, 50, -1, - 52, 50, 49, -1, - 52, 49, 53, -1, - 53, 49, 48, -1, - 53, 48, 54, -1, - 54, 48, 47, -1, - 54, 47, 55, -1, - 55, 47, 46, -1, - 55, 46, 56, -1, - 56, 46, 45, -1, - 56, 45, 57, -1, - 57, 45, 44, -1, - 57, 44, 58, -1, - 58, 44, 43, -1, - 58, 43, 59, -1, - 59, 43, 42, -1, - 59, 42, 60, -1, - 60, 42, 41, -1, - 60, 41, 61, -1, - 61, 41, 40, -1, - 61, 40, 62, -1, - 62, 40, 39, -1, - 62, 39, 63, -1, - 63, 39, 38, -1, - 63, 38, 64, -1, - 64, 38, 37, -1, - 64, 37, 65, -1, - 65, 37, 36, -1, - 65, 36, 66, -1, - 66, 36, 35, -1, - 66, 35, 67, -1, - 67, 35, 34, -1, - 67, 34, 68, -1, - 68, 34, 33, -1, - 68, 33, 69, -1, - 69, 33, 32, -1, - 69, 32, 70, -1, - 70, 32, 31, -1, - 70, 31, 71, -1, - 71, 31, 30, -1, - 71, 30, 72, -1, - 72, 30, 29, -1, - 72, 29, 73, -1, - 73, 29, 28, -1, - 73, 28, 74, -1, - 74, 28, 27, -1, - 74, 27, 75, -1, - 75, 27, 26, -1, - 75, 26, 76, -1, - 76, 26, 25, -1, - 76, 25, 77, -1, - 77, 25, 24, -1, - 77, 24, 78, -1, - 78, 24, 23, -1, - 78, 23, 79, -1, - 79, 23, 22, -1, - 79, 22, 80, -1, - 80, 22, 21, -1, - 80, 21, 81, -1, - 81, 21, 20, -1, - 81, 20, 82, -1, - 82, 20, 19, -1, - 82, 19, 83, -1, - 83, 19, 18, -1, - 83, 18, 84, -1, - 84, 18, 17, -1, - 84, 17, 85, -1, - 85, 17, 16, -1, - 85, 16, 86, -1, - 86, 16, 15, -1, - 86, 15, 87, -1, - 87, 15, 14, -1, - 87, 14, 88, -1, - 88, 14, 13, -1, - 88, 13, 89, -1, - 89, 13, 12, -1, - 89, 12, 90, -1, - 90, 12, 11, -1, - 90, 11, 91, -1, - 91, 11, 10, -1, - 91, 10, 92, -1, - 92, 10, 9, -1, - 92, 9, 93, -1, - 93, 9, 8, -1, - 93, 8, 94, -1, - 94, 8, 7, -1, - 94, 7, 95, -1, - 95, 7, 6, -1, - 95, 6, 96, -1, - 96, 6, 5, -1, - 96, 5, 97, -1, - 97, 5, 4, -1, - 97, 4, 98, -1, - 98, 4, 3, -1, - 98, 3, 99, -1, - 99, 3, 2, -1, - 99, 2, 100, -1, - 100, 2, 1, -1, - 100, 1, 101, -1, - 101, 1, 0, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.1828 4.47086 -0.550578, - 8.21435 4.47086 0.56782, - 8.29639 4.47086 0.814413, - 8.40881 4.47086 1.04873, - 8.5498 4.47086 1.26704, - 8.71714 4.47086 1.46588, - 8.90816 4.47086 1.64209, - 9.11983 4.47086 1.79287, - 9.34879 4.47086 1.91583, - 9.5914 4.47086 2.009, - 9.8438 4.47086 2.07092, - 10.102 4.47086 2.1006, - 10.3618 4.47086 2.09756, - 10.6193 4.47086 2.06186, - 10.8701 4.47086 1.99405, - 11.1105 4.47086 1.89523, - 11.3365 4.47086 1.76695, - 11.5446 4.47086 1.61126, - 11.7315 4.47086 1.43064, - 11.8941 4.47086 1.22794, - 12.03 4.47086 1.00639, - 12.1369 4.47086 0.76951, - 12.2131 4.47086 0.521066, - 12.2575 4.47086 0.265002, - 12.2697 4.47086 0.0415097, - 12.2506 4.47086 -0.237917, - 12.1939 4.47086 -0.512187 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 26, 0, 25, -1, - 25, 0, 24, -1, - 24, 0, 1, -1, - 24, 1, 23, -1, - 23, 1, 2, -1, - 23, 2, 22, -1, - 22, 2, 3, -1, - 22, 3, 21, -1, - 21, 3, 4, -1, - 21, 4, 20, -1, - 20, 4, 5, -1, - 20, 5, 19, -1, - 19, 5, 6, -1, - 19, 6, 18, -1, - 18, 6, 7, -1, - 18, 7, 17, -1, - 17, 7, 8, -1, - 17, 8, 16, -1, - 16, 8, 9, -1, - 16, 9, 15, -1, - 15, 9, 10, -1, - 15, 10, 14, -1, - 14, 10, 11, -1, - 14, 11, 13, -1, - 13, 11, 12, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.17274 4.47086 0.372197, - 12.1162 4.47086 -0.739143, - 12.0021 4.47086 -0.974208, - 11.8593 4.47086 -1.19296, - 11.6899 4.47086 -1.3919, - 11.4967 4.47086 -1.56781, - 11.2828 4.47086 -1.71788, - 11.0517 4.47086 -1.83971, - 10.807 4.47086 -1.93132, - 10.5527 4.47086 -1.99125, - 10.2929 4.47086 -2.01855, - 10.0317 4.47086 -2.01276, - 9.7733 4.47086 -1.97399, - 9.5219 4.47086 -1.90285, - 9.28151 4.47086 -1.80049, - 9.05601 4.47086 -1.66855, - 8.84899 4.47086 -1.50915, - 8.6638 4.47086 -1.32485, - 8.5034 4.47086 -1.11862, - 8.37037 4.47086 -0.893748, - 8.26685 4.47086 -0.653862, - 8.19449 4.47086 -0.402811, - 8.15446 4.47086 -0.144625, - 8.14741 4.47086 0.116551 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 23, 0, 22, -1, - 22, 0, 21, -1, - 21, 0, 1, -1, - 21, 1, 20, -1, - 20, 1, 2, -1, - 20, 2, 19, -1, - 19, 2, 3, -1, - 19, 3, 18, -1, - 18, 3, 4, -1, - 18, 4, 17, -1, - 17, 4, 5, -1, - 17, 5, 16, -1, - 16, 5, 6, -1, - 16, 6, 15, -1, - 15, 6, 7, -1, - 15, 7, 14, -1, - 14, 7, 8, -1, - 14, 8, 13, -1, - 13, 8, 9, -1, - 13, 9, 12, -1, - 12, 9, 10, -1, - 12, 10, 11, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.21435 4.47086 0.56782, - 8.17274 4.47086 0.372197, - 8.14741 4.47086 0.116551, - 8.15446 4.47086 -0.144625, - 8.19449 4.47086 -0.402811, - 8.26685 4.47086 -0.653862, - 8.37037 4.47086 -0.893748, - 8.5034 4.47086 -1.11862, - 8.6638 4.47086 -1.32485, - 8.84899 4.47086 -1.50915, - 9.05601 4.47086 -1.66855, - 9.28151 4.47086 -1.80049, - 9.5219 4.47086 -1.90285, - 9.7733 4.47086 -1.97399, - 10.0317 4.47086 -2.01276, - 10.2929 4.47086 -2.01855, - 10.5527 4.47086 -1.99125, - 10.807 4.47086 -1.93132, - 11.0517 4.47086 -1.83971, - 11.2828 4.47086 -1.71788, - 11.4967 4.47086 -1.56781, - 11.6899 4.47086 -1.3919, - 11.8593 4.47086 -1.19296, - 12.0021 4.47086 -0.974208, - 12.1162 4.47086 -0.739143, - 12.1828 4.47086 -0.550578, - 12.1939 4.47086 -0.512187, - 12.2506 4.47086 -0.237917, - 12.2697 4.47086 0.0415097, - 12.2697 3.47086 0.0415097, - 12.2532 3.47086 -0.218162, - 12.2043 3.47086 -0.473697, - 12.1235 3.47086 -0.721028, - 12.0122 3.47086 -0.956215, - 11.8722 3.47086 -1.17551, - 11.7056 3.47086 -1.37543, - 11.5153 3.47086 -1.55278, - 11.3041 3.47086 -1.70475, - 11.0754 3.47086 -1.8289, - 10.8329 3.47086 -1.92327, - 10.5805 3.47086 -1.98635, - 10.3221 3.47086 -2.01713, - 10.0619 3.47086 -2.01513, - 9.80409 3.47086 -1.98038, - 9.55266 3.47086 -1.91343, - 9.31167 3.47086 -1.81535, - 9.08495 3.47086 -1.68769, - 8.87611 3.47086 -1.5325, - 8.68848 3.47086 -1.35224, - 8.52504 3.47086 -1.14979, - 8.3884 3.47086 -0.928364, - 8.28074 3.47086 -0.691494, - 8.20377 3.47086 -0.442951, - 8.15871 3.47086 -0.186693, - 8.14629 3.47086 0.0732003, - 8.1667 3.47086 0.332588, - 8.21961 3.47086 0.58734, - 8.30418 3.47086 0.8334, - 8.41907 3.47086 1.06685, - 8.56245 3.47086 1.28397, - 8.73203 3.47086 1.4813, - 8.92512 3.47086 1.65571, - 9.13863 3.47086 1.80441, - 9.36917 3.47086 1.92503, - 9.61306 3.47086 2.01566, - 9.86643 3.47086 2.07485, - 10.1252 3.47086 2.10166, - 10.3854 3.47086 2.09566, - 10.6426 3.47086 2.05695, - 10.893 3.47086 1.98615, - 11.1325 3.47086 1.88437, - 11.3572 3.47086 1.75325, - 11.5636 3.47086 1.59486, - 11.7485 3.47086 1.41174, - 11.9088 3.47086 1.2068, - 12.042 3.47086 0.983304, - 12.146 3.47086 0.744806, - 12.2191 3.47086 0.49511, - 12.2603 3.47086 0.238189, - 12.2697 3.47086 0.0415097, - 12.2697 4.47086 0.0415097, - 12.2575 4.47086 0.265002, - 12.2131 4.47086 0.521066, - 12.1369 4.47086 0.76951, - 12.03 4.47086 1.00639, - 11.8941 4.47086 1.22794, - 11.7315 4.47086 1.43064, - 11.5446 4.47086 1.61126, - 11.3365 4.47086 1.76695, - 11.1105 4.47086 1.89523, - 10.8701 4.47086 1.99405, - 10.6193 4.47086 2.06186, - 10.3618 4.47086 2.09756, - 10.102 4.47086 2.1006, - 9.8438 4.47086 2.07092, - 9.5914 4.47086 2.009, - 9.34879 4.47086 1.91583, - 9.11983 4.47086 1.79287, - 8.90816 4.47086 1.64209, - 8.71714 4.47086 1.46588, - 8.5498 4.47086 1.26704, - 8.40881 4.47086 1.04873, - 8.29639 4.47086 0.814413 - ] - } - normal Normal { - vector [ - -0.966871 -0 0.255266, - -0.987054 -0 0.160387, - -0.999337 -0 0.0363957, - -0.995917 0 -0.0902771, - -0.976504 0 -0.2155, - -0.94141 0 -0.337263, - -0.8912 0 -0.45361, - -0.826679 0 -0.562673, - -0.748884 0 -0.662701, - -0.659063 0 -0.752087, - -0.558659 0 -0.829397, - -0.449285 0 -0.893389, - -0.332696 0 -0.943034, - -0.210764 0 -0.977537, - -0.0854487 0 -0.996343, - 0.0412392 0 -0.999149, - 0.167265 0 -0.985912, - 0.290605 0 -0.956843, - 0.409278 0 -0.91241, - 0.521379 0 -0.853325, - 0.625108 0 -0.780538, - 0.7188 0 -0.695217, - 0.800949 0 -0.598733, - 0.870237 0 -0.492634, - 0.92555 0 -0.378625, - 0.95788 0 -0.287169, - 0.963266 0 -0.268549, - 0.990774 0 -0.135525, - 1 0 0, - 1 0 0, - 0.992037 0 -0.125943, - 0.968277 0 -0.249881, - 0.929096 0 -0.369839, - 0.875119 0 -0.483907, - 0.807206 0 -0.59027, - 0.726438 0 -0.687232, - 0.634102 0 -0.773249, - 0.531667 0 -0.846953, - 0.420766 0 -0.907169, - 0.303164 0 -0.952938, - 0.180734 0 -0.983532, - 0.0554254 0 -0.998463, - -0.0707655 0 -0.997493, - -0.195829 0 -0.980638, - -0.317775 0 -0.948166, - -0.43466 0 -0.900595, - -0.544622 0 -0.838681, - -0.645912 0 -0.763412, - -0.736915 0 -0.675985, - -0.816183 0 -0.577793, - -0.882454 0 -0.470399, - -0.934671 0 -0.355515, - -0.972003 0 -0.234969, - -0.993856 0 -0.11068, - -0.999882 -0 0.0153703, - -0.989985 -0 0.141176, - -0.964321 -0 0.264734, - -0.923302 -0 0.384076, - -0.867578 -0 0.497301, - -0.798038 -0 0.602607, - -0.71579 -0 0.698316, - -0.622142 -0 0.782904, - -0.518587 -0 0.855025, - -0.406773 -0 0.913529, - -0.288481 -0 0.957486, - -0.165595 -0 0.986194, - -0.0400722 -0 0.999197, - 0.0860889 0 0.996287, - 0.210879 0 0.977512, - 0.332311 0 0.94317, - 0.448451 0 0.893808, - 0.557449 0 0.830211, - 0.65757 0 0.753394, - 0.747218 0 0.664578, - 0.824968 0 0.56518, - 0.88958 0 0.45678, - 0.940025 0 0.341107, - 0.9755 0 0.220001, - 0.99544 0 0.0953915, - 1 0 2.44921e-016, - 1 0 2.44921e-016, - 0.994108 0 0.108396, - 0.972575 0 0.23259, - 0.93559 0 0.353088, - 0.883741 0 0.467977, - 0.817851 0 0.57543, - 0.738967 0 0.673741, - 0.648343 0 0.761348, - 0.547419 0 0.836859, - 0.437797 0 0.899074, - 0.321219 0 0.947005, - 0.199538 0 0.97989, - 0.0746869 0 0.997207, - -0.0513509 -0 0.998681, - -0.176573 -0 0.984288, - -0.298989 -0 0.954256, - -0.416656 -0 0.909064, - -0.527702 -0 0.849429, - -0.630365 -0 0.776299, - -0.723013 -0 0.690835, - -0.804173 -0 0.594395, - -0.872558 -0 0.488511, - -0.927079 -0 0.374867 - ] - } - coordIndex [ - 28, 29, 30, -1, - 28, 30, 27, -1, - 27, 30, 31, -1, - 27, 31, 26, -1, - 26, 31, 32, -1, - 26, 32, 25, -1, - 25, 32, 24, -1, - 24, 32, 33, -1, - 24, 33, 23, -1, - 23, 33, 34, -1, - 23, 34, 22, -1, - 22, 34, 35, -1, - 22, 35, 21, -1, - 21, 35, 36, -1, - 21, 36, 20, -1, - 20, 36, 37, -1, - 20, 37, 19, -1, - 19, 37, 38, -1, - 19, 38, 18, -1, - 18, 38, 39, -1, - 18, 39, 17, -1, - 17, 39, 40, -1, - 17, 40, 16, -1, - 16, 40, 41, -1, - 16, 41, 15, -1, - 15, 41, 42, -1, - 15, 42, 14, -1, - 14, 42, 43, -1, - 14, 43, 13, -1, - 13, 43, 44, -1, - 13, 44, 12, -1, - 12, 44, 45, -1, - 12, 45, 11, -1, - 11, 45, 46, -1, - 11, 46, 10, -1, - 10, 46, 47, -1, - 10, 47, 9, -1, - 9, 47, 48, -1, - 9, 48, 8, -1, - 8, 48, 49, -1, - 8, 49, 7, -1, - 7, 49, 50, -1, - 7, 50, 6, -1, - 6, 50, 51, -1, - 6, 51, 5, -1, - 5, 51, 52, -1, - 5, 52, 4, -1, - 4, 52, 53, -1, - 4, 53, 3, -1, - 3, 53, 54, -1, - 3, 54, 2, -1, - 2, 54, 55, -1, - 2, 55, 1, -1, - 1, 55, 56, -1, - 1, 56, 0, -1, - 0, 56, 102, -1, - 102, 56, 57, -1, - 102, 57, 101, -1, - 101, 57, 58, -1, - 101, 58, 100, -1, - 100, 58, 59, -1, - 100, 59, 99, -1, - 99, 59, 60, -1, - 99, 60, 98, -1, - 98, 60, 61, -1, - 98, 61, 97, -1, - 97, 61, 62, -1, - 97, 62, 96, -1, - 96, 62, 63, -1, - 96, 63, 95, -1, - 95, 63, 64, -1, - 95, 64, 94, -1, - 94, 64, 65, -1, - 94, 65, 93, -1, - 93, 65, 66, -1, - 93, 66, 92, -1, - 92, 66, 67, -1, - 92, 67, 91, -1, - 91, 67, 68, -1, - 91, 68, 90, -1, - 90, 68, 69, -1, - 90, 69, 89, -1, - 89, 69, 70, -1, - 89, 70, 88, -1, - 88, 70, 71, -1, - 88, 71, 87, -1, - 87, 71, 72, -1, - 87, 72, 86, -1, - 86, 72, 73, -1, - 86, 73, 85, -1, - 85, 73, 74, -1, - 85, 74, 84, -1, - 84, 74, 75, -1, - 84, 75, 83, -1, - 83, 75, 76, -1, - 83, 76, 82, -1, - 82, 76, 77, -1, - 82, 77, 81, -1, - 81, 77, 78, -1, - 81, 78, 79, -1, - 81, 79, 80, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.21435 4.47086 0.56782, - 12.1828 4.47086 -0.550578, - 12.1728 4.24273 -0.556044, - 12.1388 3.46958 -0.574505, - 12.0943 2.47086 -0.598196, - 8.26497 2.47086 0.480991, - 8.23938 3.46958 0.524437, - 8.22 4.24273 0.55795 - ] - } - normal Normal { - vector [ - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921, - -0.271089 0.0348995 -0.961921 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 5, -1, - 5, 0, 1, -1, - 5, 1, 4, -1, - 4, 1, 2, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.0742 2.47086 -0.654749, - 8.25261 2.47086 0.422248, - 8.26497 2.47086 0.480991, - 12.0943 2.47086 -0.598196 - ] - } - normal Normal { - vector [ - 0 1 -0, - 0 1 -0, - 0 1 -0, - 0 1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1109421936 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.1162 4.47086 -0.739143, - 8.17274 4.47086 0.372197, - 8.18201 4.2361 0.3781, - 8.21257 3.46754 0.397373, - 8.25261 2.47086 0.422248, - 12.0742 2.47086 -0.654749, - 12.0953 3.46754 -0.696873, - 12.1113 4.2361 -0.729264 - ] - } - normal Normal { - vector [ - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921, - 0.271089 0.0348995 0.961921 - ] - } - coordIndex [ - 7, 0, 6, -1, - 6, 0, 1, -1, - 6, 1, 5, -1, - 5, 1, 2, -1, - 5, 2, 4, -1, - 4, 2, 3, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.1728 4.24273 -0.556044, - 12.1388 3.46958 -0.574505, - 12.0943 2.47086 -0.598196, - 12.0742 2.47086 -0.654749, - 12.0953 3.46754 -0.696873, - 12.1113 4.2361 -0.729264, - 12.1162 4.47086 -0.739143, - 12.1828 4.47086 -0.550578 - ] - } - normal Normal { - vector [ - -0.956157 0.0348995 0.290767, - -0.952115 0.0348995 0.303743, - -0.946454 0.0348995 0.320947, - -0.936353 0.0348995 0.34932, - -0.930709 0.0348995 0.364092, - -0.926328 0.0348995 0.375097, - -0.924986 0.0348995 0.378394, - -0.957296 0.0348995 0.286994 - ] - } - coordIndex [ - 1, 0, 7, -1, - 1, 7, 2, -1, - 2, 7, 3, -1, - 3, 7, 6, -1, - 3, 6, 4, -1, - 4, 6, 5, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.18201 4.2361 0.3781, - 8.21257 3.46754 0.397373, - 8.25261 2.47086 0.422248, - 8.26497 2.47086 0.480991, - 8.23938 3.46958 0.524437, - 8.22 4.24273 0.55795, - 8.21435 4.47086 0.56782, - 8.17274 4.47086 0.372197 - ] - } - normal Normal { - vector [ - 0.985876 0.0348995 -0.163802, - 0.983865 0.0348995 -0.175474, - 0.980965 0.0348995 -0.191021, - 0.974764 0.0348995 -0.220492, - 0.970608 0.0348995 -0.238121, - 0.96728 0.0348995 -0.251298, - 0.966282 0.0348995 -0.255111, - 0.986453 0.0348995 -0.160289 - ] - } - coordIndex [ - 1, 0, 7, -1, - 1, 7, 2, -1, - 2, 7, 3, -1, - 3, 7, 6, -1, - 3, 6, 4, -1, - 4, 6, 5, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70873 0.470857 -2.68457, - 7.70873 -7.02914 -2.68457, - 8.30873 -7.02914 -2.68457, - 8.30873 0.470857 -2.68457 - ] - } - normal Normal { - vector [ - 0 0 1, - 0 0 1, - 0 0 1, - 0 0 1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 8.30873 -7.02914 -2.68457, - 8.30873 -7.02914 -2.08457, - 8.30873 0.470857 -2.08457, - 8.30873 0.470857 -2.68457 - ] - } - normal Normal { - vector [ - -1 0 0, - -1 0 0, - -1 0 0, - -1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70873 0.470857 -2.08457, - 7.70873 0.470857 -2.68457, - 8.30873 0.470857 -2.68457, - 8.30873 0.470857 -2.08457 - ] - } - normal Normal { - vector [ - -0 -1 -0, - -0 -1 -0, - -0 -1 -0, - -0 -1 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 7.70873 -7.02914 -2.08457, - 7.70873 0.470857 -2.08457, - 8.30873 0.470857 -2.08457, - 8.30873 -7.02914 -2.08457 - ] - } - normal Normal { - vector [ - -0 0 -1, - -0 0 -1, - -0 0 -1, - -0 0 -1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 10.7079 -11.4291 0.571301, - 10.6911 -11.4291 0.69971, - 10.6419 -11.4291 0.819506, - 10.5636 -11.4291 0.922651, - 10.4614 -11.4291 1.00223, - 10.3423 -11.4291 1.0529, - 10.2141 -11.4291 1.07126, - 10.0855 -11.4291 1.05609, - 9.96506 -11.4291 1.0084, - 9.86095 -11.4291 0.931382, - 9.78011 -11.4291 0.830213, - 9.72796 -11.4291 0.711677, - 9.70801 -11.4291 0.583724, - 9.72158 -11.4291 0.454938, - 9.76778 -11.4291 0.333957, - 9.84349 -11.4291 0.228898, - 9.94365 -11.4291 0.146807, - 10.0615 -11.4291 0.0931917, - 10.1892 -11.4291 0.0716482, - 10.3182 -11.4291 0.0836216, - 10.4397 -11.4291 0.128309, - 10.5457 -11.4291 0.202713, - 10.629 -11.4291 0.301841, - 10.6841 -11.4291 0.419045, - 10.7072 -11.4291 0.546463 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 24, 0, 23, -1, - 23, 0, 22, -1, - 22, 0, 1, -1, - 22, 1, 21, -1, - 21, 1, 2, -1, - 21, 2, 20, -1, - 20, 2, 3, -1, - 20, 3, 19, -1, - 19, 3, 4, -1, - 19, 4, 18, -1, - 18, 4, 5, -1, - 18, 5, 17, -1, - 17, 5, 6, -1, - 17, 6, 16, -1, - 16, 6, 7, -1, - 16, 7, 15, -1, - 15, 7, 8, -1, - 15, 8, 14, -1, - 14, 8, 9, -1, - 14, 9, 13, -1, - 13, 9, 10, -1, - 13, 10, 12, -1, - 12, 10, 11, -1 - ] - } -} -Shape { - appearance USE A1914361957 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 10.7079 -6.42914 0.571301, - 10.7079 -11.4291 0.571301, - 10.7072 -11.4291 0.546463, - 10.6841 -11.4291 0.419045, - 10.629 -11.4291 0.301841, - 10.5457 -11.4291 0.202713, - 10.4397 -11.4291 0.128309, - 10.3182 -11.4291 0.0836216, - 10.1892 -11.4291 0.0716482, - 10.0615 -11.4291 0.0931917, - 9.94365 -11.4291 0.146807, - 9.84349 -11.4291 0.228898, - 9.76778 -11.4291 0.333957, - 9.72158 -11.4291 0.454938, - 9.70801 -11.4291 0.583724, - 9.72796 -11.4291 0.711677, - 9.78011 -11.4291 0.830213, - 9.86095 -11.4291 0.931382, - 9.96506 -11.4291 1.0084, - 10.0855 -11.4291 1.05609, - 10.2141 -11.4291 1.07126, - 10.3423 -11.4291 1.0529, - 10.4614 -11.4291 1.00223, - 10.5636 -11.4291 0.922651, - 10.6419 -11.4291 0.819506, - 10.6911 -11.4291 0.69971, - 10.7079 -11.4291 0.571301, - 10.7079 -6.42914 0.571301, - 10.6911 -6.42914 0.69971, - 10.6419 -6.42914 0.819506, - 10.5636 -6.42914 0.922651, - 10.4614 -6.42914 1.00223, - 10.3423 -6.42914 1.0529, - 10.2141 -6.42914 1.07126, - 10.0855 -6.42914 1.05609, - 9.96506 -6.42914 1.0084, - 9.86095 -6.42914 0.931382, - 9.78011 -6.42914 0.830213, - 9.72796 -6.42914 0.711677, - 9.70801 -6.42914 0.583724, - 9.72158 -6.42914 0.454938, - 9.76778 -6.42914 0.333957, - 9.84349 -6.42914 0.228898, - 9.94365 -6.42914 0.146807, - 10.0615 -6.42914 0.0931917, - 10.1892 -6.42914 0.0716482, - 10.3182 -6.42914 0.0836216, - 10.4397 -6.42914 0.128309, - 10.5457 -6.42914 0.202713, - 10.629 -6.42914 0.301841, - 10.6841 -6.42914 0.419045, - 10.7072 -6.42914 0.546463 - ] - } - normal Normal { - vector [ - 1 0 -2.44921e-016, - 1 0 -2.44921e-016, - 0.998765 0 -0.0496767, - 0.952509 0 -0.304512, - 0.842357 0 -0.53892, - 0.675699 0 -0.737177, - 0.463716 0 -0.885984, - 0.220626 0 -0.975359, - -0.0372642 -0 -0.999305, - -0.292654 -0 -0.956218, - -0.528413 -0 -0.848987, - -0.728725 -0 -0.684806, - -0.880154 -0 -0.474687, - -0.972542 -0 -0.232726, - -0.999691 0 0.024846, - -0.95978 0 0.280752, - -0.855487 0 0.517824, - -0.693807 0 0.720161, - -0.485586 0 0.874189, - -0.244791 0 0.969576, - 0.012424 0 0.999923, - 0.268806 0 0.963194, - 0.507156 0 0.861854, - 0.711486 0 0.7027, - 0.868089 0 0.496409, - 0.96646 0 0.256818, - 1 0 0, - 1 0 0, - 0.96646 0 0.256818, - 0.868089 0 0.496409, - 0.711486 0 0.7027, - 0.507156 0 0.861854, - 0.268806 0 0.963194, - 0.012424 0 0.999923, - -0.244791 0 0.969576, - -0.485586 0 0.874189, - -0.693807 0 0.720161, - -0.855487 0 0.517824, - -0.95978 0 0.280752, - -0.999691 0 0.024846, - -0.972542 -0 -0.232726, - -0.880154 -0 -0.474687, - -0.728725 -0 -0.684806, - -0.528413 -0 -0.848987, - -0.292654 -0 -0.956218, - -0.0372642 -0 -0.999305, - 0.220626 0 -0.975359, - 0.463716 0 -0.885984, - 0.675699 0 -0.737177, - 0.842357 0 -0.53892, - 0.952509 0 -0.304512, - 0.998765 0 -0.0496767 - ] - } - coordIndex [ - 0, 1, 2, -1, - 0, 2, 51, -1, - 51, 2, 3, -1, - 51, 3, 50, -1, - 50, 3, 4, -1, - 50, 4, 49, -1, - 49, 4, 5, -1, - 49, 5, 48, -1, - 48, 5, 6, -1, - 48, 6, 47, -1, - 47, 6, 7, -1, - 47, 7, 46, -1, - 46, 7, 8, -1, - 46, 8, 45, -1, - 45, 8, 9, -1, - 45, 9, 44, -1, - 44, 9, 10, -1, - 44, 10, 43, -1, - 43, 10, 11, -1, - 43, 11, 42, -1, - 42, 11, 12, -1, - 42, 12, 41, -1, - 41, 12, 13, -1, - 41, 13, 40, -1, - 40, 13, 14, -1, - 40, 14, 39, -1, - 39, 14, 15, -1, - 39, 15, 38, -1, - 38, 15, 16, -1, - 38, 16, 37, -1, - 37, 16, 17, -1, - 37, 17, 36, -1, - 36, 17, 18, -1, - 36, 18, 35, -1, - 35, 18, 19, -1, - 35, 19, 34, -1, - 34, 19, 20, -1, - 34, 20, 33, -1, - 33, 20, 21, -1, - 33, 21, 32, -1, - 32, 21, 22, -1, - 32, 22, 31, -1, - 31, 22, 23, -1, - 31, 23, 30, -1, - 30, 23, 24, -1, - 30, 24, 29, -1, - 29, 24, 25, -1, - 29, 25, 28, -1, - 28, 25, 26, -1, - 28, 26, 27, -1 - ] - } -} -Shape { - appearance USE A2735237687 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 10.8079 -6.42914 0.571301, - 10.7915 -6.42914 0.710402, - 10.7434 -6.42914 0.841924, - 10.666 -6.42914 0.958699, - 10.5637 -6.42914 1.05437, - 10.442 -6.42914 1.12371, - 10.3076 -6.42914 1.16295, - 10.1677 -6.42914 1.16996, - 10.03 -6.42914 1.14434, - 9.90201 -6.42914 1.0875, - 9.79067 -6.42914 1.00253, - 9.70206 -6.42914 0.894064, - 9.64102 -6.42914 0.768009, - 9.61086 -6.42914 0.631237, - 9.61323 -6.42914 0.491199, - 9.648 -6.42914 0.355525, - 9.71327 -6.42914 0.231609, - 9.8055 -6.42914 0.126203, - 9.91965 -6.42914 0.0450497, - 10.0495 -6.42914 -0.00742763, - 10.188 -6.42914 -0.0283703, - 10.3276 -6.42914 -0.0166368, - 10.4606 -6.42914 0.0271335, - 10.5799 -6.42914 0.100555, - 10.6789 -6.42914 0.199628, - 10.7522 -6.42914 0.318953, - 10.7959 -6.42914 0.452029, - 10.8079 -6.42914 0.571301, - 10.8079 -6.77914 0.571301, - 10.7959 -6.77914 0.452029, - 10.7522 -6.77914 0.318953, - 10.6789 -6.77914 0.199628, - 10.5799 -6.77914 0.100555, - 10.4606 -6.77914 0.0271335, - 10.3276 -6.77914 -0.0166368, - 10.188 -6.77914 -0.0283703, - 10.0495 -6.77914 -0.00742763, - 9.91965 -6.77914 0.0450497, - 9.8055 -6.77914 0.126203, - 9.71327 -6.77914 0.231609, - 9.648 -6.77914 0.355525, - 9.61323 -6.77914 0.491199, - 9.61086 -6.77914 0.631237, - 9.64102 -6.77914 0.768009, - 9.70206 -6.77914 0.894064, - 9.79067 -6.77914 1.00253, - 9.90201 -6.77914 1.0875, - 10.03 -6.77914 1.14434, - 10.1677 -6.77914 1.16996, - 10.3076 -6.77914 1.16295, - 10.442 -6.77914 1.12371, - 10.5637 -6.77914 1.05437, - 10.666 -6.77914 0.958699, - 10.7434 -6.77914 0.841924, - 10.7915 -6.77914 0.710402, - 10.8079 -6.77914 0.571301 - ] - } - normal Normal { - vector [ - -1 -0 -0, - -0.972755 -0 -0.231835, - -0.892505 -0 -0.451038, - -0.763622 -0 -0.645664, - -0.593129 -0 -0.805107, - -0.390317 -0 -0.92068, - -0.166237 -0 -0.986086, - 0.066902 -0 -0.99776, - 0.296395 -0 -0.955065, - 0.509738 -0 -0.86033, - 0.695305 -0 -0.718715, - 0.842985 -0 -0.537937, - 0.944731 -0 -0.327847, - 0.994998 -0 -0.0998931, - 0.991048 0 0.133504, - 0.933096 0 0.359627, - 0.8243 0 0.566154, - 0.670587 0 0.741831, - 0.480335 0 0.877085, - 0.263908 0 0.964548, - 0.033102 0 0.999452, - -0.199508 -0 0.979896, - -0.421247 -0 0.906946, - -0.620032 -0 0.784576, - -0.785032 -0 0.619455, - -0.907256 -0 0.42058, - -0.980043 -0 0.198787, - -1 -0 2.44921e-016, - -1 -0 2.44921e-016, - -0.980043 -0 0.198787, - -0.907256 -0 0.42058, - -0.785032 -0 0.619455, - -0.620032 -0 0.784576, - -0.421247 -0 0.906946, - -0.199508 -0 0.979896, - 0.033102 0 0.999452, - 0.263908 0 0.964548, - 0.480335 0 0.877085, - 0.670587 0 0.741831, - 0.8243 0 0.566154, - 0.933096 0 0.359627, - 0.991048 0 0.133504, - 0.994998 -0 -0.0998931, - 0.944731 -0 -0.327847, - 0.842985 -0 -0.537937, - 0.695305 -0 -0.718715, - 0.509738 -0 -0.86033, - 0.296395 -0 -0.955065, - 0.066902 -0 -0.99776, - -0.166237 -0 -0.986086, - -0.390317 -0 -0.92068, - -0.593129 -0 -0.805107, - -0.763622 -0 -0.645664, - -0.892505 -0 -0.451038, - -0.972755 -0 -0.231835, - -1 -0 -0 - ] - } - coordIndex [ - 0, 55, 1, -1, - 1, 55, 54, -1, - 1, 54, 2, -1, - 2, 54, 53, -1, - 2, 53, 3, -1, - 3, 53, 52, -1, - 3, 52, 4, -1, - 4, 52, 51, -1, - 4, 51, 5, -1, - 5, 51, 50, -1, - 5, 50, 6, -1, - 6, 50, 49, -1, - 6, 49, 7, -1, - 7, 49, 48, -1, - 7, 48, 8, -1, - 8, 48, 47, -1, - 8, 47, 9, -1, - 9, 47, 46, -1, - 9, 46, 10, -1, - 10, 46, 45, -1, - 10, 45, 11, -1, - 11, 45, 44, -1, - 11, 44, 12, -1, - 12, 44, 43, -1, - 12, 43, 13, -1, - 13, 43, 42, -1, - 13, 42, 14, -1, - 14, 42, 41, -1, - 14, 41, 15, -1, - 15, 41, 40, -1, - 15, 40, 16, -1, - 16, 40, 39, -1, - 16, 39, 17, -1, - 17, 39, 38, -1, - 17, 38, 18, -1, - 18, 38, 37, -1, - 18, 37, 19, -1, - 19, 37, 36, -1, - 19, 36, 20, -1, - 20, 36, 35, -1, - 20, 35, 21, -1, - 21, 35, 34, -1, - 21, 34, 22, -1, - 22, 34, 33, -1, - 22, 33, 23, -1, - 23, 33, 32, -1, - 23, 32, 24, -1, - 24, 32, 31, -1, - 24, 31, 25, -1, - 25, 31, 30, -1, - 25, 30, 26, -1, - 26, 30, 29, -1, - 26, 29, 27, -1, - 27, 29, 28, -1 - ] - } -} -Shape { - appearance USE A2735237687 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 9.62443 -6.82914 0.431248, - 9.67324 -6.82914 0.298933, - 9.75158 -6.82914 0.181666, - 9.85514 -6.82914 0.0859256, - 9.97818 -6.82914 0.0170017, - 10.1139 -6.82914 -0.0212979, - 10.2548 -6.82914 -0.0268573, - 10.3932 -6.82914 0.000630445, - 10.5212 -6.82914 0.0596471, - 10.632 -6.82914 0.146932, - 10.7194 -6.82914 0.257663, - 10.7784 -6.82914 0.385721, - 10.806 -6.82914 0.524033, - 10.8005 -6.82914 0.664957, - 10.8 -6.82914 0.668033, - 10.8 -7.02914 0.668033, - 10.8005 -7.02914 0.664957, - 10.806 -7.02914 0.524033, - 10.7784 -7.02914 0.385721, - 10.7194 -7.02914 0.257663, - 10.632 -7.02914 0.146932, - 10.5212 -7.02914 0.0596471, - 10.3932 -7.02914 0.000630445, - 10.2548 -7.02914 -0.0268573, - 10.1139 -7.02914 -0.0212979, - 9.97818 -7.02914 0.0170017, - 9.85514 -7.02914 0.0859256, - 9.75158 -7.02914 0.181666, - 9.67324 -7.02914 0.298933, - 9.62443 -7.02914 0.431248, - 9.60785 -7.02914 0.571301, - 9.60785 -6.82914 0.571301 - ] - } - normal Normal { - vector [ - 0.972376 0 0.233421, - 0.891029 0 0.453946, - 0.760454 0 0.649392, - 0.587865 0 0.808959, - 0.382798 0 0.923832, - 0.156581 0 0.987665, - -0.0782864 -0 0.996931, - -0.308829 -0 0.951118, - -0.522309 -0 0.852757, - -0.706932 -0 0.707282, - -0.852498 -0 0.522731, - -0.950965 -0 0.309299, - -0.996892 -0 0.0787798, - -0.987742 -0 -0.156092, - -0.986918 -0 -0.161221, - -0.986918 -0 -0.161221, - -0.987742 -0 -0.156092, - -0.996892 -0 0.0787798, - -0.950965 -0 0.309299, - -0.852498 -0 0.522731, - -0.706932 -0 0.707282, - -0.522309 -0 0.852757, - -0.308829 -0 0.951118, - -0.0782864 -0 0.996931, - 0.156581 0 0.987665, - 0.382798 0 0.923832, - 0.587865 0 0.808959, - 0.760454 0 0.649392, - 0.891029 0 0.453946, - 0.972376 0 0.233421, - 1 -0 -1.22461e-016, - 1 -0 -1.22461e-016 - ] - } - coordIndex [ - 16, 15, 14, -1, - 16, 14, 13, -1, - 16, 13, 17, -1, - 17, 13, 12, -1, - 17, 12, 18, -1, - 18, 12, 11, -1, - 18, 11, 19, -1, - 19, 11, 10, -1, - 19, 10, 20, -1, - 20, 10, 9, -1, - 20, 9, 21, -1, - 21, 9, 8, -1, - 21, 8, 22, -1, - 22, 8, 7, -1, - 22, 7, 23, -1, - 23, 7, 6, -1, - 23, 6, 24, -1, - 24, 6, 5, -1, - 24, 5, 25, -1, - 25, 5, 4, -1, - 25, 4, 26, -1, - 26, 4, 3, -1, - 26, 3, 27, -1, - 27, 3, 2, -1, - 27, 2, 28, -1, - 28, 2, 1, -1, - 28, 1, 29, -1, - 29, 1, 0, -1, - 29, 0, 30, -1, - 30, 0, 31, -1 - ] - } -} -Shape { - appearance USE A2735237687 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 10.8079 -6.42914 0.571301, - 10.7915 -6.42914 0.710402, - 10.7434 -6.42914 0.841924, - 10.666 -6.42914 0.958699, - 10.5637 -6.42914 1.05437, - 10.442 -6.42914 1.12371, - 10.3076 -6.42914 1.16295, - 10.1677 -6.42914 1.16996, - 10.03 -6.42914 1.14434, - 9.90201 -6.42914 1.0875, - 9.79067 -6.42914 1.00253, - 9.70206 -6.42914 0.894064, - 9.64102 -6.42914 0.768009, - 9.61086 -6.42914 0.631237, - 9.61323 -6.42914 0.491199, - 9.648 -6.42914 0.355525, - 9.71327 -6.42914 0.231609, - 9.8055 -6.42914 0.126203, - 9.91965 -6.42914 0.0450497, - 10.0495 -6.42914 -0.00742763, - 10.188 -6.42914 -0.0283703, - 10.3276 -6.42914 -0.0166368, - 10.4606 -6.42914 0.0271335, - 10.5799 -6.42914 0.100555, - 10.6789 -6.42914 0.199628, - 10.7522 -6.42914 0.318953, - 10.7959 -6.42914 0.452029, - 10.7079 -6.42914 0.571301, - 10.7072 -6.42914 0.546463, - 10.6841 -6.42914 0.419045, - 10.629 -6.42914 0.301841, - 10.5457 -6.42914 0.202713, - 10.4397 -6.42914 0.128309, - 10.3182 -6.42914 0.0836216, - 10.1892 -6.42914 0.0716482, - 10.0615 -6.42914 0.0931917, - 9.94365 -6.42914 0.146807, - 9.84349 -6.42914 0.228898, - 9.76778 -6.42914 0.333957, - 9.72158 -6.42914 0.454938, - 9.70801 -6.42914 0.583724, - 9.72796 -6.42914 0.711677, - 9.78011 -6.42914 0.830213, - 9.86095 -6.42914 0.931382, - 9.96506 -6.42914 1.0084, - 10.0855 -6.42914 1.05609, - 10.2141 -6.42914 1.07126, - 10.3423 -6.42914 1.0529, - 10.4614 -6.42914 1.00223, - 10.5636 -6.42914 0.922651, - 10.6419 -6.42914 0.819506, - 10.6911 -6.42914 0.69971 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 26, 0, 25, -1, - 25, 0, 1, -1, - 25, 1, 24, -1, - 24, 1, 2, -1, - 24, 2, 28, -1, - 24, 28, 29, -1, - 24, 29, 23, -1, - 23, 29, 30, -1, - 23, 30, 22, -1, - 22, 30, 31, -1, - 22, 31, 21, -1, - 21, 31, 32, -1, - 21, 32, 20, -1, - 20, 32, 33, -1, - 20, 33, 19, -1, - 19, 33, 34, -1, - 19, 34, 18, -1, - 18, 34, 35, -1, - 18, 35, 17, -1, - 17, 35, 36, -1, - 17, 36, 16, -1, - 16, 36, 37, -1, - 16, 37, 15, -1, - 15, 37, 38, -1, - 15, 38, 14, -1, - 14, 38, 39, -1, - 14, 39, 13, -1, - 13, 39, 40, -1, - 13, 40, 12, -1, - 12, 40, 41, -1, - 12, 41, 11, -1, - 11, 41, 42, -1, - 11, 42, 10, -1, - 10, 42, 43, -1, - 10, 43, 9, -1, - 9, 43, 44, -1, - 9, 44, 8, -1, - 8, 44, 45, -1, - 8, 45, 7, -1, - 7, 45, 46, -1, - 7, 46, 6, -1, - 6, 46, 47, -1, - 6, 47, 5, -1, - 5, 47, 48, -1, - 5, 48, 4, -1, - 4, 48, 49, -1, - 4, 49, 3, -1, - 3, 49, 50, -1, - 3, 50, 2, -1, - 2, 50, 51, -1, - 2, 51, 27, -1, - 2, 27, 28, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 9.60785 -7.02914 4.5713, - 9.60785 -7.02914 0.571301, - 9.60785 -6.82914 0.571301, - 9.60785 -6.82914 4.5713 - ] - } - normal Normal { - vector [ - 1 0 0, - 1 0 0, - 1 0 0, - 1 0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 10.8 -7.02914 0.668033, - 10.8 -7.02914 4.5713, - 10.8 -6.82914 4.5713, - 10.8 -6.82914 0.668033 - ] - } - normal Normal { - vector [ - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 0.470857 -2.67977, - 12.7087 0.470857 -2.07977, - 13.3087 0.470857 -2.07977, - 13.3087 0.470857 -2.67977 - ] - } - normal Normal { - vector [ - 0 1 0, - 0 1 0, - 0 1 0, - 0 1 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 -7.02914 -2.67977, - 12.7087 0.470857 -2.67977, - 13.3087 0.470857 -2.67977, - 13.3087 -7.02914 -2.67977 - ] - } - normal Normal { - vector [ - 0 0 -1, - 0 0 -1, - 0 0 -1, - 0 0 -1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 -7.02914 -2.07977, - 12.7087 -7.02914 -2.67977, - 13.3087 -7.02914 -2.67977, - 13.3087 -7.02914 -2.07977 - ] - } - normal Normal { - vector [ - 0 -1 0, - 0 -1 0, - 0 -1 0, - 0 -1 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 -7.02914 -2.07977, - 12.7087 0.470857 -2.07977, - 12.7087 0.470857 -2.67977, - 12.7087 -7.02914 -2.67977 - ] - } - normal Normal { - vector [ - -1 -0 0, - -1 -0 0, - -1 -0 0, - -1 -0 0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 12.7087 0.470857 -2.07977, - 12.7087 -7.02914 -2.07977, - 13.3087 -7.02914 -2.07977, - 13.3087 0.470857 -2.07977 - ] - } - normal Normal { - vector [ - -0 0 1, - -0 0 1, - -0 0 1, - -0 0 1 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} -Shape { - appearance USE A4266473842 - geometry IndexedFaceSet { - creaseAngle 2 - coord Coordinate { - point [ - 13.3087 -7.02914 -2.07977, - 13.3087 -7.02914 -2.67977, - 13.3087 0.470857 -2.67977, - 13.3087 0.470857 -2.07977 - ] - } - normal Normal { - vector [ - 1 0 -0, - 1 0 -0, - 1 0 -0, - 1 0 -0 - ] - } - coordIndex [ - 3, 0, 2, -1, - 2, 0, 1, -1 - ] - } -} \ No newline at end of file diff --git a/KiCad_M644_breakout_v1.2d/3d_terminal_blocks/300_2_5_wrl_settings.png b/KiCad_M644_breakout_v1.2d/3d_terminal_blocks/300_2_5_wrl_settings.png deleted file mode 100644 index e97a1a4..0000000 Binary files a/KiCad_M644_breakout_v1.2d/3d_terminal_blocks/300_2_5_wrl_settings.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-B.Mask.gbr b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-B.Mask.gbr deleted file mode 100644 index 3e263a2..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-B.Mask.gbr +++ /dev/null @@ -1,4144 +0,0 @@ -G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* -G04 #@! TF.CreationDate,2019-04-02T23:20:26+04:00* -G04 #@! TF.ProjectId,M644_breakout_v1.2d,4d363434-5f62-4726-9561-6b6f75745f76,v1.2d* -G04 #@! TF.SameCoordinates,Original* -G04 #@! TF.FileFunction,Soldermask,Bot* -G04 #@! TF.FilePolarity,Negative* -%FSLAX46Y46*% -G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* -G04 Created by KiCad (PCBNEW (5.0.2)-1) date 02/04/2019 23:20:26* -%MOMM*% -%LPD*% -G01* -G04 APERTURE LIST* -%ADD10C,0.100000*% -G04 APERTURE END LIST* -D10* -G36* -X163314949Y-120594152D02* -X163331579Y-120595790D01* -X163376165Y-120609315D01* -X163509928Y-120649892D01* -X163674296Y-120737749D01* -X163818366Y-120855984D01* -X163936601Y-121000054D01* -X164024458Y-121164422D01* -X164078560Y-121342772D01* -X164092250Y-121481769D01* -X164092250Y-123365431D01* -X164078560Y-123504428D01* -X164027872Y-123671523D01* -X164023093Y-123695547D01* -X164023093Y-123720052D01* -X164027873Y-123744085D01* -X164037251Y-123766724D01* -X164050864Y-123787099D01* -X164068191Y-123804426D01* -X164088566Y-123818040D01* -X164111205Y-123827417D01* -X164135238Y-123832198D01* -X164147491Y-123832800D01* -X164556900Y-123832800D01* -X164556900Y-126094400D01* -X162675300Y-126094400D01* -X162675300Y-124215051D01* -X162672898Y-124190665D01* -X162665785Y-124167216D01* -X162654234Y-124145605D01* -X162638688Y-124126663D01* -X162627345Y-124117353D01* -X162627421Y-124117260D01* -X162617909Y-124109454D01* -X162617904Y-124109451D01* -X162473834Y-123991216D01* -X162446521Y-123957935D01* -X162429200Y-123940614D01* -X162408825Y-123927000D01* -X162386186Y-123917623D01* -X162362153Y-123912842D01* -X162337649Y-123912842D01* -X162313615Y-123917622D01* -X162290976Y-123926999D01* -X162270601Y-123940613D01* -X162253274Y-123957940D01* -X162239660Y-123978315D01* -X162230283Y-124000954D01* -X162225502Y-124024987D01* -X162224900Y-124037240D01* -X162224900Y-124654400D01* -X159923300Y-124654400D01* -X159923300Y-122752800D01* -X162074950Y-122752800D01* -X162099336Y-122750398D01* -X162122785Y-122743285D01* -X162144396Y-122731734D01* -X162163338Y-122716188D01* -X162178884Y-122697246D01* -X162190435Y-122675635D01* -X162197548Y-122652186D01* -X162199950Y-122627800D01* -X162199950Y-121481776D01* -X162213641Y-121342771D01* -X162227166Y-121298185D01* -X162267743Y-121164422D01* -X162355600Y-121000054D01* -X162473835Y-120855984D01* -X162617905Y-120737749D01* -X162782273Y-120649892D01* -X162916036Y-120609315D01* -X162960622Y-120595790D01* -X162977252Y-120594152D01* -X163146100Y-120577522D01* -X163314949Y-120594152D01* -X163314949Y-120594152D01* -G37* -G36* -X168314949Y-120594152D02* -X168331579Y-120595790D01* -X168376165Y-120609315D01* -X168509928Y-120649892D01* -X168674296Y-120737749D01* -X168818366Y-120855984D01* -X168936601Y-121000054D01* -X169024458Y-121164422D01* -X169078560Y-121342772D01* -X169092250Y-121481769D01* -X169092250Y-123365431D01* -X169078560Y-123504428D01* -X169024458Y-123682778D01* -X168936601Y-123847146D01* -X168818366Y-123991216D01* -X168674296Y-124109451D01* -X168674292Y-124109453D01* -X168672601Y-124110841D01* -X168655274Y-124128169D01* -X168641660Y-124148543D01* -X168632283Y-124171182D01* -X168627502Y-124195216D01* -X168626900Y-124207468D01* -X168626900Y-126094400D01* -X166745300Y-126094400D01* -X166745300Y-123832800D01* -X167144709Y-123832800D01* -X167169095Y-123830398D01* -X167192544Y-123823285D01* -X167214155Y-123811734D01* -X167233097Y-123796188D01* -X167248643Y-123777246D01* -X167260194Y-123755635D01* -X167267307Y-123732186D01* -X167269709Y-123707800D01* -X167267307Y-123683414D01* -X167264329Y-123671525D01* -X167230638Y-123560461D01* -X167213640Y-123504428D01* -X167211684Y-123484570D01* -X167199950Y-123365430D01* -X167199950Y-121481776D01* -X167213641Y-121342771D01* -X167227166Y-121298185D01* -X167267743Y-121164422D01* -X167355600Y-121000054D01* -X167473835Y-120855984D01* -X167617905Y-120737749D01* -X167782273Y-120649892D01* -X167916036Y-120609315D01* -X167960622Y-120595790D01* -X167977252Y-120594152D01* -X168146100Y-120577522D01* -X168314949Y-120594152D01* -X168314949Y-120594152D01* -G37* -G36* -X148049445Y-124041858D02* -X148140229Y-124059916D01* -X148311262Y-124130760D01* -X148437412Y-124215051D01* -X148465190Y-124233612D01* -X148596088Y-124364510D01* -X148596090Y-124364513D01* -X148698940Y-124518438D01* -X148769784Y-124689471D01* -X148805900Y-124871038D01* -X148805900Y-125056162D01* -X148769784Y-125237729D01* -X148698940Y-125408762D01* -X148597479Y-125560609D01* -X148596088Y-125562690D01* -X148465190Y-125693588D01* -X148465187Y-125693590D01* -X148311262Y-125796440D01* -X148140229Y-125867284D01* -X148049446Y-125885342D01* -X147958664Y-125903400D01* -X147773536Y-125903400D01* -X147682754Y-125885342D01* -X147591971Y-125867284D01* -X147420938Y-125796440D01* -X147267013Y-125693590D01* -X147267010Y-125693588D01* -X147136112Y-125562690D01* -X147134721Y-125560609D01* -X147033260Y-125408762D01* -X146962416Y-125237729D01* -X146926300Y-125056162D01* -X146926300Y-124871038D01* -X146962416Y-124689471D01* -X147033260Y-124518438D01* -X147136110Y-124364513D01* -X147136112Y-124364510D01* -X147267010Y-124233612D01* -X147294788Y-124215051D01* -X147420938Y-124130760D01* -X147591971Y-124059916D01* -X147682755Y-124041858D01* -X147773536Y-124023800D01* -X147958664Y-124023800D01* -X148049445Y-124041858D01* -X148049445Y-124041858D01* -G37* -G36* -X130269445Y-124041858D02* -X130360229Y-124059916D01* -X130531262Y-124130760D01* -X130657412Y-124215051D01* -X130685190Y-124233612D01* -X130816088Y-124364510D01* -X130816090Y-124364513D01* -X130918940Y-124518438D01* -X130989784Y-124689471D01* -X131025900Y-124871038D01* -X131025900Y-125056162D01* -X130989784Y-125237729D01* -X130918940Y-125408762D01* -X130817479Y-125560609D01* -X130816088Y-125562690D01* -X130685190Y-125693588D01* -X130685187Y-125693590D01* -X130531262Y-125796440D01* -X130360229Y-125867284D01* -X130269446Y-125885342D01* -X130178664Y-125903400D01* -X129993536Y-125903400D01* -X129902754Y-125885342D01* -X129811971Y-125867284D01* -X129640938Y-125796440D01* -X129487013Y-125693590D01* -X129487010Y-125693588D01* -X129356112Y-125562690D01* -X129354721Y-125560609D01* -X129253260Y-125408762D01* -X129182416Y-125237729D01* -X129146300Y-125056162D01* -X129146300Y-124871038D01* -X129182416Y-124689471D01* -X129253260Y-124518438D01* -X129356110Y-124364513D01* -X129356112Y-124364510D01* -X129487010Y-124233612D01* -X129514788Y-124215051D01* -X129640938Y-124130760D01* -X129811971Y-124059916D01* -X129902755Y-124041858D01* -X129993536Y-124023800D01* -X130178664Y-124023800D01* -X130269445Y-124041858D01* -X130269445Y-124041858D01* -G37* -G36* -X132809445Y-124041858D02* -X132900229Y-124059916D01* -X133071262Y-124130760D01* -X133197412Y-124215051D01* -X133225190Y-124233612D01* -X133356088Y-124364510D01* -X133356090Y-124364513D01* -X133458940Y-124518438D01* -X133529784Y-124689471D01* -X133565900Y-124871038D01* -X133565900Y-125056162D01* -X133529784Y-125237729D01* -X133458940Y-125408762D01* -X133357479Y-125560609D01* -X133356088Y-125562690D01* -X133225190Y-125693588D01* -X133225187Y-125693590D01* -X133071262Y-125796440D01* -X132900229Y-125867284D01* -X132809446Y-125885342D01* -X132718664Y-125903400D01* -X132533536Y-125903400D01* -X132442754Y-125885342D01* -X132351971Y-125867284D01* -X132180938Y-125796440D01* -X132027013Y-125693590D01* -X132027010Y-125693588D01* -X131896112Y-125562690D01* -X131894721Y-125560609D01* -X131793260Y-125408762D01* -X131722416Y-125237729D01* -X131686300Y-125056162D01* -X131686300Y-124871038D01* -X131722416Y-124689471D01* -X131793260Y-124518438D01* -X131896110Y-124364513D01* -X131896112Y-124364510D01* -X132027010Y-124233612D01* -X132054788Y-124215051D01* -X132180938Y-124130760D01* -X132351971Y-124059916D01* -X132442755Y-124041858D01* -X132533536Y-124023800D01* -X132718664Y-124023800D01* -X132809445Y-124041858D01* -X132809445Y-124041858D01* -G37* -G36* -X135349445Y-124041858D02* -X135440229Y-124059916D01* -X135611262Y-124130760D01* -X135737412Y-124215051D01* -X135765190Y-124233612D01* -X135896088Y-124364510D01* -X135896090Y-124364513D01* -X135998940Y-124518438D01* -X136069784Y-124689471D01* -X136105900Y-124871038D01* -X136105900Y-125056162D01* -X136069784Y-125237729D01* -X135998940Y-125408762D01* -X135897479Y-125560609D01* -X135896088Y-125562690D01* -X135765190Y-125693588D01* -X135765187Y-125693590D01* -X135611262Y-125796440D01* -X135440229Y-125867284D01* -X135349446Y-125885342D01* -X135258664Y-125903400D01* -X135073536Y-125903400D01* -X134982754Y-125885342D01* -X134891971Y-125867284D01* -X134720938Y-125796440D01* -X134567013Y-125693590D01* -X134567010Y-125693588D01* -X134436112Y-125562690D01* -X134434721Y-125560609D01* -X134333260Y-125408762D01* -X134262416Y-125237729D01* -X134226300Y-125056162D01* -X134226300Y-124871038D01* -X134262416Y-124689471D01* -X134333260Y-124518438D01* -X134436110Y-124364513D01* -X134436112Y-124364510D01* -X134567010Y-124233612D01* -X134594788Y-124215051D01* -X134720938Y-124130760D01* -X134891971Y-124059916D01* -X134982755Y-124041858D01* -X135073536Y-124023800D01* -X135258664Y-124023800D01* -X135349445Y-124041858D01* -X135349445Y-124041858D01* -G37* -G36* -X137889445Y-124041858D02* -X137980229Y-124059916D01* -X138151262Y-124130760D01* -X138277412Y-124215051D01* -X138305190Y-124233612D01* -X138436088Y-124364510D01* -X138436090Y-124364513D01* -X138538940Y-124518438D01* -X138609784Y-124689471D01* -X138645900Y-124871038D01* -X138645900Y-125056162D01* -X138609784Y-125237729D01* -X138538940Y-125408762D01* -X138437479Y-125560609D01* -X138436088Y-125562690D01* -X138305190Y-125693588D01* -X138305187Y-125693590D01* -X138151262Y-125796440D01* -X137980229Y-125867284D01* -X137889446Y-125885342D01* -X137798664Y-125903400D01* -X137613536Y-125903400D01* -X137522754Y-125885342D01* -X137431971Y-125867284D01* -X137260938Y-125796440D01* -X137107013Y-125693590D01* -X137107010Y-125693588D01* -X136976112Y-125562690D01* -X136974721Y-125560609D01* -X136873260Y-125408762D01* -X136802416Y-125237729D01* -X136766300Y-125056162D01* -X136766300Y-124871038D01* -X136802416Y-124689471D01* -X136873260Y-124518438D01* -X136976110Y-124364513D01* -X136976112Y-124364510D01* -X137107010Y-124233612D01* -X137134788Y-124215051D01* -X137260938Y-124130760D01* -X137431971Y-124059916D01* -X137522755Y-124041858D01* -X137613536Y-124023800D01* -X137798664Y-124023800D01* -X137889445Y-124041858D01* -X137889445Y-124041858D01* -G37* -G36* -X140429445Y-124041858D02* -X140520229Y-124059916D01* -X140691262Y-124130760D01* -X140817412Y-124215051D01* -X140845190Y-124233612D01* -X140976088Y-124364510D01* -X140976090Y-124364513D01* -X141078940Y-124518438D01* -X141149784Y-124689471D01* -X141185900Y-124871038D01* -X141185900Y-125056162D01* -X141149784Y-125237729D01* -X141078940Y-125408762D01* -X140977479Y-125560609D01* -X140976088Y-125562690D01* -X140845190Y-125693588D01* -X140845187Y-125693590D01* -X140691262Y-125796440D01* -X140520229Y-125867284D01* -X140429446Y-125885342D01* -X140338664Y-125903400D01* -X140153536Y-125903400D01* -X140062754Y-125885342D01* -X139971971Y-125867284D01* -X139800938Y-125796440D01* -X139647013Y-125693590D01* -X139647010Y-125693588D01* -X139516112Y-125562690D01* -X139514721Y-125560609D01* -X139413260Y-125408762D01* -X139342416Y-125237729D01* -X139306300Y-125056162D01* -X139306300Y-124871038D01* -X139342416Y-124689471D01* -X139413260Y-124518438D01* -X139516110Y-124364513D01* -X139516112Y-124364510D01* -X139647010Y-124233612D01* -X139674788Y-124215051D01* -X139800938Y-124130760D01* -X139971971Y-124059916D01* -X140062755Y-124041858D01* -X140153536Y-124023800D01* -X140338664Y-124023800D01* -X140429445Y-124041858D01* -X140429445Y-124041858D01* -G37* -G36* -X145509445Y-124041858D02* -X145600229Y-124059916D01* -X145771262Y-124130760D01* -X145897412Y-124215051D01* -X145925190Y-124233612D01* -X146056088Y-124364510D01* -X146056090Y-124364513D01* -X146158940Y-124518438D01* -X146229784Y-124689471D01* -X146265900Y-124871038D01* -X146265900Y-125056162D01* -X146229784Y-125237729D01* -X146158940Y-125408762D01* -X146057479Y-125560609D01* -X146056088Y-125562690D01* -X145925190Y-125693588D01* -X145925187Y-125693590D01* -X145771262Y-125796440D01* -X145600229Y-125867284D01* -X145509446Y-125885342D01* -X145418664Y-125903400D01* -X145233536Y-125903400D01* -X145142754Y-125885342D01* -X145051971Y-125867284D01* -X144880938Y-125796440D01* -X144727013Y-125693590D01* -X144727010Y-125693588D01* -X144596112Y-125562690D01* -X144594721Y-125560609D01* -X144493260Y-125408762D01* -X144422416Y-125237729D01* -X144386300Y-125056162D01* -X144386300Y-124871038D01* -X144422416Y-124689471D01* -X144493260Y-124518438D01* -X144596110Y-124364513D01* -X144596112Y-124364510D01* -X144727010Y-124233612D01* -X144754788Y-124215051D01* -X144880938Y-124130760D01* -X145051971Y-124059916D01* -X145142755Y-124041858D01* -X145233536Y-124023800D01* -X145418664Y-124023800D01* -X145509445Y-124041858D01* -X145509445Y-124041858D01* -G37* -G36* -X150589445Y-124041858D02* -X150680229Y-124059916D01* -X150851262Y-124130760D01* -X150977412Y-124215051D01* -X151005190Y-124233612D01* -X151136088Y-124364510D01* -X151136090Y-124364513D01* -X151238940Y-124518438D01* -X151309784Y-124689471D01* -X151345900Y-124871038D01* -X151345900Y-125056162D01* -X151309784Y-125237729D01* -X151238940Y-125408762D01* -X151137479Y-125560609D01* -X151136088Y-125562690D01* -X151005190Y-125693588D01* -X151005187Y-125693590D01* -X150851262Y-125796440D01* -X150680229Y-125867284D01* -X150589446Y-125885342D01* -X150498664Y-125903400D01* -X150313536Y-125903400D01* -X150222754Y-125885342D01* -X150131971Y-125867284D01* -X149960938Y-125796440D01* -X149807013Y-125693590D01* -X149807010Y-125693588D01* -X149676112Y-125562690D01* -X149674721Y-125560609D01* -X149573260Y-125408762D01* -X149502416Y-125237729D01* -X149466300Y-125056162D01* -X149466300Y-124871038D01* -X149502416Y-124689471D01* -X149573260Y-124518438D01* -X149676110Y-124364513D01* -X149676112Y-124364510D01* -X149807010Y-124233612D01* -X149834788Y-124215051D01* -X149960938Y-124130760D01* -X150131971Y-124059916D01* -X150222755Y-124041858D01* -X150313536Y-124023800D01* -X150498664Y-124023800D01* -X150589445Y-124041858D01* -X150589445Y-124041858D01* -G37* -G36* -X153129445Y-124041858D02* -X153220229Y-124059916D01* -X153391262Y-124130760D01* -X153517412Y-124215051D01* -X153545190Y-124233612D01* -X153676088Y-124364510D01* -X153676090Y-124364513D01* -X153778940Y-124518438D01* -X153849784Y-124689471D01* -X153885900Y-124871038D01* -X153885900Y-125056162D01* -X153849784Y-125237729D01* -X153778940Y-125408762D01* -X153677479Y-125560609D01* -X153676088Y-125562690D01* -X153545190Y-125693588D01* -X153545187Y-125693590D01* -X153391262Y-125796440D01* -X153220229Y-125867284D01* -X153129446Y-125885342D01* -X153038664Y-125903400D01* -X152853536Y-125903400D01* -X152762754Y-125885342D01* -X152671971Y-125867284D01* -X152500938Y-125796440D01* -X152347013Y-125693590D01* -X152347010Y-125693588D01* -X152216112Y-125562690D01* -X152214721Y-125560609D01* -X152113260Y-125408762D01* -X152042416Y-125237729D01* -X152006300Y-125056162D01* -X152006300Y-124871038D01* -X152042416Y-124689471D01* -X152113260Y-124518438D01* -X152216110Y-124364513D01* -X152216112Y-124364510D01* -X152347010Y-124233612D01* -X152374788Y-124215051D01* -X152500938Y-124130760D01* -X152671971Y-124059916D01* -X152762755Y-124041858D01* -X152853536Y-124023800D01* -X153038664Y-124023800D01* -X153129445Y-124041858D01* -X153129445Y-124041858D01* -G37* -G36* -X155669445Y-124041858D02* -X155760229Y-124059916D01* -X155931262Y-124130760D01* -X156057412Y-124215051D01* -X156085190Y-124233612D01* -X156216088Y-124364510D01* -X156216090Y-124364513D01* -X156318940Y-124518438D01* -X156389784Y-124689471D01* -X156425900Y-124871038D01* -X156425900Y-125056162D01* -X156389784Y-125237729D01* -X156318940Y-125408762D01* -X156217479Y-125560609D01* -X156216088Y-125562690D01* -X156085190Y-125693588D01* -X156085187Y-125693590D01* -X155931262Y-125796440D01* -X155760229Y-125867284D01* -X155669446Y-125885342D01* -X155578664Y-125903400D01* -X155393536Y-125903400D01* -X155302754Y-125885342D01* -X155211971Y-125867284D01* -X155040938Y-125796440D01* -X154887013Y-125693590D01* -X154887010Y-125693588D01* -X154756112Y-125562690D01* -X154754721Y-125560609D01* -X154653260Y-125408762D01* -X154582416Y-125237729D01* -X154546300Y-125056162D01* -X154546300Y-124871038D01* -X154582416Y-124689471D01* -X154653260Y-124518438D01* -X154756110Y-124364513D01* -X154756112Y-124364510D01* -X154887010Y-124233612D01* -X154914788Y-124215051D01* -X155040938Y-124130760D01* -X155211971Y-124059916D01* -X155302755Y-124041858D01* -X155393536Y-124023800D01* -X155578664Y-124023800D01* -X155669445Y-124041858D01* -X155669445Y-124041858D01* -G37* -G36* -X158209445Y-124041858D02* -X158300229Y-124059916D01* -X158471262Y-124130760D01* -X158597412Y-124215051D01* -X158625190Y-124233612D01* -X158756088Y-124364510D01* -X158756090Y-124364513D01* -X158858940Y-124518438D01* -X158929784Y-124689471D01* -X158965900Y-124871038D01* -X158965900Y-125056162D01* -X158929784Y-125237729D01* -X158858940Y-125408762D01* -X158757479Y-125560609D01* -X158756088Y-125562690D01* -X158625190Y-125693588D01* -X158625187Y-125693590D01* -X158471262Y-125796440D01* -X158300229Y-125867284D01* -X158209446Y-125885342D01* -X158118664Y-125903400D01* -X157933536Y-125903400D01* -X157842754Y-125885342D01* -X157751971Y-125867284D01* -X157580938Y-125796440D01* -X157427013Y-125693590D01* -X157427010Y-125693588D01* -X157296112Y-125562690D01* -X157294721Y-125560609D01* -X157193260Y-125408762D01* -X157122416Y-125237729D01* -X157086300Y-125056162D01* -X157086300Y-124871038D01* -X157122416Y-124689471D01* -X157193260Y-124518438D01* -X157296110Y-124364513D01* -X157296112Y-124364510D01* -X157427010Y-124233612D01* -X157454788Y-124215051D01* -X157580938Y-124130760D01* -X157751971Y-124059916D01* -X157842755Y-124041858D01* -X157933536Y-124023800D01* -X158118664Y-124023800D01* -X158209445Y-124041858D01* -X158209445Y-124041858D01* -G37* -G36* -X142969445Y-124041858D02* -X143060229Y-124059916D01* -X143231262Y-124130760D01* -X143357412Y-124215051D01* -X143385190Y-124233612D01* -X143516088Y-124364510D01* -X143516090Y-124364513D01* -X143618940Y-124518438D01* -X143689784Y-124689471D01* -X143725900Y-124871038D01* -X143725900Y-125056162D01* -X143689784Y-125237729D01* -X143618940Y-125408762D01* -X143517479Y-125560609D01* -X143516088Y-125562690D01* -X143385190Y-125693588D01* -X143385187Y-125693590D01* -X143231262Y-125796440D01* -X143060229Y-125867284D01* -X142969446Y-125885342D01* -X142878664Y-125903400D01* -X142693536Y-125903400D01* -X142602754Y-125885342D01* -X142511971Y-125867284D01* -X142340938Y-125796440D01* -X142187013Y-125693590D01* -X142187010Y-125693588D01* -X142056112Y-125562690D01* -X142054721Y-125560609D01* -X141953260Y-125408762D01* -X141882416Y-125237729D01* -X141846300Y-125056162D01* -X141846300Y-124871038D01* -X141882416Y-124689471D01* -X141953260Y-124518438D01* -X142056110Y-124364513D01* -X142056112Y-124364510D01* -X142187010Y-124233612D01* -X142214788Y-124215051D01* -X142340938Y-124130760D01* -X142511971Y-124059916D01* -X142602755Y-124041858D01* -X142693536Y-124023800D01* -X142878664Y-124023800D01* -X142969445Y-124041858D01* -X142969445Y-124041858D01* -G37* -G36* -X172106543Y-124069119D02* -X172172727Y-124075637D01* -X172284197Y-124109451D01* -X172342567Y-124127157D01* -X172473808Y-124197308D01* -X172499091Y-124210822D01* -X172526858Y-124233610D01* -X172636286Y-124323414D01* -X172719548Y-124424871D01* -X172748878Y-124460609D01* -X172748879Y-124460611D01* -X172832543Y-124617133D01* -X172849716Y-124673747D01* -X172884063Y-124786973D01* -X172901459Y-124963600D01* -X172884063Y-125140227D01* -X172854487Y-125237727D01* -X172832543Y-125310067D01* -X172779788Y-125408763D01* -X172748878Y-125466591D01* -X172719548Y-125502329D01* -X172636286Y-125603786D01* -X172534829Y-125687048D01* -X172499091Y-125716378D01* -X172499089Y-125716379D01* -X172342567Y-125800043D01* -X172285953Y-125817216D01* -X172172727Y-125851563D01* -X172106542Y-125858082D01* -X172040360Y-125864600D01* -X171951840Y-125864600D01* -X171885658Y-125858082D01* -X171819473Y-125851563D01* -X171706247Y-125817216D01* -X171649633Y-125800043D01* -X171493111Y-125716379D01* -X171493109Y-125716378D01* -X171457371Y-125687048D01* -X171355914Y-125603786D01* -X171272652Y-125502329D01* -X171243322Y-125466591D01* -X171212412Y-125408763D01* -X171159657Y-125310067D01* -X171137713Y-125237727D01* -X171108137Y-125140227D01* -X171090741Y-124963600D01* -X171108137Y-124786973D01* -X171142484Y-124673747D01* -X171159657Y-124617133D01* -X171243321Y-124460611D01* -X171243322Y-124460609D01* -X171272652Y-124424871D01* -X171355914Y-124323414D01* -X171465342Y-124233610D01* -X171493109Y-124210822D01* -X171518392Y-124197308D01* -X171649633Y-124127157D01* -X171708003Y-124109451D01* -X171819473Y-124075637D01* -X171885657Y-124069119D01* -X171951840Y-124062600D01* -X172040360Y-124062600D01* -X172106543Y-124069119D01* -X172106543Y-124069119D01* -G37* -G36* -X174646543Y-124069119D02* -X174712727Y-124075637D01* -X174824197Y-124109451D01* -X174882567Y-124127157D01* -X175013808Y-124197308D01* -X175039091Y-124210822D01* -X175066858Y-124233610D01* -X175176286Y-124323414D01* -X175259548Y-124424871D01* -X175288878Y-124460609D01* -X175288879Y-124460611D01* -X175372543Y-124617133D01* -X175389716Y-124673747D01* -X175424063Y-124786973D01* -X175441459Y-124963600D01* -X175424063Y-125140227D01* -X175394487Y-125237727D01* -X175372543Y-125310067D01* -X175319788Y-125408763D01* -X175288878Y-125466591D01* -X175259548Y-125502329D01* -X175176286Y-125603786D01* -X175074829Y-125687048D01* -X175039091Y-125716378D01* -X175039089Y-125716379D01* -X174882567Y-125800043D01* -X174825953Y-125817216D01* -X174712727Y-125851563D01* -X174646542Y-125858082D01* -X174580360Y-125864600D01* -X174491840Y-125864600D01* -X174425658Y-125858082D01* -X174359473Y-125851563D01* -X174246247Y-125817216D01* -X174189633Y-125800043D01* -X174033111Y-125716379D01* -X174033109Y-125716378D01* -X173997371Y-125687048D01* -X173895914Y-125603786D01* -X173812652Y-125502329D01* -X173783322Y-125466591D01* -X173752412Y-125408763D01* -X173699657Y-125310067D01* -X173677713Y-125237727D01* -X173648137Y-125140227D01* -X173630741Y-124963600D01* -X173648137Y-124786973D01* -X173682484Y-124673747D01* -X173699657Y-124617133D01* -X173783321Y-124460611D01* -X173783322Y-124460609D01* -X173812652Y-124424871D01* -X173895914Y-124323414D01* -X174005342Y-124233610D01* -X174033109Y-124210822D01* -X174058392Y-124197308D01* -X174189633Y-124127157D01* -X174248003Y-124109451D01* -X174359473Y-124075637D01* -X174425657Y-124069119D01* -X174491840Y-124062600D01* -X174580360Y-124062600D01* -X174646543Y-124069119D01* -X174646543Y-124069119D01* -G37* -G36* -X151206900Y-121434400D02* -X151049121Y-121434400D01* -X151024735Y-121436802D01* -X151001286Y-121443915D01* -X150979675Y-121455466D01* -X150960733Y-121471012D01* -X150945187Y-121489954D01* -X150933636Y-121511565D01* -X150926523Y-121535014D01* -X150924121Y-121559400D01* -X150926523Y-121583786D01* -X150933636Y-121607235D01* -X150945187Y-121628846D01* -X150960733Y-121647788D01* -X150979666Y-121663326D01* -X151012200Y-121685065D01* -X151144635Y-121817500D01* -X151248688Y-121973227D01* -X151320362Y-122146262D01* -X151356900Y-122329954D01* -X151356900Y-122517246D01* -X151320362Y-122700938D01* -X151248688Y-122873973D01* -X151144635Y-123029700D01* -X151012200Y-123162135D01* -X150856473Y-123266188D01* -X150683438Y-123337862D01* -X150499746Y-123374400D01* -X150312454Y-123374400D01* -X150128762Y-123337862D01* -X149955727Y-123266188D01* -X149800000Y-123162135D01* -X149667565Y-123029700D01* -X149563512Y-122873973D01* -X149491838Y-122700938D01* -X149455300Y-122517246D01* -X149455300Y-122329954D01* -X149491838Y-122146262D01* -X149563512Y-121973227D01* -X149667565Y-121817500D01* -X149800000Y-121685065D01* -X149832534Y-121663326D01* -X149851467Y-121647788D01* -X149867013Y-121628846D01* -X149878564Y-121607235D01* -X149885677Y-121583786D01* -X149888079Y-121559400D01* -X149885677Y-121535014D01* -X149878564Y-121511565D01* -X149867013Y-121489954D01* -X149851467Y-121471012D01* -X149832525Y-121455466D01* -X149810914Y-121443915D01* -X149787465Y-121436802D01* -X149763079Y-121434400D01* -X149605300Y-121434400D01* -X149605300Y-120032800D01* -X151206900Y-120032800D01* -X151206900Y-121434400D01* -X151206900Y-121434400D01* -G37* -G36* -X153223438Y-121509338D02* -X153396473Y-121581012D01* -X153552200Y-121685065D01* -X153684635Y-121817500D01* -X153770572Y-121946114D01* -X153786112Y-121965049D01* -X153805054Y-121980595D01* -X153826665Y-121992146D01* -X153836679Y-121995184D01* -X153829875Y-122017614D01* -X153827473Y-122042000D01* -X153829875Y-122066386D01* -X153836985Y-122089826D01* -X153860362Y-122146262D01* -X153896900Y-122329954D01* -X153896900Y-122517246D01* -X153860362Y-122700938D01* -X153788688Y-122873973D01* -X153684635Y-123029700D01* -X153552200Y-123162135D01* -X153396473Y-123266188D01* -X153223438Y-123337862D01* -X153039746Y-123374400D01* -X152852454Y-123374400D01* -X152668762Y-123337862D01* -X152495727Y-123266188D01* -X152340000Y-123162135D01* -X152207565Y-123029700D01* -X152103512Y-122873973D01* -X152031838Y-122700938D01* -X151995300Y-122517246D01* -X151995300Y-122329954D01* -X152031838Y-122146262D01* -X152103512Y-121973227D01* -X152207565Y-121817500D01* -X152340000Y-121685065D01* -X152495727Y-121581012D01* -X152668762Y-121509338D01* -X152852454Y-121472800D01* -X153039746Y-121472800D01* -X153223438Y-121509338D01* -X153223438Y-121509338D01* -G37* -G36* -X148143438Y-121509338D02* -X148316473Y-121581012D01* -X148472200Y-121685065D01* -X148604635Y-121817500D01* -X148708688Y-121973227D01* -X148780362Y-122146262D01* -X148816900Y-122329954D01* -X148816900Y-122517246D01* -X148780362Y-122700938D01* -X148708688Y-122873973D01* -X148604635Y-123029700D01* -X148472200Y-123162135D01* -X148316473Y-123266188D01* -X148143438Y-123337862D01* -X147959746Y-123374400D01* -X147772454Y-123374400D01* -X147588762Y-123337862D01* -X147415727Y-123266188D01* -X147260000Y-123162135D01* -X147127565Y-123029700D01* -X147023512Y-122873973D01* -X146951838Y-122700938D01* -X146915300Y-122517246D01* -X146915300Y-122329954D01* -X146951838Y-122146262D01* -X147023512Y-121973227D01* -X147127565Y-121817500D01* -X147260000Y-121685065D01* -X147415727Y-121581012D01* -X147588762Y-121509338D01* -X147772454Y-121472800D01* -X147959746Y-121472800D01* -X148143438Y-121509338D01* -X148143438Y-121509338D01* -G37* -G36* -X172106543Y-121529119D02* -X172172727Y-121535637D01* -X172251063Y-121559400D01* -X172342567Y-121587157D01* -X172420560Y-121628846D01* -X172499091Y-121670822D01* -X172534829Y-121700152D01* -X172636286Y-121783414D01* -X172712811Y-121876661D01* -X172748878Y-121920609D01* -X172748879Y-121920611D01* -X172832543Y-122077133D01* -X172832543Y-122077134D01* -X172884063Y-122246973D01* -X172901459Y-122423600D01* -X172884063Y-122600227D01* -X172868301Y-122652186D01* -X172832543Y-122770067D01* -X172777004Y-122873971D01* -X172748878Y-122926591D01* -X172719548Y-122962329D01* -X172636286Y-123063786D01* -X172534829Y-123147048D01* -X172499091Y-123176378D01* -X172499089Y-123176379D01* -X172342567Y-123260043D01* -X172322309Y-123266188D01* -X172172727Y-123311563D01* -X172106543Y-123318081D01* -X172040360Y-123324600D01* -X171951840Y-123324600D01* -X171885657Y-123318081D01* -X171819473Y-123311563D01* -X171669891Y-123266188D01* -X171649633Y-123260043D01* -X171493111Y-123176379D01* -X171493109Y-123176378D01* -X171457371Y-123147048D01* -X171355914Y-123063786D01* -X171272652Y-122962329D01* -X171243322Y-122926591D01* -X171215196Y-122873971D01* -X171159657Y-122770067D01* -X171123899Y-122652186D01* -X171108137Y-122600227D01* -X171090741Y-122423600D01* -X171108137Y-122246973D01* -X171159657Y-122077134D01* -X171159657Y-122077133D01* -X171243321Y-121920611D01* -X171243322Y-121920609D01* -X171279389Y-121876661D01* -X171355914Y-121783414D01* -X171457371Y-121700152D01* -X171493109Y-121670822D01* -X171571640Y-121628846D01* -X171649633Y-121587157D01* -X171741137Y-121559400D01* -X171819473Y-121535637D01* -X171885657Y-121529119D01* -X171951840Y-121522600D01* -X172040360Y-121522600D01* -X172106543Y-121529119D01* -X172106543Y-121529119D01* -G37* -G36* -X174646543Y-121529119D02* -X174712727Y-121535637D01* -X174791063Y-121559400D01* -X174882567Y-121587157D01* -X174960560Y-121628846D01* -X175039091Y-121670822D01* -X175074829Y-121700152D01* -X175176286Y-121783414D01* -X175252811Y-121876661D01* -X175288878Y-121920609D01* -X175288879Y-121920611D01* -X175372543Y-122077133D01* -X175372543Y-122077134D01* -X175424063Y-122246973D01* -X175441459Y-122423600D01* -X175424063Y-122600227D01* -X175408301Y-122652186D01* -X175372543Y-122770067D01* -X175317004Y-122873971D01* -X175288878Y-122926591D01* -X175259548Y-122962329D01* -X175176286Y-123063786D01* -X175074829Y-123147048D01* -X175039091Y-123176378D01* -X175039089Y-123176379D01* -X174882567Y-123260043D01* -X174862309Y-123266188D01* -X174712727Y-123311563D01* -X174646543Y-123318081D01* -X174580360Y-123324600D01* -X174491840Y-123324600D01* -X174425657Y-123318081D01* -X174359473Y-123311563D01* -X174209891Y-123266188D01* -X174189633Y-123260043D01* -X174033111Y-123176379D01* -X174033109Y-123176378D01* -X173997371Y-123147048D01* -X173895914Y-123063786D01* -X173812652Y-122962329D01* -X173783322Y-122926591D01* -X173755196Y-122873971D01* -X173699657Y-122770067D01* -X173663899Y-122652186D01* -X173648137Y-122600227D01* -X173630741Y-122423600D01* -X173648137Y-122246973D01* -X173699657Y-122077134D01* -X173699657Y-122077133D01* -X173783321Y-121920611D01* -X173783322Y-121920609D01* -X173819389Y-121876661D01* -X173895914Y-121783414D01* -X173997371Y-121700152D01* -X174033109Y-121670822D01* -X174111640Y-121628846D01* -X174189633Y-121587157D01* -X174281137Y-121559400D01* -X174359473Y-121535637D01* -X174425657Y-121529119D01* -X174491840Y-121522600D01* -X174580360Y-121522600D01* -X174646543Y-121529119D01* -X174646543Y-121529119D01* -G37* -G36* -X155622166Y-120361446D02* -X155637712Y-120380388D01* -X155656654Y-120395934D01* -X155678265Y-120407485D01* -X155701714Y-120414598D01* -X155726100Y-120417000D01* -X156425900Y-120417000D01* -X156425900Y-121941000D01* -X155561121Y-121941000D01* -X155557546Y-121938066D01* -X155535935Y-121926515D01* -X155512486Y-121919402D01* -X155488100Y-121917000D01* -X153992259Y-121917000D01* -X153997098Y-121901047D01* -X153999500Y-121876661D01* -X153999500Y-120515400D01* -X155488100Y-120515400D01* -X155512486Y-120512998D01* -X155535935Y-120505885D01* -X155557546Y-120494334D01* -X155576488Y-120478788D01* -X155592034Y-120459846D01* -X155603585Y-120438235D01* -X155610698Y-120414786D01* -X155613100Y-120390400D01* -X155613100Y-120344484D01* -X155622166Y-120361446D01* -X155622166Y-120361446D01* -G37* -G36* -X158711900Y-121941000D02* -X157899100Y-121941000D01* -X157899100Y-120417000D01* -X158711900Y-120417000D01* -X158711900Y-121941000D01* -X158711900Y-121941000D01* -G37* -G36* -X174646542Y-118989118D02* -X174712727Y-118995637D01* -X174825953Y-119029984D01* -X174882567Y-119047157D01* -X175021187Y-119121252D01* -X175039091Y-119130822D01* -X175074829Y-119160152D01* -X175176286Y-119243414D01* -X175259548Y-119344871D01* -X175288878Y-119380609D01* -X175288879Y-119380611D01* -X175372543Y-119537133D01* -X175372543Y-119537134D01* -X175424063Y-119706973D01* -X175441459Y-119883600D01* -X175424063Y-120060227D01* -X175389716Y-120173453D01* -X175372543Y-120230067D01* -X175349833Y-120272554D01* -X175288878Y-120386591D01* -X175265893Y-120414598D01* -X175176286Y-120523786D01* -X175074829Y-120607048D01* -X175039091Y-120636378D01* -X175039089Y-120636379D01* -X174882567Y-120720043D01* -X174825953Y-120737216D01* -X174712727Y-120771563D01* -X174646543Y-120778081D01* -X174580360Y-120784600D01* -X174491840Y-120784600D01* -X174425657Y-120778081D01* -X174359473Y-120771563D01* -X174246247Y-120737216D01* -X174189633Y-120720043D01* -X174033111Y-120636379D01* -X174033109Y-120636378D01* -X173997371Y-120607048D01* -X173895914Y-120523786D01* -X173806307Y-120414598D01* -X173783322Y-120386591D01* -X173722367Y-120272554D01* -X173699657Y-120230067D01* -X173682484Y-120173453D01* -X173648137Y-120060227D01* -X173630741Y-119883600D01* -X173648137Y-119706973D01* -X173699657Y-119537134D01* -X173699657Y-119537133D01* -X173783321Y-119380611D01* -X173783322Y-119380609D01* -X173812652Y-119344871D01* -X173895914Y-119243414D01* -X173997371Y-119160152D01* -X174033109Y-119130822D01* -X174051013Y-119121252D01* -X174189633Y-119047157D01* -X174246247Y-119029984D01* -X174359473Y-118995637D01* -X174425658Y-118989118D01* -X174491840Y-118982600D01* -X174580360Y-118982600D01* -X174646542Y-118989118D01* -X174646542Y-118989118D01* -G37* -G36* -X172106542Y-118989118D02* -X172172727Y-118995637D01* -X172285953Y-119029984D01* -X172342567Y-119047157D01* -X172481187Y-119121252D01* -X172499091Y-119130822D01* -X172534829Y-119160152D01* -X172636286Y-119243414D01* -X172719548Y-119344871D01* -X172748878Y-119380609D01* -X172748879Y-119380611D01* -X172832543Y-119537133D01* -X172832543Y-119537134D01* -X172884063Y-119706973D01* -X172901459Y-119883600D01* -X172884063Y-120060227D01* -X172849716Y-120173453D01* -X172832543Y-120230067D01* -X172809833Y-120272554D01* -X172748878Y-120386591D01* -X172725893Y-120414598D01* -X172636286Y-120523786D01* -X172534829Y-120607048D01* -X172499091Y-120636378D01* -X172499089Y-120636379D01* -X172342567Y-120720043D01* -X172285953Y-120737216D01* -X172172727Y-120771563D01* -X172106543Y-120778081D01* -X172040360Y-120784600D01* -X171951840Y-120784600D01* -X171885657Y-120778081D01* -X171819473Y-120771563D01* -X171706247Y-120737216D01* -X171649633Y-120720043D01* -X171493111Y-120636379D01* -X171493109Y-120636378D01* -X171457371Y-120607048D01* -X171355914Y-120523786D01* -X171266307Y-120414598D01* -X171243322Y-120386591D01* -X171182367Y-120272554D01* -X171159657Y-120230067D01* -X171142484Y-120173453D01* -X171108137Y-120060227D01* -X171090741Y-119883600D01* -X171108137Y-119706973D01* -X171159657Y-119537134D01* -X171159657Y-119537133D01* -X171243321Y-119380611D01* -X171243322Y-119380609D01* -X171272652Y-119344871D01* -X171355914Y-119243414D01* -X171457371Y-119160152D01* -X171493109Y-119130822D01* -X171511013Y-119121252D01* -X171649633Y-119047157D01* -X171706247Y-119029984D01* -X171819473Y-118995637D01* -X171885658Y-118989118D01* -X171951840Y-118982600D01* -X172040360Y-118982600D01* -X172106542Y-118989118D01* -X172106542Y-118989118D01* -G37* -G36* -X155601100Y-120289516D02* -X155592034Y-120272554D01* -X155576488Y-120253612D01* -X155557546Y-120238066D01* -X155535935Y-120226515D01* -X155512486Y-120219402D01* -X155488100Y-120217000D01* -X153999500Y-120217000D01* -X153999500Y-118815400D01* -X155601100Y-118815400D01* -X155601100Y-120289516D01* -X155601100Y-120289516D01* -G37* -G36* -X151206900Y-119734400D02* -X149605300Y-119734400D01* -X149605300Y-118332800D01* -X151206900Y-118332800D01* -X151206900Y-119734400D01* -X151206900Y-119734400D01* -G37* -G36* -X169463900Y-117288400D02* -X169398900Y-117288400D01* -X169374514Y-117290802D01* -X169351065Y-117297915D01* -X169329454Y-117309466D01* -X169310512Y-117325012D01* -X169294966Y-117343954D01* -X169283415Y-117365565D01* -X169276302Y-117389014D01* -X169273900Y-117413400D01* -X169273900Y-119637400D01* -X167372300Y-119637400D01* -X167372300Y-117413400D01* -X167369898Y-117389014D01* -X167362785Y-117365565D01* -X167351234Y-117343954D01* -X167335688Y-117325012D01* -X167316746Y-117309466D01* -X167295135Y-117297915D01* -X167271686Y-117290802D01* -X167247300Y-117288400D01* -X167162300Y-117288400D01* -X167162300Y-115386800D01* -X169463900Y-115386800D01* -X169463900Y-117288400D01* -X169463900Y-117288400D01* -G37* -G36* -X164173900Y-119637400D02* -X162264555Y-119637400D01* -X162262785Y-119631565D01* -X162251234Y-119609954D01* -X162235688Y-119591012D01* -X162216746Y-119575466D01* -X162195135Y-119563915D01* -X162171686Y-119556802D01* -X162147300Y-119554400D01* -X159923300Y-119554400D01* -X159923300Y-117652800D01* -X162147300Y-117652800D01* -X162171686Y-117650398D01* -X162195135Y-117643285D01* -X162216746Y-117631734D01* -X162235688Y-117616188D01* -X162251234Y-117597246D01* -X162262785Y-117575635D01* -X162269898Y-117552186D01* -X162272300Y-117527800D01* -X162272300Y-117335800D01* -X164173900Y-117335800D01* -X164173900Y-119637400D01* -X164173900Y-119637400D01* -G37* -G36* -X127823438Y-116429338D02* -X127996473Y-116501012D01* -X128152200Y-116605065D01* -X128284635Y-116737500D01* -X128388688Y-116893227D01* -X128460362Y-117066262D01* -X128496900Y-117249954D01* -X128496900Y-117437246D01* -X128460362Y-117620938D01* -X128388688Y-117793973D01* -X128284635Y-117949700D01* -X128152200Y-118082135D01* -X127996473Y-118186188D01* -X127823438Y-118257862D01* -X127639746Y-118294400D01* -X127452454Y-118294400D01* -X127268762Y-118257862D01* -X127095727Y-118186188D01* -X126940000Y-118082135D01* -X126807565Y-117949700D01* -X126703512Y-117793973D01* -X126631838Y-117620938D01* -X126595300Y-117437246D01* -X126595300Y-117249954D01* -X126631838Y-117066262D01* -X126703512Y-116893227D01* -X126807565Y-116737500D01* -X126940000Y-116605065D01* -X127095727Y-116501012D01* -X127268762Y-116429338D01* -X127452454Y-116392800D01* -X127639746Y-116392800D01* -X127823438Y-116429338D01* -X127823438Y-116429338D01* -G37* -G36* -X125189446Y-116421858D02* -X125280229Y-116439916D01* -X125451262Y-116510760D01* -X125592399Y-116605065D01* -X125605190Y-116613612D01* -X125736088Y-116744510D01* -X125736090Y-116744513D01* -X125838940Y-116898438D01* -X125909784Y-117069471D01* -X125909784Y-117069473D01* -X125945900Y-117251036D01* -X125945900Y-117436164D01* -X125929179Y-117520225D01* -X125909784Y-117617729D01* -X125838940Y-117788762D01* -X125737479Y-117940609D01* -X125736088Y-117942690D01* -X125605190Y-118073588D01* -X125605187Y-118073590D01* -X125451262Y-118176440D01* -X125280229Y-118247284D01* -X125189445Y-118265342D01* -X125098664Y-118283400D01* -X124913536Y-118283400D01* -X124822755Y-118265342D01* -X124731971Y-118247284D01* -X124560938Y-118176440D01* -X124407013Y-118073590D01* -X124407010Y-118073588D01* -X124276112Y-117942690D01* -X124274721Y-117940609D01* -X124173260Y-117788762D01* -X124102416Y-117617729D01* -X124083021Y-117520225D01* -X124066300Y-117436164D01* -X124066300Y-117251036D01* -X124102416Y-117069473D01* -X124102416Y-117069471D01* -X124173260Y-116898438D01* -X124276110Y-116744513D01* -X124276112Y-116744510D01* -X124407010Y-116613612D01* -X124419801Y-116605065D01* -X124560938Y-116510760D01* -X124731971Y-116439916D01* -X124822754Y-116421858D01* -X124913536Y-116403800D01* -X125098664Y-116403800D01* -X125189446Y-116421858D01* -X125189446Y-116421858D01* -G37* -G36* -X174646542Y-116449118D02* -X174712727Y-116455637D01* -X174825953Y-116489984D01* -X174882567Y-116507157D01* -X175021187Y-116581252D01* -X175039091Y-116590822D01* -X175066858Y-116613610D01* -X175176286Y-116703414D01* -X175259548Y-116804871D01* -X175288878Y-116840609D01* -X175288879Y-116840611D01* -X175372543Y-116997133D01* -X175372543Y-116997134D01* -X175424063Y-117166973D01* -X175441459Y-117343600D01* -X175424063Y-117520227D01* -X175394954Y-117616188D01* -X175372543Y-117690067D01* -X175319788Y-117788763D01* -X175288878Y-117846591D01* -X175259548Y-117882329D01* -X175176286Y-117983786D01* -X175074829Y-118067048D01* -X175039091Y-118096378D01* -X175039089Y-118096379D01* -X174882567Y-118180043D01* -X174862309Y-118186188D01* -X174712727Y-118231563D01* -X174646542Y-118238082D01* -X174580360Y-118244600D01* -X174491840Y-118244600D01* -X174425658Y-118238082D01* -X174359473Y-118231563D01* -X174209891Y-118186188D01* -X174189633Y-118180043D01* -X174033111Y-118096379D01* -X174033109Y-118096378D01* -X173997371Y-118067048D01* -X173895914Y-117983786D01* -X173812652Y-117882329D01* -X173783322Y-117846591D01* -X173752412Y-117788763D01* -X173699657Y-117690067D01* -X173677246Y-117616188D01* -X173648137Y-117520227D01* -X173630741Y-117343600D01* -X173648137Y-117166973D01* -X173699657Y-116997134D01* -X173699657Y-116997133D01* -X173783321Y-116840611D01* -X173783322Y-116840609D01* -X173812652Y-116804871D01* -X173895914Y-116703414D01* -X174005342Y-116613610D01* -X174033109Y-116590822D01* -X174051013Y-116581252D01* -X174189633Y-116507157D01* -X174246247Y-116489984D01* -X174359473Y-116455637D01* -X174425658Y-116449118D01* -X174491840Y-116442600D01* -X174580360Y-116442600D01* -X174646542Y-116449118D01* -X174646542Y-116449118D01* -G37* -G36* -X172897100Y-118244600D02* -X171095100Y-118244600D01* -X171095100Y-116442600D01* -X172897100Y-116442600D01* -X172897100Y-118244600D01* -X172897100Y-118244600D01* -G37* -G36* -X142786100Y-117686500D02* -X141262100Y-117686500D01* -X141262100Y-116873700D01* -X142786100Y-116873700D01* -X142786100Y-117686500D01* -X142786100Y-117686500D01* -G37* -G36* -X151168100Y-117623000D02* -X149644100Y-117623000D01* -X149644100Y-116810200D01* -X151168100Y-116810200D01* -X151168100Y-117623000D01* -X151168100Y-117623000D01* -G37* -G36* -X125189446Y-113881858D02* -X125280229Y-113899916D01* -X125451262Y-113970760D01* -X125451263Y-113970761D01* -X125605190Y-114073612D01* -X125736088Y-114204510D01* -X125736090Y-114204513D01* -X125838940Y-114358438D01* -X125909784Y-114529471D01* -X125909784Y-114529473D01* -X125945900Y-114711036D01* -X125945900Y-114896164D01* -X125927842Y-114986945D01* -X125909784Y-115077729D01* -X125838940Y-115248762D01* -X125838939Y-115248763D01* -X125736088Y-115402690D01* -X125605190Y-115533588D01* -X125605187Y-115533590D01* -X125451262Y-115636440D01* -X125280229Y-115707284D01* -X125189445Y-115725342D01* -X125098664Y-115743400D01* -X124913536Y-115743400D01* -X124822755Y-115725342D01* -X124731971Y-115707284D01* -X124560938Y-115636440D01* -X124407013Y-115533590D01* -X124407010Y-115533588D01* -X124276112Y-115402690D01* -X124173261Y-115248763D01* -X124173260Y-115248762D01* -X124102416Y-115077729D01* -X124084358Y-114986945D01* -X124066300Y-114896164D01* -X124066300Y-114711036D01* -X124102416Y-114529473D01* -X124102416Y-114529471D01* -X124173260Y-114358438D01* -X124276110Y-114204513D01* -X124276112Y-114204510D01* -X124407010Y-114073612D01* -X124560937Y-113970761D01* -X124560938Y-113970760D01* -X124731971Y-113899916D01* -X124822754Y-113881858D01* -X124913536Y-113863800D01* -X125098664Y-113863800D01* -X125189446Y-113881858D01* -X125189446Y-113881858D01* -G37* -G36* -X128765300Y-115565600D02* -X127952500Y-115565600D01* -X127952500Y-114041600D01* -X128765300Y-114041600D01* -X128765300Y-115565600D01* -X128765300Y-115565600D01* -G37* -G36* -X131051300Y-115565600D02* -X130238500Y-115565600D01* -X130238500Y-114041600D01* -X131051300Y-114041600D01* -X131051300Y-115565600D01* -X131051300Y-115565600D01* -G37* -G36* -X142786100Y-115400500D02* -X141262100Y-115400500D01* -X141262100Y-114587700D01* -X142786100Y-114587700D01* -X142786100Y-115400500D01* -X142786100Y-115400500D01* -G37* -G36* -X151168100Y-115337000D02* -X149644100Y-115337000D01* -X149644100Y-114524200D01* -X151168100Y-114524200D01* -X151168100Y-115337000D01* -X151168100Y-115337000D01* -G37* -G36* -X172273438Y-113254338D02* -X172446473Y-113326012D01* -X172602200Y-113430065D01* -X172734635Y-113562500D01* -X172838688Y-113718227D01* -X172910362Y-113891262D01* -X172946900Y-114074954D01* -X172946900Y-114262246D01* -X172910362Y-114445938D01* -X172838688Y-114618973D01* -X172734635Y-114774700D01* -X172602200Y-114907135D01* -X172446473Y-115011188D01* -X172273438Y-115082862D01* -X172089746Y-115119400D01* -X171902454Y-115119400D01* -X171718762Y-115082862D01* -X171545727Y-115011188D01* -X171390000Y-114907135D01* -X171257565Y-114774700D01* -X171153512Y-114618973D01* -X171081838Y-114445938D01* -X171045300Y-114262246D01* -X171045300Y-114074954D01* -X171081838Y-113891262D01* -X171153512Y-113718227D01* -X171257565Y-113562500D01* -X171390000Y-113430065D01* -X171545727Y-113326012D01* -X171718762Y-113254338D01* -X171902454Y-113217800D01* -X172089746Y-113217800D01* -X172273438Y-113254338D01* -X172273438Y-113254338D01* -G37* -G36* -X174813438Y-113254338D02* -X174986473Y-113326012D01* -X175142200Y-113430065D01* -X175274635Y-113562500D01* -X175378688Y-113718227D01* -X175450362Y-113891262D01* -X175486900Y-114074954D01* -X175486900Y-114262246D01* -X175450362Y-114445938D01* -X175378688Y-114618973D01* -X175274635Y-114774700D01* -X175142200Y-114907135D01* -X174986473Y-115011188D01* -X174813438Y-115082862D01* -X174629746Y-115119400D01* -X174442454Y-115119400D01* -X174258762Y-115082862D01* -X174085727Y-115011188D01* -X173930000Y-114907135D01* -X173797565Y-114774700D01* -X173693512Y-114618973D01* -X173621838Y-114445938D01* -X173585300Y-114262246D01* -X173585300Y-114074954D01* -X173621838Y-113891262D01* -X173693512Y-113718227D01* -X173797565Y-113562500D01* -X173930000Y-113430065D01* -X174085727Y-113326012D01* -X174258762Y-113254338D01* -X174442454Y-113217800D01* -X174629746Y-113217800D01* -X174813438Y-113254338D01* -X174813438Y-113254338D01* -G37* -G36* -X125189445Y-111341858D02* -X125280229Y-111359916D01* -X125451262Y-111430760D01* -X125476095Y-111447353D01* -X125605190Y-111533612D01* -X125736088Y-111664510D01* -X125736090Y-111664513D01* -X125838940Y-111818438D01* -X125909784Y-111989471D01* -X125945900Y-112171038D01* -X125945900Y-112356162D01* -X125909784Y-112537729D01* -X125838940Y-112708762D01* -X125838939Y-112708763D01* -X125736088Y-112862690D01* -X125605190Y-112993588D01* -X125605187Y-112993590D01* -X125451262Y-113096440D01* -X125280229Y-113167284D01* -X125189446Y-113185342D01* -X125098664Y-113203400D01* -X124913536Y-113203400D01* -X124822754Y-113185342D01* -X124731971Y-113167284D01* -X124560938Y-113096440D01* -X124407013Y-112993590D01* -X124407010Y-112993588D01* -X124276112Y-112862690D01* -X124173261Y-112708763D01* -X124173260Y-112708762D01* -X124102416Y-112537729D01* -X124066300Y-112356162D01* -X124066300Y-112171038D01* -X124102416Y-111989471D01* -X124173260Y-111818438D01* -X124276110Y-111664513D01* -X124276112Y-111664510D01* -X124407010Y-111533612D01* -X124536105Y-111447353D01* -X124560938Y-111430760D01* -X124731971Y-111359916D01* -X124822755Y-111341858D01* -X124913536Y-111323800D01* -X125098664Y-111323800D01* -X125189445Y-111341858D01* -X125189445Y-111341858D01* -G37* -G36* -X129075412Y-111408764D02* -X129237198Y-111475778D01* -X129382807Y-111573071D01* -X129506629Y-111696893D01* -X129603922Y-111842502D01* -X129670936Y-112004288D01* -X129705100Y-112176041D01* -X129705100Y-112351159D01* -X129670936Y-112522912D01* -X129603922Y-112684698D01* -X129506629Y-112830307D01* -X129382807Y-112954129D01* -X129237198Y-113051422D01* -X129128517Y-113096439D01* -X129075412Y-113118436D01* -X128903659Y-113152600D01* -X128728541Y-113152600D01* -X128556788Y-113118436D01* -X128503683Y-113096439D01* -X128395002Y-113051422D01* -X128249393Y-112954129D01* -X128125571Y-112830307D01* -X128028278Y-112684698D01* -X127961264Y-112522912D01* -X127927100Y-112351159D01* -X127927100Y-112176041D01* -X127961264Y-112004288D01* -X128028278Y-111842502D01* -X128125571Y-111696893D01* -X128249393Y-111573071D01* -X128395002Y-111475778D01* -X128556788Y-111408764D01* -X128728541Y-111374600D01* -X128903659Y-111374600D01* -X129075412Y-111408764D01* -X129075412Y-111408764D01* -G37* -G36* -X147086900Y-112514400D02* -X138485300Y-112514400D01* -X138485300Y-110912800D01* -X147086900Y-110912800D01* -X147086900Y-112514400D01* -X147086900Y-112514400D01* -G37* -G36* -X169463900Y-112188400D02* -X167162300Y-112188400D01* -X167162300Y-110286800D01* -X169463900Y-110286800D01* -X169463900Y-112188400D01* -X169463900Y-112188400D01* -G37* -G36* -X172456828Y-110184720D02* -X172536437Y-110192561D01* -X172638579Y-110223546D01* -X172689651Y-110239038D01* -X172838201Y-110318440D01* -X172860840Y-110327818D01* -X172884874Y-110332598D01* -X172897126Y-110333200D01* -X175298100Y-110333200D01* -X175298100Y-111146000D01* -X173272949Y-111146000D01* -X173248563Y-111148402D01* -X173225114Y-111155515D01* -X173203503Y-111167066D01* -X173184561Y-111182612D01* -X173169015Y-111201554D01* -X173157464Y-111223165D01* -X173153336Y-111234702D01* -X173138017Y-111285200D01* -X173131662Y-111306151D01* -X173095075Y-111374600D01* -X173056188Y-111447352D01* -X172954617Y-111571117D01* -X172830852Y-111672688D01* -X172785562Y-111696896D01* -X172689651Y-111748162D01* -X172638579Y-111763654D01* -X172536437Y-111794639D01* -X172456828Y-111802480D01* -X172417024Y-111806400D01* -X170813176Y-111806400D01* -X170773372Y-111802480D01* -X170693763Y-111794639D01* -X170591621Y-111763654D01* -X170540549Y-111748162D01* -X170444638Y-111696896D01* -X170399348Y-111672688D01* -X170275583Y-111571117D01* -X170174012Y-111447352D01* -X170135125Y-111374600D01* -X170098538Y-111306151D01* -X170061063Y-111182612D01* -X170052061Y-111152937D01* -X170036368Y-110993600D01* -X170052061Y-110834263D01* -X170098538Y-110681050D01* -X170098538Y-110681049D01* -X170153386Y-110578436D01* -X170174012Y-110539848D01* -X170275583Y-110416083D01* -X170399348Y-110314512D01* -X170465075Y-110279380D01* -X170540549Y-110239038D01* -X170591621Y-110223546D01* -X170693763Y-110192561D01* -X170773372Y-110184720D01* -X170813176Y-110180800D01* -X172417024Y-110180800D01* -X172456828Y-110184720D01* -X172456828Y-110184720D01* -G37* -G36* -X157542043Y-110235275D02* -X157616678Y-110242626D01* -X157712436Y-110271674D01* -X157760316Y-110286198D01* -X157808599Y-110312006D01* -X157892692Y-110356955D01* -X158008722Y-110452178D01* -X158103945Y-110568208D01* -X158127673Y-110612600D01* -X158174702Y-110700584D01* -X158174702Y-110700585D01* -X158218274Y-110844222D01* -X158232986Y-110993600D01* -X158218274Y-111142978D01* -X158206251Y-111182612D01* -X158174702Y-111286616D01* -X158164260Y-111306151D01* -X158103945Y-111418992D01* -X158008722Y-111535022D01* -X157892692Y-111630245D01* -X157828581Y-111664513D01* -X157760316Y-111701002D01* -X157712436Y-111715526D01* -X157616678Y-111744574D01* -X157542043Y-111751925D01* -X157504727Y-111755600D01* -X156007473Y-111755600D01* -X155970157Y-111751925D01* -X155895522Y-111744574D01* -X155799764Y-111715526D01* -X155751884Y-111701002D01* -X155683619Y-111664513D01* -X155619508Y-111630245D01* -X155503478Y-111535022D01* -X155408255Y-111418992D01* -X155347940Y-111306151D01* -X155337498Y-111286616D01* -X155305949Y-111182612D01* -X155293926Y-111142978D01* -X155279214Y-110993600D01* -X155293926Y-110844222D01* -X155337498Y-110700585D01* -X155337498Y-110700584D01* -X155384527Y-110612600D01* -X155408255Y-110568208D01* -X155503478Y-110452178D01* -X155619508Y-110356955D01* -X155703601Y-110312006D01* -X155751884Y-110286198D01* -X155799764Y-110271674D01* -X155895522Y-110242626D01* -X155970157Y-110235275D01* -X156007473Y-110231600D01* -X157504727Y-110231600D01* -X157542043Y-110235275D01* -X157542043Y-110235275D01* -G37* -G36* -X160896300Y-111590500D02* -X159372300Y-111590500D01* -X159372300Y-110777700D01* -X160896300Y-110777700D01* -X160896300Y-111590500D01* -X160896300Y-111590500D01* -G37* -G36* -X134912100Y-110815800D02* -X133388100Y-110815800D01* -X133388100Y-110003000D01* -X134912100Y-110003000D01* -X134912100Y-110815800D01* -X134912100Y-110815800D01* -G37* -G36* -X125189445Y-108801858D02* -X125280229Y-108819916D01* -X125451262Y-108890760D01* -X125476095Y-108907353D01* -X125605190Y-108993612D01* -X125736088Y-109124510D01* -X125736090Y-109124513D01* -X125838940Y-109278438D01* -X125909784Y-109449471D01* -X125909784Y-109449473D01* -X125942273Y-109612800D01* -X125945900Y-109631038D01* -X125945900Y-109816162D01* -X125909784Y-109997729D01* -X125838940Y-110168762D01* -X125838939Y-110168763D01* -X125736088Y-110322690D01* -X125605190Y-110453588D01* -X125605187Y-110453590D01* -X125451262Y-110556440D01* -X125280229Y-110627284D01* -X125189446Y-110645342D01* -X125098664Y-110663400D01* -X124913536Y-110663400D01* -X124822754Y-110645342D01* -X124731971Y-110627284D01* -X124560938Y-110556440D01* -X124407013Y-110453590D01* -X124407010Y-110453588D01* -X124276112Y-110322690D01* -X124173261Y-110168763D01* -X124173260Y-110168762D01* -X124102416Y-109997729D01* -X124066300Y-109816162D01* -X124066300Y-109631038D01* -X124069928Y-109612800D01* -X124102416Y-109449473D01* -X124102416Y-109449471D01* -X124173260Y-109278438D01* -X124276110Y-109124513D01* -X124276112Y-109124510D01* -X124407010Y-108993612D01* -X124536105Y-108907353D01* -X124560938Y-108890760D01* -X124731971Y-108819916D01* -X124822755Y-108801858D01* -X124913536Y-108783800D01* -X125098664Y-108783800D01* -X125189445Y-108801858D01* -X125189445Y-108801858D01* -G37* -G36* -X129075412Y-108868764D02* -X129237198Y-108935778D01* -X129382807Y-109033071D01* -X129506629Y-109156893D01* -X129603922Y-109302502D01* -X129670936Y-109464288D01* -X129705100Y-109636041D01* -X129705100Y-109811159D01* -X129670936Y-109982912D01* -X129603922Y-110144698D01* -X129506629Y-110290307D01* -X129382807Y-110414129D01* -X129237198Y-110511422D01* -X129075412Y-110578436D01* -X128903659Y-110612600D01* -X128728541Y-110612600D01* -X128556788Y-110578436D01* -X128395002Y-110511422D01* -X128249393Y-110414129D01* -X128125571Y-110290307D01* -X128028278Y-110144698D01* -X127961264Y-109982912D01* -X127927100Y-109811159D01* -X127927100Y-109636041D01* -X127961264Y-109464288D01* -X128028278Y-109302502D01* -X128125571Y-109156893D01* -X128249393Y-109033071D01* -X128395002Y-108935778D01* -X128556788Y-108868764D01* -X128728541Y-108834600D01* -X128903659Y-108834600D01* -X129075412Y-108868764D01* -X129075412Y-108868764D01* -G37* -G36* -X137786900Y-110214400D02* -X136185300Y-110214400D01* -X136185300Y-101612800D01* -X137786900Y-101612800D01* -X137786900Y-110214400D01* -X137786900Y-110214400D01* -G37* -G36* -X149386900Y-110214400D02* -X147785300Y-110214400D01* -X147785300Y-101612800D01* -X149386900Y-101612800D01* -X149386900Y-110214400D01* -X149386900Y-110214400D01* -G37* -G36* -X160896300Y-109304500D02* -X159372300Y-109304500D01* -X159372300Y-108491700D01* -X160896300Y-108491700D01* -X160896300Y-109304500D01* -X160896300Y-109304500D01* -G37* -G36* -X172456828Y-107644720D02* -X172536437Y-107652561D01* -X172638579Y-107683546D01* -X172689651Y-107699038D01* -X172723255Y-107717000D01* -X172830852Y-107774512D01* -X172954617Y-107876083D01* -X173057544Y-108001499D01* -X173074871Y-108018826D01* -X173095246Y-108032440D01* -X173117885Y-108041818D01* -X173154170Y-108047200D01* -X175298100Y-108047200D01* -X175298100Y-108860000D01* -X173154170Y-108860000D01* -X173129784Y-108862402D01* -X173106335Y-108869515D01* -X173084724Y-108881066D01* -X173057544Y-108905701D01* -X172954617Y-109031117D01* -X172830852Y-109132688D01* -X172785562Y-109156896D01* -X172689651Y-109208162D01* -X172638579Y-109223654D01* -X172536437Y-109254639D01* -X172456828Y-109262480D01* -X172417024Y-109266400D01* -X170813176Y-109266400D01* -X170773372Y-109262480D01* -X170693763Y-109254639D01* -X170591621Y-109223654D01* -X170540549Y-109208162D01* -X170444638Y-109156896D01* -X170399348Y-109132688D01* -X170275583Y-109031117D01* -X170174012Y-108907352D01* -X170135125Y-108834600D01* -X170098538Y-108766151D01* -X170083046Y-108715079D01* -X170052061Y-108612937D01* -X170036368Y-108453600D01* -X170052061Y-108294263D01* -X170098538Y-108141050D01* -X170098538Y-108141049D01* -X170163868Y-108018826D01* -X170174012Y-107999848D01* -X170275583Y-107876083D01* -X170399348Y-107774512D01* -X170506945Y-107717000D01* -X170540549Y-107699038D01* -X170591621Y-107683546D01* -X170693763Y-107652561D01* -X170773372Y-107644720D01* -X170813176Y-107640800D01* -X172417024Y-107640800D01* -X172456828Y-107644720D01* -X172456828Y-107644720D01* -G37* -G36* -X166259500Y-109093600D02* -X163457900Y-109093600D01* -X163457900Y-106442000D01* -X166259500Y-106442000D01* -X166259500Y-109093600D01* -X166259500Y-109093600D01* -G37* -G36* -X154152600Y-108644100D02* -X152628600Y-108644100D01* -X152628600Y-107831300D01* -X154152600Y-107831300D01* -X154152600Y-108644100D01* -X154152600Y-108644100D01* -G37* -G36* -X134912100Y-108529800D02* -X133388100Y-108529800D01* -X133388100Y-107717000D01* -X134912100Y-107717000D01* -X134912100Y-108529800D01* -X134912100Y-108529800D01* -G37* -G36* -X131952900Y-108445400D02* -X130251300Y-108445400D01* -X130251300Y-107143800D01* -X131952900Y-107143800D01* -X131952900Y-108445400D01* -X131952900Y-108445400D01* -G37* -G36* -X127823438Y-106269338D02* -X127996473Y-106341012D01* -X128152200Y-106445065D01* -X128284635Y-106577500D01* -X128388688Y-106733227D01* -X128460362Y-106906262D01* -X128496900Y-107089954D01* -X128496900Y-107277246D01* -X128460362Y-107460938D01* -X128388688Y-107633973D01* -X128284635Y-107789700D01* -X128152200Y-107922135D01* -X127996473Y-108026188D01* -X127823438Y-108097862D01* -X127639746Y-108134400D01* -X127452454Y-108134400D01* -X127268762Y-108097862D01* -X127095727Y-108026188D01* -X126940000Y-107922135D01* -X126807565Y-107789700D01* -X126703512Y-107633973D01* -X126631838Y-107460938D01* -X126595300Y-107277246D01* -X126595300Y-107089954D01* -X126631838Y-106906262D01* -X126703512Y-106733227D01* -X126807565Y-106577500D01* -X126940000Y-106445065D01* -X127095727Y-106341012D01* -X127268762Y-106269338D01* -X127452454Y-106232800D01* -X127639746Y-106232800D01* -X127823438Y-106269338D01* -X127823438Y-106269338D01* -G37* -G36* -X125189446Y-106261858D02* -X125280229Y-106279916D01* -X125451262Y-106350760D01* -X125592399Y-106445065D01* -X125605190Y-106453612D01* -X125736088Y-106584510D01* -X125736090Y-106584513D01* -X125838940Y-106738438D01* -X125909784Y-106909471D01* -X125909784Y-106909473D01* -X125945900Y-107091036D01* -X125945900Y-107276164D01* -X125927842Y-107366946D01* -X125909784Y-107457729D01* -X125838940Y-107628762D01* -X125838939Y-107628763D01* -X125736088Y-107782690D01* -X125605190Y-107913588D01* -X125605187Y-107913590D01* -X125451262Y-108016440D01* -X125280229Y-108087284D01* -X125189446Y-108105342D01* -X125098664Y-108123400D01* -X124913536Y-108123400D01* -X124822754Y-108105342D01* -X124731971Y-108087284D01* -X124560938Y-108016440D01* -X124407013Y-107913590D01* -X124407010Y-107913588D01* -X124276112Y-107782690D01* -X124173261Y-107628763D01* -X124173260Y-107628762D01* -X124102416Y-107457729D01* -X124084358Y-107366945D01* -X124066300Y-107276164D01* -X124066300Y-107091036D01* -X124102416Y-106909473D01* -X124102416Y-106909471D01* -X124173260Y-106738438D01* -X124276110Y-106584513D01* -X124276112Y-106584510D01* -X124407010Y-106453612D01* -X124419801Y-106445065D01* -X124560938Y-106350760D01* -X124731971Y-106279916D01* -X124822754Y-106261858D01* -X124913536Y-106243800D01* -X125098664Y-106243800D01* -X125189446Y-106261858D01* -X125189446Y-106261858D01* -G37* -G36* -X172456828Y-105104720D02* -X172536437Y-105112561D01* -X172638579Y-105143546D01* -X172689651Y-105159038D01* -X172765125Y-105199380D01* -X172830852Y-105234512D01* -X172954617Y-105336083D01* -X173056188Y-105459848D01* -X173091320Y-105525575D01* -X173131662Y-105601049D01* -X173137588Y-105620584D01* -X173178139Y-105754263D01* -X173193832Y-105913600D01* -X173178139Y-106072937D01* -X173147154Y-106175079D01* -X173131662Y-106226151D01* -X173091320Y-106301625D01* -X173056188Y-106367352D01* -X172954617Y-106491117D01* -X172830852Y-106592688D01* -X172777880Y-106621002D01* -X172689651Y-106668162D01* -X172638579Y-106683654D01* -X172536437Y-106714639D01* -X172456828Y-106722480D01* -X172417024Y-106726400D01* -X170813176Y-106726400D01* -X170773372Y-106722480D01* -X170693763Y-106714639D01* -X170591621Y-106683654D01* -X170540549Y-106668162D01* -X170452320Y-106621002D01* -X170399348Y-106592688D01* -X170275583Y-106491117D01* -X170174012Y-106367352D01* -X170138880Y-106301625D01* -X170098538Y-106226151D01* -X170083046Y-106175079D01* -X170052061Y-106072937D01* -X170036368Y-105913600D01* -X170052061Y-105754263D01* -X170092612Y-105620584D01* -X170098538Y-105601049D01* -X170138880Y-105525575D01* -X170174012Y-105459848D01* -X170275583Y-105336083D01* -X170399348Y-105234512D01* -X170465075Y-105199380D01* -X170540549Y-105159038D01* -X170591621Y-105143546D01* -X170693763Y-105112561D01* -X170773372Y-105104720D01* -X170813176Y-105100800D01* -X172417024Y-105100800D01* -X172456828Y-105104720D01* -X172456828Y-105104720D01* -G37* -G36* -X135445500Y-106675600D02* -X134632700Y-106675600D01* -X134632700Y-105151600D01* -X135445500Y-105151600D01* -X135445500Y-106675600D01* -X135445500Y-106675600D01* -G37* -G36* -X133159500Y-106675600D02* -X132346700Y-106675600D01* -X132346700Y-105151600D01* -X133159500Y-105151600D01* -X133159500Y-106675600D01* -X133159500Y-106675600D01* -G37* -G36* -X157542043Y-105155275D02* -X157616678Y-105162626D01* -X157712436Y-105191674D01* -X157760316Y-105206198D01* -X157808599Y-105232006D01* -X157892692Y-105276955D01* -X158008722Y-105372178D01* -X158103945Y-105488208D01* -X158134461Y-105545300D01* -X158174702Y-105620584D01* -X158174702Y-105620585D01* -X158218274Y-105764222D01* -X158232986Y-105913600D01* -X158218274Y-106062978D01* -X158189226Y-106158736D01* -X158174702Y-106206616D01* -X158164260Y-106226151D01* -X158103945Y-106338992D01* -X158008722Y-106455022D01* -X157892692Y-106550245D01* -X157828581Y-106584513D01* -X157760316Y-106621002D01* -X157712436Y-106635526D01* -X157616678Y-106664574D01* -X157542043Y-106671925D01* -X157504727Y-106675600D01* -X156007473Y-106675600D01* -X155970157Y-106671925D01* -X155895522Y-106664574D01* -X155799764Y-106635526D01* -X155751884Y-106621002D01* -X155683619Y-106584513D01* -X155619508Y-106550245D01* -X155503478Y-106455022D01* -X155408255Y-106338992D01* -X155347940Y-106226151D01* -X155337498Y-106206616D01* -X155322974Y-106158736D01* -X155293926Y-106062978D01* -X155279214Y-105913600D01* -X155293926Y-105764222D01* -X155337498Y-105620585D01* -X155337498Y-105620584D01* -X155377739Y-105545300D01* -X155408255Y-105488208D01* -X155503478Y-105372178D01* -X155619508Y-105276955D01* -X155703601Y-105232006D01* -X155751884Y-105206198D01* -X155799764Y-105191674D01* -X155895522Y-105162626D01* -X155970157Y-105155275D01* -X156007473Y-105151600D01* -X157504727Y-105151600D01* -X157542043Y-105155275D01* -X157542043Y-105155275D01* -G37* -G36* -X154152600Y-106358100D02* -X152628600Y-106358100D01* -X152628600Y-105545300D01* -X154152600Y-105545300D01* -X154152600Y-106358100D01* -X154152600Y-106358100D01* -G37* -G36* -X162699700Y-106193000D02* -X159473900Y-106193000D01* -X159473900Y-105380200D01* -X162699700Y-105380200D01* -X162699700Y-106193000D01* -X162699700Y-106193000D01* -G37* -G36* -X125189446Y-103721858D02* -X125280229Y-103739916D01* -X125451262Y-103810760D01* -X125595294Y-103907000D01* -X125605190Y-103913612D01* -X125736088Y-104044510D01* -X125736090Y-104044513D01* -X125838940Y-104198438D01* -X125909784Y-104369471D01* -X125945900Y-104551038D01* -X125945900Y-104736162D01* -X125909784Y-104917729D01* -X125838940Y-105088762D01* -X125838939Y-105088763D01* -X125736088Y-105242690D01* -X125605190Y-105373588D01* -X125605187Y-105373590D01* -X125451262Y-105476440D01* -X125280229Y-105547284D01* -X125189446Y-105565342D01* -X125098664Y-105583400D01* -X124913536Y-105583400D01* -X124822754Y-105565342D01* -X124731971Y-105547284D01* -X124560938Y-105476440D01* -X124407013Y-105373590D01* -X124407010Y-105373588D01* -X124276112Y-105242690D01* -X124173261Y-105088763D01* -X124173260Y-105088762D01* -X124102416Y-104917729D01* -X124066300Y-104736162D01* -X124066300Y-104551038D01* -X124102416Y-104369471D01* -X124173260Y-104198438D01* -X124276110Y-104044513D01* -X124276112Y-104044510D01* -X124407010Y-103913612D01* -X124416906Y-103907000D01* -X124560938Y-103810760D01* -X124731971Y-103739916D01* -X124822755Y-103721858D01* -X124913536Y-103703800D01* -X125098664Y-103703800D01* -X125189446Y-103721858D01* -X125189446Y-103721858D01* -G37* -G36* -X131952900Y-105445400D02* -X130251300Y-105445400D01* -X130251300Y-104143800D01* -X131952900Y-104143800D01* -X131952900Y-105445400D01* -X131952900Y-105445400D01* -G37* -G36* -X133159500Y-104707100D02* -X132346700Y-104707100D01* -X132346700Y-103183100D01* -X133159500Y-103183100D01* -X133159500Y-104707100D01* -X133159500Y-104707100D01* -G37* -G36* -X135445500Y-104707100D02* -X134632700Y-104707100D01* -X134632700Y-103183100D01* -X135445500Y-103183100D01* -X135445500Y-104707100D01* -X135445500Y-104707100D01* -G37* -G36* -X162699700Y-103907000D02* -X159473900Y-103907000D01* -X159473900Y-103094200D01* -X162699700Y-103094200D01* -X162699700Y-103907000D01* -X162699700Y-103907000D01* -G37* -G36* -X125189446Y-101181858D02* -X125280229Y-101199916D01* -X125451262Y-101270760D01* -X125451263Y-101270761D01* -X125605190Y-101373612D01* -X125736088Y-101504510D01* -X125736090Y-101504513D01* -X125838940Y-101658438D01* -X125909784Y-101829471D01* -X125909784Y-101829473D01* -X125945900Y-102011036D01* -X125945900Y-102196164D01* -X125927842Y-102286946D01* -X125909784Y-102377729D01* -X125838940Y-102548762D01* -X125838939Y-102548763D01* -X125736088Y-102702690D01* -X125605190Y-102833588D01* -X125605187Y-102833590D01* -X125451262Y-102936440D01* -X125280229Y-103007284D01* -X125189446Y-103025342D01* -X125098664Y-103043400D01* -X124913536Y-103043400D01* -X124822754Y-103025342D01* -X124731971Y-103007284D01* -X124560938Y-102936440D01* -X124407013Y-102833590D01* -X124407010Y-102833588D01* -X124276112Y-102702690D01* -X124173261Y-102548763D01* -X124173260Y-102548762D01* -X124102416Y-102377729D01* -X124084358Y-102286946D01* -X124066300Y-102196164D01* -X124066300Y-102011036D01* -X124102416Y-101829473D01* -X124102416Y-101829471D01* -X124173260Y-101658438D01* -X124276110Y-101504513D01* -X124276112Y-101504510D01* -X124407010Y-101373612D01* -X124560937Y-101270761D01* -X124560938Y-101270760D01* -X124731971Y-101199916D01* -X124822754Y-101181858D01* -X124913536Y-101163800D01* -X125098664Y-101163800D01* -X125189446Y-101181858D01* -X125189446Y-101181858D01* -G37* -G36* -X166259500Y-102743600D02* -X163457900Y-102743600D01* -X163457900Y-100092000D01* -X166259500Y-100092000D01* -X166259500Y-102743600D01* -X166259500Y-102743600D01* -G37* -G36* -X160058100Y-102383000D02* -X158534100Y-102383000D01* -X158534100Y-101570200D01* -X160058100Y-101570200D01* -X160058100Y-102383000D01* -X160058100Y-102383000D01* -G37* -G36* -X147086900Y-100914400D02* -X138485300Y-100914400D01* -X138485300Y-99312800D01* -X147086900Y-99312800D01* -X147086900Y-100914400D01* -X147086900Y-100914400D01* -G37* -G36* -X172273438Y-98649338D02* -X172446473Y-98721012D01* -X172602200Y-98825065D01* -X172734635Y-98957500D01* -X172838688Y-99113227D01* -X172910362Y-99286262D01* -X172946900Y-99469954D01* -X172946900Y-99657246D01* -X172910362Y-99840938D01* -X172838688Y-100013973D01* -X172734635Y-100169700D01* -X172602200Y-100302135D01* -X172446473Y-100406188D01* -X172273438Y-100477862D01* -X172089746Y-100514400D01* -X171902454Y-100514400D01* -X171718762Y-100477862D01* -X171545727Y-100406188D01* -X171390000Y-100302135D01* -X171257565Y-100169700D01* -X171153512Y-100013973D01* -X171081838Y-99840938D01* -X171045300Y-99657246D01* -X171045300Y-99469954D01* -X171081838Y-99286262D01* -X171153512Y-99113227D01* -X171257565Y-98957500D01* -X171390000Y-98825065D01* -X171545727Y-98721012D01* -X171718762Y-98649338D01* -X171902454Y-98612800D01* -X172089746Y-98612800D01* -X172273438Y-98649338D01* -X172273438Y-98649338D01* -G37* -G36* -X169733438Y-98649338D02* -X169906473Y-98721012D01* -X170062200Y-98825065D01* -X170194635Y-98957500D01* -X170298688Y-99113227D01* -X170370362Y-99286262D01* -X170406900Y-99469954D01* -X170406900Y-99657246D01* -X170370362Y-99840938D01* -X170298688Y-100013973D01* -X170194635Y-100169700D01* -X170062200Y-100302135D01* -X169906473Y-100406188D01* -X169733438Y-100477862D01* -X169549746Y-100514400D01* -X169362454Y-100514400D01* -X169178762Y-100477862D01* -X169005727Y-100406188D01* -X168850000Y-100302135D01* -X168717565Y-100169700D01* -X168613512Y-100013973D01* -X168541838Y-99840938D01* -X168505300Y-99657246D01* -X168505300Y-99469954D01* -X168541838Y-99286262D01* -X168613512Y-99113227D01* -X168717565Y-98957500D01* -X168850000Y-98825065D01* -X169005727Y-98721012D01* -X169178762Y-98649338D01* -X169362454Y-98612800D01* -X169549746Y-98612800D01* -X169733438Y-98649338D01* -X169733438Y-98649338D01* -G37* -G36* -X125189445Y-98641858D02* -X125280229Y-98659916D01* -X125451262Y-98730760D01* -X125592399Y-98825065D01* -X125605190Y-98833612D01* -X125736088Y-98964510D01* -X125736090Y-98964513D01* -X125838940Y-99118438D01* -X125909784Y-99289471D01* -X125909784Y-99289473D01* -X125945900Y-99471036D01* -X125945900Y-99656164D01* -X125929179Y-99740225D01* -X125909784Y-99837729D01* -X125838940Y-100008762D01* -X125783322Y-100092000D01* -X125736088Y-100162690D01* -X125605190Y-100293588D01* -X125605187Y-100293590D01* -X125451262Y-100396440D01* -X125280229Y-100467284D01* -X125189445Y-100485342D01* -X125098664Y-100503400D01* -X124913536Y-100503400D01* -X124822755Y-100485342D01* -X124731971Y-100467284D01* -X124560938Y-100396440D01* -X124407013Y-100293590D01* -X124407010Y-100293588D01* -X124276112Y-100162690D01* -X124228878Y-100092000D01* -X124173260Y-100008762D01* -X124102416Y-99837729D01* -X124083021Y-99740225D01* -X124066300Y-99656164D01* -X124066300Y-99471036D01* -X124102416Y-99289473D01* -X124102416Y-99289471D01* -X124173260Y-99118438D01* -X124276110Y-98964513D01* -X124276112Y-98964510D01* -X124407010Y-98833612D01* -X124419801Y-98825065D01* -X124560938Y-98730760D01* -X124731971Y-98659916D01* -X124822755Y-98641858D01* -X124913536Y-98623800D01* -X125098664Y-98623800D01* -X125189445Y-98641858D01* -X125189445Y-98641858D01* -G37* -G36* -X174646543Y-98669119D02* -X174712727Y-98675637D01* -X174825953Y-98709984D01* -X174882567Y-98727157D01* -X175021187Y-98801252D01* -X175039091Y-98810822D01* -X175066858Y-98833610D01* -X175176286Y-98923414D01* -X175259548Y-99024871D01* -X175288878Y-99060609D01* -X175288879Y-99060611D01* -X175372543Y-99217133D01* -X175372543Y-99217134D01* -X175424063Y-99386973D01* -X175441459Y-99563600D01* -X175424063Y-99740227D01* -X175394487Y-99837727D01* -X175372543Y-99910067D01* -X175319788Y-100008763D01* -X175288878Y-100066591D01* -X175268025Y-100092000D01* -X175176286Y-100203786D01* -X175074829Y-100287048D01* -X175039091Y-100316378D01* -X175039089Y-100316379D01* -X174882567Y-100400043D01* -X174862309Y-100406188D01* -X174712727Y-100451563D01* -X174646543Y-100458081D01* -X174580360Y-100464600D01* -X174491840Y-100464600D01* -X174425657Y-100458081D01* -X174359473Y-100451563D01* -X174209891Y-100406188D01* -X174189633Y-100400043D01* -X174033111Y-100316379D01* -X174033109Y-100316378D01* -X173997371Y-100287048D01* -X173895914Y-100203786D01* -X173804175Y-100092000D01* -X173783322Y-100066591D01* -X173752412Y-100008763D01* -X173699657Y-99910067D01* -X173677713Y-99837727D01* -X173648137Y-99740227D01* -X173630741Y-99563600D01* -X173648137Y-99386973D01* -X173699657Y-99217134D01* -X173699657Y-99217133D01* -X173783321Y-99060611D01* -X173783322Y-99060609D01* -X173812652Y-99024871D01* -X173895914Y-98923414D01* -X174005342Y-98833610D01* -X174033109Y-98810822D01* -X174051013Y-98801252D01* -X174189633Y-98727157D01* -X174246247Y-98709984D01* -X174359473Y-98675637D01* -X174425657Y-98669119D01* -X174491840Y-98662600D01* -X174580360Y-98662600D01* -X174646543Y-98669119D01* -X174646543Y-98669119D01* -G37* -G36* -X160058100Y-100097000D02* -X158534100Y-100097000D01* -X158534100Y-99284200D01* -X160058100Y-99284200D01* -X160058100Y-100097000D01* -X160058100Y-100097000D01* -G37* -G36* -X150683438Y-96109338D02* -X150856473Y-96181012D01* -X151012200Y-96285065D01* -X151144635Y-96417500D01* -X151248688Y-96573227D01* -X151320362Y-96746262D01* -X151356900Y-96929954D01* -X151356900Y-97117246D01* -X151320362Y-97300938D01* -X151248688Y-97473973D01* -X151144635Y-97629700D01* -X151012200Y-97762135D01* -X150856473Y-97866188D01* -X150683438Y-97937862D01* -X150499746Y-97974400D01* -X150312454Y-97974400D01* -X150128762Y-97937862D01* -X149955727Y-97866188D01* -X149800000Y-97762135D01* -X149667565Y-97629700D01* -X149563512Y-97473973D01* -X149491838Y-97300938D01* -X149455300Y-97117246D01* -X149455300Y-96929954D01* -X149491838Y-96746262D01* -X149563512Y-96573227D01* -X149667565Y-96417500D01* -X149800000Y-96285065D01* -X149955727Y-96181012D01* -X150128762Y-96109338D01* -X150312454Y-96072800D01* -X150499746Y-96072800D01* -X150683438Y-96109338D01* -X150683438Y-96109338D01* -G37* -G36* -X172273438Y-96109338D02* -X172446473Y-96181012D01* -X172602200Y-96285065D01* -X172734635Y-96417500D01* -X172838688Y-96573227D01* -X172910362Y-96746262D01* -X172946900Y-96929954D01* -X172946900Y-97117246D01* -X172910362Y-97300938D01* -X172838688Y-97473973D01* -X172734635Y-97629700D01* -X172602200Y-97762135D01* -X172446473Y-97866188D01* -X172273438Y-97937862D01* -X172089746Y-97974400D01* -X171902454Y-97974400D01* -X171718762Y-97937862D01* -X171545727Y-97866188D01* -X171390000Y-97762135D01* -X171257565Y-97629700D01* -X171153512Y-97473973D01* -X171081838Y-97300938D01* -X171045300Y-97117246D01* -X171045300Y-96929954D01* -X171081838Y-96746262D01* -X171153512Y-96573227D01* -X171257565Y-96417500D01* -X171390000Y-96285065D01* -X171545727Y-96181012D01* -X171718762Y-96109338D01* -X171902454Y-96072800D01* -X172089746Y-96072800D01* -X172273438Y-96109338D01* -X172273438Y-96109338D01* -G37* -G36* -X169733438Y-96109338D02* -X169906473Y-96181012D01* -X170062200Y-96285065D01* -X170194635Y-96417500D01* -X170298688Y-96573227D01* -X170370362Y-96746262D01* -X170406900Y-96929954D01* -X170406900Y-97117246D01* -X170370362Y-97300938D01* -X170298688Y-97473973D01* -X170194635Y-97629700D01* -X170062200Y-97762135D01* -X169906473Y-97866188D01* -X169733438Y-97937862D01* -X169549746Y-97974400D01* -X169362454Y-97974400D01* -X169178762Y-97937862D01* -X169005727Y-97866188D01* -X168850000Y-97762135D01* -X168717565Y-97629700D01* -X168613512Y-97473973D01* -X168541838Y-97300938D01* -X168505300Y-97117246D01* -X168505300Y-96929954D01* -X168541838Y-96746262D01* -X168613512Y-96573227D01* -X168717565Y-96417500D01* -X168850000Y-96285065D01* -X169005727Y-96181012D01* -X169178762Y-96109338D01* -X169362454Y-96072800D01* -X169549746Y-96072800D01* -X169733438Y-96109338D01* -X169733438Y-96109338D01* -G37* -G36* -X155763438Y-96109338D02* -X155936473Y-96181012D01* -X156092200Y-96285065D01* -X156224635Y-96417500D01* -X156328688Y-96573227D01* -X156400362Y-96746262D01* -X156436900Y-96929954D01* -X156436900Y-97117246D01* -X156400362Y-97300938D01* -X156328688Y-97473973D01* -X156224635Y-97629700D01* -X156092200Y-97762135D01* -X155936473Y-97866188D01* -X155763438Y-97937862D01* -X155579746Y-97974400D01* -X155392454Y-97974400D01* -X155208762Y-97937862D01* -X155035727Y-97866188D01* -X154880000Y-97762135D01* -X154747565Y-97629700D01* -X154643512Y-97473973D01* -X154571838Y-97300938D01* -X154535300Y-97117246D01* -X154535300Y-96929954D01* -X154571838Y-96746262D01* -X154643512Y-96573227D01* -X154747565Y-96417500D01* -X154880000Y-96285065D01* -X155035727Y-96181012D01* -X155208762Y-96109338D01* -X155392454Y-96072800D01* -X155579746Y-96072800D01* -X155763438Y-96109338D01* -X155763438Y-96109338D01* -G37* -G36* -X153223438Y-96109338D02* -X153396473Y-96181012D01* -X153552200Y-96285065D01* -X153684635Y-96417500D01* -X153788688Y-96573227D01* -X153860362Y-96746262D01* -X153896900Y-96929954D01* -X153896900Y-97117246D01* -X153860362Y-97300938D01* -X153788688Y-97473973D01* -X153684635Y-97629700D01* -X153552200Y-97762135D01* -X153396473Y-97866188D01* -X153223438Y-97937862D01* -X153039746Y-97974400D01* -X152852454Y-97974400D01* -X152668762Y-97937862D01* -X152495727Y-97866188D01* -X152340000Y-97762135D01* -X152207565Y-97629700D01* -X152103512Y-97473973D01* -X152031838Y-97300938D01* -X151995300Y-97117246D01* -X151995300Y-96929954D01* -X152031838Y-96746262D01* -X152103512Y-96573227D01* -X152207565Y-96417500D01* -X152340000Y-96285065D01* -X152495727Y-96181012D01* -X152668762Y-96109338D01* -X152852454Y-96072800D01* -X153039746Y-96072800D01* -X153223438Y-96109338D01* -X153223438Y-96109338D01* -G37* -G36* -X125189445Y-96101858D02* -X125280229Y-96119916D01* -X125451262Y-96190760D01* -X125592399Y-96285065D01* -X125605190Y-96293612D01* -X125736088Y-96424510D01* -X125736090Y-96424513D01* -X125838940Y-96578438D01* -X125909784Y-96749471D01* -X125909784Y-96749473D01* -X125945900Y-96931036D01* -X125945900Y-97116164D01* -X125929179Y-97200225D01* -X125909784Y-97297729D01* -X125838940Y-97468762D01* -X125737479Y-97620609D01* -X125736088Y-97622690D01* -X125605190Y-97753588D01* -X125605187Y-97753590D01* -X125451262Y-97856440D01* -X125280229Y-97927284D01* -X125189446Y-97945342D01* -X125098664Y-97963400D01* -X124913536Y-97963400D01* -X124822754Y-97945342D01* -X124731971Y-97927284D01* -X124560938Y-97856440D01* -X124407013Y-97753590D01* -X124407010Y-97753588D01* -X124276112Y-97622690D01* -X124274721Y-97620609D01* -X124173260Y-97468762D01* -X124102416Y-97297729D01* -X124083021Y-97200225D01* -X124066300Y-97116164D01* -X124066300Y-96931036D01* -X124102416Y-96749473D01* -X124102416Y-96749471D01* -X124173260Y-96578438D01* -X124276110Y-96424513D01* -X124276112Y-96424510D01* -X124407010Y-96293612D01* -X124419801Y-96285065D01* -X124560938Y-96190760D01* -X124731971Y-96119916D01* -X124822754Y-96101858D01* -X124913536Y-96083800D01* -X125098664Y-96083800D01* -X125189445Y-96101858D01* -X125189445Y-96101858D01* -G37* -G36* -X174646543Y-96129119D02* -X174712727Y-96135637D01* -X174825953Y-96169984D01* -X174882567Y-96187157D01* -X175021187Y-96261252D01* -X175039091Y-96270822D01* -X175066858Y-96293610D01* -X175176286Y-96383414D01* -X175259548Y-96484871D01* -X175288878Y-96520609D01* -X175288879Y-96520611D01* -X175372543Y-96677133D01* -X175372543Y-96677134D01* -X175424063Y-96846973D01* -X175441459Y-97023600D01* -X175424063Y-97200227D01* -X175394487Y-97297727D01* -X175372543Y-97370067D01* -X175319788Y-97468763D01* -X175288878Y-97526591D01* -X175259548Y-97562329D01* -X175176286Y-97663786D01* -X175074829Y-97747048D01* -X175039091Y-97776378D01* -X175039089Y-97776379D01* -X174882567Y-97860043D01* -X174862309Y-97866188D01* -X174712727Y-97911563D01* -X174646542Y-97918082D01* -X174580360Y-97924600D01* -X174491840Y-97924600D01* -X174425658Y-97918082D01* -X174359473Y-97911563D01* -X174209891Y-97866188D01* -X174189633Y-97860043D01* -X174033111Y-97776379D01* -X174033109Y-97776378D01* -X173997371Y-97747048D01* -X173895914Y-97663786D01* -X173812652Y-97562329D01* -X173783322Y-97526591D01* -X173752412Y-97468763D01* -X173699657Y-97370067D01* -X173677713Y-97297727D01* -X173648137Y-97200227D01* -X173630741Y-97023600D01* -X173648137Y-96846973D01* -X173699657Y-96677134D01* -X173699657Y-96677133D01* -X173783321Y-96520611D01* -X173783322Y-96520609D01* -X173812652Y-96484871D01* -X173895914Y-96383414D01* -X174005342Y-96293610D01* -X174033109Y-96270822D01* -X174051013Y-96261252D01* -X174189633Y-96187157D01* -X174246247Y-96169984D01* -X174359473Y-96135637D01* -X174425658Y-96129118D01* -X174491840Y-96122600D01* -X174580360Y-96122600D01* -X174646543Y-96129119D01* -X174646543Y-96129119D01* -G37* -G36* -X143548100Y-97430000D02* -X142024100Y-97430000D01* -X142024100Y-96617200D01* -X143548100Y-96617200D01* -X143548100Y-97430000D01* -X143548100Y-97430000D01* -G37* -G36* -X172273438Y-93569338D02* -X172446473Y-93641012D01* -X172602200Y-93745065D01* -X172734635Y-93877500D01* -X172838688Y-94033227D01* -X172910362Y-94206262D01* -X172946900Y-94389954D01* -X172946900Y-94577246D01* -X172910362Y-94760938D01* -X172838688Y-94933973D01* -X172734635Y-95089700D01* -X172602200Y-95222135D01* -X172446473Y-95326188D01* -X172273438Y-95397862D01* -X172089746Y-95434400D01* -X171902454Y-95434400D01* -X171718762Y-95397862D01* -X171545727Y-95326188D01* -X171390000Y-95222135D01* -X171257565Y-95089700D01* -X171153512Y-94933973D01* -X171081838Y-94760938D01* -X171045300Y-94577246D01* -X171045300Y-94389954D01* -X171081838Y-94206262D01* -X171153512Y-94033227D01* -X171257565Y-93877500D01* -X171390000Y-93745065D01* -X171545727Y-93641012D01* -X171718762Y-93569338D01* -X171902454Y-93532800D01* -X172089746Y-93532800D01* -X172273438Y-93569338D01* -X172273438Y-93569338D01* -G37* -G36* -X169733438Y-93569338D02* -X169906473Y-93641012D01* -X170062200Y-93745065D01* -X170194635Y-93877500D01* -X170298688Y-94033227D01* -X170370362Y-94206262D01* -X170406900Y-94389954D01* -X170406900Y-94577246D01* -X170370362Y-94760938D01* -X170298688Y-94933973D01* -X170194635Y-95089700D01* -X170062200Y-95222135D01* -X169906473Y-95326188D01* -X169733438Y-95397862D01* -X169549746Y-95434400D01* -X169362454Y-95434400D01* -X169178762Y-95397862D01* -X169005727Y-95326188D01* -X168850000Y-95222135D01* -X168717565Y-95089700D01* -X168613512Y-94933973D01* -X168541838Y-94760938D01* -X168505300Y-94577246D01* -X168505300Y-94389954D01* -X168541838Y-94206262D01* -X168613512Y-94033227D01* -X168717565Y-93877500D01* -X168850000Y-93745065D01* -X169005727Y-93641012D01* -X169178762Y-93569338D01* -X169362454Y-93532800D01* -X169549746Y-93532800D01* -X169733438Y-93569338D01* -X169733438Y-93569338D01* -G37* -G36* -X155763438Y-93569338D02* -X155936473Y-93641012D01* -X156092200Y-93745065D01* -X156224635Y-93877500D01* -X156328688Y-94033227D01* -X156400362Y-94206262D01* -X156436900Y-94389954D01* -X156436900Y-94577246D01* -X156400362Y-94760938D01* -X156328688Y-94933973D01* -X156224635Y-95089700D01* -X156092200Y-95222135D01* -X155936473Y-95326188D01* -X155763438Y-95397862D01* -X155579746Y-95434400D01* -X155392454Y-95434400D01* -X155208762Y-95397862D01* -X155035727Y-95326188D01* -X154880000Y-95222135D01* -X154747565Y-95089700D01* -X154643512Y-94933973D01* -X154571838Y-94760938D01* -X154535300Y-94577246D01* -X154535300Y-94389954D01* -X154571838Y-94206262D01* -X154643512Y-94033227D01* -X154747565Y-93877500D01* -X154880000Y-93745065D01* -X155035727Y-93641012D01* -X155208762Y-93569338D01* -X155392454Y-93532800D01* -X155579746Y-93532800D01* -X155763438Y-93569338D01* -X155763438Y-93569338D01* -G37* -G36* -X153223438Y-93569338D02* -X153396473Y-93641012D01* -X153552200Y-93745065D01* -X153684635Y-93877500D01* -X153788688Y-94033227D01* -X153860362Y-94206262D01* -X153896900Y-94389954D01* -X153896900Y-94577246D01* -X153860362Y-94760938D01* -X153788688Y-94933973D01* -X153684635Y-95089700D01* -X153552200Y-95222135D01* -X153396473Y-95326188D01* -X153223438Y-95397862D01* -X153039746Y-95434400D01* -X152852454Y-95434400D01* -X152668762Y-95397862D01* -X152495727Y-95326188D01* -X152340000Y-95222135D01* -X152207565Y-95089700D01* -X152103512Y-94933973D01* -X152031838Y-94760938D01* -X151995300Y-94577246D01* -X151995300Y-94389954D01* -X152031838Y-94206262D01* -X152103512Y-94033227D01* -X152207565Y-93877500D01* -X152340000Y-93745065D01* -X152495727Y-93641012D01* -X152668762Y-93569338D01* -X152852454Y-93532800D01* -X153039746Y-93532800D01* -X153223438Y-93569338D01* -X153223438Y-93569338D01* -G37* -G36* -X150683438Y-93569338D02* -X150856473Y-93641012D01* -X151012200Y-93745065D01* -X151144635Y-93877500D01* -X151248688Y-94033227D01* -X151320362Y-94206262D01* -X151356900Y-94389954D01* -X151356900Y-94577246D01* -X151320362Y-94760938D01* -X151248688Y-94933973D01* -X151144635Y-95089700D01* -X151012200Y-95222135D01* -X150856473Y-95326188D01* -X150683438Y-95397862D01* -X150499746Y-95434400D01* -X150312454Y-95434400D01* -X150128762Y-95397862D01* -X149955727Y-95326188D01* -X149800000Y-95222135D01* -X149667565Y-95089700D01* -X149563512Y-94933973D01* -X149491838Y-94760938D01* -X149455300Y-94577246D01* -X149455300Y-94389954D01* -X149491838Y-94206262D01* -X149563512Y-94033227D01* -X149667565Y-93877500D01* -X149800000Y-93745065D01* -X149955727Y-93641012D01* -X150128762Y-93569338D01* -X150312454Y-93532800D01* -X150499746Y-93532800D01* -X150683438Y-93569338D01* -X150683438Y-93569338D01* -G37* -G36* -X174646542Y-93589118D02* -X174712727Y-93595637D01* -X174821932Y-93628764D01* -X174882567Y-93647157D01* -X174973529Y-93695778D01* -X175039091Y-93730822D01* -X175074829Y-93760152D01* -X175176286Y-93843414D01* -X175236590Y-93916896D01* -X175288878Y-93980609D01* -X175288879Y-93980611D01* -X175372543Y-94137133D01* -X175372543Y-94137134D01* -X175424063Y-94306973D01* -X175441459Y-94483600D01* -X175424063Y-94660227D01* -X175398981Y-94742912D01* -X175372543Y-94830067D01* -X175332651Y-94904698D01* -X175288878Y-94986591D01* -X175259548Y-95022329D01* -X175176286Y-95123786D01* -X175074829Y-95207048D01* -X175039091Y-95236378D01* -X175039089Y-95236379D01* -X174882567Y-95320043D01* -X174862309Y-95326188D01* -X174712727Y-95371563D01* -X174646542Y-95378082D01* -X174580360Y-95384600D01* -X174491840Y-95384600D01* -X174425657Y-95378081D01* -X174359473Y-95371563D01* -X174209891Y-95326188D01* -X174189633Y-95320043D01* -X174033111Y-95236379D01* -X174033109Y-95236378D01* -X173997371Y-95207048D01* -X173895914Y-95123786D01* -X173812652Y-95022329D01* -X173783322Y-94986591D01* -X173739549Y-94904698D01* -X173699657Y-94830067D01* -X173673219Y-94742912D01* -X173648137Y-94660227D01* -X173630741Y-94483600D01* -X173648137Y-94306973D01* -X173699657Y-94137134D01* -X173699657Y-94137133D01* -X173783321Y-93980611D01* -X173783322Y-93980609D01* -X173835610Y-93916896D01* -X173895914Y-93843414D01* -X173997371Y-93760152D01* -X174033109Y-93730822D01* -X174098671Y-93695778D01* -X174189633Y-93647157D01* -X174250268Y-93628764D01* -X174359473Y-93595637D01* -X174425658Y-93589118D01* -X174491840Y-93582600D01* -X174580360Y-93582600D01* -X174646542Y-93589118D01* -X174646542Y-93589118D01* -G37* -G36* -X162095412Y-93628764D02* -X162257198Y-93695778D01* -X162402807Y-93793071D01* -X162526629Y-93916893D01* -X162623922Y-94062502D01* -X162690936Y-94224288D01* -X162725100Y-94396041D01* -X162725100Y-94571159D01* -X162690936Y-94742912D01* -X162623922Y-94904698D01* -X162526629Y-95050307D01* -X162402807Y-95174129D01* -X162257198Y-95271422D01* -X162095412Y-95338436D01* -X161923659Y-95372600D01* -X161748541Y-95372600D01* -X161576788Y-95338436D01* -X161415002Y-95271422D01* -X161269393Y-95174129D01* -X161145571Y-95050307D01* -X161048278Y-94904698D01* -X160981264Y-94742912D01* -X160947100Y-94571159D01* -X160947100Y-94396041D01* -X160981264Y-94224288D01* -X161048278Y-94062502D01* -X161145571Y-93916893D01* -X161269393Y-93793071D01* -X161415002Y-93695778D01* -X161576788Y-93628764D01* -X161748541Y-93594600D01* -X161923659Y-93594600D01* -X162095412Y-93628764D01* -X162095412Y-93628764D01* -G37* -G36* -X164635412Y-93628764D02* -X164797198Y-93695778D01* -X164942807Y-93793071D01* -X165066629Y-93916893D01* -X165163922Y-94062502D01* -X165230936Y-94224288D01* -X165265100Y-94396041D01* -X165265100Y-94571159D01* -X165230936Y-94742912D01* -X165163922Y-94904698D01* -X165066629Y-95050307D01* -X164942807Y-95174129D01* -X164797198Y-95271422D01* -X164635412Y-95338436D01* -X164463659Y-95372600D01* -X164288541Y-95372600D01* -X164116788Y-95338436D01* -X163955002Y-95271422D01* -X163809393Y-95174129D01* -X163685571Y-95050307D01* -X163588278Y-94904698D01* -X163521264Y-94742912D01* -X163487100Y-94571159D01* -X163487100Y-94396041D01* -X163521264Y-94224288D01* -X163588278Y-94062502D01* -X163685571Y-93916893D01* -X163809393Y-93793071D01* -X163955002Y-93695778D01* -X164116788Y-93628764D01* -X164288541Y-93594600D01* -X164463659Y-93594600D01* -X164635412Y-93628764D01* -X164635412Y-93628764D01* -G37* -G36* -X143548100Y-95144000D02* -X142024100Y-95144000D01* -X142024100Y-94331200D01* -X143548100Y-94331200D01* -X143548100Y-95144000D01* -X143548100Y-95144000D01* -G37* -G36* -X153223438Y-91029338D02* -X153396473Y-91101012D01* -X153552200Y-91205065D01* -X153684635Y-91337500D01* -X153788688Y-91493227D01* -X153860362Y-91666262D01* -X153896900Y-91849954D01* -X153896900Y-92037246D01* -X153860362Y-92220938D01* -X153788688Y-92393973D01* -X153684635Y-92549700D01* -X153552200Y-92682135D01* -X153396473Y-92786188D01* -X153223438Y-92857862D01* -X153039746Y-92894400D01* -X152852454Y-92894400D01* -X152668762Y-92857862D01* -X152495727Y-92786188D01* -X152340000Y-92682135D01* -X152207565Y-92549700D01* -X152103512Y-92393973D01* -X152031838Y-92220938D01* -X151995300Y-92037246D01* -X151995300Y-91849954D01* -X152031838Y-91666262D01* -X152103512Y-91493227D01* -X152207565Y-91337500D01* -X152340000Y-91205065D01* -X152495727Y-91101012D01* -X152668762Y-91029338D01* -X152852454Y-90992800D01* -X153039746Y-90992800D01* -X153223438Y-91029338D01* -X153223438Y-91029338D01* -G37* -G36* -X150683438Y-91029338D02* -X150856473Y-91101012D01* -X151012200Y-91205065D01* -X151144635Y-91337500D01* -X151248688Y-91493227D01* -X151320362Y-91666262D01* -X151356900Y-91849954D01* -X151356900Y-92037246D01* -X151320362Y-92220938D01* -X151248688Y-92393973D01* -X151144635Y-92549700D01* -X151012200Y-92682135D01* -X150856473Y-92786188D01* -X150683438Y-92857862D01* -X150499746Y-92894400D01* -X150312454Y-92894400D01* -X150128762Y-92857862D01* -X149955727Y-92786188D01* -X149800000Y-92682135D01* -X149667565Y-92549700D01* -X149563512Y-92393973D01* -X149491838Y-92220938D01* -X149455300Y-92037246D01* -X149455300Y-91849954D01* -X149491838Y-91666262D01* -X149563512Y-91493227D01* -X149667565Y-91337500D01* -X149800000Y-91205065D01* -X149955727Y-91101012D01* -X150128762Y-91029338D01* -X150312454Y-90992800D01* -X150499746Y-90992800D01* -X150683438Y-91029338D01* -X150683438Y-91029338D01* -G37* -G36* -X169733438Y-91029338D02* -X169906473Y-91101012D01* -X170062200Y-91205065D01* -X170194635Y-91337500D01* -X170298688Y-91493227D01* -X170370362Y-91666262D01* -X170406900Y-91849954D01* -X170406900Y-92037246D01* -X170370362Y-92220938D01* -X170298688Y-92393973D01* -X170194635Y-92549700D01* -X170062200Y-92682135D01* -X169906473Y-92786188D01* -X169733438Y-92857862D01* -X169549746Y-92894400D01* -X169362454Y-92894400D01* -X169178762Y-92857862D01* -X169005727Y-92786188D01* -X168850000Y-92682135D01* -X168717565Y-92549700D01* -X168613512Y-92393973D01* -X168541838Y-92220938D01* -X168505300Y-92037246D01* -X168505300Y-91849954D01* -X168541838Y-91666262D01* -X168613512Y-91493227D01* -X168717565Y-91337500D01* -X168850000Y-91205065D01* -X169005727Y-91101012D01* -X169178762Y-91029338D01* -X169362454Y-90992800D01* -X169549746Y-90992800D01* -X169733438Y-91029338D01* -X169733438Y-91029338D01* -G37* -G36* -X172273438Y-91029338D02* -X172446473Y-91101012D01* -X172602200Y-91205065D01* -X172734635Y-91337500D01* -X172838688Y-91493227D01* -X172910362Y-91666262D01* -X172946900Y-91849954D01* -X172946900Y-92037246D01* -X172910362Y-92220938D01* -X172838688Y-92393973D01* -X172734635Y-92549700D01* -X172602200Y-92682135D01* -X172446473Y-92786188D01* -X172273438Y-92857862D01* -X172089746Y-92894400D01* -X171902454Y-92894400D01* -X171718762Y-92857862D01* -X171545727Y-92786188D01* -X171390000Y-92682135D01* -X171257565Y-92549700D01* -X171153512Y-92393973D01* -X171081838Y-92220938D01* -X171045300Y-92037246D01* -X171045300Y-91849954D01* -X171081838Y-91666262D01* -X171153512Y-91493227D01* -X171257565Y-91337500D01* -X171390000Y-91205065D01* -X171545727Y-91101012D01* -X171718762Y-91029338D01* -X171902454Y-90992800D01* -X172089746Y-90992800D01* -X172273438Y-91029338D01* -X172273438Y-91029338D01* -G37* -G36* -X155763438Y-91029338D02* -X155936473Y-91101012D01* -X156092200Y-91205065D01* -X156224635Y-91337500D01* -X156328688Y-91493227D01* -X156400362Y-91666262D01* -X156436900Y-91849954D01* -X156436900Y-92037246D01* -X156400362Y-92220938D01* -X156328688Y-92393973D01* -X156224635Y-92549700D01* -X156092200Y-92682135D01* -X155936473Y-92786188D01* -X155763438Y-92857862D01* -X155579746Y-92894400D01* -X155392454Y-92894400D01* -X155208762Y-92857862D01* -X155035727Y-92786188D01* -X154880000Y-92682135D01* -X154747565Y-92549700D01* -X154643512Y-92393973D01* -X154571838Y-92220938D01* -X154535300Y-92037246D01* -X154535300Y-91849954D01* -X154571838Y-91666262D01* -X154643512Y-91493227D01* -X154747565Y-91337500D01* -X154880000Y-91205065D01* -X155035727Y-91101012D01* -X155208762Y-91029338D01* -X155392454Y-90992800D01* -X155579746Y-90992800D01* -X155763438Y-91029338D01* -X155763438Y-91029338D01* -G37* -G36* -X175437100Y-92844600D02* -X173635100Y-92844600D01* -X173635100Y-91042600D01* -X175437100Y-91042600D01* -X175437100Y-92844600D01* -X175437100Y-92844600D01* -G37* -G36* -X162095412Y-91088764D02* -X162257198Y-91155778D01* -X162402807Y-91253071D01* -X162526629Y-91376893D01* -X162623922Y-91522502D01* -X162690936Y-91684288D01* -X162725100Y-91856041D01* -X162725100Y-92031159D01* -X162690936Y-92202912D01* -X162623922Y-92364698D01* -X162526629Y-92510307D01* -X162402807Y-92634129D01* -X162257198Y-92731422D01* -X162095412Y-92798436D01* -X161923659Y-92832600D01* -X161748541Y-92832600D01* -X161576788Y-92798436D01* -X161415002Y-92731422D01* -X161269393Y-92634129D01* -X161145571Y-92510307D01* -X161048278Y-92364698D01* -X160981264Y-92202912D01* -X160947100Y-92031159D01* -X160947100Y-91856041D01* -X160981264Y-91684288D01* -X161048278Y-91522502D01* -X161145571Y-91376893D01* -X161269393Y-91253071D01* -X161415002Y-91155778D01* -X161576788Y-91088764D01* -X161748541Y-91054600D01* -X161923659Y-91054600D01* -X162095412Y-91088764D01* -X162095412Y-91088764D01* -G37* -G36* -X164635412Y-91088764D02* -X164797198Y-91155778D01* -X164942807Y-91253071D01* -X165066629Y-91376893D01* -X165163922Y-91522502D01* -X165230936Y-91684288D01* -X165265100Y-91856041D01* -X165265100Y-92031159D01* -X165230936Y-92202912D01* -X165163922Y-92364698D01* -X165066629Y-92510307D01* -X164942807Y-92634129D01* -X164797198Y-92731422D01* -X164664981Y-92786188D01* -X164635412Y-92798436D01* -X164463659Y-92832600D01* -X164288541Y-92832600D01* -X164116788Y-92798436D01* -X164087219Y-92786188D01* -X163955002Y-92731422D01* -X163809393Y-92634129D01* -X163685571Y-92510307D01* -X163588278Y-92364698D01* -X163521264Y-92202912D01* -X163487100Y-92031159D01* -X163487100Y-91856041D01* -X163521264Y-91684288D01* -X163588278Y-91522502D01* -X163685571Y-91376893D01* -X163809393Y-91253071D01* -X163955002Y-91155778D01* -X164116788Y-91088764D01* -X164288541Y-91054600D01* -X164463659Y-91054600D01* -X164635412Y-91088764D01* -X164635412Y-91088764D01* -G37* -G36* -X164635412Y-88548764D02* -X164797198Y-88615778D01* -X164942807Y-88713071D01* -X165066629Y-88836893D01* -X165163922Y-88982502D01* -X165230936Y-89144288D01* -X165265100Y-89316041D01* -X165265100Y-89491159D01* -X165230936Y-89662912D01* -X165163922Y-89824698D01* -X165066629Y-89970307D01* -X164942807Y-90094129D01* -X164797198Y-90191422D01* -X164635412Y-90258436D01* -X164463659Y-90292600D01* -X164288541Y-90292600D01* -X164116788Y-90258436D01* -X163955002Y-90191422D01* -X163809393Y-90094129D01* -X163685571Y-89970307D01* -X163588278Y-89824698D01* -X163521264Y-89662912D01* -X163487100Y-89491159D01* -X163487100Y-89316041D01* -X163521264Y-89144288D01* -X163588278Y-88982502D01* -X163685571Y-88836893D01* -X163809393Y-88713071D01* -X163955002Y-88615778D01* -X164116788Y-88548764D01* -X164288541Y-88514600D01* -X164463659Y-88514600D01* -X164635412Y-88548764D01* -X164635412Y-88548764D01* -G37* -G36* -X162095412Y-88548764D02* -X162257198Y-88615778D01* -X162402807Y-88713071D01* -X162526629Y-88836893D01* -X162623922Y-88982502D01* -X162690936Y-89144288D01* -X162725100Y-89316041D01* -X162725100Y-89491159D01* -X162690936Y-89662912D01* -X162623922Y-89824698D01* -X162526629Y-89970307D01* -X162402807Y-90094129D01* -X162257198Y-90191422D01* -X162095412Y-90258436D01* -X161923659Y-90292600D01* -X161748541Y-90292600D01* -X161576788Y-90258436D01* -X161415002Y-90191422D01* -X161269393Y-90094129D01* -X161145571Y-89970307D01* -X161048278Y-89824698D01* -X160981264Y-89662912D01* -X160947100Y-89491159D01* -X160947100Y-89316041D01* -X160981264Y-89144288D01* -X161048278Y-88982502D01* -X161145571Y-88836893D01* -X161269393Y-88713071D01* -X161415002Y-88615778D01* -X161576788Y-88548764D01* -X161748541Y-88514600D01* -X161923659Y-88514600D01* -X162095412Y-88548764D01* -X162095412Y-88548764D01* -G37* -G36* -X135349445Y-85941858D02* -X135440229Y-85959916D01* -X135611262Y-86030760D01* -X135611263Y-86030761D01* -X135765190Y-86133612D01* -X135896088Y-86264510D01* -X135896090Y-86264513D01* -X135998940Y-86418438D01* -X136069784Y-86589471D01* -X136105900Y-86771038D01* -X136105900Y-86956162D01* -X136069784Y-87137729D01* -X135998940Y-87308762D01* -X135998939Y-87308763D01* -X135896088Y-87462690D01* -X135765190Y-87593588D01* -X135765187Y-87593590D01* -X135611262Y-87696440D01* -X135440229Y-87767284D01* -X135349445Y-87785342D01* -X135258664Y-87803400D01* -X135073536Y-87803400D01* -X134982755Y-87785342D01* -X134891971Y-87767284D01* -X134720938Y-87696440D01* -X134567013Y-87593590D01* -X134567010Y-87593588D01* -X134436112Y-87462690D01* -X134333261Y-87308763D01* -X134333260Y-87308762D01* -X134262416Y-87137729D01* -X134226300Y-86956162D01* -X134226300Y-86771038D01* -X134262416Y-86589471D01* -X134333260Y-86418438D01* -X134436110Y-86264513D01* -X134436112Y-86264510D01* -X134567010Y-86133612D01* -X134720937Y-86030761D01* -X134720938Y-86030760D01* -X134891971Y-85959916D01* -X134982755Y-85941858D01* -X135073536Y-85923800D01* -X135258664Y-85923800D01* -X135349445Y-85941858D01* -X135349445Y-85941858D01* -G37* -G36* -X132809445Y-85941858D02* -X132900229Y-85959916D01* -X133071262Y-86030760D01* -X133071263Y-86030761D01* -X133225190Y-86133612D01* -X133356088Y-86264510D01* -X133356090Y-86264513D01* -X133458940Y-86418438D01* -X133529784Y-86589471D01* -X133565900Y-86771038D01* -X133565900Y-86956162D01* -X133529784Y-87137729D01* -X133458940Y-87308762D01* -X133458939Y-87308763D01* -X133356088Y-87462690D01* -X133225190Y-87593588D01* -X133225187Y-87593590D01* -X133071262Y-87696440D01* -X132900229Y-87767284D01* -X132809445Y-87785342D01* -X132718664Y-87803400D01* -X132533536Y-87803400D01* -X132442755Y-87785342D01* -X132351971Y-87767284D01* -X132180938Y-87696440D01* -X132027013Y-87593590D01* -X132027010Y-87593588D01* -X131896112Y-87462690D01* -X131793261Y-87308763D01* -X131793260Y-87308762D01* -X131722416Y-87137729D01* -X131686300Y-86956162D01* -X131686300Y-86771038D01* -X131722416Y-86589471D01* -X131793260Y-86418438D01* -X131896110Y-86264513D01* -X131896112Y-86264510D01* -X132027010Y-86133612D01* -X132180937Y-86030761D01* -X132180938Y-86030760D01* -X132351971Y-85959916D01* -X132442755Y-85941858D01* -X132533536Y-85923800D01* -X132718664Y-85923800D01* -X132809445Y-85941858D01* -X132809445Y-85941858D01* -G37* -G36* -X130269445Y-85941858D02* -X130360229Y-85959916D01* -X130531262Y-86030760D01* -X130531263Y-86030761D01* -X130685190Y-86133612D01* -X130816088Y-86264510D01* -X130816090Y-86264513D01* -X130918940Y-86418438D01* -X130989784Y-86589471D01* -X131025900Y-86771038D01* -X131025900Y-86956162D01* -X130989784Y-87137729D01* -X130918940Y-87308762D01* -X130918939Y-87308763D01* -X130816088Y-87462690D01* -X130685190Y-87593588D01* -X130685187Y-87593590D01* -X130531262Y-87696440D01* -X130360229Y-87767284D01* -X130269445Y-87785342D01* -X130178664Y-87803400D01* -X129993536Y-87803400D01* -X129902755Y-87785342D01* -X129811971Y-87767284D01* -X129640938Y-87696440D01* -X129487013Y-87593590D01* -X129487010Y-87593588D01* -X129356112Y-87462690D01* -X129253261Y-87308763D01* -X129253260Y-87308762D01* -X129182416Y-87137729D01* -X129146300Y-86956162D01* -X129146300Y-86771038D01* -X129182416Y-86589471D01* -X129253260Y-86418438D01* -X129356110Y-86264513D01* -X129356112Y-86264510D01* -X129487010Y-86133612D01* -X129640937Y-86030761D01* -X129640938Y-86030760D01* -X129811971Y-85959916D01* -X129902755Y-85941858D01* -X129993536Y-85923800D01* -X130178664Y-85923800D01* -X130269445Y-85941858D01* -X130269445Y-85941858D01* -G37* -G36* -X150589445Y-85941858D02* -X150680229Y-85959916D01* -X150851262Y-86030760D01* -X150851263Y-86030761D01* -X151005190Y-86133612D01* -X151136088Y-86264510D01* -X151136090Y-86264513D01* -X151238940Y-86418438D01* -X151309784Y-86589471D01* -X151345900Y-86771038D01* -X151345900Y-86956162D01* -X151309784Y-87137729D01* -X151238940Y-87308762D01* -X151238939Y-87308763D01* -X151136088Y-87462690D01* -X151005190Y-87593588D01* -X151005187Y-87593590D01* -X150851262Y-87696440D01* -X150680229Y-87767284D01* -X150589445Y-87785342D01* -X150498664Y-87803400D01* -X150313536Y-87803400D01* -X150222755Y-87785342D01* -X150131971Y-87767284D01* -X149960938Y-87696440D01* -X149807013Y-87593590D01* -X149807010Y-87593588D01* -X149676112Y-87462690D01* -X149573261Y-87308763D01* -X149573260Y-87308762D01* -X149502416Y-87137729D01* -X149466300Y-86956162D01* -X149466300Y-86771038D01* -X149502416Y-86589471D01* -X149573260Y-86418438D01* -X149676110Y-86264513D01* -X149676112Y-86264510D01* -X149807010Y-86133612D01* -X149960937Y-86030761D01* -X149960938Y-86030760D01* -X150131971Y-85959916D01* -X150222755Y-85941858D01* -X150313536Y-85923800D01* -X150498664Y-85923800D01* -X150589445Y-85941858D01* -X150589445Y-85941858D01* -G37* -G36* -X137889445Y-85941858D02* -X137980229Y-85959916D01* -X138151262Y-86030760D01* -X138151263Y-86030761D01* -X138305190Y-86133612D01* -X138436088Y-86264510D01* -X138436090Y-86264513D01* -X138538940Y-86418438D01* -X138609784Y-86589471D01* -X138645900Y-86771038D01* -X138645900Y-86956162D01* -X138609784Y-87137729D01* -X138538940Y-87308762D01* -X138538939Y-87308763D01* -X138436088Y-87462690D01* -X138305190Y-87593588D01* -X138305187Y-87593590D01* -X138151262Y-87696440D01* -X137980229Y-87767284D01* -X137889445Y-87785342D01* -X137798664Y-87803400D01* -X137613536Y-87803400D01* -X137522755Y-87785342D01* -X137431971Y-87767284D01* -X137260938Y-87696440D01* -X137107013Y-87593590D01* -X137107010Y-87593588D01* -X136976112Y-87462690D01* -X136873261Y-87308763D01* -X136873260Y-87308762D01* -X136802416Y-87137729D01* -X136766300Y-86956162D01* -X136766300Y-86771038D01* -X136802416Y-86589471D01* -X136873260Y-86418438D01* -X136976110Y-86264513D01* -X136976112Y-86264510D01* -X137107010Y-86133612D01* -X137260937Y-86030761D01* -X137260938Y-86030760D01* -X137431971Y-85959916D01* -X137522755Y-85941858D01* -X137613536Y-85923800D01* -X137798664Y-85923800D01* -X137889445Y-85941858D01* -X137889445Y-85941858D01* -G37* -G36* -X148049445Y-85941858D02* -X148140229Y-85959916D01* -X148311262Y-86030760D01* -X148311263Y-86030761D01* -X148465190Y-86133612D01* -X148596088Y-86264510D01* -X148596090Y-86264513D01* -X148698940Y-86418438D01* -X148769784Y-86589471D01* -X148805900Y-86771038D01* -X148805900Y-86956162D01* -X148769784Y-87137729D01* -X148698940Y-87308762D01* -X148698939Y-87308763D01* -X148596088Y-87462690D01* -X148465190Y-87593588D01* -X148465187Y-87593590D01* -X148311262Y-87696440D01* -X148140229Y-87767284D01* -X148049445Y-87785342D01* -X147958664Y-87803400D01* -X147773536Y-87803400D01* -X147682755Y-87785342D01* -X147591971Y-87767284D01* -X147420938Y-87696440D01* -X147267013Y-87593590D01* -X147267010Y-87593588D01* -X147136112Y-87462690D01* -X147033261Y-87308763D01* -X147033260Y-87308762D01* -X146962416Y-87137729D01* -X146926300Y-86956162D01* -X146926300Y-86771038D01* -X146962416Y-86589471D01* -X147033260Y-86418438D01* -X147136110Y-86264513D01* -X147136112Y-86264510D01* -X147267010Y-86133612D01* -X147420937Y-86030761D01* -X147420938Y-86030760D01* -X147591971Y-85959916D01* -X147682755Y-85941858D01* -X147773536Y-85923800D01* -X147958664Y-85923800D01* -X148049445Y-85941858D01* -X148049445Y-85941858D01* -G37* -G36* -X145509445Y-85941858D02* -X145600229Y-85959916D01* -X145771262Y-86030760D01* -X145771263Y-86030761D01* -X145925190Y-86133612D01* -X146056088Y-86264510D01* -X146056090Y-86264513D01* -X146158940Y-86418438D01* -X146229784Y-86589471D01* -X146265900Y-86771038D01* -X146265900Y-86956162D01* -X146229784Y-87137729D01* -X146158940Y-87308762D01* -X146158939Y-87308763D01* -X146056088Y-87462690D01* -X145925190Y-87593588D01* -X145925187Y-87593590D01* -X145771262Y-87696440D01* -X145600229Y-87767284D01* -X145509445Y-87785342D01* -X145418664Y-87803400D01* -X145233536Y-87803400D01* -X145142755Y-87785342D01* -X145051971Y-87767284D01* -X144880938Y-87696440D01* -X144727013Y-87593590D01* -X144727010Y-87593588D01* -X144596112Y-87462690D01* -X144493261Y-87308763D01* -X144493260Y-87308762D01* -X144422416Y-87137729D01* -X144386300Y-86956162D01* -X144386300Y-86771038D01* -X144422416Y-86589471D01* -X144493260Y-86418438D01* -X144596110Y-86264513D01* -X144596112Y-86264510D01* -X144727010Y-86133612D01* -X144880937Y-86030761D01* -X144880938Y-86030760D01* -X145051971Y-85959916D01* -X145142755Y-85941858D01* -X145233536Y-85923800D01* -X145418664Y-85923800D01* -X145509445Y-85941858D01* -X145509445Y-85941858D01* -G37* -G36* -X142969445Y-85941858D02* -X143060229Y-85959916D01* -X143231262Y-86030760D01* -X143231263Y-86030761D01* -X143385190Y-86133612D01* -X143516088Y-86264510D01* -X143516090Y-86264513D01* -X143618940Y-86418438D01* -X143689784Y-86589471D01* -X143725900Y-86771038D01* -X143725900Y-86956162D01* -X143689784Y-87137729D01* -X143618940Y-87308762D01* -X143618939Y-87308763D01* -X143516088Y-87462690D01* -X143385190Y-87593588D01* -X143385187Y-87593590D01* -X143231262Y-87696440D01* -X143060229Y-87767284D01* -X142969445Y-87785342D01* -X142878664Y-87803400D01* -X142693536Y-87803400D01* -X142602755Y-87785342D01* -X142511971Y-87767284D01* -X142340938Y-87696440D01* -X142187013Y-87593590D01* -X142187010Y-87593588D01* -X142056112Y-87462690D01* -X141953261Y-87308763D01* -X141953260Y-87308762D01* -X141882416Y-87137729D01* -X141846300Y-86956162D01* -X141846300Y-86771038D01* -X141882416Y-86589471D01* -X141953260Y-86418438D01* -X142056110Y-86264513D01* -X142056112Y-86264510D01* -X142187010Y-86133612D01* -X142340937Y-86030761D01* -X142340938Y-86030760D01* -X142511971Y-85959916D01* -X142602755Y-85941858D01* -X142693536Y-85923800D01* -X142878664Y-85923800D01* -X142969445Y-85941858D01* -X142969445Y-85941858D01* -G37* -G36* -X140429445Y-85941858D02* -X140520229Y-85959916D01* -X140691262Y-86030760D01* -X140691263Y-86030761D01* -X140845190Y-86133612D01* -X140976088Y-86264510D01* -X140976090Y-86264513D01* -X141078940Y-86418438D01* -X141149784Y-86589471D01* -X141185900Y-86771038D01* -X141185900Y-86956162D01* -X141149784Y-87137729D01* -X141078940Y-87308762D01* -X141078939Y-87308763D01* -X140976088Y-87462690D01* -X140845190Y-87593588D01* -X140845187Y-87593590D01* -X140691262Y-87696440D01* -X140520229Y-87767284D01* -X140429445Y-87785342D01* -X140338664Y-87803400D01* -X140153536Y-87803400D01* -X140062755Y-87785342D01* -X139971971Y-87767284D01* -X139800938Y-87696440D01* -X139647013Y-87593590D01* -X139647010Y-87593588D01* -X139516112Y-87462690D01* -X139413261Y-87308763D01* -X139413260Y-87308762D01* -X139342416Y-87137729D01* -X139306300Y-86956162D01* -X139306300Y-86771038D01* -X139342416Y-86589471D01* -X139413260Y-86418438D01* -X139516110Y-86264513D01* -X139516112Y-86264510D01* -X139647010Y-86133612D01* -X139800937Y-86030761D01* -X139800938Y-86030760D01* -X139971971Y-85959916D01* -X140062755Y-85941858D01* -X140153536Y-85923800D01* -X140338664Y-85923800D01* -X140429445Y-85941858D01* -X140429445Y-85941858D01* -G37* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-B.SilkS.gbr b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-B.SilkS.gbr deleted file mode 100644 index 2e6a852..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-B.SilkS.gbr +++ /dev/null @@ -1,891 +0,0 @@ -G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* -G04 #@! TF.CreationDate,2019-04-02T23:20:26+04:00* -G04 #@! TF.ProjectId,M644_breakout_v1.2d,4d363434-5f62-4726-9561-6b6f75745f76,v1.2d* -G04 #@! TF.SameCoordinates,Original* -G04 #@! TF.FileFunction,Legend,Bot* -G04 #@! TF.FilePolarity,Positive* -%FSLAX46Y46*% -G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* -G04 Created by KiCad (PCBNEW (5.0.2)-1) date 02/04/2019 23:20:26* -%MOMM*% -%LPD*% -G01* -G04 APERTURE LIST* -%ADD10C,0.406400*% -%ADD11C,0.101600*% -%ADD12C,0.100000*% -%ADD13C,0.254000*% -%ADD14C,0.203200*% -%ADD15C,0.050800*% -%ADD16C,0.152400*% -%ADD17C,0.200000*% -G04 APERTURE END LIST* -D10* -X148495200Y-100109700D02* -G75* -G03X148495200Y-100109700I-425900J0D01* -G01* -D11* -G04 #@! TO.C,D3* -X163406100Y-126883600D02* -X167886100Y-126883600D01* -X167886100Y-123043600D02* -X163406100Y-123043600D01* -D12* -G04 #@! TO.C,D1* -G36* -X162124100Y-119753600D02* -X162124100Y-120053600D01* -X160024100Y-120053600D01* -X160024100Y-119753600D01* -X162124100Y-119753600D01* -G37* -D13* -X161774100Y-121203600D02* -X161074100Y-119953600D01* -X160374100Y-121203600D02* -X161774100Y-121203600D01* -X161074100Y-119953600D02* -X160374100Y-121203600D01* -D12* -G04 #@! TO.C,D2* -G36* -X167173100Y-119536600D02* -X166873100Y-119536600D01* -X166873100Y-117436600D01* -X167173100Y-117436600D01* -X167173100Y-119536600D01* -G37* -D13* -X165723100Y-119186600D02* -X166973100Y-118486600D01* -X165723100Y-117786600D02* -X165723100Y-119186600D01* -X166973100Y-118486600D02* -X165723100Y-117786600D01* -D12* -G04 #@! TO.C,D4* -G36* -X169363100Y-112387600D02* -X169363100Y-112687600D01* -X167263100Y-112687600D01* -X167263100Y-112387600D01* -X169363100Y-112387600D01* -G37* -D13* -X169013100Y-113837600D02* -X168313100Y-112587600D01* -X167613100Y-113837600D02* -X169013100Y-113837600D01* -X168313100Y-112587600D02* -X167613100Y-113837600D01* -D11* -G04 #@! TO.C,L2* -X131985100Y-105532600D02* -X131985100Y-107056600D01* -X130206100Y-105532600D02* -X130206100Y-107056600D01* -D13* -G04 #@! TO.C,IC1* -X147068800Y-101913600D02* -G75* -G03X147068800Y-101913600I-282700J0D01* -G01* -D14* -X147586100Y-110313600D02* -X147586100Y-101513600D01* -X147186100Y-110713600D02* -X147586100Y-110313600D01* -X138386100Y-110713600D02* -X147186100Y-110713600D01* -X137986100Y-110313600D02* -X138386100Y-110713600D01* -X137986100Y-101513600D02* -X137986100Y-110313600D01* -X138386100Y-101113600D02* -X137986100Y-101513600D01* -X147186100Y-101113600D02* -X138386100Y-101113600D01* -X147586100Y-101513600D02* -X147186100Y-101113600D01* -D15* -G04 #@! TO.C,Q1* -X154978100Y-111882600D02* -G75* -G03X158534100Y-111882600I1778000J0D01* -G01* -D16* -X154470100Y-111882600D02* -G75* -G03X159042100Y-111882600I2286000J0D01* -G01* -X154470100Y-105024600D02* -G75* -G02X159042100Y-105024600I2286000J0D01* -G01* -D15* -X154978100Y-105024600D02* -G75* -G02X158534100Y-105024600I1778000J0D01* -G01* -X158534100Y-105024600D02* -X158534100Y-111882600D01* -X154978100Y-111882600D02* -X154978100Y-105024600D01* -D16* -X159042100Y-105024600D02* -X159042100Y-111882600D01* -X154470100Y-111882600D02* -X154470100Y-105024600D01* -G04 #@! TD* -G04 #@! TO.C,D3* -D17* -X170638385Y-125609047D02* -X170638385Y-124402547D01* -X170351123Y-124402547D01* -X170178766Y-124460000D01* -X170063861Y-124574904D01* -X170006409Y-124689809D01* -X169948957Y-124919619D01* -X169948957Y-125091976D01* -X170006409Y-125321785D01* -X170063861Y-125436690D01* -X170178766Y-125551595D01* -X170351123Y-125609047D01* -X170638385Y-125609047D01* -X169546790Y-124402547D02* -X168799909Y-124402547D01* -X169202076Y-124862166D01* -X169029719Y-124862166D01* -X168914814Y-124919619D01* -X168857361Y-124977071D01* -X168799909Y-125091976D01* -X168799909Y-125379238D01* -X168857361Y-125494142D01* -X168914814Y-125551595D01* -X169029719Y-125609047D01* -X169374433Y-125609047D01* -X169489338Y-125551595D01* -X169546790Y-125494142D01* -G04 #@! TO.C,D1* -X161804047Y-124801714D02* -X160597547Y-124801714D01* -X160597547Y-125088976D01* -X160655000Y-125261333D01* -X160769904Y-125376238D01* -X160884809Y-125433690D01* -X161114619Y-125491142D01* -X161286976Y-125491142D01* -X161516785Y-125433690D01* -X161631690Y-125376238D01* -X161746595Y-125261333D01* -X161804047Y-125088976D01* -X161804047Y-124801714D01* -X161804047Y-126640190D02* -X161804047Y-125950761D01* -X161804047Y-126295476D02* -X160597547Y-126295476D01* -X160769904Y-126180571D01* -X160884809Y-126065666D01* -X160942261Y-125950761D01* -G04 #@! TO.C,D2* -X165952738Y-116782547D02* -X165952738Y-115576047D01* -X165665476Y-115576047D01* -X165493119Y-115633500D01* -X165378214Y-115748404D01* -X165320761Y-115863309D01* -X165263309Y-116093119D01* -X165263309Y-116265476D01* -X165320761Y-116495285D01* -X165378214Y-116610190D01* -X165493119Y-116725095D01* -X165665476Y-116782547D01* -X165952738Y-116782547D01* -X164803690Y-115690952D02* -X164746238Y-115633500D01* -X164631333Y-115576047D01* -X164344071Y-115576047D01* -X164229166Y-115633500D01* -X164171714Y-115690952D01* -X164114261Y-115805857D01* -X164114261Y-115920761D01* -X164171714Y-116093119D01* -X164861142Y-116782547D01* -X164114261Y-116782547D01* -G04 #@! TO.C,D4* -X166884047Y-112101714D02* -X165677547Y-112101714D01* -X165677547Y-112388976D01* -X165735000Y-112561333D01* -X165849904Y-112676238D01* -X165964809Y-112733690D01* -X166194619Y-112791142D01* -X166366976Y-112791142D01* -X166596785Y-112733690D01* -X166711690Y-112676238D01* -X166826595Y-112561333D01* -X166884047Y-112388976D01* -X166884047Y-112101714D01* -X166079714Y-113825285D02* -X166884047Y-113825285D01* -X165620095Y-113538023D02* -X166481880Y-113250761D01* -X166481880Y-113997642D01* -G04 #@! TO.C,C12* -X165263309Y-110952642D02* -X165320761Y-111010095D01* -X165493119Y-111067547D01* -X165608023Y-111067547D01* -X165780380Y-111010095D01* -X165895285Y-110895190D01* -X165952738Y-110780285D01* -X166010190Y-110550476D01* -X166010190Y-110378119D01* -X165952738Y-110148309D01* -X165895285Y-110033404D01* -X165780380Y-109918500D01* -X165608023Y-109861047D01* -X165493119Y-109861047D01* -X165320761Y-109918500D01* -X165263309Y-109975952D01* -X164114261Y-111067547D02* -X164803690Y-111067547D01* -X164458976Y-111067547D02* -X164458976Y-109861047D01* -X164573880Y-110033404D01* -X164688785Y-110148309D01* -X164803690Y-110205761D01* -X163654642Y-109975952D02* -X163597190Y-109918500D01* -X163482285Y-109861047D01* -X163195023Y-109861047D01* -X163080119Y-109918500D01* -X163022666Y-109975952D01* -X162965214Y-110090857D01* -X162965214Y-110205761D01* -X163022666Y-110378119D01* -X163712095Y-111067547D01* -X162965214Y-111067547D01* -G04 #@! TO.C,L2* -X130054047Y-103381047D02* -X130054047Y-102806523D01* -X128847547Y-102806523D01* -X128962452Y-103725761D02* -X128905000Y-103783214D01* -X128847547Y-103898119D01* -X128847547Y-104185380D01* -X128905000Y-104300285D01* -X128962452Y-104357738D01* -X129077357Y-104415190D01* -X129192261Y-104415190D01* -X129364619Y-104357738D01* -X130054047Y-103668309D01* -X130054047Y-104415190D01* -G04 #@! TO.C,IC1* -X147422833Y-98848166D02* -X147422833Y-97159066D01* -X145653300Y-98687300D02* -X145733733Y-98767733D01* -X145975033Y-98848166D01* -X146135900Y-98848166D01* -X146377200Y-98767733D01* -X146538066Y-98606866D01* -X146618500Y-98446000D01* -X146698933Y-98124266D01* -X146698933Y-97882966D01* -X146618500Y-97561233D01* -X146538066Y-97400366D01* -X146377200Y-97239500D01* -X146135900Y-97159066D01* -X145975033Y-97159066D01* -X145733733Y-97239500D01* -X145653300Y-97319933D01* -X144044633Y-98848166D02* -X145009833Y-98848166D01* -X144527233Y-98848166D02* -X144527233Y-97159066D01* -X144688100Y-97400366D01* -X144848966Y-97561233D01* -X145009833Y-97641666D01* -G04 #@! TO.C,R2* -X159899047Y-97551142D02* -X159324523Y-97148976D01* -X159899047Y-96861714D02* -X158692547Y-96861714D01* -X158692547Y-97321333D01* -X158750000Y-97436238D01* -X158807452Y-97493690D01* -X158922357Y-97551142D01* -X159094714Y-97551142D01* -X159209619Y-97493690D01* -X159267071Y-97436238D01* -X159324523Y-97321333D01* -X159324523Y-96861714D01* -X158807452Y-98010761D02* -X158750000Y-98068214D01* -X158692547Y-98183119D01* -X158692547Y-98470380D01* -X158750000Y-98585285D01* -X158807452Y-98642738D01* -X158922357Y-98700190D01* -X159037261Y-98700190D01* -X159209619Y-98642738D01* -X159899047Y-97953309D01* -X159899047Y-98700190D01* -G04 #@! TO.C,R1* -X131608309Y-117417547D02* -X132010476Y-116843023D01* -X132297738Y-117417547D02* -X132297738Y-116211047D01* -X131838119Y-116211047D01* -X131723214Y-116268500D01* -X131665761Y-116325952D01* -X131608309Y-116440857D01* -X131608309Y-116613214D01* -X131665761Y-116728119D01* -X131723214Y-116785571D01* -X131838119Y-116843023D01* -X132297738Y-116843023D01* -X130459261Y-117417547D02* -X131148690Y-117417547D01* -X130803976Y-117417547D02* -X130803976Y-116211047D01* -X130918880Y-116383404D01* -X131033785Y-116498309D01* -X131148690Y-116555761D01* -G04 #@! TO.C,R9* -X151072547Y-112866690D02* -X150498023Y-112464523D01* -X151072547Y-112177261D02* -X149866047Y-112177261D01* -X149866047Y-112636880D01* -X149923500Y-112751785D01* -X149980952Y-112809238D01* -X150095857Y-112866690D01* -X150268214Y-112866690D01* -X150383119Y-112809238D01* -X150440571Y-112751785D01* -X150498023Y-112636880D01* -X150498023Y-112177261D01* -X151072547Y-113441214D02* -X151072547Y-113671023D01* -X151015095Y-113785928D01* -X150957642Y-113843380D01* -X150785285Y-113958285D01* -X150555476Y-114015738D01* -X150095857Y-114015738D01* -X149980952Y-113958285D01* -X149923500Y-113900833D01* -X149866047Y-113785928D01* -X149866047Y-113556119D01* -X149923500Y-113441214D01* -X149980952Y-113383761D01* -X150095857Y-113326309D01* -X150383119Y-113326309D01* -X150498023Y-113383761D01* -X150555476Y-113441214D01* -X150612928Y-113556119D01* -X150612928Y-113785928D01* -X150555476Y-113900833D01* -X150498023Y-113958285D01* -X150383119Y-114015738D01* -G04 #@! TO.C,R10* -X157643309Y-123767547D02* -X158045476Y-123193023D01* -X158332738Y-123767547D02* -X158332738Y-122561047D01* -X157873119Y-122561047D01* -X157758214Y-122618500D01* -X157700761Y-122675952D01* -X157643309Y-122790857D01* -X157643309Y-122963214D01* -X157700761Y-123078119D01* -X157758214Y-123135571D01* -X157873119Y-123193023D01* -X158332738Y-123193023D01* -X156494261Y-123767547D02* -X157183690Y-123767547D01* -X156838976Y-123767547D02* -X156838976Y-122561047D01* -X156953880Y-122733404D01* -X157068785Y-122848309D01* -X157183690Y-122905761D01* -X155747380Y-122561047D02* -X155632476Y-122561047D01* -X155517571Y-122618500D01* -X155460119Y-122675952D01* -X155402666Y-122790857D01* -X155345214Y-123020666D01* -X155345214Y-123307928D01* -X155402666Y-123537738D01* -X155460119Y-123652642D01* -X155517571Y-123710095D01* -X155632476Y-123767547D01* -X155747380Y-123767547D01* -X155862285Y-123710095D01* -X155919738Y-123652642D01* -X155977190Y-123537738D01* -X156034642Y-123307928D01* -X156034642Y-123020666D01* -X155977190Y-122790857D01* -X155919738Y-122675952D01* -X155862285Y-122618500D01* -X155747380Y-122561047D01* -G04 #@! TO.C,Q1* -X153727452Y-111076595D02* -X153670000Y-110961690D01* -X153555095Y-110846785D01* -X153382738Y-110674428D01* -X153325285Y-110559523D01* -X153325285Y-110444619D01* -X153612547Y-110502071D02* -X153555095Y-110387166D01* -X153440190Y-110272261D01* -X153210380Y-110214809D01* -X152808214Y-110214809D01* -X152578404Y-110272261D01* -X152463500Y-110387166D01* -X152406047Y-110502071D01* -X152406047Y-110731880D01* -X152463500Y-110846785D01* -X152578404Y-110961690D01* -X152808214Y-111019142D01* -X153210380Y-111019142D01* -X153440190Y-110961690D01* -X153555095Y-110846785D01* -X153612547Y-110731880D01* -X153612547Y-110502071D01* -X153612547Y-112168190D02* -X153612547Y-111478761D01* -X153612547Y-111823476D02* -X152406047Y-111823476D01* -X152578404Y-111708571D01* -X152693309Y-111593666D01* -X152750761Y-111478761D01* -G04 #@! TO.C,C2* -X160482642Y-112866690D02* -X160540095Y-112809238D01* -X160597547Y-112636880D01* -X160597547Y-112521976D01* -X160540095Y-112349619D01* -X160425190Y-112234714D01* -X160310285Y-112177261D01* -X160080476Y-112119809D01* -X159908119Y-112119809D01* -X159678309Y-112177261D01* -X159563404Y-112234714D01* -X159448500Y-112349619D01* -X159391047Y-112521976D01* -X159391047Y-112636880D01* -X159448500Y-112809238D01* -X159505952Y-112866690D01* -X159505952Y-113326309D02* -X159448500Y-113383761D01* -X159391047Y-113498666D01* -X159391047Y-113785928D01* -X159448500Y-113900833D01* -X159505952Y-113958285D01* -X159620857Y-114015738D01* -X159735761Y-114015738D01* -X159908119Y-113958285D01* -X160597547Y-113268857D01* -X160597547Y-114015738D01* -G04 #@! TO.C,C1* -X153434142Y-103901142D02* -X153491595Y-103843690D01* -X153549047Y-103671333D01* -X153549047Y-103556428D01* -X153491595Y-103384071D01* -X153376690Y-103269166D01* -X153261785Y-103211714D01* -X153031976Y-103154261D01* -X152859619Y-103154261D01* -X152629809Y-103211714D01* -X152514904Y-103269166D01* -X152400000Y-103384071D01* -X152342547Y-103556428D01* -X152342547Y-103671333D01* -X152400000Y-103843690D01* -X152457452Y-103901142D01* -X153549047Y-105050190D02* -X153549047Y-104360761D01* -X153549047Y-104705476D02* -X152342547Y-104705476D01* -X152514904Y-104590571D01* -X152629809Y-104475666D01* -X152687261Y-104360761D01* -G04 #@! TO.C,C7* -X160482642Y-107151690D02* -X160540095Y-107094238D01* -X160597547Y-106921880D01* -X160597547Y-106806976D01* -X160540095Y-106634619D01* -X160425190Y-106519714D01* -X160310285Y-106462261D01* -X160080476Y-106404809D01* -X159908119Y-106404809D01* -X159678309Y-106462261D01* -X159563404Y-106519714D01* -X159448500Y-106634619D01* -X159391047Y-106806976D01* -X159391047Y-106921880D01* -X159448500Y-107094238D01* -X159505952Y-107151690D01* -X159391047Y-107553857D02* -X159391047Y-108358190D01* -X160597547Y-107841119D01* -G04 #@! TO.C,C3* -X132887357Y-101763309D02* -X132829904Y-101820761D01* -X132772452Y-101993119D01* -X132772452Y-102108023D01* -X132829904Y-102280380D01* -X132944809Y-102395285D01* -X133059714Y-102452738D01* -X133289523Y-102510190D01* -X133461880Y-102510190D01* -X133691690Y-102452738D01* -X133806595Y-102395285D01* -X133921500Y-102280380D01* -X133978952Y-102108023D01* -X133978952Y-101993119D01* -X133921500Y-101820761D01* -X133864047Y-101763309D01* -X133978952Y-101361142D02* -X133978952Y-100614261D01* -X133519333Y-101016428D01* -X133519333Y-100844071D01* -X133461880Y-100729166D01* -X133404428Y-100671714D01* -X133289523Y-100614261D01* -X133002261Y-100614261D01* -X132887357Y-100671714D01* -X132829904Y-100729166D01* -X132772452Y-100844071D01* -X132772452Y-101188785D01* -X132829904Y-101303690D01* -X132887357Y-101361142D01* -G04 #@! TO.C,C5* -X174158571Y-112858571D02* -X174215714Y-112915714D01* -X174387142Y-112972857D01* -X174501428Y-112972857D01* -X174672857Y-112915714D01* -X174787142Y-112801428D01* -X174844285Y-112687142D01* -X174901428Y-112458571D01* -X174901428Y-112287142D01* -X174844285Y-112058571D01* -X174787142Y-111944285D01* -X174672857Y-111830000D01* -X174501428Y-111772857D01* -X174387142Y-111772857D01* -X174215714Y-111830000D01* -X174158571Y-111887142D01* -X173072857Y-111772857D02* -X173644285Y-111772857D01* -X173701428Y-112344285D01* -X173644285Y-112287142D01* -X173530000Y-112230000D01* -X173244285Y-112230000D01* -X173130000Y-112287142D01* -X173072857Y-112344285D01* -X173015714Y-112458571D01* -X173015714Y-112744285D01* -X173072857Y-112858571D01* -X173130000Y-112915714D01* -X173244285Y-112972857D01* -X173530000Y-112972857D01* -X173644285Y-112915714D01* -X173701428Y-112858571D01* -G04 #@! TO.C,C8* -X133114142Y-107711142D02* -X133171595Y-107653690D01* -X133229047Y-107481333D01* -X133229047Y-107366428D01* -X133171595Y-107194071D01* -X133056690Y-107079166D01* -X132941785Y-107021714D01* -X132711976Y-106964261D01* -X132539619Y-106964261D01* -X132309809Y-107021714D01* -X132194904Y-107079166D01* -X132080000Y-107194071D01* -X132022547Y-107366428D01* -X132022547Y-107481333D01* -X132080000Y-107653690D01* -X132137452Y-107711142D01* -X132539619Y-108400571D02* -X132482166Y-108285666D01* -X132424714Y-108228214D01* -X132309809Y-108170761D01* -X132252357Y-108170761D01* -X132137452Y-108228214D01* -X132080000Y-108285666D01* -X132022547Y-108400571D01* -X132022547Y-108630380D01* -X132080000Y-108745285D01* -X132137452Y-108802738D01* -X132252357Y-108860190D01* -X132309809Y-108860190D01* -X132424714Y-108802738D01* -X132482166Y-108745285D01* -X132539619Y-108630380D01* -X132539619Y-108400571D01* -X132597071Y-108285666D01* -X132654523Y-108228214D01* -X132769428Y-108170761D01* -X132999238Y-108170761D01* -X133114142Y-108228214D01* -X133171595Y-108285666D01* -X133229047Y-108400571D01* -X133229047Y-108630380D01* -X133171595Y-108745285D01* -X133114142Y-108802738D01* -X132999238Y-108860190D01* -X132769428Y-108860190D01* -X132654523Y-108802738D01* -X132597071Y-108745285D01* -X132539619Y-108630380D01* -G04 #@! TO.C,C9* -X144607642Y-116041690D02* -X144665095Y-115984238D01* -X144722547Y-115811880D01* -X144722547Y-115696976D01* -X144665095Y-115524619D01* -X144550190Y-115409714D01* -X144435285Y-115352261D01* -X144205476Y-115294809D01* -X144033119Y-115294809D01* -X143803309Y-115352261D01* -X143688404Y-115409714D01* -X143573500Y-115524619D01* -X143516047Y-115696976D01* -X143516047Y-115811880D01* -X143573500Y-115984238D01* -X143630952Y-116041690D01* -X144722547Y-116616214D02* -X144722547Y-116846023D01* -X144665095Y-116960928D01* -X144607642Y-117018380D01* -X144435285Y-117133285D01* -X144205476Y-117190738D01* -X143745857Y-117190738D01* -X143630952Y-117133285D01* -X143573500Y-117075833D01* -X143516047Y-116960928D01* -X143516047Y-116731119D01* -X143573500Y-116616214D01* -X143630952Y-116558761D01* -X143745857Y-116501309D01* -X144033119Y-116501309D01* -X144148023Y-116558761D01* -X144205476Y-116616214D01* -X144262928Y-116731119D01* -X144262928Y-116960928D01* -X144205476Y-117075833D01* -X144148023Y-117133285D01* -X144033119Y-117190738D01* -G04 #@! TO.C,C10* -X141432642Y-95086690D02* -X141490095Y-95029238D01* -X141547547Y-94856880D01* -X141547547Y-94741976D01* -X141490095Y-94569619D01* -X141375190Y-94454714D01* -X141260285Y-94397261D01* -X141030476Y-94339809D01* -X140858119Y-94339809D01* -X140628309Y-94397261D01* -X140513404Y-94454714D01* -X140398500Y-94569619D01* -X140341047Y-94741976D01* -X140341047Y-94856880D01* -X140398500Y-95029238D01* -X140455952Y-95086690D01* -X141547547Y-96235738D02* -X141547547Y-95546309D01* -X141547547Y-95891023D02* -X140341047Y-95891023D01* -X140513404Y-95776119D01* -X140628309Y-95661214D01* -X140685761Y-95546309D01* -X140341047Y-96982619D02* -X140341047Y-97097523D01* -X140398500Y-97212428D01* -X140455952Y-97269880D01* -X140570857Y-97327333D01* -X140800666Y-97384785D01* -X141087928Y-97384785D01* -X141317738Y-97327333D01* -X141432642Y-97269880D01* -X141490095Y-97212428D01* -X141547547Y-97097523D01* -X141547547Y-96982619D01* -X141490095Y-96867714D01* -X141432642Y-96810261D01* -X141317738Y-96752809D01* -X141087928Y-96695357D01* -X140800666Y-96695357D01* -X140570857Y-96752809D01* -X140455952Y-96810261D01* -X140398500Y-96867714D01* -X140341047Y-96982619D01* -G04 #@! TO.C,C11* -X135372904Y-112159142D02* -X135430357Y-112216595D01* -X135602714Y-112274047D01* -X135717619Y-112274047D01* -X135889976Y-112216595D01* -X136004880Y-112101690D01* -X136062333Y-111986785D01* -X136119785Y-111756976D01* -X136119785Y-111584619D01* -X136062333Y-111354809D01* -X136004880Y-111239904D01* -X135889976Y-111125000D01* -X135717619Y-111067547D01* -X135602714Y-111067547D01* -X135430357Y-111125000D01* -X135372904Y-111182452D01* -X134223857Y-112274047D02* -X134913285Y-112274047D01* -X134568571Y-112274047D02* -X134568571Y-111067547D01* -X134683476Y-111239904D01* -X134798380Y-111354809D01* -X134913285Y-111412261D01* -X133074809Y-112274047D02* -X133764238Y-112274047D01* -X133419523Y-112274047D02* -X133419523Y-111067547D01* -X133534428Y-111239904D01* -X133649333Y-111354809D01* -X133764238Y-111412261D01* -G04 #@! TO.C,C4* -X174153309Y-107777642D02* -X174210761Y-107835095D01* -X174383119Y-107892547D01* -X174498023Y-107892547D01* -X174670380Y-107835095D01* -X174785285Y-107720190D01* -X174842738Y-107605285D01* -X174900190Y-107375476D01* -X174900190Y-107203119D01* -X174842738Y-106973309D01* -X174785285Y-106858404D01* -X174670380Y-106743500D01* -X174498023Y-106686047D01* -X174383119Y-106686047D01* -X174210761Y-106743500D01* -X174153309Y-106800952D01* -X173119166Y-107088214D02* -X173119166Y-107892547D01* -X173406428Y-106628595D02* -X173693690Y-107490380D01* -X172946809Y-107490380D01* -G04 #@! TO.C,C6* -X162117314Y-101001914D02* -X162163276Y-100955952D01* -X162209238Y-100818066D01* -X162209238Y-100726142D01* -X162163276Y-100588257D01* -X162071352Y-100496333D01* -X161979428Y-100450371D01* -X161795580Y-100404409D01* -X161657695Y-100404409D01* -X161473847Y-100450371D01* -X161381923Y-100496333D01* -X161290000Y-100588257D01* -X161244038Y-100726142D01* -X161244038Y-100818066D01* -X161290000Y-100955952D01* -X161335961Y-101001914D01* -X161244038Y-101829228D02* -X161244038Y-101645380D01* -X161290000Y-101553457D01* -X161335961Y-101507495D01* -X161473847Y-101415571D01* -X161657695Y-101369609D01* -X162025390Y-101369609D01* -X162117314Y-101415571D01* -X162163276Y-101461533D01* -X162209238Y-101553457D01* -X162209238Y-101737304D01* -X162163276Y-101829228D01* -X162117314Y-101875190D01* -X162025390Y-101921152D01* -X161795580Y-101921152D01* -X161703657Y-101875190D01* -X161657695Y-101829228D01* -X161611733Y-101737304D01* -X161611733Y-101553457D01* -X161657695Y-101461533D01* -X161703657Y-101415571D01* -X161795580Y-101369609D01* -G04 #@! TO.C,R7* -X149332647Y-119851690D02* -X148758123Y-119449523D01* -X149332647Y-119162261D02* -X148126147Y-119162261D01* -X148126147Y-119621880D01* -X148183600Y-119736785D01* -X148241052Y-119794238D01* -X148355957Y-119851690D01* -X148528314Y-119851690D01* -X148643219Y-119794238D01* -X148700671Y-119736785D01* -X148758123Y-119621880D01* -X148758123Y-119162261D01* -X148126147Y-120253857D02* -X148126147Y-121058190D01* -X149332647Y-120541119D01* -G04 #@! TO.C,R8* -X153726847Y-119851690D02* -X153152323Y-119449523D01* -X153726847Y-119162261D02* -X152520347Y-119162261D01* -X152520347Y-119621880D01* -X152577800Y-119736785D01* -X152635252Y-119794238D01* -X152750157Y-119851690D01* -X152922514Y-119851690D01* -X153037419Y-119794238D01* -X153094871Y-119736785D01* -X153152323Y-119621880D01* -X153152323Y-119162261D01* -X153037419Y-120541119D02* -X152979966Y-120426214D01* -X152922514Y-120368761D01* -X152807609Y-120311309D01* -X152750157Y-120311309D01* -X152635252Y-120368761D01* -X152577800Y-120426214D01* -X152520347Y-120541119D01* -X152520347Y-120770928D01* -X152577800Y-120885833D01* -X152635252Y-120943285D01* -X152750157Y-121000738D01* -X152807609Y-121000738D01* -X152922514Y-120943285D01* -X152979966Y-120885833D01* -X153037419Y-120770928D01* -X153037419Y-120541119D01* -X153094871Y-120426214D01* -X153152323Y-120368761D01* -X153267228Y-120311309D01* -X153497038Y-120311309D01* -X153611942Y-120368761D01* -X153669395Y-120426214D01* -X153726847Y-120541119D01* -X153726847Y-120770928D01* -X153669395Y-120885833D01* -X153611942Y-120943285D01* -X153497038Y-121000738D01* -X153267228Y-121000738D01* -X153152323Y-120943285D01* -X153094871Y-120885833D01* -X153037419Y-120770928D01* -G04 #@! TD* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Bottom.gbr b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Bottom.gbr deleted file mode 100644 index a6f2100..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Bottom.gbr +++ /dev/null @@ -1,6883 +0,0 @@ -G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* -G04 #@! TF.CreationDate,2019-04-02T23:20:26+04:00* -G04 #@! TF.ProjectId,M644_breakout_v1.2d,4d363434-5f62-4726-9561-6b6f75745f76,v1.2d* -G04 #@! TF.SameCoordinates,Original* -G04 #@! TF.FileFunction,Copper,L2,Bot* -G04 #@! TF.FilePolarity,Positive* -%FSLAX46Y46*% -G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* -G04 Created by KiCad (PCBNEW (5.0.2)-1) date 02/04/2019 23:20:26* -%MOMM*% -%LPD*% -G01* -G04 APERTURE LIST* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD10R,1.780000X2.160000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD11R,2.200000X1.800000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD12R,1.800000X2.200000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD13R,2.700000X2.550000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD14R,1.600000X1.200000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD15O,3.048000X1.524000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD16C,1.676400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD17C,1.778000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD18R,0.500000X1.500000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD19R,1.500000X0.500000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD20R,1.422400X0.711200*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD21R,0.711200X1.422400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD22O,2.844800X1.422400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD23O,1.790700X3.581400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD24C,1.800000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD25R,1.500000X1.300000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD26R,1.700000X1.700000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD27O,1.700000X1.700000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD28C,7.620000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD29C,1.930400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD30C,0.800000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD31C,1.270000*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD32C,0.609600*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD33C,0.406400*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD34C,0.381000*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD35C,1.270000*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD36C,0.812800*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD37C,1.422400*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD38C,1.016000*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD39C,0.304800*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD40C,0.254000*% -G04 #@! TD* -G04 APERTURE END LIST* -D10* -G04 #@! TO.P,D3,A* -G04 #@! TO.N,GND* -X167686100Y-124963600D03* -G04 #@! TO.P,D3,C* -G04 #@! TO.N,Net-(D1-PadA)* -X163616100Y-124963600D03* -G04 #@! TD* -D11* -G04 #@! TO.P,D1,A* -G04 #@! TO.N,Net-(D1-PadA)* -X161074100Y-123703600D03* -G04 #@! TO.P,D1,C* -G04 #@! TO.N,Net-(D1-PadC)* -X161074100Y-118603600D03* -G04 #@! TD* -D12* -G04 #@! TO.P,D2,A* -G04 #@! TO.N,Net-(D1-PadC)* -X163223100Y-118486600D03* -G04 #@! TO.P,D2,C* -G04 #@! TO.N,Net-(D2-PadC)* -X168323100Y-118486600D03* -G04 #@! TD* -D11* -G04 #@! TO.P,D4,A* -G04 #@! TO.N,Net-(D2-PadC)* -X168313100Y-116337600D03* -G04 #@! TO.P,D4,C* -G04 #@! TO.N,Net-(C4-PadP$1)* -X168313100Y-111237600D03* -G04 #@! TD* -D13* -G04 #@! TO.P,C12,-* -G04 #@! TO.N,GND* -X164858700Y-107767800D03* -G04 #@! TO.P,C12,+* -G04 #@! TO.N,VCC* -X164858700Y-101417800D03* -G04 #@! TD* -D14* -G04 #@! TO.P,L2,2* -G04 #@! TO.N,Net-(C11-PadP$1)* -X131102100Y-107794600D03* -G04 #@! TO.P,L2,1* -G04 #@! TO.N,VCC* -X131102100Y-104794600D03* -G04 #@! TD* -D15* -G04 #@! TO.P,IC2,3* -G04 #@! TO.N,VCC* -X171615100Y-105913600D03* -G04 #@! TO.P,IC2,2* -G04 #@! TO.N,GND* -X171615100Y-108453600D03* -G04 #@! TO.P,IC2,1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X171615100Y-110993600D03* -G04 #@! TD* -D16* -G04 #@! TO.P,SV1,6* -G04 #@! TO.N,GND* -X164376100Y-94483600D03* -G04 #@! TO.P,SV1,5* -G04 #@! TO.N,/RESET* -X161836100Y-94483600D03* -G04 #@! TO.P,SV1,4* -G04 #@! TO.N,/MOSI* -X164376100Y-91943600D03* -G04 #@! TO.P,SV1,3* -G04 #@! TO.N,/SCK* -X161836100Y-91943600D03* -G04 #@! TO.P,SV1,2* -G04 #@! TO.N,VCC* -X164376100Y-89403600D03* -G04 #@! TO.P,SV1,1* -G04 #@! TO.N,/MISO* -X161836100Y-89403600D03* -G04 #@! TD* -D17* -G04 #@! TO.P,JP3,12* -G04 #@! TO.N,/PC3* -X130086100Y-124963600D03* -G04 #@! TO.P,JP3,11* -G04 #@! TO.N,/PC2* -X132626100Y-124963600D03* -G04 #@! TO.P,JP3,10* -G04 #@! TO.N,/PC1* -X135166100Y-124963600D03* -G04 #@! TO.P,JP3,9* -G04 #@! TO.N,/PC0* -X137706100Y-124963600D03* -G04 #@! TO.P,JP3,8* -G04 #@! TO.N,/PD7* -X140246100Y-124963600D03* -G04 #@! TO.P,JP3,7* -G04 #@! TO.N,/PD6* -X142786100Y-124963600D03* -G04 #@! TO.P,JP3,6* -G04 #@! TO.N,/PD5* -X145326100Y-124963600D03* -G04 #@! TO.P,JP3,5* -G04 #@! TO.N,/PD4* -X147866100Y-124963600D03* -G04 #@! TO.P,JP3,4* -G04 #@! TO.N,/PD3'* -X150406100Y-124963600D03* -G04 #@! TO.P,JP3,3* -G04 #@! TO.N,/PD2* -X152946100Y-124963600D03* -G04 #@! TO.P,JP3,2* -G04 #@! TO.N,/PD1'* -X155486100Y-124963600D03* -G04 #@! TO.P,JP3,1* -G04 #@! TO.N,/PD0* -X158026100Y-124963600D03* -G04 #@! TD* -D18* -G04 #@! TO.P,IC1,44* -G04 #@! TO.N,/PB4* -X146786100Y-100113600D03* -G04 #@! TO.P,IC1,43* -G04 #@! TO.N,/PB3* -X145986100Y-100113600D03* -G04 #@! TO.P,IC1,42* -G04 #@! TO.N,/PB2* -X145186100Y-100113600D03* -G04 #@! TO.P,IC1,41* -G04 #@! TO.N,/PB1* -X144386100Y-100113600D03* -G04 #@! TO.P,IC1,40* -G04 #@! TO.N,/PB0* -X143586100Y-100113600D03* -G04 #@! TO.P,IC1,39* -G04 #@! TO.N,GND* -X142786100Y-100113600D03* -G04 #@! TO.P,IC1,38* -G04 #@! TO.N,VCC* -X141986100Y-100113600D03* -G04 #@! TO.P,IC1,37* -G04 #@! TO.N,/PA0* -X141186100Y-100113600D03* -G04 #@! TO.P,IC1,36* -G04 #@! TO.N,/PA1* -X140386100Y-100113600D03* -G04 #@! TO.P,IC1,35* -G04 #@! TO.N,/PA2* -X139586100Y-100113600D03* -G04 #@! TO.P,IC1,34* -G04 #@! TO.N,/PA3* -X138786100Y-100113600D03* -D19* -G04 #@! TO.P,IC1,33* -G04 #@! TO.N,/PA4* -X136986100Y-101913600D03* -G04 #@! TO.P,IC1,32* -G04 #@! TO.N,/PA5* -X136986100Y-102713600D03* -G04 #@! TO.P,IC1,31* -G04 #@! TO.N,/PA6* -X136986100Y-103513600D03* -G04 #@! TO.P,IC1,30* -G04 #@! TO.N,/PA7* -X136986100Y-104313600D03* -G04 #@! TO.P,IC1,29* -G04 #@! TO.N,/AREF* -X136986100Y-105113600D03* -G04 #@! TO.P,IC1,28* -G04 #@! TO.N,GND* -X136986100Y-105913600D03* -G04 #@! TO.P,IC1,27* -G04 #@! TO.N,Net-(C11-PadP$1)* -X136986100Y-106713600D03* -G04 #@! TO.P,IC1,26* -G04 #@! TO.N,/PC7* -X136986100Y-107513600D03* -G04 #@! TO.P,IC1,25* -G04 #@! TO.N,/PC6* -X136986100Y-108313600D03* -G04 #@! TO.P,IC1,24* -G04 #@! TO.N,/PC5* -X136986100Y-109113600D03* -G04 #@! TO.P,IC1,23* -G04 #@! TO.N,/PC4* -X136986100Y-109913600D03* -D18* -G04 #@! TO.P,IC1,22* -G04 #@! TO.N,/PC3* -X138786100Y-111713600D03* -G04 #@! TO.P,IC1,21* -G04 #@! TO.N,/PC2* -X139586100Y-111713600D03* -G04 #@! TO.P,IC1,20* -G04 #@! TO.N,/PC1* -X140386100Y-111713600D03* -G04 #@! TO.P,IC1,19* -G04 #@! TO.N,/PC0* -X141186100Y-111713600D03* -G04 #@! TO.P,IC1,18* -G04 #@! TO.N,GND* -X141986100Y-111713600D03* -G04 #@! TO.P,IC1,17* -G04 #@! TO.N,VCC* -X142786100Y-111713600D03* -G04 #@! TO.P,IC1,16* -G04 #@! TO.N,/PD7* -X143586100Y-111713600D03* -G04 #@! TO.P,IC1,15* -G04 #@! TO.N,/PD6* -X144386100Y-111713600D03* -G04 #@! TO.P,IC1,14* -G04 #@! TO.N,/PD5* -X145186100Y-111713600D03* -G04 #@! TO.P,IC1,13* -G04 #@! TO.N,/PD4* -X145986100Y-111713600D03* -G04 #@! TO.P,IC1,12* -G04 #@! TO.N,/PD3* -X146786100Y-111713600D03* -D19* -G04 #@! TO.P,IC1,11* -G04 #@! TO.N,/PD2* -X148586100Y-109913600D03* -G04 #@! TO.P,IC1,10* -G04 #@! TO.N,/PD1* -X148586100Y-109113600D03* -G04 #@! TO.P,IC1,9* -G04 #@! TO.N,/PD0* -X148586100Y-108313600D03* -G04 #@! TO.P,IC1,8* -G04 #@! TO.N,Net-(C2-PadP$1)* -X148586100Y-107513600D03* -G04 #@! TO.P,IC1,7* -G04 #@! TO.N,Net-(C1-PadP$1)* -X148586100Y-106713600D03* -G04 #@! TO.P,IC1,6* -G04 #@! TO.N,GND* -X148586100Y-105913600D03* -G04 #@! TO.P,IC1,5* -G04 #@! TO.N,VCC* -X148586100Y-105113600D03* -G04 #@! TO.P,IC1,4* -G04 #@! TO.N,/RESET* -X148586100Y-104313600D03* -G04 #@! TO.P,IC1,3* -G04 #@! TO.N,/SCK* -X148586100Y-103513600D03* -G04 #@! TO.P,IC1,2* -G04 #@! TO.N,/MISO* -X148586100Y-102713600D03* -G04 #@! TO.P,IC1,1* -G04 #@! TO.N,/MOSI* -X148586100Y-101913600D03* -G04 #@! TD* -D20* -G04 #@! TO.P,R2,P$2* -G04 #@! TO.N,VCC* -X159296100Y-101976600D03* -G04 #@! TO.P,R2,P$1* -G04 #@! TO.N,/RESET* -X159296100Y-99690600D03* -G04 #@! TD* -D21* -G04 #@! TO.P,R1,P$2* -G04 #@! TO.N,Net-(LED1-PadA)* -X128358900Y-114803600D03* -G04 #@! TO.P,R1,P$1* -G04 #@! TO.N,/PC4* -X130644900Y-114803600D03* -G04 #@! TD* -D20* -G04 #@! TO.P,R9,P$2* -G04 #@! TO.N,GND* -X150406100Y-114930600D03* -G04 #@! TO.P,R9,P$1* -G04 #@! TO.N,/PD3'* -X150406100Y-117216600D03* -G04 #@! TD* -D21* -G04 #@! TO.P,R10,P$2* -G04 #@! TO.N,GND* -X158305500Y-121179000D03* -G04 #@! TO.P,R10,P$1* -G04 #@! TO.N,/PD1'* -X156019500Y-121179000D03* -G04 #@! TD* -D22* -G04 #@! TO.P,Q1,2* -G04 #@! TO.N,Net-(C1-PadP$1)* -X156756100Y-105913600D03* -G04 #@! TO.P,Q1,1* -G04 #@! TO.N,Net-(C2-PadP$1)* -X156756100Y-110993600D03* -G04 #@! TD* -D20* -G04 #@! TO.P,C2,P$2* -G04 #@! TO.N,GND* -X160134300Y-108898100D03* -G04 #@! TO.P,C2,P$1* -G04 #@! TO.N,Net-(C2-PadP$1)* -X160134300Y-111184100D03* -G04 #@! TD* -G04 #@! TO.P,C1,P$2* -G04 #@! TO.N,GND* -X153390600Y-108237700D03* -G04 #@! TO.P,C1,P$1* -G04 #@! TO.N,Net-(C1-PadP$1)* -X153390600Y-105951700D03* -G04 #@! TD* -G04 #@! TO.P,C7,P$2* -G04 #@! TO.N,GND* -X160235900Y-105786600D03* -G04 #@! TO.P,C7,P$1* -G04 #@! TO.N,VCC* -X160235900Y-103500600D03* -G04 #@! TD* -D21* -G04 #@! TO.P,C3,P$2* -G04 #@! TO.N,/AREF* -X135039100Y-103945100D03* -G04 #@! TO.P,C3,P$1* -G04 #@! TO.N,GND* -X132753100Y-103945100D03* -G04 #@! TD* -D20* -G04 #@! TO.P,C5,P$2* -G04 #@! TO.N,GND* -X173088300Y-108453600D03* -G04 #@! TO.P,C5,P$1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X173088300Y-110739600D03* -G04 #@! TD* -D16* -G04 #@! TO.P,LED1,K* -G04 #@! TO.N,GND* -X128816100Y-109723600D03* -G04 #@! TO.P,LED1,A* -G04 #@! TO.N,Net-(LED1-PadA)* -X128816100Y-112263600D03* -G04 #@! TD* -D21* -G04 #@! TO.P,C8,P$2* -G04 #@! TO.N,VCC* -X132753100Y-105913600D03* -G04 #@! TO.P,C8,P$1* -G04 #@! TO.N,GND* -X135039100Y-105913600D03* -G04 #@! TD* -D20* -G04 #@! TO.P,C9,P$2* -G04 #@! TO.N,VCC* -X142024100Y-117280100D03* -G04 #@! TO.P,C9,P$1* -G04 #@! TO.N,GND* -X142024100Y-114994100D03* -G04 #@! TD* -G04 #@! TO.P,C10,P$2* -G04 #@! TO.N,VCC* -X142786100Y-94737600D03* -G04 #@! TO.P,C10,P$1* -G04 #@! TO.N,GND* -X142786100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,C11,P$2* -G04 #@! TO.N,GND* -X134150100Y-110409400D03* -G04 #@! TO.P,C11,P$1* -G04 #@! TO.N,Net-(C11-PadP$1)* -X134150100Y-108123400D03* -G04 #@! TD* -D17* -G04 #@! TO.P,JP1,9* -G04 #@! TO.N,/PA3* -X130086100Y-86863600D03* -G04 #@! TO.P,JP1,8* -G04 #@! TO.N,/PA2* -X132626100Y-86863600D03* -G04 #@! TO.P,JP1,7* -G04 #@! TO.N,/PA1* -X135166100Y-86863600D03* -G04 #@! TO.P,JP1,6* -G04 #@! TO.N,/PA0* -X137706100Y-86863600D03* -G04 #@! TO.P,JP1,5* -G04 #@! TO.N,/PB0* -X140246100Y-86863600D03* -G04 #@! TO.P,JP1,4* -G04 #@! TO.N,/PB1* -X142786100Y-86863600D03* -G04 #@! TO.P,JP1,3* -G04 #@! TO.N,/PB2* -X145326100Y-86863600D03* -G04 #@! TO.P,JP1,2* -G04 #@! TO.N,/PB3* -X147866100Y-86863600D03* -G04 #@! TO.P,JP1,1* -G04 #@! TO.N,/PB4* -X150406100Y-86863600D03* -G04 #@! TD* -G04 #@! TO.P,JP2,9* -G04 #@! TO.N,/PC6* -X125006100Y-117343600D03* -G04 #@! TO.P,JP2,8* -G04 #@! TO.N,/PC7* -X125006100Y-114803600D03* -G04 #@! TO.P,JP2,7* -G04 #@! TO.N,/PA7* -X125006100Y-112263600D03* -G04 #@! TO.P,JP2,6* -G04 #@! TO.N,GND* -X125006100Y-109723600D03* -G04 #@! TO.P,JP2,5* -G04 #@! TO.N,/AREF* -X125006100Y-107183600D03* -G04 #@! TO.P,JP2,4* -G04 #@! TO.N,VCC* -X125006100Y-104643600D03* -G04 #@! TO.P,JP2,3* -G04 #@! TO.N,/PA5* -X125006100Y-102103600D03* -G04 #@! TO.P,JP2,2* -G04 #@! TO.N,/PA4* -X125006100Y-99563600D03* -G04 #@! TO.P,JP2,1* -G04 #@! TO.N,/PA6* -X125006100Y-97023600D03* -G04 #@! TD* -D20* -G04 #@! TO.P,C4,P$2* -G04 #@! TO.N,GND* -X174536100Y-108453600D03* -G04 #@! TO.P,C4,P$1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X174536100Y-110739600D03* -G04 #@! TD* -G04 #@! TO.P,C6,P$2* -G04 #@! TO.N,GND* -X161937700Y-105786600D03* -G04 #@! TO.P,C6,P$1* -G04 #@! TO.N,VCC* -X161937700Y-103500600D03* -G04 #@! TD* -D23* -G04 #@! TO.P,X2,2* -G04 #@! TO.N,Net-(D1-PadA)* -X163146100Y-122423600D03* -G04 #@! TO.P,X2,1* -G04 #@! TO.N,GND* -X168146100Y-122423600D03* -G04 #@! TD* -D24* -G04 #@! TO.P,JP4,1* -G04 #@! TO.N,/SCK* -X150406100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP5,1* -G04 #@! TO.N,/SCK* -X152946100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP6,1* -G04 #@! TO.N,/MISO* -X152946100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP7,1* -G04 #@! TO.N,/MISO* -X150406100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP8,1* -G04 #@! TO.N,/MOSI* -X150406100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP9,1* -G04 #@! TO.N,/MOSI* -X152946100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP11,1* -G04 #@! TO.N,/SCK* -X155486100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP12,1* -G04 #@! TO.N,/MISO* -X155486100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP13,1* -G04 #@! TO.N,/MOSI* -X155486100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP14,1* -G04 #@! TO.N,VCC* -X171996100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP15,1* -G04 #@! TO.N,VCC* -X171996100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP16,1* -G04 #@! TO.N,VCC* -X171996100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP17,1* -G04 #@! TO.N,VCC* -X171996100Y-99563600D03* -G04 #@! TD* -G04 #@! TO.P,JP19,1* -G04 #@! TO.N,GND* -X169456100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP20,1* -G04 #@! TO.N,GND* -X169456100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP21,1* -G04 #@! TO.N,GND* -X169456100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP22,1* -G04 #@! TO.N,GND* -X169456100Y-99563600D03* -G04 #@! TD* -G04 #@! TO.P,JP24,1* -G04 #@! TO.N,/PD2* -X152946100Y-122423600D03* -G04 #@! TD* -G04 #@! TO.P,JP25,1* -G04 #@! TO.N,/PD3'* -X150406100Y-122423600D03* -G04 #@! TD* -G04 #@! TO.P,JP26,1* -G04 #@! TO.N,/PD4* -X147866100Y-122423600D03* -G04 #@! TD* -G04 #@! TO.P,JP27,1* -G04 #@! TO.N,/PC5* -X127546100Y-107183600D03* -G04 #@! TD* -G04 #@! TO.P,JP28,1* -G04 #@! TO.N,/PC4* -X127546100Y-117343600D03* -G04 #@! TD* -G04 #@! TO.P,JP10,1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X171996100Y-114168600D03* -G04 #@! TD* -G04 #@! TO.P,JP29,1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X174536100Y-114168600D03* -G04 #@! TD* -D25* -G04 #@! TO.P,R7,2* -G04 #@! TO.N,/PD3'* -X150406100Y-120733600D03* -G04 #@! TO.P,R7,1* -G04 #@! TO.N,/PD3* -X150406100Y-119033600D03* -G04 #@! TD* -G04 #@! TO.P,R8,2* -G04 #@! TO.N,/PD1'* -X154800300Y-121216200D03* -G04 #@! TO.P,R8,1* -G04 #@! TO.N,/PD1* -X154800300Y-119516200D03* -G04 #@! TD* -D26* -G04 #@! TO.P,REF\002A\002A,1* -G04 #@! TO.N,GND* -X171996100Y-117343600D03* -D27* -G04 #@! TO.P,REF\002A\002A,2* -X174536100Y-117343600D03* -G04 #@! TO.P,REF\002A\002A,3* -X171996100Y-119883600D03* -G04 #@! TO.P,REF\002A\002A,4* -X174536100Y-119883600D03* -G04 #@! TO.P,REF\002A\002A,5* -X171996100Y-122423600D03* -G04 #@! TO.P,REF\002A\002A,6* -X174536100Y-122423600D03* -G04 #@! TO.P,REF\002A\002A,7* -X171996100Y-124963600D03* -G04 #@! TO.P,REF\002A\002A,8* -X174536100Y-124963600D03* -G04 #@! TD* -D26* -G04 #@! TO.P,REF\002A\002A,1* -G04 #@! TO.N,VCC* -X174536100Y-91943600D03* -D27* -G04 #@! TO.P,REF\002A\002A,2* -X174536100Y-94483600D03* -G04 #@! TO.P,REF\002A\002A,3* -X174536100Y-97023600D03* -G04 #@! TO.P,REF\002A\002A,4* -X174536100Y-99563600D03* -G04 #@! TD* -D28* -G04 #@! TO.N,* -X125006100Y-86330200D03* -X125006100Y-123693600D03* -X171970700Y-86330200D03* -D29* -G04 #@! TO.N,GND* -X174536100Y-119883600D03* -X174536100Y-122423600D03* -X174536100Y-124963600D03* -X174536100Y-117343600D03* -X162153600Y-108453600D03* -X162153600Y-100833600D03* -X171996100Y-124963600D03* -X171996100Y-122423600D03* -X171996100Y-119883600D03* -X171996100Y-117343600D03* -D30* -X170091100Y-124963600D03* -X170091100Y-123058600D03* -X165646100Y-122423600D03* -X165646100Y-119883600D03* -X165646100Y-116073600D03* -X162471100Y-116073600D03* -X159296100Y-116073600D03* -X164376100Y-113533600D03* -X161836100Y-113533600D03* -X168186100Y-108453600D03* -X170726100Y-102103600D03* -X174536100Y-107183600D03* -X157899100Y-108453600D03* -X164884100Y-104770600D03* -X156756100Y-104008600D03* -X163753800Y-96261600D03* -X162090100Y-99182600D03* -X165646100Y-85593600D03* -X161836100Y-84323600D03* -X154216100Y-84323600D03* -X146596100Y-84323600D03* -X138976100Y-84323600D03* -X132626100Y-84323600D03* -X145326100Y-108453600D03* -X142659100Y-108453600D03* -X142659100Y-105913600D03* -X142659100Y-103373600D03* -X145326100Y-103373600D03* -X145326100Y-105913600D03* -X127546100Y-91459194D03* -X125006100Y-93213600D03* -X122466100Y-95753600D03* -X122466100Y-99563600D03* -X122466100Y-103373600D03* -X122466100Y-107183600D03* -X122466100Y-112263600D03* -X122466100Y-117343600D03* -X129578100Y-121407600D03* -X148501100Y-112263600D03* -X149009100Y-115311600D03* -X131991100Y-95372600D03* -X154089100Y-104262600D03* -X154978100Y-107818600D03* -X137198100Y-99055600D03* -X156883100Y-88768600D03* -D29* -G04 #@! TO.N,VCC* -X142786100Y-93213600D03* -X141516100Y-119248600D03* -X128816100Y-104643600D03* -X166916100Y-100833600D03* -X166916100Y-98293600D03* -X166916100Y-95753600D03* -X174536100Y-94483600D03* -X174536100Y-97023600D03* -X174536100Y-99563600D03* -X174536100Y-91943600D03* -D31* -G04 #@! TO.N,/PA7* -X139433300Y-104338800D03* -G04 #@! TO.N,/AREF* -X133896100Y-102484600D03* -G04 #@! TO.N,/PC7* -X139484100Y-107056600D03* -G04 #@! TO.N,/PC6* -X140627100Y-108275800D03* -G04 #@! TO.N,/MISO* -X151930100Y-100579600D03* -G04 #@! TO.N,/MOSI* -X150533100Y-99690600D03* -G04 #@! TD* -D32* -G04 #@! TO.N,GND* -X141978500Y-109596800D02* -X141986000Y-110790400D01* -D33* -X141947900Y-105913600D02* -X141978500Y-109596800D01* -D32* -X137871200Y-105913600D02* -X141947900Y-105913600D01* -D33* -X142659100Y-106040600D02* -X142659100Y-105913600D01* -X142659100Y-105913600D02* -X142659100Y-103373600D01* -D32* -X142659100Y-101913100D02* -X142786100Y-101024100D01* -D33* -X141947900Y-105913600D02* -X142659100Y-106040600D01* -X137515600Y-110993600D02* -X134340600Y-110993600D01* -X139420600Y-109596600D02* -X137515600Y-110993600D01* -X141978500Y-109596800D02* -X141960600Y-109596600D01* -X141960600Y-109596600D02* -X139420600Y-109596600D01* -D32* -X155168600Y-108898100D02* -X153974800Y-108263100D01* -X157518100Y-108898100D02* -X156756100Y-108898100D01* -X151168100Y-105888200D02* -X154089100Y-103691100D01* -X154089100Y-103691100D02* -X156629100Y-103688237D01* -X157725500Y-103687000D02* -X159207200Y-104906100D01* -X148586100Y-105913600D02* -X151168100Y-105888200D01* -D33* -X141986100Y-111713600D02* -X142024100Y-113724100D01* -X141960600Y-111688100D02* -X141986100Y-111713600D01* -X141986000Y-110790400D02* -X141960600Y-111688100D01* -X142024100Y-113724100D02* -X142024100Y-114994100D01* -X142786100Y-100113600D02* -X142786100Y-97023600D01* -X142786100Y-101024100D02* -X142786100Y-100113600D01* -D32* -X142659100Y-105913600D02* -X143421100Y-105913600D01* -X143421100Y-105913600D02* -X145326100Y-105913600D01* -D33* -X153974800Y-108263100D02* -X153695400Y-108161500D01* -X153974800Y-108263100D02* -X153390600Y-108237700D01* -D34* -X136986100Y-105913600D02* -X137871200Y-105913600D01* -D33* -X162153600Y-100833600D02* -X163753800Y-96261600D01* -X135039100Y-105913600D02* -X136986100Y-105913600D01* -X132753100Y-103945100D02* -X132943600Y-103945100D01* -X132943600Y-103945100D02* -X133769100Y-104770600D01* -X133769100Y-104770600D02* -X133769100Y-105278600D01* -X133769100Y-105278600D02* -X134404100Y-105913600D01* -X134404100Y-105913600D02* -X135039100Y-105913600D01* -X134340600Y-110993600D02* -X134340600Y-110549100D01* -X134340600Y-110549100D02* -X134150100Y-110409400D01* -D35* -X168186100Y-108453600D02* -X168186100Y-108453600D01* -X174536100Y-124963600D02* -X174536100Y-122423600D01* -X174536100Y-119883600D02* -X174536100Y-122423600D01* -X174536100Y-117343600D02* -X174536100Y-119883600D01* -D32* -X125006100Y-109723600D02* -X122466100Y-108453600D01* -X122466100Y-108453600D02* -X122466100Y-107183600D01* -X122466100Y-104643600D02* -X123736100Y-103373600D01* -D33* -X123736100Y-103373600D02* -X127546100Y-103373600D01* -X127546100Y-103373600D02* -X128155700Y-103018000D01* -X128155700Y-103018000D02* -X129552700Y-103018000D01* -X129552700Y-103018000D02* -X130136900Y-103424400D01* -X130136900Y-103424400D02* -X131914900Y-103449800D01* -X131914900Y-103449800D02* -X132753100Y-103945100D01* -D32* -X125006100Y-109723600D02* -X128816100Y-109723600D01* -X158661100Y-107818600D02* -X157518100Y-108898100D01* -X159249800Y-107184800D02* -X158661100Y-107818600D01* -X158661100Y-107818600D02* -X160134300Y-108898100D01* -X159207200Y-104906100D02* -X159249800Y-104906100D01* -X159249800Y-104906100D02* -X159249800Y-105786600D01* -X159249800Y-105786600D02* -X159249800Y-105913600D01* -X159249800Y-105913600D02* -X159249800Y-107184800D01* -D36* -X159249800Y-105786600D02* -X160235900Y-105786600D01* -X159249800Y-105786600D02* -X159249800Y-105913600D01* -D35* -X171996100Y-124963600D02* -X174536100Y-124963600D01* -X171996100Y-119883600D02* -X171996100Y-117343600D01* -X171996100Y-121153600D02* -X171996100Y-122423600D01* -X171996100Y-121153600D02* -X171996100Y-119883600D01* -X171996100Y-122423600D02* -X171996100Y-124963600D01* -X171996100Y-117343600D02* -X174536100Y-117343600D01* -X168146100Y-122423600D02* -X167686100Y-124963600D01* -D37* -X168146100Y-122423600D02* -X171996100Y-121153600D01* -D35* -X168186100Y-108453600D02* -X165646100Y-109469600D01* -X165646100Y-109469600D02* -X165646100Y-116073600D01* -X165646100Y-119883600D02* -X168146100Y-122423600D01* -X165646100Y-108453600D02* -X168186100Y-108453600D01* -X164858700Y-107767800D02* -X165331600Y-108179700D01* -X165331600Y-108179700D02* -X165646100Y-108453600D01* -X164376100Y-107183600D02* -X165138100Y-107386800D01* -X165138100Y-107386800D02* -X164858700Y-107767800D01* -D38* -X161937700Y-105786600D02* -X164376100Y-107183600D01* -D33* -X150406100Y-114168600D02* -X150406100Y-114930600D01* -X148501100Y-112263600D02* -X148501100Y-112263600D01* -X148501100Y-111628600D02* -X148501100Y-112263600D01* -X143421100Y-106548600D02* -X145326100Y-108453600D01* -X143421100Y-105913600D02* -X143421100Y-106548600D01* -X158305500Y-115159200D02* -X158305500Y-116073600D01* -X165011100Y-108453600D02* -X164852300Y-108612400D01* -X164852300Y-108612400D02* -X158305500Y-115159200D01* -X165057700Y-108453600D02* -X165011100Y-108453600D01* -X165331600Y-108179700D02* -X165057700Y-108453600D01* -D36* -X160235900Y-105786600D02* -X161937700Y-105786600D01* -X164096700Y-108479000D02* -X162153600Y-108453600D01* -X164852300Y-108612400D02* -X164096700Y-108479000D01* -X171615100Y-108453600D02* -X173088300Y-108453600D01* -X173088300Y-108453600D02* -X174536100Y-108453600D01* -D35* -X165646100Y-119883600D02* -X165646100Y-119883600D01* -X165646100Y-116073600D02* -X165646100Y-119883600D01* -D33* -X158305500Y-116073600D02* -X158305500Y-121179000D01* -D35* -X168186100Y-108453600D02* -X171615100Y-108453600D01* -D32* -X156756100Y-108898100D02* -X155168600Y-108898100D01* -X156629100Y-103688237D02* -X157725500Y-103687000D01* -D33* -X163753800Y-96261600D02* -X164376100Y-94483600D01* -X145326100Y-108453600D02* -X148501100Y-111628600D01* -X142659100Y-105913600D02* -X142659100Y-105913600D01* -X142659100Y-103373600D02* -X142659100Y-101913100D01* -D32* -X145326100Y-105913600D02* -X148586100Y-105913600D01* -X122466100Y-107183600D02* -X122466100Y-104643600D01* -D33* -X148501100Y-112263600D02* -X150406100Y-114168600D01* -G04 #@! TO.N,VCC* -X142786100Y-113597100D02* -X142786100Y-111713600D01* -X141389100Y-96210800D02* -X141389100Y-97099800D01* -X141389100Y-97099800D02* -X141986100Y-98331600D01* -X141986100Y-98331600D02* -X141986100Y-100113600D01* -X142024100Y-117280100D02* -X142913100Y-117153100D01* -X142913100Y-117153100D02* -X143262400Y-116803800D01* -X143262400Y-116803800D02* -X143319500Y-116645100D01* -X143319500Y-116645100D02* -X143319500Y-114168600D01* -X143319500Y-114168600D02* -X143332200Y-114143200D01* -X143332200Y-114143200D02* -X142786100Y-113597100D01* -X141897100Y-94737600D02* -X141389100Y-96210800D01* -X142786100Y-94737600D02* -X141897100Y-94737600D01* -D36* -X142786100Y-93213600D02* -X142786100Y-94737600D01* -X141516100Y-119248600D02* -X142024100Y-117280100D01* -D34* -X142786100Y-93213600D02* -X142976600Y-93150100D01* -X143262400Y-116803800D02* -X143294100Y-116835600D01* -D33* -X131102100Y-104794600D02* -X131888100Y-105048600D01* -X131888100Y-105048600D02* -X132753100Y-105913600D01* -D35* -X166916100Y-102992600D02* -X166865300Y-102916400D01* -X166865300Y-102916400D02* -X171615100Y-105913600D01* -X166916100Y-98293600D02* -X166916100Y-95753600D01* -X166916100Y-98293600D02* -X166916100Y-100833600D01* -X166916100Y-100833600D02* -X166916100Y-102103600D01* -X166916100Y-102103600D02* -X166916100Y-102992600D01* -X174536100Y-94483600D02* -X174536100Y-91943600D01* -X174536100Y-97023600D02* -X174536100Y-94483600D01* -X174536100Y-102357600D02* -X174536100Y-99563600D01* -X171615100Y-105913600D02* -X174536100Y-102357600D01* -X174536100Y-99563600D02* -X174536100Y-97023600D01* -D32* -X128816100Y-104643600D02* -X131102100Y-104794600D01* -X125006100Y-104643600D02* -X128816100Y-104643600D01* -D33* -X159291500Y-101976600D02* -X159296100Y-101976600D01* -X159215300Y-102494500D02* -X159291500Y-101976600D01* -X166916100Y-93213600D02* -X164376100Y-89403600D01* -X166916100Y-95753600D02* -X166916100Y-93213600D01* -D38* -X166916100Y-102103600D02* -X164858700Y-101417800D01* -X174536100Y-91943600D02* -X171996100Y-91943600D01* -X171996100Y-94483600D02* -X171996100Y-91943600D01* -X171996100Y-97023600D02* -X171996100Y-94483600D01* -X174536100Y-94483600D02* -X171996100Y-94483600D01* -X174536100Y-97023600D02* -X171996100Y-97023600D01* -X171996100Y-99563600D02* -X171996100Y-97023600D01* -X174536100Y-99563600D02* -X171996100Y-99563600D01* -D36* -X160235900Y-103500600D02* -X159215300Y-102494500D01* -D38* -X164858700Y-101417800D02* -X161937700Y-103500600D01* -D36* -X161937700Y-103500600D02* -X160235900Y-103500600D01* -D33* -X149136100Y-105151600D02* -X148586100Y-105113600D01* -X150876000Y-105126200D02* -X149136100Y-105151600D01* -X159215300Y-102494500D02* -X153708100Y-102484600D01* -X153708100Y-102484600D02* -X150876000Y-105126200D01* -G04 #@! TO.N,/PB4* -X148501100Y-90673600D02* -X150406100Y-86863600D01* -X147866100Y-97658600D02* -X148501100Y-90673600D01* -X146786100Y-100113600D02* -X146811500Y-98967200D01* -X146811500Y-98967200D02* -X147866100Y-97658600D01* -G04 #@! TO.N,/PB3* -X147231100Y-90673600D02* -X147866100Y-86863600D01* -X146900900Y-97607800D02* -X147231100Y-90673600D01* -X145986100Y-100113600D02* -X145986500Y-98801600D01* -X145986500Y-98801600D02* -X146900900Y-97607800D01* -G04 #@! TO.N,/PB2* -X145326100Y-89403600D02* -X145326100Y-86863600D01* -X146037300Y-91384800D02* -X145326100Y-89403600D01* -X146037300Y-91359400D02* -X146037300Y-91384800D01* -X146011900Y-97633200D02* -X146037300Y-91359400D01* -X145186100Y-100113600D02* -X145148300Y-98700000D01* -X145148300Y-98700000D02* -X146011900Y-97633200D01* -G04 #@! TO.N,/PB1* -X142760700Y-87955800D02* -X142786100Y-86863600D01* -X145224500Y-92299200D02* -X142760700Y-87955800D01* -X145224500Y-97430000D02* -X145224500Y-92299200D01* -X144386100Y-100113600D02* -X144360900Y-98547600D01* -X144360900Y-98547600D02* -X145224500Y-97430000D01* -G04 #@! TO.N,/PB0* -X140246100Y-88133600D02* -X140246100Y-86863600D01* -X144411700Y-92477000D02* -X140246100Y-88133600D01* -X144411700Y-97252200D02* -X144411700Y-92477000D01* -X143586100Y-100113600D02* -X143573500Y-98446000D01* -X143573500Y-98446000D02* -X144411700Y-97252200D01* -G04 #@! TO.N,/PA0* -X137706100Y-90673600D02* -X137706100Y-86863600D01* -X140246100Y-97023600D02* -X137706100Y-90673600D01* -X141186100Y-100113600D02* -X141160500Y-98623800D01* -X141160500Y-98623800D02* -X140246100Y-97023600D01* -G04 #@! TO.N,/PA1* -X135166100Y-89403600D02* -X135166100Y-86863600D01* -X140386100Y-100113600D02* -X140398500Y-98776200D01* -X140398500Y-98776200D02* -X135166100Y-89403600D01* -G04 #@! TO.N,/PA2* -X132626100Y-89403600D02* -X132626100Y-86863600D01* -X139586100Y-100113600D02* -X139585700Y-98928600D01* -X139585700Y-98928600D02* -X132626100Y-89403600D01* -G04 #@! TO.N,/PA3* -X130086100Y-89403600D02* -X130086100Y-86863600D01* -X138786100Y-100113600D02* -X138772900Y-99309600D01* -X138772900Y-99309600D02* -X130086100Y-89403600D01* -G04 #@! TO.N,/PA4* -X127546100Y-99563600D02* -X134023100Y-99563600D01* -X134023100Y-99563600D02* -X136055100Y-101849600D01* -X136055100Y-101849600D02* -X136986100Y-101913600D01* -X125006100Y-99563600D02* -X127546100Y-99563600D01* -G04 #@! TO.N,/PA5* -X132270500Y-102078200D02* -X133261100Y-101214600D01* -X133261100Y-101214600D02* -X134404100Y-101214600D01* -X134404100Y-101214600D02* -X135801100Y-102738600D01* -X135801100Y-102738600D02* -X136986100Y-102713600D01* -X125006100Y-102103600D02* -X132270500Y-102078200D01* -G04 #@! TO.N,/PA6* -X138258600Y-103545000D02* -X136986100Y-103513600D01* -X138518900Y-103291100D02* -X138258600Y-103545000D01* -X138518900Y-101798800D02* -X138518900Y-103291100D01* -X125006100Y-97023600D02* -X133515100Y-97023600D01* -X133515100Y-97023600D02* -X138518900Y-101798800D01* -G04 #@! TO.N,/PA7* -X139433300Y-104338800D02* -X136986100Y-104313600D01* -G04 #@! TO.N,/AREF* -X136144100Y-105113600D02* -X136986100Y-105113600D01* -X135293100Y-104516600D02* -X136144100Y-105113600D01* -X135166100Y-104072100D02* -X135293100Y-104516600D01* -X135039100Y-103945100D02* -X135166100Y-104072100D01* -X133896100Y-102484600D02* -X135039100Y-103945100D01* -G04 #@! TO.N,Net-(C11-PadP$1)* -X131102100Y-107794600D02* -X134126100Y-108048600D01* -X134126100Y-108048600D02* -X134150100Y-108123400D01* -X134150100Y-108123400D02* -X134658100Y-108072600D01* -X134658100Y-108072600D02* -X136055100Y-106675600D01* -X136055100Y-106675600D02* -X136948100Y-106675600D01* -X136948100Y-106675600D02* -X136986100Y-106713600D01* -G04 #@! TO.N,/PC7* -X139484100Y-107056600D02* -X138315700Y-107513800D01* -X138315700Y-107513800D02* -X136986100Y-107513600D01* -G04 #@! TO.N,/PC6* -X140627100Y-108275800D02* -X138442700Y-108275800D01* -X138442700Y-108275800D02* -X136986100Y-108313600D01* -G04 #@! TO.N,/PC5* -X135216900Y-108910800D02* -X136986100Y-109113600D01* -X132422900Y-108910800D02* -X135216900Y-108910800D01* -X132118100Y-109215600D02* -X132422900Y-108910800D01* -X130340100Y-109215600D02* -X132118100Y-109215600D01* -X127546100Y-107183600D02* -X128816100Y-107691600D01* -X128816100Y-107691600D02* -X130340100Y-109215600D01* -G04 #@! TO.N,/PC4* -X131482900Y-114841900D02* -X133057900Y-109622000D01* -X133057900Y-109622000D02* -X135293100Y-109622000D01* -X135293100Y-109622000D02* -X136986100Y-109913600D01* -X131444600Y-114803600D02* -X130644900Y-114803600D01* -X131482900Y-114841900D02* -X131444600Y-114803600D01* -X128816100Y-117343600D02* -X127546100Y-117343600D01* -X130086100Y-117343600D02* -X128816100Y-117343600D01* -X131279900Y-116149800D02* -X130086100Y-117343600D01* -X131482900Y-114841900D02* -X131279900Y-115514800D01* -X131279900Y-115514800D02* -X131279900Y-116149800D01* -G04 #@! TO.N,/PC3* -X138747500Y-112670000D02* -X138786100Y-111713600D01* -X131864100Y-120518600D02* -X138747500Y-112670000D01* -X131356100Y-121153600D02* -X131864100Y-120518600D01* -X130086100Y-124963600D02* -X130086100Y-123693600D01* -X130086100Y-123693600D02* -X131356100Y-121153600D01* -G04 #@! TO.N,/PC2* -X139560300Y-113203400D02* -X139586100Y-111713600D01* -X134023100Y-120899600D02* -X139560300Y-113203400D01* -X132626100Y-124963600D02* -X133896100Y-121153600D01* -X133896100Y-121153600D02* -X134023100Y-120899600D01* -G04 #@! TO.N,/PC1* -X135166100Y-124963600D02* -X135166100Y-122423600D01* -X135166100Y-122423600D02* -X140246100Y-113533600D01* -X140246100Y-113533600D02* -X140386100Y-111713600D01* -G04 #@! TO.N,/PC0* -X141109700Y-113533600D02* -X141186100Y-111713600D01* -X137706100Y-123693600D02* -X141109700Y-113533600D01* -X137706100Y-124963600D02* -X137706100Y-123693600D01* -G04 #@! TO.N,/PD7* -X140246100Y-124963600D02* -X140246100Y-122423600D01* -X140246100Y-122423600D02* -X141516100Y-121153600D01* -X141516100Y-121153600D02* -X142749300Y-121172000D01* -X142749300Y-121172000D02* -X143043800Y-120984300D01* -X143043800Y-120984300D02* -X143070100Y-120925500D01* -X143070100Y-120925500D02* -X144056100Y-117343600D01* -X144056100Y-117343600D02* -X144056100Y-114016200D01* -X144056100Y-114016200D02* -X143598900Y-113025600D01* -X143598900Y-113025600D02* -X143586100Y-111713600D01* -G04 #@! TO.N,/PD6* -X144411700Y-112974800D02* -X144386100Y-111713600D01* -X144741900Y-113533600D02* -X144411700Y-112974800D01* -X144741900Y-117927800D02* -X144741900Y-113533600D01* -X143725900Y-122220400D02* -X144741900Y-117927800D01* -X142811500Y-123160200D02* -X143725900Y-122220400D01* -X142786100Y-124963600D02* -X142811500Y-123160200D01* -G04 #@! TO.N,/PD5* -X145199100Y-112771600D02* -X145186100Y-111713600D01* -X145427700Y-113330400D02* -X145199100Y-112771600D01* -X145427700Y-118385000D02* -X145427700Y-113330400D01* -X145326100Y-124963600D02* -X145427700Y-118385000D01* -G04 #@! TO.N,/PD4* -X145986500Y-112746200D02* -X145986100Y-111713600D01* -X146392900Y-114194000D02* -X145986500Y-112746200D01* -X147866100Y-124963600D02* -X147866100Y-122423600D01* -X147866100Y-122423600D02* -X146392900Y-114194000D01* -G04 #@! TO.N,/PD3* -X146773900Y-112695400D02* -X146786100Y-111713600D01* -X148501100Y-117343600D02* -X146773900Y-112695400D01* -X149136100Y-118613600D02* -X148501100Y-117343600D01* -X149771100Y-119248600D02* -X149136100Y-118613600D01* -X150191100Y-119248600D02* -X149771100Y-119248600D01* -X150406100Y-119033600D02* -X150191100Y-119248600D01* -G04 #@! TO.N,/PD2* -X149644100Y-110231600D02* -X148586100Y-109913600D01* -X152946100Y-117343600D02* -X149644100Y-110231600D01* -X152946100Y-124963600D02* -X152946100Y-122423600D01* -X152946100Y-122423600D02* -X152946100Y-117343600D01* -X152946100Y-124963600D02* -X152946100Y-122423600D01* -G04 #@! TO.N,/PD1* -X150126700Y-109215600D02* -X148586100Y-109113600D01* -X154851100Y-117470600D02* -X150126700Y-109215600D01* -X154851100Y-119465400D02* -X154851100Y-117470600D01* -X154800300Y-119516200D02* -X154851100Y-119465400D01* -G04 #@! TO.N,/PD0* -X150406100Y-108453600D02* -X148586100Y-108313600D01* -X152946100Y-110993600D02* -X150406100Y-108453600D01* -X157010100Y-118740600D02* -X152946100Y-110993600D01* -X158026100Y-124963600D02* -X157010100Y-122550600D01* -X157010100Y-122550600D02* -X157010100Y-118740600D01* -G04 #@! TO.N,Net-(C2-PadP$1)* -X149326600Y-107501100D02* -X150710900Y-107539200D01* -X150710900Y-107539200D02* -X154647900Y-110968200D01* -X148586100Y-107513600D02* -X149326600Y-107501100D01* -X154647900Y-110968200D02* -X156756100Y-110993600D01* -X157391100Y-111184100D02* -X160134300Y-111184100D01* -X156756100Y-110993600D02* -X157391100Y-111184100D01* -G04 #@! TO.N,Net-(C1-PadP$1)* -X149326600Y-106739100D02* -X151739600Y-106726400D01* -X148586100Y-106713600D02* -X149326600Y-106739100D01* -X151739600Y-106726400D02* -X153390600Y-105951700D01* -X153390600Y-105951700D02* -X156756100Y-105913600D01* -D34* -G04 #@! TO.N,/RESET* -X148628100Y-104326100D02* -X150596600Y-104326100D01* -X148586100Y-104313600D02* -X148628100Y-104326100D01* -D33* -X159296100Y-99690600D02* -X161836100Y-94483600D01* -X158661100Y-99563600D02* -X159296100Y-99690600D01* -X157010100Y-101722600D02* -X158661100Y-99563600D01* -X150596600Y-104326100D02* -X153327100Y-101722600D01* -X153327100Y-101722600D02* -X157010100Y-101722600D01* -G04 #@! TO.N,/SCK* -X148586100Y-103513600D02* -X148691600Y-103564100D01* -D34* -X148882100Y-103500600D02* -X149199600Y-103500600D01* -X148586100Y-103513600D02* -X148882100Y-103500600D01* -D33* -X156756100Y-97023600D02* -X161836100Y-91943600D01* -X150406100Y-97023600D02* -X152946100Y-97023600D01* -X152946100Y-97023600D02* -X155486100Y-97023600D01* -X155486100Y-97023600D02* -X156756100Y-97023600D01* -X152946100Y-100325600D02* -X152946100Y-97023600D01* -X152946100Y-101087600D02* -X152946100Y-100325600D01* -X150304500Y-103472324D02* -X152946100Y-101087600D01* -X149199600Y-103500600D02* -X150304500Y-103500600D01* -X150304500Y-103500600D02* -X150304500Y-103472324D01* -G04 #@! TO.N,/MISO* -X156756100Y-94483600D02* -X161836100Y-89403600D01* -X156756100Y-94483600D02* -X155486100Y-94483600D01* -X155486100Y-94483600D02* -X152946100Y-94483600D01* -X152946100Y-94483600D02* -X150406100Y-94483600D01* -X149588300Y-102733100D02* -X148586100Y-102713600D01* -X149776600Y-102733100D02* -X151930100Y-100579600D01* -X149588300Y-102733100D02* -X149776600Y-102733100D01* -D34* -G04 #@! TO.N,/MOSI* -X148586100Y-101913600D02* -X148602700Y-101938500D01* -D33* -X154216100Y-91943600D02* -X156756100Y-91943600D01* -X156756100Y-91943600D02* -X160248600Y-87498600D01* -X160248600Y-87498600D02* -X162471100Y-87498600D01* -X162471100Y-87498600D02* -X163106100Y-88133600D01* -X163106100Y-88133600D02* -X163106100Y-90673600D01* -X163106100Y-90673600D02* -X164376100Y-91943600D01* -X150406100Y-91943600D02* -X154216100Y-91943600D01* -X149742500Y-101913600D02* -X150533100Y-101123000D01* -X148586100Y-101913600D02* -X149742500Y-101913600D01* -X150533100Y-101123000D02* -X150533100Y-99690600D01* -D36* -G04 #@! TO.N,Net-(C4-PadP$1)* -X171615100Y-110993600D02* -X171012100Y-111025600D01* -X171615100Y-110993600D02* -X171284900Y-110968200D01* -D35* -X171615100Y-110993600D02* -X170726100Y-111247600D01* -X168313100Y-111237600D02* -X169374500Y-111159200D01* -X169374500Y-111159200D02* -X171615100Y-110993600D01* -X171996100Y-113780800D02* -X171996100Y-114168600D01* -X169374500Y-111159200D02* -X171996100Y-113780800D01* -X171996100Y-114168600D02* -X174536100Y-114168600D01* -D36* -X171615100Y-110993600D02* -X173088300Y-110739600D01* -X173088300Y-110739600D02* -X174536100Y-110739600D01* -D33* -G04 #@! TO.N,Net-(LED1-PadA)* -X128358900Y-114803600D02* -X128816100Y-112263600D01* -G04 #@! TO.N,/PD3'* -X150406100Y-124963600D02* -X150406100Y-122423600D01* -X150406100Y-122423600D02* -X150406100Y-120733600D01* -X151549100Y-117851600D02* -X150406100Y-117216600D01* -X151676100Y-117978600D02* -X151549100Y-117851600D01* -X151676100Y-120201100D02* -X151676100Y-117978600D01* -X151358600Y-120518600D02* -X151676100Y-120201100D01* -X150621100Y-120518600D02* -X151358600Y-120518600D01* -X150406100Y-120733600D02* -X150621100Y-120518600D01* -G04 #@! TO.N,/PD1'* -X154800300Y-122372800D02* -X154800300Y-121216200D01* -X155486100Y-123058600D02* -X154800300Y-122372800D01* -X155486100Y-124963600D02* -X155486100Y-123058600D01* -X154837500Y-121179000D02* -X156019500Y-121179000D01* -X154800300Y-121216200D02* -X154837500Y-121179000D01* -D35* -G04 #@! TO.N,Net-(D1-PadA)* -X163146100Y-122423600D02* -X163616100Y-124963600D01* -X161074100Y-123703600D02* -X163146100Y-122423600D01* -G04 #@! TO.N,Net-(D1-PadC)* -X161074100Y-118603600D02* -X163223100Y-118486600D01* -G04 #@! TO.N,Net-(D2-PadC)* -X168323100Y-118486600D02* -X168313100Y-116337600D01* -G04 #@! TD* -D39* -G04 #@! TO.N,GND* -G36* -X146443700Y-102793776D02* -X146443700Y-109025474D01* -X145897974Y-109571200D01* -X139674226Y-109571200D01* -X139128500Y-109025474D01* -X139128500Y-108936200D01* -X139754787Y-108936200D01* -X139778733Y-108972037D01* -X139930863Y-109124167D01* -X140109749Y-109243695D01* -X140308517Y-109326028D01* -X140519528Y-109368000D01* -X140734672Y-109368000D01* -X140945683Y-109326028D01* -X141144451Y-109243695D01* -X141323337Y-109124167D01* -X141475467Y-108972037D01* -X141594995Y-108793151D01* -X141677328Y-108594383D01* -X141719300Y-108383372D01* -X141719300Y-108168228D01* -X141677328Y-107957217D01* -X141594995Y-107758449D01* -X141475467Y-107579563D01* -X141323337Y-107427433D01* -X141144451Y-107307905D01* -X140945683Y-107225572D01* -X140734672Y-107183600D01* -X140572436Y-107183600D01* -X140576300Y-107164172D01* -X140576300Y-106949028D01* -X140534328Y-106738017D01* -X140451995Y-106539249D01* -X140332467Y-106360363D01* -X140180337Y-106208233D01* -X140001451Y-106088705D01* -X139802683Y-106006372D01* -X139591672Y-105964400D01* -X139376528Y-105964400D01* -X139165517Y-106006372D01* -X139128500Y-106021705D01* -X139128500Y-105391770D01* -X139325728Y-105431000D01* -X139540872Y-105431000D01* -X139751883Y-105389028D01* -X139950651Y-105306695D01* -X140129537Y-105187167D01* -X140281667Y-105035037D01* -X140401195Y-104856151D01* -X140483528Y-104657383D01* -X140525500Y-104446372D01* -X140525500Y-104231228D01* -X140483528Y-104020217D01* -X140401195Y-103821449D01* -X140281667Y-103642563D01* -X140129537Y-103490433D01* -X139950651Y-103370905D01* -X139763500Y-103293384D01* -X139763500Y-102129000D01* -X145889720Y-102129000D01* -X146443700Y-102793776D01* -X146443700Y-102793776D01* -G37* -X146443700Y-102793776D02* -X146443700Y-109025474D01* -X145897974Y-109571200D01* -X139674226Y-109571200D01* -X139128500Y-109025474D01* -X139128500Y-108936200D01* -X139754787Y-108936200D01* -X139778733Y-108972037D01* -X139930863Y-109124167D01* -X140109749Y-109243695D01* -X140308517Y-109326028D01* -X140519528Y-109368000D01* -X140734672Y-109368000D01* -X140945683Y-109326028D01* -X141144451Y-109243695D01* -X141323337Y-109124167D01* -X141475467Y-108972037D01* -X141594995Y-108793151D01* -X141677328Y-108594383D01* -X141719300Y-108383372D01* -X141719300Y-108168228D01* -X141677328Y-107957217D01* -X141594995Y-107758449D01* -X141475467Y-107579563D01* -X141323337Y-107427433D01* -X141144451Y-107307905D01* -X140945683Y-107225572D01* -X140734672Y-107183600D01* -X140572436Y-107183600D01* -X140576300Y-107164172D01* -X140576300Y-106949028D01* -X140534328Y-106738017D01* -X140451995Y-106539249D01* -X140332467Y-106360363D01* -X140180337Y-106208233D01* -X140001451Y-106088705D01* -X139802683Y-106006372D01* -X139591672Y-105964400D01* -X139376528Y-105964400D01* -X139165517Y-106006372D01* -X139128500Y-106021705D01* -X139128500Y-105391770D01* -X139325728Y-105431000D01* -X139540872Y-105431000D01* -X139751883Y-105389028D01* -X139950651Y-105306695D01* -X140129537Y-105187167D01* -X140281667Y-105035037D01* -X140401195Y-104856151D01* -X140483528Y-104657383D01* -X140525500Y-104446372D01* -X140525500Y-104231228D01* -X140483528Y-104020217D01* -X140401195Y-103821449D01* -X140281667Y-103642563D01* -X140129537Y-103490433D01* -X139950651Y-103370905D01* -X139763500Y-103293384D01* -X139763500Y-102129000D01* -X145889720Y-102129000D01* -X146443700Y-102793776D01* -D40* -G36* -X158539278Y-103433086D02* -X158784536Y-103674860D01* -X158784536Y-103856200D01* -X158798758Y-104000599D01* -X158840878Y-104139449D01* -X158909276Y-104267413D01* -X159001325Y-104379575D01* -X159113487Y-104471624D01* -X159241451Y-104540022D01* -X159380301Y-104582142D01* -X159524700Y-104596364D01* -X159910639Y-104596364D01* -X160011833Y-104627061D01* -X160015940Y-104627466D01* -X160019897Y-104628635D01* -X160127891Y-104638492D01* -X160179754Y-104643600D01* -X160183857Y-104643600D01* -X160244116Y-104649100D01* -X160296141Y-104643600D01* -X161441152Y-104643600D01* -X161494423Y-104670026D01* -X161731084Y-104734035D01* -X161975685Y-104750644D01* -X162218827Y-104719214D01* -X162451165Y-104640954D01* -X162528817Y-104596364D01* -X162648900Y-104596364D01* -X162793299Y-104582142D01* -X162932149Y-104540022D01* -X163060113Y-104471624D01* -X163172275Y-104379575D01* -X163264324Y-104267413D01* -X163332722Y-104139449D01* -X163373352Y-104005512D01* -X164176316Y-103432964D01* -X165588545Y-103432964D01* -X165591425Y-103442495D01* -X165600270Y-103459085D01* -X165606194Y-103476921D01* -X165663750Y-103578146D01* -X165686686Y-103621164D01* -X165697045Y-103636703D01* -X165739740Y-103711791D01* -X165754218Y-103728522D01* -X165770139Y-103758307D01* -X165855226Y-103861985D01* -X165940522Y-103966140D01* -X165941082Y-103966600D01* -X165941541Y-103967160D01* -X166045354Y-104052357D01* -X166149195Y-104137759D01* -X166149834Y-104138101D01* -X166150394Y-104138561D01* -X166269068Y-104201994D01* -X166387341Y-104265371D01* -X166388032Y-104265581D01* -X166388673Y-104265924D01* -X166475469Y-104292253D01* -X169367286Y-106117037D01* -X169376184Y-106207377D01* -X169461875Y-106489864D01* -X169601031Y-106750206D01* -X169788303Y-106978397D01* -X170016494Y-107165669D01* -X170276836Y-107304825D01* -X170416087Y-107347066D01* -X170373462Y-107360978D01* -X170169518Y-107475545D01* -X169991844Y-107627698D01* -X169847267Y-107811590D01* -X169741344Y-108020154D01* -X169678957Y-108242322D01* -X169768138Y-108428600D01* -X171590100Y-108428600D01* -X171590100Y-108408600D01* -X171640100Y-108408600D01* -X171640100Y-108428600D01* -X174511100Y-108428600D01* -X174511100Y-107774750D01* -X174403350Y-107667000D01* -X173269255Y-107667000D01* -X173238356Y-107627698D01* -X173060682Y-107475545D01* -X172856738Y-107360978D01* -X172814113Y-107347066D01* -X172953364Y-107304825D01* -X173213706Y-107165669D01* -X173441897Y-106978397D01* -X173629169Y-106750206D01* -X173768325Y-106489864D01* -X173854016Y-106207377D01* -X173882951Y-105913600D01* -X173854016Y-105619823D01* -X173793986Y-105421929D01* -X175044100Y-103900052D01* -X175044100Y-107667000D01* -X174668850Y-107667000D01* -X174561100Y-107774750D01* -X174561100Y-108428600D01* -X174581100Y-108428600D01* -X174581100Y-108478600D01* -X174561100Y-108478600D01* -X174561100Y-109132450D01* -X174668850Y-109240200D01* -X175044100Y-109240200D01* -X175044100Y-109643836D01* -X174861361Y-109643836D01* -X174760167Y-109613139D01* -X174592246Y-109596600D01* -X173159122Y-109596600D01* -X173117715Y-109591448D01* -X173046833Y-109596600D01* -X173032154Y-109596600D01* -X172990814Y-109600672D01* -X172955042Y-109603272D01* -X172953364Y-109602375D01* -X172814113Y-109560134D01* -X172856738Y-109546222D01* -X173060682Y-109431655D01* -X173238356Y-109279502D01* -X173269255Y-109240200D01* -X174403350Y-109240200D01* -X174511100Y-109132450D01* -X174511100Y-108478600D01* -X171640100Y-108478600D01* -X171640100Y-108498600D01* -X171590100Y-108498600D01* -X171590100Y-108478600D01* -X169768138Y-108478600D01* -X169678957Y-108664878D01* -X169741344Y-108887046D01* -X169847267Y-109095610D01* -X169991844Y-109279502D01* -X170169518Y-109431655D01* -X170373462Y-109546222D01* -X170416087Y-109560134D01* -X170276836Y-109602375D01* -X170027611Y-109735589D01* -X169856102Y-109748265D01* -X169824313Y-109722176D01* -X169696349Y-109653778D01* -X169557499Y-109611658D01* -X169413100Y-109597436D01* -X167213100Y-109597436D01* -X167068701Y-109611658D01* -X166929851Y-109653778D01* -X166801887Y-109722176D01* -X166689725Y-109814225D01* -X166597676Y-109926387D01* -X166529278Y-110054351D01* -X166487158Y-110193201D01* -X166472936Y-110337600D01* -X166472936Y-112137600D01* -X166487158Y-112281999D01* -X166529278Y-112420849D01* -X166597676Y-112548813D01* -X166689725Y-112660975D01* -X166801887Y-112753024D01* -X166929851Y-112821422D01* -X167068701Y-112863542D01* -X167213100Y-112877764D01* -X169153329Y-112877764D01* -X170359500Y-114083935D01* -X170359500Y-114329791D01* -X170422393Y-114645979D01* -X170545764Y-114943821D01* -X170724870Y-115211872D01* -X170952828Y-115439830D01* -X171220879Y-115618936D01* -X171518721Y-115742307D01* -X171834909Y-115805200D01* -X172157291Y-115805200D01* -X172473479Y-115742307D01* -X172771321Y-115618936D01* -X172889158Y-115540200D01* -X173643042Y-115540200D01* -X173760879Y-115618936D01* -X174058721Y-115742307D01* -X174374909Y-115805200D01* -X174697291Y-115805200D01* -X175013479Y-115742307D01* -X175044100Y-115729623D01* -X175044100Y-116171671D01* -X175002847Y-116150658D01* -X174761147Y-116082522D01* -X174561100Y-116170593D01* -X174561100Y-117318600D01* -X174581100Y-117318600D01* -X174581100Y-117368600D01* -X174561100Y-117368600D01* -X174561100Y-118516607D01* -X174761147Y-118604678D01* -X175002847Y-118536542D01* -X175044100Y-118515529D01* -X175044100Y-118711671D01* -X175002847Y-118690658D01* -X174761147Y-118622522D01* -X174561100Y-118710593D01* -X174561100Y-119858600D01* -X174581100Y-119858600D01* -X174581100Y-119908600D01* -X174561100Y-119908600D01* -X174561100Y-121056607D01* -X174761147Y-121144678D01* -X175002847Y-121076542D01* -X175044100Y-121055529D01* -X175044100Y-121251671D01* -X175002847Y-121230658D01* -X174761147Y-121162522D01* -X174561100Y-121250593D01* -X174561100Y-122398600D01* -X174581100Y-122398600D01* -X174581100Y-122448600D01* -X174561100Y-122448600D01* -X174561100Y-123596607D01* -X174761147Y-123684678D01* -X175002847Y-123616542D01* -X175044100Y-123595529D01* -X175044100Y-123791671D01* -X175002847Y-123770658D01* -X174761147Y-123702522D01* -X174561100Y-123790593D01* -X174561100Y-124938600D01* -X174581100Y-124938600D01* -X174581100Y-124988600D01* -X174561100Y-124988600D01* -X174561100Y-126136607D01* -X174761147Y-126224678D01* -X175002847Y-126156542D01* -X175044100Y-126135529D01* -X175044100Y-126692000D01* -X164855619Y-126692000D01* -X164917313Y-126659024D01* -X165029475Y-126566975D01* -X165121524Y-126454813D01* -X165189922Y-126326849D01* -X165232042Y-126187999D01* -X165246264Y-126043600D01* -X165246264Y-125096350D01* -X166365100Y-125096350D01* -X166365100Y-126086050D01* -X166381663Y-126169318D01* -X166414153Y-126247755D01* -X166461320Y-126318346D01* -X166521353Y-126378379D01* -X166591945Y-126425547D01* -X166670382Y-126458037D01* -X166753650Y-126474600D01* -X167553350Y-126474600D01* -X167661100Y-126366850D01* -X167661100Y-124988600D01* -X167711100Y-124988600D01* -X167711100Y-126366850D01* -X167818850Y-126474600D01* -X168618550Y-126474600D01* -X168701818Y-126458037D01* -X168780255Y-126425547D01* -X168850847Y-126378379D01* -X168910880Y-126318346D01* -X168958047Y-126247755D01* -X168990537Y-126169318D01* -X169007100Y-126086050D01* -X169007100Y-125188647D01* -X170735023Y-125188647D01* -X170744895Y-125238277D01* -X170822523Y-125477097D01* -X170945251Y-125696184D01* -X171108363Y-125887118D01* -X171305590Y-126042562D01* -X171529353Y-126156542D01* -X171771053Y-126224678D01* -X171971100Y-126136607D01* -X171971100Y-124988600D01* -X172021100Y-124988600D01* -X172021100Y-126136607D01* -X172221147Y-126224678D01* -X172462847Y-126156542D01* -X172686610Y-126042562D01* -X172883837Y-125887118D01* -X173046949Y-125696184D01* -X173169677Y-125477097D01* -X173247305Y-125238277D01* -X173257177Y-125188647D01* -X173275023Y-125188647D01* -X173284895Y-125238277D01* -X173362523Y-125477097D01* -X173485251Y-125696184D01* -X173648363Y-125887118D01* -X173845590Y-126042562D01* -X174069353Y-126156542D01* -X174311053Y-126224678D01* -X174511100Y-126136607D01* -X174511100Y-124988600D01* -X173363116Y-124988600D01* -X173275023Y-125188647D01* -X173257177Y-125188647D01* -X173169084Y-124988600D01* -X172021100Y-124988600D01* -X171971100Y-124988600D01* -X170823116Y-124988600D01* -X170735023Y-125188647D01* -X169007100Y-125188647D01* -X169007100Y-125096350D01* -X168899350Y-124988600D01* -X167711100Y-124988600D01* -X167661100Y-124988600D01* -X166472850Y-124988600D01* -X166365100Y-125096350D01* -X165246264Y-125096350D01* -X165246264Y-123883600D01* -X165242084Y-123841150D01* -X166365100Y-123841150D01* -X166365100Y-124830850D01* -X166472850Y-124938600D01* -X167661100Y-124938600D01* -X167661100Y-124918600D01* -X167711100Y-124918600D01* -X167711100Y-124938600D01* -X168899350Y-124938600D01* -X169007100Y-124830850D01* -X169007100Y-124738553D01* -X170735023Y-124738553D01* -X170823116Y-124938600D01* -X171971100Y-124938600D01* -X171971100Y-123790593D01* -X172021100Y-123790593D01* -X172021100Y-124938600D01* -X173169084Y-124938600D01* -X173257177Y-124738553D01* -X173275023Y-124738553D01* -X173363116Y-124938600D01* -X174511100Y-124938600D01* -X174511100Y-123790593D01* -X174311053Y-123702522D01* -X174069353Y-123770658D01* -X173845590Y-123884638D01* -X173648363Y-124040082D01* -X173485251Y-124231016D01* -X173362523Y-124450103D01* -X173284895Y-124688923D01* -X173275023Y-124738553D01* -X173257177Y-124738553D01* -X173247305Y-124688923D01* -X173169677Y-124450103D01* -X173046949Y-124231016D01* -X172883837Y-124040082D01* -X172686610Y-123884638D01* -X172462847Y-123770658D01* -X172221147Y-123702522D01* -X172021100Y-123790593D01* -X171971100Y-123790593D01* -X171771053Y-123702522D01* -X171529353Y-123770658D01* -X171305590Y-123884638D01* -X171108363Y-124040082D01* -X170945251Y-124231016D01* -X170822523Y-124450103D01* -X170744895Y-124688923D01* -X170735023Y-124738553D01* -X169007100Y-124738553D01* -X169007100Y-124321238D01* -X169066293Y-124274498D01* -X169235030Y-124076617D01* -X169361920Y-123849619D01* -X169442087Y-123602228D01* -X169472450Y-123343950D01* -X169472450Y-122648647D01* -X170735023Y-122648647D01* -X170744895Y-122698277D01* -X170822523Y-122937097D01* -X170945251Y-123156184D01* -X171108363Y-123347118D01* -X171305590Y-123502562D01* -X171529353Y-123616542D01* -X171771053Y-123684678D01* -X171971100Y-123596607D01* -X171971100Y-122448600D01* -X172021100Y-122448600D01* -X172021100Y-123596607D01* -X172221147Y-123684678D01* -X172462847Y-123616542D01* -X172686610Y-123502562D01* -X172883837Y-123347118D01* -X173046949Y-123156184D01* -X173169677Y-122937097D01* -X173247305Y-122698277D01* -X173257177Y-122648647D01* -X173275023Y-122648647D01* -X173284895Y-122698277D01* -X173362523Y-122937097D01* -X173485251Y-123156184D01* -X173648363Y-123347118D01* -X173845590Y-123502562D01* -X174069353Y-123616542D01* -X174311053Y-123684678D01* -X174511100Y-123596607D01* -X174511100Y-122448600D01* -X173363116Y-122448600D01* -X173275023Y-122648647D01* -X173257177Y-122648647D01* -X173169084Y-122448600D01* -X172021100Y-122448600D01* -X171971100Y-122448600D01* -X170823116Y-122448600D01* -X170735023Y-122648647D01* -X169472450Y-122648647D01* -X169472450Y-122448600D01* -X168171100Y-122448600D01* -X168171100Y-122468600D01* -X168121100Y-122468600D01* -X168121100Y-122448600D01* -X166819750Y-122448600D01* -X166819750Y-123343950D01* -X166832523Y-123452600D01* -X166753650Y-123452600D01* -X166670382Y-123469163D01* -X166591945Y-123501653D01* -X166521353Y-123548821D01* -X166461320Y-123608854D01* -X166414153Y-123679445D01* -X166381663Y-123757882D01* -X166365100Y-123841150D01* -X165242084Y-123841150D01* -X165232042Y-123739201D01* -X165189922Y-123600351D01* -X165121524Y-123472387D01* -X165029475Y-123360225D01* -X164917313Y-123268176D01* -X164789349Y-123199778D01* -X164778050Y-123196350D01* -X164778050Y-121448080D01* -X164754437Y-121208332D01* -X164661120Y-120900708D01* -X164509582Y-120617200D01* -X164305646Y-120368704D01* -X164240458Y-120315205D01* -X164267499Y-120312542D01* -X164406349Y-120270422D01* -X164534313Y-120202024D01* -X164646475Y-120109975D01* -X164738524Y-119997813D01* -X164806922Y-119869849D01* -X164849042Y-119730999D01* -X164863264Y-119586600D01* -X164863264Y-117386600D01* -X164849042Y-117242201D01* -X164806922Y-117103351D01* -X164738524Y-116975387D01* -X164646475Y-116863225D01* -X164534313Y-116771176D01* -X164406349Y-116702778D01* -X164267499Y-116660658D01* -X164123100Y-116646436D01* -X162323100Y-116646436D01* -X162178701Y-116660658D01* -X162039851Y-116702778D01* -X161911887Y-116771176D01* -X161799725Y-116863225D01* -X161717484Y-116963436D01* -X159974100Y-116963436D01* -X159829701Y-116977658D01* -X159690851Y-117019778D01* -X159562887Y-117088176D01* -X159450725Y-117180225D01* -X159358676Y-117292387D01* -X159290278Y-117420351D01* -X159248158Y-117559201D01* -X159233936Y-117703600D01* -X159233936Y-119503600D01* -X159248158Y-119647999D01* -X159290278Y-119786849D01* -X159358676Y-119914813D01* -X159450725Y-120026975D01* -X159562887Y-120119024D01* -X159690851Y-120187422D01* -X159829701Y-120229542D01* -X159974100Y-120243764D01* -X161989977Y-120243764D01* -X162039851Y-120270422D01* -X162088375Y-120285142D01* -X161986555Y-120368704D01* -X161782619Y-120617200D01* -X161631081Y-120900708D01* -X161537764Y-121208332D01* -X161514150Y-121448080D01* -X161514150Y-121819539D01* -X161119343Y-122063436D01* -X159974100Y-122063436D01* -X159829701Y-122077658D01* -X159690851Y-122119778D01* -X159562887Y-122188176D01* -X159450725Y-122280225D01* -X159358676Y-122392387D01* -X159290278Y-122520351D01* -X159248158Y-122659201D01* -X159233936Y-122803600D01* -X159233936Y-123872490D01* -X159062360Y-123700914D01* -X158796111Y-123523012D01* -X158500270Y-123400470D01* -X158377354Y-123376021D01* -X157949900Y-122360817D01* -X157949900Y-122321200D01* -X158172750Y-122321200D01* -X158280500Y-122213450D01* -X158280500Y-121204000D01* -X158330500Y-121204000D01* -X158330500Y-122213450D01* -X158438250Y-122321200D01* -X158703550Y-122321200D01* -X158786818Y-122304637D01* -X158865255Y-122272147D01* -X158935846Y-122224980D01* -X158995879Y-122164947D01* -X159043047Y-122094355D01* -X159075537Y-122015918D01* -X159092100Y-121932650D01* -X159092100Y-121311750D01* -X158984350Y-121204000D01* -X158330500Y-121204000D01* -X158280500Y-121204000D01* -X158260500Y-121204000D01* -X158260500Y-121154000D01* -X158280500Y-121154000D01* -X158280500Y-120144550D01* -X158330500Y-120144550D01* -X158330500Y-121154000D01* -X158984350Y-121154000D01* -X159092100Y-121046250D01* -X159092100Y-120425350D01* -X159075537Y-120342082D01* -X159043047Y-120263645D01* -X158995879Y-120193053D01* -X158935846Y-120133020D01* -X158865255Y-120085853D01* -X158786818Y-120053363D01* -X158703550Y-120036800D01* -X158438250Y-120036800D01* -X158330500Y-120144550D01* -X158280500Y-120144550D01* -X158172750Y-120036800D01* -X157949900Y-120036800D01* -X157949900Y-118744137D01* -X157950588Y-118655322D01* -X157941208Y-118606177D01* -X157936302Y-118556367D01* -X157923892Y-118515458D01* -X157915880Y-118473480D01* -X157897091Y-118427105D01* -X157882563Y-118379214D01* -X157840664Y-118300827D01* -X156338644Y-115437600D01* -X166472936Y-115437600D01* -X166472936Y-117237600D01* -X166487158Y-117381999D01* -X166529278Y-117520849D01* -X166597676Y-117648813D01* -X166682936Y-117752703D01* -X166682936Y-119586600D01* -X166697158Y-119730999D01* -X166739278Y-119869849D01* -X166807676Y-119997813D01* -X166899725Y-120109975D01* -X167011887Y-120202024D01* -X167139851Y-120270422D01* -X167278701Y-120312542D01* -X167423100Y-120326764D01* -X167596068Y-120326764D01* -X167430006Y-120411542D01* -X167225907Y-120572702D01* -X167057170Y-120770583D01* -X166930280Y-120997581D01* -X166850113Y-121244972D01* -X166819750Y-121503250D01* -X166819750Y-122398600D01* -X168121100Y-122398600D01* -X168121100Y-122378600D01* -X168171100Y-122378600D01* -X168171100Y-122398600D01* -X169472450Y-122398600D01* -X169472450Y-122198553D01* -X170735023Y-122198553D01* -X170823116Y-122398600D01* -X171971100Y-122398600D01* -X171971100Y-121250593D01* -X172021100Y-121250593D01* -X172021100Y-122398600D01* -X173169084Y-122398600D01* -X173257177Y-122198553D01* -X173275023Y-122198553D01* -X173363116Y-122398600D01* -X174511100Y-122398600D01* -X174511100Y-121250593D01* -X174311053Y-121162522D01* -X174069353Y-121230658D01* -X173845590Y-121344638D01* -X173648363Y-121500082D01* -X173485251Y-121691016D01* -X173362523Y-121910103D01* -X173284895Y-122148923D01* -X173275023Y-122198553D01* -X173257177Y-122198553D01* -X173247305Y-122148923D01* -X173169677Y-121910103D01* -X173046949Y-121691016D01* -X172883837Y-121500082D01* -X172686610Y-121344638D01* -X172462847Y-121230658D01* -X172221147Y-121162522D01* -X172021100Y-121250593D01* -X171971100Y-121250593D01* -X171771053Y-121162522D01* -X171529353Y-121230658D01* -X171305590Y-121344638D01* -X171108363Y-121500082D01* -X170945251Y-121691016D01* -X170822523Y-121910103D01* -X170744895Y-122148923D01* -X170735023Y-122198553D01* -X169472450Y-122198553D01* -X169472450Y-121503250D01* -X169442087Y-121244972D01* -X169361920Y-120997581D01* -X169235030Y-120770583D01* -X169066293Y-120572702D01* -X168862194Y-120411542D01* -X168696132Y-120326764D01* -X169223100Y-120326764D01* -X169367499Y-120312542D01* -X169506349Y-120270422D01* -X169634313Y-120202024D01* -X169746475Y-120109975D01* -X169747564Y-120108647D01* -X170735023Y-120108647D01* -X170744895Y-120158277D01* -X170822523Y-120397097D01* -X170945251Y-120616184D01* -X171108363Y-120807118D01* -X171305590Y-120962562D01* -X171529353Y-121076542D01* -X171771053Y-121144678D01* -X171971100Y-121056607D01* -X171971100Y-119908600D01* -X172021100Y-119908600D01* -X172021100Y-121056607D01* -X172221147Y-121144678D01* -X172462847Y-121076542D01* -X172686610Y-120962562D01* -X172883837Y-120807118D01* -X173046949Y-120616184D01* -X173169677Y-120397097D01* -X173247305Y-120158277D01* -X173257177Y-120108647D01* -X173275023Y-120108647D01* -X173284895Y-120158277D01* -X173362523Y-120397097D01* -X173485251Y-120616184D01* -X173648363Y-120807118D01* -X173845590Y-120962562D01* -X174069353Y-121076542D01* -X174311053Y-121144678D01* -X174511100Y-121056607D01* -X174511100Y-119908600D01* -X173363116Y-119908600D01* -X173275023Y-120108647D01* -X173257177Y-120108647D01* -X173169084Y-119908600D01* -X172021100Y-119908600D01* -X171971100Y-119908600D01* -X170823116Y-119908600D01* -X170735023Y-120108647D01* -X169747564Y-120108647D01* -X169838524Y-119997813D01* -X169906922Y-119869849D01* -X169949042Y-119730999D01* -X169963264Y-119586600D01* -X169963264Y-117728333D01* -X170028524Y-117648813D01* -X170096922Y-117520849D01* -X170110420Y-117476350D01* -X170715100Y-117476350D01* -X170715100Y-118236050D01* -X170731663Y-118319318D01* -X170764153Y-118397755D01* -X170811320Y-118468346D01* -X170871353Y-118528379D01* -X170941945Y-118575547D01* -X171020382Y-118608037D01* -X171103650Y-118624600D01* -X171763682Y-118624600D01* -X171529353Y-118690658D01* -X171305590Y-118804638D01* -X171108363Y-118960082D01* -X170945251Y-119151016D01* -X170822523Y-119370103D01* -X170744895Y-119608923D01* -X170735023Y-119658553D01* -X170823116Y-119858600D01* -X171971100Y-119858600D01* -X171971100Y-118710593D01* -X171775773Y-118624600D01* -X171863350Y-118624600D01* -X171971100Y-118516850D01* -X171971100Y-117368600D01* -X172021100Y-117368600D01* -X172021100Y-118516850D01* -X172128850Y-118624600D01* -X172216427Y-118624600D01* -X172021100Y-118710593D01* -X172021100Y-119858600D01* -X173169084Y-119858600D01* -X173257177Y-119658553D01* -X173275023Y-119658553D01* -X173363116Y-119858600D01* -X174511100Y-119858600D01* -X174511100Y-118710593D01* -X174311053Y-118622522D01* -X174069353Y-118690658D01* -X173845590Y-118804638D01* -X173648363Y-118960082D01* -X173485251Y-119151016D01* -X173362523Y-119370103D01* -X173284895Y-119608923D01* -X173275023Y-119658553D01* -X173257177Y-119658553D01* -X173247305Y-119608923D01* -X173169677Y-119370103D01* -X173046949Y-119151016D01* -X172883837Y-118960082D01* -X172686610Y-118804638D01* -X172462847Y-118690658D01* -X172228518Y-118624600D01* -X172888550Y-118624600D01* -X172971818Y-118608037D01* -X173050255Y-118575547D01* -X173120847Y-118528379D01* -X173180880Y-118468346D01* -X173228047Y-118397755D01* -X173260537Y-118319318D01* -X173277100Y-118236050D01* -X173277100Y-117579089D01* -X173284895Y-117618277D01* -X173362523Y-117857097D01* -X173485251Y-118076184D01* -X173648363Y-118267118D01* -X173845590Y-118422562D01* -X174069353Y-118536542D01* -X174311053Y-118604678D01* -X174511100Y-118516607D01* -X174511100Y-117368600D01* -X173363116Y-117368600D01* -X173277100Y-117563930D01* -X173277100Y-117476350D01* -X173169350Y-117368600D01* -X172021100Y-117368600D01* -X171971100Y-117368600D01* -X170822850Y-117368600D01* -X170715100Y-117476350D01* -X170110420Y-117476350D01* -X170139042Y-117381999D01* -X170153264Y-117237600D01* -X170153264Y-116451150D01* -X170715100Y-116451150D01* -X170715100Y-117210850D01* -X170822850Y-117318600D01* -X171971100Y-117318600D01* -X171971100Y-116170350D01* -X172021100Y-116170350D01* -X172021100Y-117318600D01* -X173169350Y-117318600D01* -X173277100Y-117210850D01* -X173277100Y-117123270D01* -X173363116Y-117318600D01* -X174511100Y-117318600D01* -X174511100Y-116170593D01* -X174311053Y-116082522D01* -X174069353Y-116150658D01* -X173845590Y-116264638D01* -X173648363Y-116420082D01* -X173485251Y-116611016D01* -X173362523Y-116830103D01* -X173284895Y-117068923D01* -X173277100Y-117108111D01* -X173277100Y-116451150D01* -X173260537Y-116367882D01* -X173228047Y-116289445D01* -X173180880Y-116218854D01* -X173120847Y-116158821D01* -X173050255Y-116111653D01* -X172971818Y-116079163D01* -X172888550Y-116062600D01* -X172128850Y-116062600D01* -X172021100Y-116170350D01* -X171971100Y-116170350D01* -X171863350Y-116062600D01* -X171103650Y-116062600D01* -X171020382Y-116079163D01* -X170941945Y-116111653D01* -X170871353Y-116158821D01* -X170811320Y-116218854D01* -X170764153Y-116289445D01* -X170731663Y-116367882D01* -X170715100Y-116451150D01* -X170153264Y-116451150D01* -X170153264Y-115437600D01* -X170139042Y-115293201D01* -X170096922Y-115154351D01* -X170028524Y-115026387D01* -X169936475Y-114914225D01* -X169824313Y-114822176D01* -X169696349Y-114753778D01* -X169557499Y-114711658D01* -X169413100Y-114697436D01* -X167213100Y-114697436D01* -X167068701Y-114711658D01* -X166929851Y-114753778D01* -X166801887Y-114822176D01* -X166689725Y-114914225D01* -X166597676Y-115026387D01* -X166529278Y-115154351D01* -X166487158Y-115293201D01* -X166472936Y-115437600D01* -X156338644Y-115437600D01* -X154480331Y-111895192D01* -X154490544Y-111896323D01* -X154527827Y-111904882D01* -X154582329Y-111906480D01* -X154590415Y-111907375D01* -X154628492Y-111907834D01* -X154712872Y-111910308D01* -X154720941Y-111908948D01* -X154925190Y-111911408D01* -X155016198Y-112022302D01* -X155236654Y-112203226D01* -X155488170Y-112337665D01* -X155761082Y-112420451D01* -X155973778Y-112441400D01* -X157538422Y-112441400D01* -X157751118Y-112420451D01* -X158024030Y-112337665D01* -X158275546Y-112203226D01* -X158372205Y-112123900D01* -X158973840Y-112123900D01* -X159011887Y-112155124D01* -X159139851Y-112223522D01* -X159278701Y-112265642D01* -X159423100Y-112279864D01* -X160845500Y-112279864D01* -X160989899Y-112265642D01* -X161128749Y-112223522D01* -X161256713Y-112155124D01* -X161368875Y-112063075D01* -X161460924Y-111950913D01* -X161529322Y-111822949D01* -X161571442Y-111684099D01* -X161585664Y-111539700D01* -X161585664Y-110828500D01* -X161571442Y-110684101D01* -X161529322Y-110545251D01* -X161460924Y-110417287D01* -X161368875Y-110305125D01* -X161256713Y-110213076D01* -X161128749Y-110144678D01* -X160989899Y-110102558D01* -X160845500Y-110088336D01* -X159423100Y-110088336D01* -X159278701Y-110102558D01* -X159139851Y-110144678D01* -X159011887Y-110213076D01* -X158973840Y-110244300D01* -X158708434Y-110244300D01* -X158676926Y-110185354D01* -X158496002Y-109964898D01* -X158275546Y-109783974D01* -X158024030Y-109649535D01* -X157751118Y-109566749D01* -X157538422Y-109545800D01* -X155973778Y-109545800D01* -X155761082Y-109566749D01* -X155488170Y-109649535D01* -X155236654Y-109783974D01* -X155016198Y-109964898D01* -X154978967Y-110010265D01* -X153854454Y-109030850D01* -X158992100Y-109030850D01* -X158992100Y-109296150D01* -X159008663Y-109379418D01* -X159041153Y-109457855D01* -X159088320Y-109528446D01* -X159148353Y-109588479D01* -X159218945Y-109635647D01* -X159297382Y-109668137D01* -X159380650Y-109684700D01* -X160001550Y-109684700D01* -X160109300Y-109576950D01* -X160109300Y-108923100D01* -X160159300Y-108923100D01* -X160159300Y-109576950D01* -X160267050Y-109684700D01* -X160887950Y-109684700D01* -X160971218Y-109668137D01* -X161049655Y-109635647D01* -X161120247Y-109588479D01* -X161180280Y-109528446D01* -X161227447Y-109457855D01* -X161259937Y-109379418D01* -X161276500Y-109296150D01* -X161276500Y-109030850D01* -X161168750Y-108923100D01* -X160159300Y-108923100D01* -X160109300Y-108923100D01* -X159099850Y-108923100D01* -X158992100Y-109030850D01* -X153854454Y-109030850D01* -X153846933Y-109024300D01* -X154144250Y-109024300D01* -X154227518Y-109007737D01* -X154305955Y-108975247D01* -X154376547Y-108928079D01* -X154436580Y-108868046D01* -X154483747Y-108797455D01* -X154516237Y-108719018D01* -X154532800Y-108635750D01* -X154532800Y-108500050D01* -X158992100Y-108500050D01* -X158992100Y-108765350D01* -X159099850Y-108873100D01* -X160109300Y-108873100D01* -X160109300Y-108219250D01* -X160159300Y-108219250D01* -X160159300Y-108873100D01* -X161168750Y-108873100D01* -X161276500Y-108765350D01* -X161276500Y-108500050D01* -X161259937Y-108416782D01* -X161227447Y-108338345D01* -X161180280Y-108267754D01* -X161120247Y-108207721D01* -X161049655Y-108160553D01* -X160971218Y-108128063D01* -X160887950Y-108111500D01* -X160267050Y-108111500D01* -X160159300Y-108219250D01* -X160109300Y-108219250D01* -X160001550Y-108111500D01* -X159380650Y-108111500D01* -X159297382Y-108128063D01* -X159218945Y-108160553D01* -X159148353Y-108207721D01* -X159088320Y-108267754D01* -X159041153Y-108338345D01* -X159008663Y-108416782D01* -X158992100Y-108500050D01* -X154532800Y-108500050D01* -X154532800Y-108370450D01* -X154425050Y-108262700D01* -X153415600Y-108262700D01* -X153415600Y-108282700D01* -X153365600Y-108282700D01* -X153365600Y-108262700D01* -X153345600Y-108262700D01* -X153345600Y-108212700D01* -X153365600Y-108212700D01* -X153365600Y-107558850D01* -X153415600Y-107558850D01* -X153415600Y-108212700D01* -X154425050Y-108212700D01* -X154532800Y-108104950D01* -X154532800Y-107900550D01* -X163077700Y-107900550D01* -X163077700Y-109085250D01* -X163094263Y-109168518D01* -X163126753Y-109246955D01* -X163173921Y-109317547D01* -X163233954Y-109377580D01* -X163304545Y-109424747D01* -X163382982Y-109457237D01* -X163466250Y-109473800D01* -X164725950Y-109473800D01* -X164833700Y-109366050D01* -X164833700Y-107792800D01* -X164883700Y-107792800D01* -X164883700Y-109366050D01* -X164991450Y-109473800D01* -X166251150Y-109473800D01* -X166334418Y-109457237D01* -X166412855Y-109424747D01* -X166483446Y-109377580D01* -X166543479Y-109317547D01* -X166590647Y-109246955D01* -X166623137Y-109168518D01* -X166639700Y-109085250D01* -X166639700Y-107900550D01* -X166531950Y-107792800D01* -X164883700Y-107792800D01* -X164833700Y-107792800D01* -X163185450Y-107792800D01* -X163077700Y-107900550D01* -X154532800Y-107900550D01* -X154532800Y-107839650D01* -X154516237Y-107756382D01* -X154483747Y-107677945D01* -X154436580Y-107607354D01* -X154376547Y-107547321D01* -X154305955Y-107500153D01* -X154227518Y-107467663D01* -X154144250Y-107451100D01* -X153523350Y-107451100D01* -X153415600Y-107558850D01* -X153365600Y-107558850D01* -X153257850Y-107451100D01* -X152636950Y-107451100D01* -X152553682Y-107467663D01* -X152475245Y-107500153D01* -X152404653Y-107547321D01* -X152344620Y-107607354D01* -X152298801Y-107675927D01* -X152169116Y-107562976D01* -X153267748Y-107047464D01* -X154101800Y-107047464D01* -X154246199Y-107033242D01* -X154385049Y-106991122D01* -X154513013Y-106922724D01* -X154567217Y-106878240D01* -X154959974Y-106873793D01* -X155016198Y-106942302D01* -X155236654Y-107123226D01* -X155488170Y-107257665D01* -X155761082Y-107340451D01* -X155973778Y-107361400D01* -X157538422Y-107361400D01* -X157751118Y-107340451D01* -X158024030Y-107257665D01* -X158275546Y-107123226D01* -X158496002Y-106942302D01* -X158676926Y-106721846D01* -X158811365Y-106470330D01* -X158894151Y-106197418D01* -X158921538Y-105919350D01* -X159093700Y-105919350D01* -X159093700Y-106184650D01* -X159110263Y-106267918D01* -X159142753Y-106346355D01* -X159189920Y-106416946D01* -X159249953Y-106476979D01* -X159320545Y-106524147D01* -X159398982Y-106556637D01* -X159482250Y-106573200D01* -X160103150Y-106573200D01* -X160210900Y-106465450D01* -X160210900Y-105811600D01* -X160260900Y-105811600D01* -X160260900Y-106465450D01* -X160368650Y-106573200D01* -X160989550Y-106573200D01* -X161072818Y-106556637D01* -X161086800Y-106550845D01* -X161100782Y-106556637D01* -X161184050Y-106573200D01* -X161804950Y-106573200D01* -X161912700Y-106465450D01* -X161912700Y-105811600D01* -X161962700Y-105811600D01* -X161962700Y-106465450D01* -X162070450Y-106573200D01* -X162691350Y-106573200D01* -X162774618Y-106556637D01* -X162853055Y-106524147D01* -X162923647Y-106476979D01* -X162950276Y-106450350D01* -X163077700Y-106450350D01* -X163077700Y-107635050D01* -X163185450Y-107742800D01* -X164833700Y-107742800D01* -X164833700Y-106169550D01* -X164883700Y-106169550D01* -X164883700Y-107742800D01* -X166531950Y-107742800D01* -X166639700Y-107635050D01* -X166639700Y-106450350D01* -X166623137Y-106367082D01* -X166590647Y-106288645D01* -X166543479Y-106218053D01* -X166483446Y-106158020D01* -X166412855Y-106110853D01* -X166334418Y-106078363D01* -X166251150Y-106061800D01* -X164991450Y-106061800D01* -X164883700Y-106169550D01* -X164833700Y-106169550D01* -X164725950Y-106061800D01* -X163466250Y-106061800D01* -X163382982Y-106078363D01* -X163304545Y-106110853D01* -X163233954Y-106158020D01* -X163173921Y-106218053D01* -X163126753Y-106288645D01* -X163094263Y-106367082D01* -X163077700Y-106450350D01* -X162950276Y-106450350D01* -X162983680Y-106416946D01* -X163030847Y-106346355D01* -X163063337Y-106267918D01* -X163079900Y-106184650D01* -X163079900Y-105919350D01* -X162972150Y-105811600D01* -X161962700Y-105811600D01* -X161912700Y-105811600D01* -X160260900Y-105811600D01* -X160210900Y-105811600D01* -X159201450Y-105811600D01* -X159093700Y-105919350D01* -X158921538Y-105919350D01* -X158922105Y-105913600D01* -X158894151Y-105629782D01* -X158820975Y-105388550D01* -X159093700Y-105388550D01* -X159093700Y-105653850D01* -X159201450Y-105761600D01* -X160210900Y-105761600D01* -X160210900Y-105107750D01* -X160260900Y-105107750D01* -X160260900Y-105761600D01* -X161912700Y-105761600D01* -X161912700Y-105107750D01* -X161962700Y-105107750D01* -X161962700Y-105761600D01* -X162972150Y-105761600D01* -X163079900Y-105653850D01* -X163079900Y-105388550D01* -X163063337Y-105305282D01* -X163030847Y-105226845D01* -X162983680Y-105156254D01* -X162923647Y-105096221D01* -X162853055Y-105049053D01* -X162774618Y-105016563D01* -X162691350Y-105000000D01* -X162070450Y-105000000D01* -X161962700Y-105107750D01* -X161912700Y-105107750D01* -X161804950Y-105000000D01* -X161184050Y-105000000D01* -X161100782Y-105016563D01* -X161086800Y-105022355D01* -X161072818Y-105016563D01* -X160989550Y-105000000D01* -X160368650Y-105000000D01* -X160260900Y-105107750D01* -X160210900Y-105107750D01* -X160103150Y-105000000D01* -X159482250Y-105000000D01* -X159398982Y-105016563D01* -X159320545Y-105049053D01* -X159249953Y-105096221D01* -X159189920Y-105156254D01* -X159142753Y-105226845D01* -X159110263Y-105305282D01* -X159093700Y-105388550D01* -X158820975Y-105388550D01* -X158811365Y-105356870D01* -X158676926Y-105105354D01* -X158496002Y-104884898D01* -X158275546Y-104703974D01* -X158024030Y-104569535D01* -X157751118Y-104486749D01* -X157538422Y-104465800D01* -X155973778Y-104465800D01* -X155761082Y-104486749D01* -X155488170Y-104569535D01* -X155236654Y-104703974D01* -X155016198Y-104884898D01* -X154926287Y-104994455D01* -X154535197Y-104998882D01* -X154513013Y-104980676D01* -X154385049Y-104912278D01* -X154246199Y-104870158D01* -X154101800Y-104855936D01* -X152679400Y-104855936D01* -X152535001Y-104870158D01* -X152525131Y-104873152D01* -X154077647Y-103425065D01* -X158539278Y-103433086D01* -X158539278Y-103433086D01* -G37* -X158539278Y-103433086D02* -X158784536Y-103674860D01* -X158784536Y-103856200D01* -X158798758Y-104000599D01* -X158840878Y-104139449D01* -X158909276Y-104267413D01* -X159001325Y-104379575D01* -X159113487Y-104471624D01* -X159241451Y-104540022D01* -X159380301Y-104582142D01* -X159524700Y-104596364D01* -X159910639Y-104596364D01* -X160011833Y-104627061D01* -X160015940Y-104627466D01* -X160019897Y-104628635D01* -X160127891Y-104638492D01* -X160179754Y-104643600D01* -X160183857Y-104643600D01* -X160244116Y-104649100D01* -X160296141Y-104643600D01* -X161441152Y-104643600D01* -X161494423Y-104670026D01* -X161731084Y-104734035D01* -X161975685Y-104750644D01* -X162218827Y-104719214D01* -X162451165Y-104640954D01* -X162528817Y-104596364D01* -X162648900Y-104596364D01* -X162793299Y-104582142D01* -X162932149Y-104540022D01* -X163060113Y-104471624D01* -X163172275Y-104379575D01* -X163264324Y-104267413D01* -X163332722Y-104139449D01* -X163373352Y-104005512D01* -X164176316Y-103432964D01* -X165588545Y-103432964D01* -X165591425Y-103442495D01* -X165600270Y-103459085D01* -X165606194Y-103476921D01* -X165663750Y-103578146D01* -X165686686Y-103621164D01* -X165697045Y-103636703D01* -X165739740Y-103711791D01* -X165754218Y-103728522D01* -X165770139Y-103758307D01* -X165855226Y-103861985D01* -X165940522Y-103966140D01* -X165941082Y-103966600D01* -X165941541Y-103967160D01* -X166045354Y-104052357D01* -X166149195Y-104137759D01* -X166149834Y-104138101D01* -X166150394Y-104138561D01* -X166269068Y-104201994D01* -X166387341Y-104265371D01* -X166388032Y-104265581D01* -X166388673Y-104265924D01* -X166475469Y-104292253D01* -X169367286Y-106117037D01* -X169376184Y-106207377D01* -X169461875Y-106489864D01* -X169601031Y-106750206D01* -X169788303Y-106978397D01* -X170016494Y-107165669D01* -X170276836Y-107304825D01* -X170416087Y-107347066D01* -X170373462Y-107360978D01* -X170169518Y-107475545D01* -X169991844Y-107627698D01* -X169847267Y-107811590D01* -X169741344Y-108020154D01* -X169678957Y-108242322D01* -X169768138Y-108428600D01* -X171590100Y-108428600D01* -X171590100Y-108408600D01* -X171640100Y-108408600D01* -X171640100Y-108428600D01* -X174511100Y-108428600D01* -X174511100Y-107774750D01* -X174403350Y-107667000D01* -X173269255Y-107667000D01* -X173238356Y-107627698D01* -X173060682Y-107475545D01* -X172856738Y-107360978D01* -X172814113Y-107347066D01* -X172953364Y-107304825D01* -X173213706Y-107165669D01* -X173441897Y-106978397D01* -X173629169Y-106750206D01* -X173768325Y-106489864D01* -X173854016Y-106207377D01* -X173882951Y-105913600D01* -X173854016Y-105619823D01* -X173793986Y-105421929D01* -X175044100Y-103900052D01* -X175044100Y-107667000D01* -X174668850Y-107667000D01* -X174561100Y-107774750D01* -X174561100Y-108428600D01* -X174581100Y-108428600D01* -X174581100Y-108478600D01* -X174561100Y-108478600D01* -X174561100Y-109132450D01* -X174668850Y-109240200D01* -X175044100Y-109240200D01* -X175044100Y-109643836D01* -X174861361Y-109643836D01* -X174760167Y-109613139D01* -X174592246Y-109596600D01* -X173159122Y-109596600D01* -X173117715Y-109591448D01* -X173046833Y-109596600D01* -X173032154Y-109596600D01* -X172990814Y-109600672D01* -X172955042Y-109603272D01* -X172953364Y-109602375D01* -X172814113Y-109560134D01* -X172856738Y-109546222D01* -X173060682Y-109431655D01* -X173238356Y-109279502D01* -X173269255Y-109240200D01* -X174403350Y-109240200D01* -X174511100Y-109132450D01* -X174511100Y-108478600D01* -X171640100Y-108478600D01* -X171640100Y-108498600D01* -X171590100Y-108498600D01* -X171590100Y-108478600D01* -X169768138Y-108478600D01* -X169678957Y-108664878D01* -X169741344Y-108887046D01* -X169847267Y-109095610D01* -X169991844Y-109279502D01* -X170169518Y-109431655D01* -X170373462Y-109546222D01* -X170416087Y-109560134D01* -X170276836Y-109602375D01* -X170027611Y-109735589D01* -X169856102Y-109748265D01* -X169824313Y-109722176D01* -X169696349Y-109653778D01* -X169557499Y-109611658D01* -X169413100Y-109597436D01* -X167213100Y-109597436D01* -X167068701Y-109611658D01* -X166929851Y-109653778D01* -X166801887Y-109722176D01* -X166689725Y-109814225D01* -X166597676Y-109926387D01* -X166529278Y-110054351D01* -X166487158Y-110193201D01* -X166472936Y-110337600D01* -X166472936Y-112137600D01* -X166487158Y-112281999D01* -X166529278Y-112420849D01* -X166597676Y-112548813D01* -X166689725Y-112660975D01* -X166801887Y-112753024D01* -X166929851Y-112821422D01* -X167068701Y-112863542D01* -X167213100Y-112877764D01* -X169153329Y-112877764D01* -X170359500Y-114083935D01* -X170359500Y-114329791D01* -X170422393Y-114645979D01* -X170545764Y-114943821D01* -X170724870Y-115211872D01* -X170952828Y-115439830D01* -X171220879Y-115618936D01* -X171518721Y-115742307D01* -X171834909Y-115805200D01* -X172157291Y-115805200D01* -X172473479Y-115742307D01* -X172771321Y-115618936D01* -X172889158Y-115540200D01* -X173643042Y-115540200D01* -X173760879Y-115618936D01* -X174058721Y-115742307D01* -X174374909Y-115805200D01* -X174697291Y-115805200D01* -X175013479Y-115742307D01* -X175044100Y-115729623D01* -X175044100Y-116171671D01* -X175002847Y-116150658D01* -X174761147Y-116082522D01* -X174561100Y-116170593D01* -X174561100Y-117318600D01* -X174581100Y-117318600D01* -X174581100Y-117368600D01* -X174561100Y-117368600D01* -X174561100Y-118516607D01* -X174761147Y-118604678D01* -X175002847Y-118536542D01* -X175044100Y-118515529D01* -X175044100Y-118711671D01* -X175002847Y-118690658D01* -X174761147Y-118622522D01* -X174561100Y-118710593D01* -X174561100Y-119858600D01* -X174581100Y-119858600D01* -X174581100Y-119908600D01* -X174561100Y-119908600D01* -X174561100Y-121056607D01* -X174761147Y-121144678D01* -X175002847Y-121076542D01* -X175044100Y-121055529D01* -X175044100Y-121251671D01* -X175002847Y-121230658D01* -X174761147Y-121162522D01* -X174561100Y-121250593D01* -X174561100Y-122398600D01* -X174581100Y-122398600D01* -X174581100Y-122448600D01* -X174561100Y-122448600D01* -X174561100Y-123596607D01* -X174761147Y-123684678D01* -X175002847Y-123616542D01* -X175044100Y-123595529D01* -X175044100Y-123791671D01* -X175002847Y-123770658D01* -X174761147Y-123702522D01* -X174561100Y-123790593D01* -X174561100Y-124938600D01* -X174581100Y-124938600D01* -X174581100Y-124988600D01* -X174561100Y-124988600D01* -X174561100Y-126136607D01* -X174761147Y-126224678D01* -X175002847Y-126156542D01* -X175044100Y-126135529D01* -X175044100Y-126692000D01* -X164855619Y-126692000D01* -X164917313Y-126659024D01* -X165029475Y-126566975D01* -X165121524Y-126454813D01* -X165189922Y-126326849D01* -X165232042Y-126187999D01* -X165246264Y-126043600D01* -X165246264Y-125096350D01* -X166365100Y-125096350D01* -X166365100Y-126086050D01* -X166381663Y-126169318D01* -X166414153Y-126247755D01* -X166461320Y-126318346D01* -X166521353Y-126378379D01* -X166591945Y-126425547D01* -X166670382Y-126458037D01* -X166753650Y-126474600D01* -X167553350Y-126474600D01* -X167661100Y-126366850D01* -X167661100Y-124988600D01* -X167711100Y-124988600D01* -X167711100Y-126366850D01* -X167818850Y-126474600D01* -X168618550Y-126474600D01* -X168701818Y-126458037D01* -X168780255Y-126425547D01* -X168850847Y-126378379D01* -X168910880Y-126318346D01* -X168958047Y-126247755D01* -X168990537Y-126169318D01* -X169007100Y-126086050D01* -X169007100Y-125188647D01* -X170735023Y-125188647D01* -X170744895Y-125238277D01* -X170822523Y-125477097D01* -X170945251Y-125696184D01* -X171108363Y-125887118D01* -X171305590Y-126042562D01* -X171529353Y-126156542D01* -X171771053Y-126224678D01* -X171971100Y-126136607D01* -X171971100Y-124988600D01* -X172021100Y-124988600D01* -X172021100Y-126136607D01* -X172221147Y-126224678D01* -X172462847Y-126156542D01* -X172686610Y-126042562D01* -X172883837Y-125887118D01* -X173046949Y-125696184D01* -X173169677Y-125477097D01* -X173247305Y-125238277D01* -X173257177Y-125188647D01* -X173275023Y-125188647D01* -X173284895Y-125238277D01* -X173362523Y-125477097D01* -X173485251Y-125696184D01* -X173648363Y-125887118D01* -X173845590Y-126042562D01* -X174069353Y-126156542D01* -X174311053Y-126224678D01* -X174511100Y-126136607D01* -X174511100Y-124988600D01* -X173363116Y-124988600D01* -X173275023Y-125188647D01* -X173257177Y-125188647D01* -X173169084Y-124988600D01* -X172021100Y-124988600D01* -X171971100Y-124988600D01* -X170823116Y-124988600D01* -X170735023Y-125188647D01* -X169007100Y-125188647D01* -X169007100Y-125096350D01* -X168899350Y-124988600D01* -X167711100Y-124988600D01* -X167661100Y-124988600D01* -X166472850Y-124988600D01* -X166365100Y-125096350D01* -X165246264Y-125096350D01* -X165246264Y-123883600D01* -X165242084Y-123841150D01* -X166365100Y-123841150D01* -X166365100Y-124830850D01* -X166472850Y-124938600D01* -X167661100Y-124938600D01* -X167661100Y-124918600D01* -X167711100Y-124918600D01* -X167711100Y-124938600D01* -X168899350Y-124938600D01* -X169007100Y-124830850D01* -X169007100Y-124738553D01* -X170735023Y-124738553D01* -X170823116Y-124938600D01* -X171971100Y-124938600D01* -X171971100Y-123790593D01* -X172021100Y-123790593D01* -X172021100Y-124938600D01* -X173169084Y-124938600D01* -X173257177Y-124738553D01* -X173275023Y-124738553D01* -X173363116Y-124938600D01* -X174511100Y-124938600D01* -X174511100Y-123790593D01* -X174311053Y-123702522D01* -X174069353Y-123770658D01* -X173845590Y-123884638D01* -X173648363Y-124040082D01* -X173485251Y-124231016D01* -X173362523Y-124450103D01* -X173284895Y-124688923D01* -X173275023Y-124738553D01* -X173257177Y-124738553D01* -X173247305Y-124688923D01* -X173169677Y-124450103D01* -X173046949Y-124231016D01* -X172883837Y-124040082D01* -X172686610Y-123884638D01* -X172462847Y-123770658D01* -X172221147Y-123702522D01* -X172021100Y-123790593D01* -X171971100Y-123790593D01* -X171771053Y-123702522D01* -X171529353Y-123770658D01* -X171305590Y-123884638D01* -X171108363Y-124040082D01* -X170945251Y-124231016D01* -X170822523Y-124450103D01* -X170744895Y-124688923D01* -X170735023Y-124738553D01* -X169007100Y-124738553D01* -X169007100Y-124321238D01* -X169066293Y-124274498D01* -X169235030Y-124076617D01* -X169361920Y-123849619D01* -X169442087Y-123602228D01* -X169472450Y-123343950D01* -X169472450Y-122648647D01* -X170735023Y-122648647D01* -X170744895Y-122698277D01* -X170822523Y-122937097D01* -X170945251Y-123156184D01* -X171108363Y-123347118D01* -X171305590Y-123502562D01* -X171529353Y-123616542D01* -X171771053Y-123684678D01* -X171971100Y-123596607D01* -X171971100Y-122448600D01* -X172021100Y-122448600D01* -X172021100Y-123596607D01* -X172221147Y-123684678D01* -X172462847Y-123616542D01* -X172686610Y-123502562D01* -X172883837Y-123347118D01* -X173046949Y-123156184D01* -X173169677Y-122937097D01* -X173247305Y-122698277D01* -X173257177Y-122648647D01* -X173275023Y-122648647D01* -X173284895Y-122698277D01* -X173362523Y-122937097D01* -X173485251Y-123156184D01* -X173648363Y-123347118D01* -X173845590Y-123502562D01* -X174069353Y-123616542D01* -X174311053Y-123684678D01* -X174511100Y-123596607D01* -X174511100Y-122448600D01* -X173363116Y-122448600D01* -X173275023Y-122648647D01* -X173257177Y-122648647D01* -X173169084Y-122448600D01* -X172021100Y-122448600D01* -X171971100Y-122448600D01* -X170823116Y-122448600D01* -X170735023Y-122648647D01* -X169472450Y-122648647D01* -X169472450Y-122448600D01* -X168171100Y-122448600D01* -X168171100Y-122468600D01* -X168121100Y-122468600D01* -X168121100Y-122448600D01* -X166819750Y-122448600D01* -X166819750Y-123343950D01* -X166832523Y-123452600D01* -X166753650Y-123452600D01* -X166670382Y-123469163D01* -X166591945Y-123501653D01* -X166521353Y-123548821D01* -X166461320Y-123608854D01* -X166414153Y-123679445D01* -X166381663Y-123757882D01* -X166365100Y-123841150D01* -X165242084Y-123841150D01* -X165232042Y-123739201D01* -X165189922Y-123600351D01* -X165121524Y-123472387D01* -X165029475Y-123360225D01* -X164917313Y-123268176D01* -X164789349Y-123199778D01* -X164778050Y-123196350D01* -X164778050Y-121448080D01* -X164754437Y-121208332D01* -X164661120Y-120900708D01* -X164509582Y-120617200D01* -X164305646Y-120368704D01* -X164240458Y-120315205D01* -X164267499Y-120312542D01* -X164406349Y-120270422D01* -X164534313Y-120202024D01* -X164646475Y-120109975D01* -X164738524Y-119997813D01* -X164806922Y-119869849D01* -X164849042Y-119730999D01* -X164863264Y-119586600D01* -X164863264Y-117386600D01* -X164849042Y-117242201D01* -X164806922Y-117103351D01* -X164738524Y-116975387D01* -X164646475Y-116863225D01* -X164534313Y-116771176D01* -X164406349Y-116702778D01* -X164267499Y-116660658D01* -X164123100Y-116646436D01* -X162323100Y-116646436D01* -X162178701Y-116660658D01* -X162039851Y-116702778D01* -X161911887Y-116771176D01* -X161799725Y-116863225D01* -X161717484Y-116963436D01* -X159974100Y-116963436D01* -X159829701Y-116977658D01* -X159690851Y-117019778D01* -X159562887Y-117088176D01* -X159450725Y-117180225D01* -X159358676Y-117292387D01* -X159290278Y-117420351D01* -X159248158Y-117559201D01* -X159233936Y-117703600D01* -X159233936Y-119503600D01* -X159248158Y-119647999D01* -X159290278Y-119786849D01* -X159358676Y-119914813D01* -X159450725Y-120026975D01* -X159562887Y-120119024D01* -X159690851Y-120187422D01* -X159829701Y-120229542D01* -X159974100Y-120243764D01* -X161989977Y-120243764D01* -X162039851Y-120270422D01* -X162088375Y-120285142D01* -X161986555Y-120368704D01* -X161782619Y-120617200D01* -X161631081Y-120900708D01* -X161537764Y-121208332D01* -X161514150Y-121448080D01* -X161514150Y-121819539D01* -X161119343Y-122063436D01* -X159974100Y-122063436D01* -X159829701Y-122077658D01* -X159690851Y-122119778D01* -X159562887Y-122188176D01* -X159450725Y-122280225D01* -X159358676Y-122392387D01* -X159290278Y-122520351D01* -X159248158Y-122659201D01* -X159233936Y-122803600D01* -X159233936Y-123872490D01* -X159062360Y-123700914D01* -X158796111Y-123523012D01* -X158500270Y-123400470D01* -X158377354Y-123376021D01* -X157949900Y-122360817D01* -X157949900Y-122321200D01* -X158172750Y-122321200D01* -X158280500Y-122213450D01* -X158280500Y-121204000D01* -X158330500Y-121204000D01* -X158330500Y-122213450D01* -X158438250Y-122321200D01* -X158703550Y-122321200D01* -X158786818Y-122304637D01* -X158865255Y-122272147D01* -X158935846Y-122224980D01* -X158995879Y-122164947D01* -X159043047Y-122094355D01* -X159075537Y-122015918D01* -X159092100Y-121932650D01* -X159092100Y-121311750D01* -X158984350Y-121204000D01* -X158330500Y-121204000D01* -X158280500Y-121204000D01* -X158260500Y-121204000D01* -X158260500Y-121154000D01* -X158280500Y-121154000D01* -X158280500Y-120144550D01* -X158330500Y-120144550D01* -X158330500Y-121154000D01* -X158984350Y-121154000D01* -X159092100Y-121046250D01* -X159092100Y-120425350D01* -X159075537Y-120342082D01* -X159043047Y-120263645D01* -X158995879Y-120193053D01* -X158935846Y-120133020D01* -X158865255Y-120085853D01* -X158786818Y-120053363D01* -X158703550Y-120036800D01* -X158438250Y-120036800D01* -X158330500Y-120144550D01* -X158280500Y-120144550D01* -X158172750Y-120036800D01* -X157949900Y-120036800D01* -X157949900Y-118744137D01* -X157950588Y-118655322D01* -X157941208Y-118606177D01* -X157936302Y-118556367D01* -X157923892Y-118515458D01* -X157915880Y-118473480D01* -X157897091Y-118427105D01* -X157882563Y-118379214D01* -X157840664Y-118300827D01* -X156338644Y-115437600D01* -X166472936Y-115437600D01* -X166472936Y-117237600D01* -X166487158Y-117381999D01* -X166529278Y-117520849D01* -X166597676Y-117648813D01* -X166682936Y-117752703D01* -X166682936Y-119586600D01* -X166697158Y-119730999D01* -X166739278Y-119869849D01* -X166807676Y-119997813D01* -X166899725Y-120109975D01* -X167011887Y-120202024D01* -X167139851Y-120270422D01* -X167278701Y-120312542D01* -X167423100Y-120326764D01* -X167596068Y-120326764D01* -X167430006Y-120411542D01* -X167225907Y-120572702D01* -X167057170Y-120770583D01* -X166930280Y-120997581D01* -X166850113Y-121244972D01* -X166819750Y-121503250D01* -X166819750Y-122398600D01* -X168121100Y-122398600D01* -X168121100Y-122378600D01* -X168171100Y-122378600D01* -X168171100Y-122398600D01* -X169472450Y-122398600D01* -X169472450Y-122198553D01* -X170735023Y-122198553D01* -X170823116Y-122398600D01* -X171971100Y-122398600D01* -X171971100Y-121250593D01* -X172021100Y-121250593D01* -X172021100Y-122398600D01* -X173169084Y-122398600D01* -X173257177Y-122198553D01* -X173275023Y-122198553D01* -X173363116Y-122398600D01* -X174511100Y-122398600D01* -X174511100Y-121250593D01* -X174311053Y-121162522D01* -X174069353Y-121230658D01* -X173845590Y-121344638D01* -X173648363Y-121500082D01* -X173485251Y-121691016D01* -X173362523Y-121910103D01* -X173284895Y-122148923D01* -X173275023Y-122198553D01* -X173257177Y-122198553D01* -X173247305Y-122148923D01* -X173169677Y-121910103D01* -X173046949Y-121691016D01* -X172883837Y-121500082D01* -X172686610Y-121344638D01* -X172462847Y-121230658D01* -X172221147Y-121162522D01* -X172021100Y-121250593D01* -X171971100Y-121250593D01* -X171771053Y-121162522D01* -X171529353Y-121230658D01* -X171305590Y-121344638D01* -X171108363Y-121500082D01* -X170945251Y-121691016D01* -X170822523Y-121910103D01* -X170744895Y-122148923D01* -X170735023Y-122198553D01* -X169472450Y-122198553D01* -X169472450Y-121503250D01* -X169442087Y-121244972D01* -X169361920Y-120997581D01* -X169235030Y-120770583D01* -X169066293Y-120572702D01* -X168862194Y-120411542D01* -X168696132Y-120326764D01* -X169223100Y-120326764D01* -X169367499Y-120312542D01* -X169506349Y-120270422D01* -X169634313Y-120202024D01* -X169746475Y-120109975D01* -X169747564Y-120108647D01* -X170735023Y-120108647D01* -X170744895Y-120158277D01* -X170822523Y-120397097D01* -X170945251Y-120616184D01* -X171108363Y-120807118D01* -X171305590Y-120962562D01* -X171529353Y-121076542D01* -X171771053Y-121144678D01* -X171971100Y-121056607D01* -X171971100Y-119908600D01* -X172021100Y-119908600D01* -X172021100Y-121056607D01* -X172221147Y-121144678D01* -X172462847Y-121076542D01* -X172686610Y-120962562D01* -X172883837Y-120807118D01* -X173046949Y-120616184D01* -X173169677Y-120397097D01* -X173247305Y-120158277D01* -X173257177Y-120108647D01* -X173275023Y-120108647D01* -X173284895Y-120158277D01* -X173362523Y-120397097D01* -X173485251Y-120616184D01* -X173648363Y-120807118D01* -X173845590Y-120962562D01* -X174069353Y-121076542D01* -X174311053Y-121144678D01* -X174511100Y-121056607D01* -X174511100Y-119908600D01* -X173363116Y-119908600D01* -X173275023Y-120108647D01* -X173257177Y-120108647D01* -X173169084Y-119908600D01* -X172021100Y-119908600D01* -X171971100Y-119908600D01* -X170823116Y-119908600D01* -X170735023Y-120108647D01* -X169747564Y-120108647D01* -X169838524Y-119997813D01* -X169906922Y-119869849D01* -X169949042Y-119730999D01* -X169963264Y-119586600D01* -X169963264Y-117728333D01* -X170028524Y-117648813D01* -X170096922Y-117520849D01* -X170110420Y-117476350D01* -X170715100Y-117476350D01* -X170715100Y-118236050D01* -X170731663Y-118319318D01* -X170764153Y-118397755D01* -X170811320Y-118468346D01* -X170871353Y-118528379D01* -X170941945Y-118575547D01* -X171020382Y-118608037D01* -X171103650Y-118624600D01* -X171763682Y-118624600D01* -X171529353Y-118690658D01* -X171305590Y-118804638D01* -X171108363Y-118960082D01* -X170945251Y-119151016D01* -X170822523Y-119370103D01* -X170744895Y-119608923D01* -X170735023Y-119658553D01* -X170823116Y-119858600D01* -X171971100Y-119858600D01* -X171971100Y-118710593D01* -X171775773Y-118624600D01* -X171863350Y-118624600D01* -X171971100Y-118516850D01* -X171971100Y-117368600D01* -X172021100Y-117368600D01* -X172021100Y-118516850D01* -X172128850Y-118624600D01* -X172216427Y-118624600D01* -X172021100Y-118710593D01* -X172021100Y-119858600D01* -X173169084Y-119858600D01* -X173257177Y-119658553D01* -X173275023Y-119658553D01* -X173363116Y-119858600D01* -X174511100Y-119858600D01* -X174511100Y-118710593D01* -X174311053Y-118622522D01* -X174069353Y-118690658D01* -X173845590Y-118804638D01* -X173648363Y-118960082D01* -X173485251Y-119151016D01* -X173362523Y-119370103D01* -X173284895Y-119608923D01* -X173275023Y-119658553D01* -X173257177Y-119658553D01* -X173247305Y-119608923D01* -X173169677Y-119370103D01* -X173046949Y-119151016D01* -X172883837Y-118960082D01* -X172686610Y-118804638D01* -X172462847Y-118690658D01* -X172228518Y-118624600D01* -X172888550Y-118624600D01* -X172971818Y-118608037D01* -X173050255Y-118575547D01* -X173120847Y-118528379D01* -X173180880Y-118468346D01* -X173228047Y-118397755D01* -X173260537Y-118319318D01* -X173277100Y-118236050D01* -X173277100Y-117579089D01* -X173284895Y-117618277D01* -X173362523Y-117857097D01* -X173485251Y-118076184D01* -X173648363Y-118267118D01* -X173845590Y-118422562D01* -X174069353Y-118536542D01* -X174311053Y-118604678D01* -X174511100Y-118516607D01* -X174511100Y-117368600D01* -X173363116Y-117368600D01* -X173277100Y-117563930D01* -X173277100Y-117476350D01* -X173169350Y-117368600D01* -X172021100Y-117368600D01* -X171971100Y-117368600D01* -X170822850Y-117368600D01* -X170715100Y-117476350D01* -X170110420Y-117476350D01* -X170139042Y-117381999D01* -X170153264Y-117237600D01* -X170153264Y-116451150D01* -X170715100Y-116451150D01* -X170715100Y-117210850D01* -X170822850Y-117318600D01* -X171971100Y-117318600D01* -X171971100Y-116170350D01* -X172021100Y-116170350D01* -X172021100Y-117318600D01* -X173169350Y-117318600D01* -X173277100Y-117210850D01* -X173277100Y-117123270D01* -X173363116Y-117318600D01* -X174511100Y-117318600D01* -X174511100Y-116170593D01* -X174311053Y-116082522D01* -X174069353Y-116150658D01* -X173845590Y-116264638D01* -X173648363Y-116420082D01* -X173485251Y-116611016D01* -X173362523Y-116830103D01* -X173284895Y-117068923D01* -X173277100Y-117108111D01* -X173277100Y-116451150D01* -X173260537Y-116367882D01* -X173228047Y-116289445D01* -X173180880Y-116218854D01* -X173120847Y-116158821D01* -X173050255Y-116111653D01* -X172971818Y-116079163D01* -X172888550Y-116062600D01* -X172128850Y-116062600D01* -X172021100Y-116170350D01* -X171971100Y-116170350D01* -X171863350Y-116062600D01* -X171103650Y-116062600D01* -X171020382Y-116079163D01* -X170941945Y-116111653D01* -X170871353Y-116158821D01* -X170811320Y-116218854D01* -X170764153Y-116289445D01* -X170731663Y-116367882D01* -X170715100Y-116451150D01* -X170153264Y-116451150D01* -X170153264Y-115437600D01* -X170139042Y-115293201D01* -X170096922Y-115154351D01* -X170028524Y-115026387D01* -X169936475Y-114914225D01* -X169824313Y-114822176D01* -X169696349Y-114753778D01* -X169557499Y-114711658D01* -X169413100Y-114697436D01* -X167213100Y-114697436D01* -X167068701Y-114711658D01* -X166929851Y-114753778D01* -X166801887Y-114822176D01* -X166689725Y-114914225D01* -X166597676Y-115026387D01* -X166529278Y-115154351D01* -X166487158Y-115293201D01* -X166472936Y-115437600D01* -X156338644Y-115437600D01* -X154480331Y-111895192D01* -X154490544Y-111896323D01* -X154527827Y-111904882D01* -X154582329Y-111906480D01* -X154590415Y-111907375D01* -X154628492Y-111907834D01* -X154712872Y-111910308D01* -X154720941Y-111908948D01* -X154925190Y-111911408D01* -X155016198Y-112022302D01* -X155236654Y-112203226D01* -X155488170Y-112337665D01* -X155761082Y-112420451D01* -X155973778Y-112441400D01* -X157538422Y-112441400D01* -X157751118Y-112420451D01* -X158024030Y-112337665D01* -X158275546Y-112203226D01* -X158372205Y-112123900D01* -X158973840Y-112123900D01* -X159011887Y-112155124D01* -X159139851Y-112223522D01* -X159278701Y-112265642D01* -X159423100Y-112279864D01* -X160845500Y-112279864D01* -X160989899Y-112265642D01* -X161128749Y-112223522D01* -X161256713Y-112155124D01* -X161368875Y-112063075D01* -X161460924Y-111950913D01* -X161529322Y-111822949D01* -X161571442Y-111684099D01* -X161585664Y-111539700D01* -X161585664Y-110828500D01* -X161571442Y-110684101D01* -X161529322Y-110545251D01* -X161460924Y-110417287D01* -X161368875Y-110305125D01* -X161256713Y-110213076D01* -X161128749Y-110144678D01* -X160989899Y-110102558D01* -X160845500Y-110088336D01* -X159423100Y-110088336D01* -X159278701Y-110102558D01* -X159139851Y-110144678D01* -X159011887Y-110213076D01* -X158973840Y-110244300D01* -X158708434Y-110244300D01* -X158676926Y-110185354D01* -X158496002Y-109964898D01* -X158275546Y-109783974D01* -X158024030Y-109649535D01* -X157751118Y-109566749D01* -X157538422Y-109545800D01* -X155973778Y-109545800D01* -X155761082Y-109566749D01* -X155488170Y-109649535D01* -X155236654Y-109783974D01* -X155016198Y-109964898D01* -X154978967Y-110010265D01* -X153854454Y-109030850D01* -X158992100Y-109030850D01* -X158992100Y-109296150D01* -X159008663Y-109379418D01* -X159041153Y-109457855D01* -X159088320Y-109528446D01* -X159148353Y-109588479D01* -X159218945Y-109635647D01* -X159297382Y-109668137D01* -X159380650Y-109684700D01* -X160001550Y-109684700D01* -X160109300Y-109576950D01* -X160109300Y-108923100D01* -X160159300Y-108923100D01* -X160159300Y-109576950D01* -X160267050Y-109684700D01* -X160887950Y-109684700D01* -X160971218Y-109668137D01* -X161049655Y-109635647D01* -X161120247Y-109588479D01* -X161180280Y-109528446D01* -X161227447Y-109457855D01* -X161259937Y-109379418D01* -X161276500Y-109296150D01* -X161276500Y-109030850D01* -X161168750Y-108923100D01* -X160159300Y-108923100D01* -X160109300Y-108923100D01* -X159099850Y-108923100D01* -X158992100Y-109030850D01* -X153854454Y-109030850D01* -X153846933Y-109024300D01* -X154144250Y-109024300D01* -X154227518Y-109007737D01* -X154305955Y-108975247D01* -X154376547Y-108928079D01* -X154436580Y-108868046D01* -X154483747Y-108797455D01* -X154516237Y-108719018D01* -X154532800Y-108635750D01* -X154532800Y-108500050D01* -X158992100Y-108500050D01* -X158992100Y-108765350D01* -X159099850Y-108873100D01* -X160109300Y-108873100D01* -X160109300Y-108219250D01* -X160159300Y-108219250D01* -X160159300Y-108873100D01* -X161168750Y-108873100D01* -X161276500Y-108765350D01* -X161276500Y-108500050D01* -X161259937Y-108416782D01* -X161227447Y-108338345D01* -X161180280Y-108267754D01* -X161120247Y-108207721D01* -X161049655Y-108160553D01* -X160971218Y-108128063D01* -X160887950Y-108111500D01* -X160267050Y-108111500D01* -X160159300Y-108219250D01* -X160109300Y-108219250D01* -X160001550Y-108111500D01* -X159380650Y-108111500D01* -X159297382Y-108128063D01* -X159218945Y-108160553D01* -X159148353Y-108207721D01* -X159088320Y-108267754D01* -X159041153Y-108338345D01* -X159008663Y-108416782D01* -X158992100Y-108500050D01* -X154532800Y-108500050D01* -X154532800Y-108370450D01* -X154425050Y-108262700D01* -X153415600Y-108262700D01* -X153415600Y-108282700D01* -X153365600Y-108282700D01* -X153365600Y-108262700D01* -X153345600Y-108262700D01* -X153345600Y-108212700D01* -X153365600Y-108212700D01* -X153365600Y-107558850D01* -X153415600Y-107558850D01* -X153415600Y-108212700D01* -X154425050Y-108212700D01* -X154532800Y-108104950D01* -X154532800Y-107900550D01* -X163077700Y-107900550D01* -X163077700Y-109085250D01* -X163094263Y-109168518D01* -X163126753Y-109246955D01* -X163173921Y-109317547D01* -X163233954Y-109377580D01* -X163304545Y-109424747D01* -X163382982Y-109457237D01* -X163466250Y-109473800D01* -X164725950Y-109473800D01* -X164833700Y-109366050D01* -X164833700Y-107792800D01* -X164883700Y-107792800D01* -X164883700Y-109366050D01* -X164991450Y-109473800D01* -X166251150Y-109473800D01* -X166334418Y-109457237D01* -X166412855Y-109424747D01* -X166483446Y-109377580D01* -X166543479Y-109317547D01* -X166590647Y-109246955D01* -X166623137Y-109168518D01* -X166639700Y-109085250D01* -X166639700Y-107900550D01* -X166531950Y-107792800D01* -X164883700Y-107792800D01* -X164833700Y-107792800D01* -X163185450Y-107792800D01* -X163077700Y-107900550D01* -X154532800Y-107900550D01* -X154532800Y-107839650D01* -X154516237Y-107756382D01* -X154483747Y-107677945D01* -X154436580Y-107607354D01* -X154376547Y-107547321D01* -X154305955Y-107500153D01* -X154227518Y-107467663D01* -X154144250Y-107451100D01* -X153523350Y-107451100D01* -X153415600Y-107558850D01* -X153365600Y-107558850D01* -X153257850Y-107451100D01* -X152636950Y-107451100D01* -X152553682Y-107467663D01* -X152475245Y-107500153D01* -X152404653Y-107547321D01* -X152344620Y-107607354D01* -X152298801Y-107675927D01* -X152169116Y-107562976D01* -X153267748Y-107047464D01* -X154101800Y-107047464D01* -X154246199Y-107033242D01* -X154385049Y-106991122D01* -X154513013Y-106922724D01* -X154567217Y-106878240D01* -X154959974Y-106873793D01* -X155016198Y-106942302D01* -X155236654Y-107123226D01* -X155488170Y-107257665D01* -X155761082Y-107340451D01* -X155973778Y-107361400D01* -X157538422Y-107361400D01* -X157751118Y-107340451D01* -X158024030Y-107257665D01* -X158275546Y-107123226D01* -X158496002Y-106942302D01* -X158676926Y-106721846D01* -X158811365Y-106470330D01* -X158894151Y-106197418D01* -X158921538Y-105919350D01* -X159093700Y-105919350D01* -X159093700Y-106184650D01* -X159110263Y-106267918D01* -X159142753Y-106346355D01* -X159189920Y-106416946D01* -X159249953Y-106476979D01* -X159320545Y-106524147D01* -X159398982Y-106556637D01* -X159482250Y-106573200D01* -X160103150Y-106573200D01* -X160210900Y-106465450D01* -X160210900Y-105811600D01* -X160260900Y-105811600D01* -X160260900Y-106465450D01* -X160368650Y-106573200D01* -X160989550Y-106573200D01* -X161072818Y-106556637D01* -X161086800Y-106550845D01* -X161100782Y-106556637D01* -X161184050Y-106573200D01* -X161804950Y-106573200D01* -X161912700Y-106465450D01* -X161912700Y-105811600D01* -X161962700Y-105811600D01* -X161962700Y-106465450D01* -X162070450Y-106573200D01* -X162691350Y-106573200D01* -X162774618Y-106556637D01* -X162853055Y-106524147D01* -X162923647Y-106476979D01* -X162950276Y-106450350D01* -X163077700Y-106450350D01* -X163077700Y-107635050D01* -X163185450Y-107742800D01* -X164833700Y-107742800D01* -X164833700Y-106169550D01* -X164883700Y-106169550D01* -X164883700Y-107742800D01* -X166531950Y-107742800D01* -X166639700Y-107635050D01* -X166639700Y-106450350D01* -X166623137Y-106367082D01* -X166590647Y-106288645D01* -X166543479Y-106218053D01* -X166483446Y-106158020D01* -X166412855Y-106110853D01* -X166334418Y-106078363D01* -X166251150Y-106061800D01* -X164991450Y-106061800D01* -X164883700Y-106169550D01* -X164833700Y-106169550D01* -X164725950Y-106061800D01* -X163466250Y-106061800D01* -X163382982Y-106078363D01* -X163304545Y-106110853D01* -X163233954Y-106158020D01* -X163173921Y-106218053D01* -X163126753Y-106288645D01* -X163094263Y-106367082D01* -X163077700Y-106450350D01* -X162950276Y-106450350D01* -X162983680Y-106416946D01* -X163030847Y-106346355D01* -X163063337Y-106267918D01* -X163079900Y-106184650D01* -X163079900Y-105919350D01* -X162972150Y-105811600D01* -X161962700Y-105811600D01* -X161912700Y-105811600D01* -X160260900Y-105811600D01* -X160210900Y-105811600D01* -X159201450Y-105811600D01* -X159093700Y-105919350D01* -X158921538Y-105919350D01* -X158922105Y-105913600D01* -X158894151Y-105629782D01* -X158820975Y-105388550D01* -X159093700Y-105388550D01* -X159093700Y-105653850D01* -X159201450Y-105761600D01* -X160210900Y-105761600D01* -X160210900Y-105107750D01* -X160260900Y-105107750D01* -X160260900Y-105761600D01* -X161912700Y-105761600D01* -X161912700Y-105107750D01* -X161962700Y-105107750D01* -X161962700Y-105761600D01* -X162972150Y-105761600D01* -X163079900Y-105653850D01* -X163079900Y-105388550D01* -X163063337Y-105305282D01* -X163030847Y-105226845D01* -X162983680Y-105156254D01* -X162923647Y-105096221D01* -X162853055Y-105049053D01* -X162774618Y-105016563D01* -X162691350Y-105000000D01* -X162070450Y-105000000D01* -X161962700Y-105107750D01* -X161912700Y-105107750D01* -X161804950Y-105000000D01* -X161184050Y-105000000D01* -X161100782Y-105016563D01* -X161086800Y-105022355D01* -X161072818Y-105016563D01* -X160989550Y-105000000D01* -X160368650Y-105000000D01* -X160260900Y-105107750D01* -X160210900Y-105107750D01* -X160103150Y-105000000D01* -X159482250Y-105000000D01* -X159398982Y-105016563D01* -X159320545Y-105049053D01* -X159249953Y-105096221D01* -X159189920Y-105156254D01* -X159142753Y-105226845D01* -X159110263Y-105305282D01* -X159093700Y-105388550D01* -X158820975Y-105388550D01* -X158811365Y-105356870D01* -X158676926Y-105105354D01* -X158496002Y-104884898D01* -X158275546Y-104703974D01* -X158024030Y-104569535D01* -X157751118Y-104486749D01* -X157538422Y-104465800D01* -X155973778Y-104465800D01* -X155761082Y-104486749D01* -X155488170Y-104569535D01* -X155236654Y-104703974D01* -X155016198Y-104884898D01* -X154926287Y-104994455D01* -X154535197Y-104998882D01* -X154513013Y-104980676D01* -X154385049Y-104912278D01* -X154246199Y-104870158D01* -X154101800Y-104855936D01* -X152679400Y-104855936D01* -X152535001Y-104870158D01* -X152525131Y-104873152D01* -X154077647Y-103425065D01* -X158539278Y-103433086D01* -G36* -X129146300Y-89326536D02* -X129143778Y-89341809D01* -X129146300Y-89418926D01* -X129146300Y-89449766D01* -X129147810Y-89465098D01* -X129149829Y-89526833D01* -X129156861Y-89556995D01* -X129159898Y-89587832D01* -X129177837Y-89646967D01* -X129191861Y-89707123D01* -X129204643Y-89735337D01* -X129213637Y-89764985D01* -X129242761Y-89819472D01* -X129268257Y-89875749D01* -X129286301Y-89900930D01* -X129300904Y-89928251D01* -X129340106Y-89976019D01* -X129349064Y-89988520D01* -X129369360Y-90011664D01* -X129418346Y-90071354D01* -X129430321Y-90081182D01* -X137795936Y-99620920D01* -X137795936Y-99809792D01* -X134205295Y-96383190D01* -X134182854Y-96355846D01* -X134138490Y-96319437D01* -X134130528Y-96311839D01* -X134102817Y-96290161D01* -X134039751Y-96238404D01* -X134029978Y-96233180D01* -X134021257Y-96226358D01* -X133948462Y-96189609D01* -X133876486Y-96151137D01* -X133865882Y-96147920D01* -X133855997Y-96142930D01* -X133777424Y-96121087D01* -X133699333Y-96097398D01* -X133688306Y-96096312D01* -X133677637Y-96093346D01* -X133596317Y-96087252D01* -X133561267Y-96083800D01* -X133550252Y-96083800D01* -X133493031Y-96079512D01* -X133457925Y-96083800D01* -X126333239Y-96083800D01* -X126268786Y-95987340D01* -X126042360Y-95760914D01* -X125776111Y-95583012D01* -X125480270Y-95460470D01* -X125166208Y-95398000D01* -X124845992Y-95398000D01* -X124531930Y-95460470D01* -X124236089Y-95583012D01* -X123969840Y-95760914D01* -X123743414Y-95987340D01* -X123565512Y-96253589D01* -X123442970Y-96549430D01* -X123380500Y-96863492D01* -X123380500Y-97183708D01* -X123442970Y-97497770D01* -X123565512Y-97793611D01* -X123743414Y-98059860D01* -X123969840Y-98286286D01* -X123980786Y-98293600D01* -X123969840Y-98300914D01* -X123743414Y-98527340D01* -X123565512Y-98793589D01* -X123442970Y-99089430D01* -X123380500Y-99403492D01* -X123380500Y-99723708D01* -X123442970Y-100037770D01* -X123565512Y-100333611D01* -X123743414Y-100599860D01* -X123969840Y-100826286D01* -X123980786Y-100833600D01* -X123969840Y-100840914D01* -X123743414Y-101067340D01* -X123565512Y-101333589D01* -X123442970Y-101629430D01* -X123380500Y-101943492D01* -X123380500Y-102263708D01* -X123442970Y-102577770D01* -X123565512Y-102873611D01* -X123743414Y-103139860D01* -X123969840Y-103366286D01* -X123980786Y-103373600D01* -X123969840Y-103380914D01* -X123743414Y-103607340D01* -X123565512Y-103873589D01* -X123442970Y-104169430D01* -X123380500Y-104483492D01* -X123380500Y-104803708D01* -X123442970Y-105117770D01* -X123565512Y-105413611D01* -X123743414Y-105679860D01* -X123969840Y-105906286D01* -X123980786Y-105913600D01* -X123969840Y-105920914D01* -X123743414Y-106147340D01* -X123565512Y-106413589D01* -X123442970Y-106709430D01* -X123380500Y-107023492D01* -X123380500Y-107343708D01* -X123442970Y-107657770D01* -X123565512Y-107953611D01* -X123743414Y-108219860D01* -X123969840Y-108446286D01* -X124236089Y-108624188D01* -X124253659Y-108631466D01* -X124246833Y-108636027D01* -X124162252Y-108844397D01* -X125006100Y-109688245D01* -X125849948Y-108844397D01* -X125765367Y-108636027D01* -X125757791Y-108631776D01* -X125776111Y-108624188D01* -X126042360Y-108446286D01* -X126268786Y-108219860D01* -X126269485Y-108218813D01* -X126274870Y-108226872D01* -X126502828Y-108454830D01* -X126770879Y-108633936D01* -X127068721Y-108757307D01* -X127384909Y-108820200D01* -X127707291Y-108820200D01* -X128023479Y-108757307D01* -X128062132Y-108741296D01* -X128008356Y-108880500D01* -X128816100Y-109688245D01* -X128830243Y-109674103D01* -X128865598Y-109709458D01* -X128851455Y-109723600D01* -X129659200Y-110531344D01* -X129862369Y-110452858D01* -X129984537Y-110234729D01* -X130027398Y-110102831D01* -X130155867Y-110141802D01* -X130293933Y-110155400D01* -X130293942Y-110155400D01* -X130340099Y-110159946D01* -X130386256Y-110155400D01* -X131915309Y-110155400D01* -X130950728Y-113352236D01* -X130289300Y-113352236D01* -X130144901Y-113366458D01* -X130006051Y-113408578D01* -X129878087Y-113476976D01* -X129765925Y-113569025D01* -X129673876Y-113681187D01* -X129605478Y-113809151D01* -X129563358Y-113948001D01* -X129549136Y-114092400D01* -X129549136Y-115514800D01* -X129563358Y-115659199D01* -X129605478Y-115798049D01* -X129673876Y-115926013D01* -X129765925Y-116038175D01* -X129878087Y-116130224D01* -X129938244Y-116162379D01* -X129696824Y-116403800D01* -X128886468Y-116403800D01* -X128817330Y-116300328D01* -X128766814Y-116249812D01* -X128858899Y-116240742D01* -X128997749Y-116198622D01* -X129125713Y-116130224D01* -X129237875Y-116038175D01* -X129329924Y-115926013D01* -X129398322Y-115798049D01* -X129440442Y-115659199D01* -X129454664Y-115514800D01* -X129454664Y-114092400D01* -X129450121Y-114046276D01* -X129516397Y-113678079D01* -X129562048Y-113659170D01* -X129819977Y-113486827D01* -X130039327Y-113267477D01* -X130211670Y-113009548D01* -X130330382Y-112722952D01* -X130390900Y-112418704D01* -X130390900Y-112108496D01* -X130330382Y-111804248D01* -X130211670Y-111517652D01* -X130039327Y-111259723D01* -X129819977Y-111040373D01* -X129562048Y-110868030D01* -X129453738Y-110823167D01* -X129503652Y-110797736D01* -X129545358Y-110769869D01* -X129623844Y-110566700D01* -X128816100Y-109758955D01* -X128008356Y-110566700D01* -X128086842Y-110769869D01* -X128180498Y-110822323D01* -X128070152Y-110868030D01* -X127812223Y-111040373D01* -X127592873Y-111259723D01* -X127420530Y-111517652D01* -X127301818Y-111804248D01* -X127241300Y-112108496D01* -X127241300Y-112418704D01* -X127301818Y-112722952D01* -X127420530Y-113009548D01* -X127592873Y-113267477D01* -X127667133Y-113341737D01* -X127648187Y-113446990D01* -X127592087Y-113476976D01* -X127479925Y-113569025D01* -X127387876Y-113681187D01* -X127319478Y-113809151D01* -X127277358Y-113948001D01* -X127263136Y-114092400D01* -X127263136Y-115514800D01* -X127277358Y-115659199D01* -X127297153Y-115724455D01* -X127068721Y-115769893D01* -X126770879Y-115893264D01* -X126502828Y-116072370D01* -X126274870Y-116300328D01* -X126269485Y-116308387D01* -X126268786Y-116307340D01* -X126042360Y-116080914D01* -X126031414Y-116073600D01* -X126042360Y-116066286D01* -X126268786Y-115839860D01* -X126446688Y-115573611D01* -X126569230Y-115277770D01* -X126631700Y-114963708D01* -X126631700Y-114643492D01* -X126569230Y-114329430D01* -X126446688Y-114033589D01* -X126268786Y-113767340D01* -X126042360Y-113540914D01* -X126031414Y-113533600D01* -X126042360Y-113526286D01* -X126268786Y-113299860D01* -X126446688Y-113033611D01* -X126569230Y-112737770D01* -X126631700Y-112423708D01* -X126631700Y-112103492D01* -X126569230Y-111789430D01* -X126446688Y-111493589D01* -X126268786Y-111227340D01* -X126042360Y-111000914D01* -X125776111Y-110823012D01* -X125758541Y-110815734D01* -X125765367Y-110811173D01* -X125849948Y-110602803D01* -X125006100Y-109758955D01* -X124162252Y-110602803D01* -X124246833Y-110811173D01* -X124254409Y-110815424D01* -X124236089Y-110823012D01* -X123969840Y-111000914D01* -X123743414Y-111227340D01* -X123565512Y-111493589D01* -X123442970Y-111789430D01* -X123380500Y-112103492D01* -X123380500Y-112423708D01* -X123442970Y-112737770D01* -X123565512Y-113033611D01* -X123743414Y-113299860D01* -X123969840Y-113526286D01* -X123980786Y-113533600D01* -X123969840Y-113540914D01* -X123743414Y-113767340D01* -X123565512Y-114033589D01* -X123442970Y-114329430D01* -X123380500Y-114643492D01* -X123380500Y-114963708D01* -X123442970Y-115277770D01* -X123565512Y-115573611D01* -X123743414Y-115839860D01* -X123969840Y-116066286D01* -X123980786Y-116073600D01* -X123969840Y-116080914D01* -X123743414Y-116307340D01* -X123565512Y-116573589D01* -X123442970Y-116869430D01* -X123380500Y-117183492D01* -X123380500Y-117503708D01* -X123442970Y-117817770D01* -X123565512Y-118113611D01* -X123743414Y-118379860D01* -X123969840Y-118606286D01* -X124236089Y-118784188D01* -X124531930Y-118906730D01* -X124845992Y-118969200D01* -X125166208Y-118969200D01* -X125480270Y-118906730D01* -X125776111Y-118784188D01* -X126042360Y-118606286D01* -X126268786Y-118379860D01* -X126269485Y-118378813D01* -X126274870Y-118386872D01* -X126502828Y-118614830D01* -X126770879Y-118793936D01* -X127068721Y-118917307D01* -X127384909Y-118980200D01* -X127707291Y-118980200D01* -X128023479Y-118917307D01* -X128321321Y-118793936D01* -X128589372Y-118614830D01* -X128817330Y-118386872D01* -X128886468Y-118283400D01* -X130039943Y-118283400D01* -X130086100Y-118287946D01* -X130132257Y-118283400D01* -X130132267Y-118283400D01* -X130270333Y-118269802D01* -X130447486Y-118216063D01* -X130610751Y-118128796D01* -X130753854Y-118011354D01* -X130783291Y-117975485D01* -X131911795Y-116846982D01* -X131947654Y-116817554D01* -X131991915Y-116763622D01* -X132065096Y-116674452D01* -X132142803Y-116529071D01* -X132152363Y-116511186D01* -X132206102Y-116334033D01* -X132219700Y-116195967D01* -X132219700Y-116195958D01* -X132224246Y-116149801D01* -X132219700Y-116103644D01* -X132219700Y-115653471D01* -X132382633Y-115113383D01* -X132409101Y-115026132D01* -X132409170Y-115025436D01* -X133564625Y-111196000D01* -X134017350Y-111196000D01* -X134125100Y-111088250D01* -X134125100Y-110561800D01* -X134175100Y-110561800D01* -X134175100Y-111088250D01* -X134282850Y-111196000D01* -X134903750Y-111196000D01* -X134987018Y-111179437D01* -X135065455Y-111146947D01* -X135136047Y-111099779D01* -X135196080Y-111039746D01* -X135243247Y-110969155D01* -X135275737Y-110890718D01* -X135292300Y-110807450D01* -X135292300Y-110575500D01* -X135675391Y-110641483D01* -X135712725Y-110686975D01* -X135824887Y-110779024D01* -X135952851Y-110847422D01* -X136091701Y-110889542D01* -X136236100Y-110903764D01* -X137736100Y-110903764D01* -X137802473Y-110897227D01* -X137795936Y-110963600D01* -X137795936Y-112329684D01* -X131173943Y-119880224D01* -X131159080Y-119895462D01* -X131143519Y-119914914D01* -X131127097Y-119933638D01* -X131114699Y-119950938D01* -X130646747Y-120535878D01* -X130610071Y-120574608D01* -X130564414Y-120647137D01* -X130517769Y-120718869D01* -X130497981Y-120768380D01* -X129469190Y-122825964D01* -X129377977Y-122367406D01* -X129035245Y-121539977D01* -X128537675Y-120795311D01* -X127904389Y-120162025D01* -X127159723Y-119664455D01* -X126332294Y-119321723D01* -X125453901Y-119147000D01* -X124558299Y-119147000D01* -X123679906Y-119321723D01* -X122852477Y-119664455D01* -X122107811Y-120162025D01* -X122007700Y-120262136D01* -X122007700Y-109696516D01* -X123679991Y-109696516D01* -X123700188Y-109955748D01* -X123770570Y-110206058D01* -X123888434Y-110437828D01* -X123918527Y-110482867D01* -X124126897Y-110567448D01* -X124970745Y-109723600D01* -X125041455Y-109723600D01* -X125885303Y-110567448D01* -X126093673Y-110482867D01* -X126220901Y-110256102D01* -X126301445Y-110008874D01* -X126332209Y-109750684D01* -X126328145Y-109698520D01* -X127541004Y-109698520D01* -X127560612Y-109947761D01* -X127628468Y-110188388D01* -X127741964Y-110411152D01* -X127769831Y-110452858D01* -X127973000Y-110531344D01* -X128780745Y-109723600D01* -X127973000Y-108915856D01* -X127769831Y-108994342D01* -X127647663Y-109212471D01* -X127570398Y-109450243D01* -X127541004Y-109698520D01* -X126328145Y-109698520D01* -X126312012Y-109491452D01* -X126241630Y-109241142D01* -X126123766Y-109009372D01* -X126093673Y-108964333D01* -X125885303Y-108879752D01* -X125041455Y-109723600D01* -X124970745Y-109723600D01* -X124126897Y-108879752D01* -X123918527Y-108964333D01* -X123791299Y-109191098D01* -X123710755Y-109438326D01* -X123679991Y-109696516D01* -X122007700Y-109696516D01* -X122007700Y-89761664D01* -X122107811Y-89861775D01* -X122852477Y-90359345D01* -X123679906Y-90702077D01* -X124558299Y-90876800D01* -X125453901Y-90876800D01* -X126332294Y-90702077D01* -X127159723Y-90359345D01* -X127904389Y-89861775D01* -X128537675Y-89228489D01* -X129035245Y-88483823D01* -X129146300Y-88215711D01* -X129146300Y-89326536D01* -X129146300Y-89326536D01* -G37* -X129146300Y-89326536D02* -X129143778Y-89341809D01* -X129146300Y-89418926D01* -X129146300Y-89449766D01* -X129147810Y-89465098D01* -X129149829Y-89526833D01* -X129156861Y-89556995D01* -X129159898Y-89587832D01* -X129177837Y-89646967D01* -X129191861Y-89707123D01* -X129204643Y-89735337D01* -X129213637Y-89764985D01* -X129242761Y-89819472D01* -X129268257Y-89875749D01* -X129286301Y-89900930D01* -X129300904Y-89928251D01* -X129340106Y-89976019D01* -X129349064Y-89988520D01* -X129369360Y-90011664D01* -X129418346Y-90071354D01* -X129430321Y-90081182D01* -X137795936Y-99620920D01* -X137795936Y-99809792D01* -X134205295Y-96383190D01* -X134182854Y-96355846D01* -X134138490Y-96319437D01* -X134130528Y-96311839D01* -X134102817Y-96290161D01* -X134039751Y-96238404D01* -X134029978Y-96233180D01* -X134021257Y-96226358D01* -X133948462Y-96189609D01* -X133876486Y-96151137D01* -X133865882Y-96147920D01* -X133855997Y-96142930D01* -X133777424Y-96121087D01* -X133699333Y-96097398D01* -X133688306Y-96096312D01* -X133677637Y-96093346D01* -X133596317Y-96087252D01* -X133561267Y-96083800D01* -X133550252Y-96083800D01* -X133493031Y-96079512D01* -X133457925Y-96083800D01* -X126333239Y-96083800D01* -X126268786Y-95987340D01* -X126042360Y-95760914D01* -X125776111Y-95583012D01* -X125480270Y-95460470D01* -X125166208Y-95398000D01* -X124845992Y-95398000D01* -X124531930Y-95460470D01* -X124236089Y-95583012D01* -X123969840Y-95760914D01* -X123743414Y-95987340D01* -X123565512Y-96253589D01* -X123442970Y-96549430D01* -X123380500Y-96863492D01* -X123380500Y-97183708D01* -X123442970Y-97497770D01* -X123565512Y-97793611D01* -X123743414Y-98059860D01* -X123969840Y-98286286D01* -X123980786Y-98293600D01* -X123969840Y-98300914D01* -X123743414Y-98527340D01* -X123565512Y-98793589D01* -X123442970Y-99089430D01* -X123380500Y-99403492D01* -X123380500Y-99723708D01* -X123442970Y-100037770D01* -X123565512Y-100333611D01* -X123743414Y-100599860D01* -X123969840Y-100826286D01* -X123980786Y-100833600D01* -X123969840Y-100840914D01* -X123743414Y-101067340D01* -X123565512Y-101333589D01* -X123442970Y-101629430D01* -X123380500Y-101943492D01* -X123380500Y-102263708D01* -X123442970Y-102577770D01* -X123565512Y-102873611D01* -X123743414Y-103139860D01* -X123969840Y-103366286D01* -X123980786Y-103373600D01* -X123969840Y-103380914D01* -X123743414Y-103607340D01* -X123565512Y-103873589D01* -X123442970Y-104169430D01* -X123380500Y-104483492D01* -X123380500Y-104803708D01* -X123442970Y-105117770D01* -X123565512Y-105413611D01* -X123743414Y-105679860D01* -X123969840Y-105906286D01* -X123980786Y-105913600D01* -X123969840Y-105920914D01* -X123743414Y-106147340D01* -X123565512Y-106413589D01* -X123442970Y-106709430D01* -X123380500Y-107023492D01* -X123380500Y-107343708D01* -X123442970Y-107657770D01* -X123565512Y-107953611D01* -X123743414Y-108219860D01* -X123969840Y-108446286D01* -X124236089Y-108624188D01* -X124253659Y-108631466D01* -X124246833Y-108636027D01* -X124162252Y-108844397D01* -X125006100Y-109688245D01* -X125849948Y-108844397D01* -X125765367Y-108636027D01* -X125757791Y-108631776D01* -X125776111Y-108624188D01* -X126042360Y-108446286D01* -X126268786Y-108219860D01* -X126269485Y-108218813D01* -X126274870Y-108226872D01* -X126502828Y-108454830D01* -X126770879Y-108633936D01* -X127068721Y-108757307D01* -X127384909Y-108820200D01* -X127707291Y-108820200D01* -X128023479Y-108757307D01* -X128062132Y-108741296D01* -X128008356Y-108880500D01* -X128816100Y-109688245D01* -X128830243Y-109674103D01* -X128865598Y-109709458D01* -X128851455Y-109723600D01* -X129659200Y-110531344D01* -X129862369Y-110452858D01* -X129984537Y-110234729D01* -X130027398Y-110102831D01* -X130155867Y-110141802D01* -X130293933Y-110155400D01* -X130293942Y-110155400D01* -X130340099Y-110159946D01* -X130386256Y-110155400D01* -X131915309Y-110155400D01* -X130950728Y-113352236D01* -X130289300Y-113352236D01* -X130144901Y-113366458D01* -X130006051Y-113408578D01* -X129878087Y-113476976D01* -X129765925Y-113569025D01* -X129673876Y-113681187D01* -X129605478Y-113809151D01* -X129563358Y-113948001D01* -X129549136Y-114092400D01* -X129549136Y-115514800D01* -X129563358Y-115659199D01* -X129605478Y-115798049D01* -X129673876Y-115926013D01* -X129765925Y-116038175D01* -X129878087Y-116130224D01* -X129938244Y-116162379D01* -X129696824Y-116403800D01* -X128886468Y-116403800D01* -X128817330Y-116300328D01* -X128766814Y-116249812D01* -X128858899Y-116240742D01* -X128997749Y-116198622D01* -X129125713Y-116130224D01* -X129237875Y-116038175D01* -X129329924Y-115926013D01* -X129398322Y-115798049D01* -X129440442Y-115659199D01* -X129454664Y-115514800D01* -X129454664Y-114092400D01* -X129450121Y-114046276D01* -X129516397Y-113678079D01* -X129562048Y-113659170D01* -X129819977Y-113486827D01* -X130039327Y-113267477D01* -X130211670Y-113009548D01* -X130330382Y-112722952D01* -X130390900Y-112418704D01* -X130390900Y-112108496D01* -X130330382Y-111804248D01* -X130211670Y-111517652D01* -X130039327Y-111259723D01* -X129819977Y-111040373D01* -X129562048Y-110868030D01* -X129453738Y-110823167D01* -X129503652Y-110797736D01* -X129545358Y-110769869D01* -X129623844Y-110566700D01* -X128816100Y-109758955D01* -X128008356Y-110566700D01* -X128086842Y-110769869D01* -X128180498Y-110822323D01* -X128070152Y-110868030D01* -X127812223Y-111040373D01* -X127592873Y-111259723D01* -X127420530Y-111517652D01* -X127301818Y-111804248D01* -X127241300Y-112108496D01* -X127241300Y-112418704D01* -X127301818Y-112722952D01* -X127420530Y-113009548D01* -X127592873Y-113267477D01* -X127667133Y-113341737D01* -X127648187Y-113446990D01* -X127592087Y-113476976D01* -X127479925Y-113569025D01* -X127387876Y-113681187D01* -X127319478Y-113809151D01* -X127277358Y-113948001D01* -X127263136Y-114092400D01* -X127263136Y-115514800D01* -X127277358Y-115659199D01* -X127297153Y-115724455D01* -X127068721Y-115769893D01* -X126770879Y-115893264D01* -X126502828Y-116072370D01* -X126274870Y-116300328D01* -X126269485Y-116308387D01* -X126268786Y-116307340D01* -X126042360Y-116080914D01* -X126031414Y-116073600D01* -X126042360Y-116066286D01* -X126268786Y-115839860D01* -X126446688Y-115573611D01* -X126569230Y-115277770D01* -X126631700Y-114963708D01* -X126631700Y-114643492D01* -X126569230Y-114329430D01* -X126446688Y-114033589D01* -X126268786Y-113767340D01* -X126042360Y-113540914D01* -X126031414Y-113533600D01* -X126042360Y-113526286D01* -X126268786Y-113299860D01* -X126446688Y-113033611D01* -X126569230Y-112737770D01* -X126631700Y-112423708D01* -X126631700Y-112103492D01* -X126569230Y-111789430D01* -X126446688Y-111493589D01* -X126268786Y-111227340D01* -X126042360Y-111000914D01* -X125776111Y-110823012D01* -X125758541Y-110815734D01* -X125765367Y-110811173D01* -X125849948Y-110602803D01* -X125006100Y-109758955D01* -X124162252Y-110602803D01* -X124246833Y-110811173D01* -X124254409Y-110815424D01* -X124236089Y-110823012D01* -X123969840Y-111000914D01* -X123743414Y-111227340D01* -X123565512Y-111493589D01* -X123442970Y-111789430D01* -X123380500Y-112103492D01* -X123380500Y-112423708D01* -X123442970Y-112737770D01* -X123565512Y-113033611D01* -X123743414Y-113299860D01* -X123969840Y-113526286D01* -X123980786Y-113533600D01* -X123969840Y-113540914D01* -X123743414Y-113767340D01* -X123565512Y-114033589D01* -X123442970Y-114329430D01* -X123380500Y-114643492D01* -X123380500Y-114963708D01* -X123442970Y-115277770D01* -X123565512Y-115573611D01* -X123743414Y-115839860D01* -X123969840Y-116066286D01* -X123980786Y-116073600D01* -X123969840Y-116080914D01* -X123743414Y-116307340D01* -X123565512Y-116573589D01* -X123442970Y-116869430D01* -X123380500Y-117183492D01* -X123380500Y-117503708D01* -X123442970Y-117817770D01* -X123565512Y-118113611D01* -X123743414Y-118379860D01* -X123969840Y-118606286D01* -X124236089Y-118784188D01* -X124531930Y-118906730D01* -X124845992Y-118969200D01* -X125166208Y-118969200D01* -X125480270Y-118906730D01* -X125776111Y-118784188D01* -X126042360Y-118606286D01* -X126268786Y-118379860D01* -X126269485Y-118378813D01* -X126274870Y-118386872D01* -X126502828Y-118614830D01* -X126770879Y-118793936D01* -X127068721Y-118917307D01* -X127384909Y-118980200D01* -X127707291Y-118980200D01* -X128023479Y-118917307D01* -X128321321Y-118793936D01* -X128589372Y-118614830D01* -X128817330Y-118386872D01* -X128886468Y-118283400D01* -X130039943Y-118283400D01* -X130086100Y-118287946D01* -X130132257Y-118283400D01* -X130132267Y-118283400D01* -X130270333Y-118269802D01* -X130447486Y-118216063D01* -X130610751Y-118128796D01* -X130753854Y-118011354D01* -X130783291Y-117975485D01* -X131911795Y-116846982D01* -X131947654Y-116817554D01* -X131991915Y-116763622D01* -X132065096Y-116674452D01* -X132142803Y-116529071D01* -X132152363Y-116511186D01* -X132206102Y-116334033D01* -X132219700Y-116195967D01* -X132219700Y-116195958D01* -X132224246Y-116149801D01* -X132219700Y-116103644D01* -X132219700Y-115653471D01* -X132382633Y-115113383D01* -X132409101Y-115026132D01* -X132409170Y-115025436D01* -X133564625Y-111196000D01* -X134017350Y-111196000D01* -X134125100Y-111088250D01* -X134125100Y-110561800D01* -X134175100Y-110561800D01* -X134175100Y-111088250D01* -X134282850Y-111196000D01* -X134903750Y-111196000D01* -X134987018Y-111179437D01* -X135065455Y-111146947D01* -X135136047Y-111099779D01* -X135196080Y-111039746D01* -X135243247Y-110969155D01* -X135275737Y-110890718D01* -X135292300Y-110807450D01* -X135292300Y-110575500D01* -X135675391Y-110641483D01* -X135712725Y-110686975D01* -X135824887Y-110779024D01* -X135952851Y-110847422D01* -X136091701Y-110889542D01* -X136236100Y-110903764D01* -X137736100Y-110903764D01* -X137802473Y-110897227D01* -X137795936Y-110963600D01* -X137795936Y-112329684D01* -X131173943Y-119880224D01* -X131159080Y-119895462D01* -X131143519Y-119914914D01* -X131127097Y-119933638D01* -X131114699Y-119950938D01* -X130646747Y-120535878D01* -X130610071Y-120574608D01* -X130564414Y-120647137D01* -X130517769Y-120718869D01* -X130497981Y-120768380D01* -X129469190Y-122825964D01* -X129377977Y-122367406D01* -X129035245Y-121539977D01* -X128537675Y-120795311D01* -X127904389Y-120162025D01* -X127159723Y-119664455D01* -X126332294Y-119321723D01* -X125453901Y-119147000D01* -X124558299Y-119147000D01* -X123679906Y-119321723D01* -X122852477Y-119664455D01* -X122107811Y-120162025D01* -X122007700Y-120262136D01* -X122007700Y-109696516D01* -X123679991Y-109696516D01* -X123700188Y-109955748D01* -X123770570Y-110206058D01* -X123888434Y-110437828D01* -X123918527Y-110482867D01* -X124126897Y-110567448D01* -X124970745Y-109723600D01* -X125041455Y-109723600D01* -X125885303Y-110567448D01* -X126093673Y-110482867D01* -X126220901Y-110256102D01* -X126301445Y-110008874D01* -X126332209Y-109750684D01* -X126328145Y-109698520D01* -X127541004Y-109698520D01* -X127560612Y-109947761D01* -X127628468Y-110188388D01* -X127741964Y-110411152D01* -X127769831Y-110452858D01* -X127973000Y-110531344D01* -X128780745Y-109723600D01* -X127973000Y-108915856D01* -X127769831Y-108994342D01* -X127647663Y-109212471D01* -X127570398Y-109450243D01* -X127541004Y-109698520D01* -X126328145Y-109698520D01* -X126312012Y-109491452D01* -X126241630Y-109241142D01* -X126123766Y-109009372D01* -X126093673Y-108964333D01* -X125885303Y-108879752D01* -X125041455Y-109723600D01* -X124970745Y-109723600D01* -X124126897Y-108879752D01* -X123918527Y-108964333D01* -X123791299Y-109191098D01* -X123710755Y-109438326D01* -X123679991Y-109696516D01* -X122007700Y-109696516D01* -X122007700Y-89761664D01* -X122107811Y-89861775D01* -X122852477Y-90359345D01* -X123679906Y-90702077D01* -X124558299Y-90876800D01* -X125453901Y-90876800D01* -X126332294Y-90702077D01* -X127159723Y-90359345D01* -X127904389Y-89861775D01* -X128537675Y-89228489D01* -X129035245Y-88483823D01* -X129146300Y-88215711D01* -X129146300Y-89326536D01* -G36* -X147836100Y-110903764D02* -X148615482Y-110903764D01* -X148969415Y-111010145D01* -X150460702Y-114222148D01* -X150431100Y-114251750D01* -X150431100Y-114905600D01* -X150451100Y-114905600D01* -X150451100Y-114955600D01* -X150431100Y-114955600D01* -X150431100Y-115609450D01* -X150538850Y-115717200D01* -X151154833Y-115717200D01* -X151363123Y-116165825D01* -X151261699Y-116135058D01* -X151117300Y-116120836D01* -X149694900Y-116120836D01* -X149550501Y-116135058D01* -X149411651Y-116177178D01* -X149283687Y-116245576D01* -X149171525Y-116337625D01* -X149142859Y-116372555D01* -X148656379Y-115063350D01* -X149263900Y-115063350D01* -X149263900Y-115328650D01* -X149280463Y-115411918D01* -X149312953Y-115490355D01* -X149360120Y-115560946D01* -X149420153Y-115620979D01* -X149490745Y-115668147D01* -X149569182Y-115700637D01* -X149652450Y-115717200D01* -X150273350Y-115717200D01* -X150381100Y-115609450D01* -X150381100Y-114955600D01* -X149371650Y-114955600D01* -X149263900Y-115063350D01* -X148656379Y-115063350D01* -X148459142Y-114532550D01* -X149263900Y-114532550D01* -X149263900Y-114797850D01* -X149371650Y-114905600D01* -X150381100Y-114905600D01* -X150381100Y-114251750D01* -X150273350Y-114144000D01* -X149652450Y-114144000D01* -X149569182Y-114160563D01* -X149490745Y-114193053D01* -X149420153Y-114240221D01* -X149360120Y-114300254D01* -X149312953Y-114370845D01* -X149280463Y-114449282D01* -X149263900Y-114532550D01* -X148459142Y-114532550D01* -X147753936Y-112634721D01* -X147762042Y-112607999D01* -X147776264Y-112463600D01* -X147776264Y-110963600D01* -X147769727Y-110897227D01* -X147836100Y-110903764D01* -X147836100Y-110903764D01* -G37* -X147836100Y-110903764D02* -X148615482Y-110903764D01* -X148969415Y-111010145D01* -X150460702Y-114222148D01* -X150431100Y-114251750D01* -X150431100Y-114905600D01* -X150451100Y-114905600D01* -X150451100Y-114955600D01* -X150431100Y-114955600D01* -X150431100Y-115609450D01* -X150538850Y-115717200D01* -X151154833Y-115717200D01* -X151363123Y-116165825D01* -X151261699Y-116135058D01* -X151117300Y-116120836D01* -X149694900Y-116120836D01* -X149550501Y-116135058D01* -X149411651Y-116177178D01* -X149283687Y-116245576D01* -X149171525Y-116337625D01* -X149142859Y-116372555D01* -X148656379Y-115063350D01* -X149263900Y-115063350D01* -X149263900Y-115328650D01* -X149280463Y-115411918D01* -X149312953Y-115490355D01* -X149360120Y-115560946D01* -X149420153Y-115620979D01* -X149490745Y-115668147D01* -X149569182Y-115700637D01* -X149652450Y-115717200D01* -X150273350Y-115717200D01* -X150381100Y-115609450D01* -X150381100Y-114955600D01* -X149371650Y-114955600D01* -X149263900Y-115063350D01* -X148656379Y-115063350D01* -X148459142Y-114532550D01* -X149263900Y-114532550D01* -X149263900Y-114797850D01* -X149371650Y-114905600D01* -X150381100Y-114905600D01* -X150381100Y-114251750D01* -X150273350Y-114144000D01* -X149652450Y-114144000D01* -X149569182Y-114160563D01* -X149490745Y-114193053D01* -X149420153Y-114240221D01* -X149360120Y-114300254D01* -X149312953Y-114370845D01* -X149280463Y-114449282D01* -X149263900Y-114532550D01* -X148459142Y-114532550D01* -X147753936Y-112634721D01* -X147762042Y-112607999D01* -X147776264Y-112463600D01* -X147776264Y-110963600D01* -X147769727Y-110897227D01* -X147836100Y-110903764D01* -G36* -X142000904Y-114121751D02* -X142109849Y-114254501D01* -X142049100Y-114315250D01* -X142049100Y-114969100D01* -X142069100Y-114969100D01* -X142069100Y-115019100D01* -X142049100Y-115019100D01* -X142049100Y-115672950D01* -X142156850Y-115780700D01* -X142379700Y-115780700D01* -X142379700Y-116184336D01* -X142355730Y-116184336D01* -X142311092Y-116168005D01* -X142088618Y-116133384D01* -X141863666Y-116142831D01* -X141692817Y-116184336D01* -X141312900Y-116184336D01* -X141209421Y-116194528D01* -X141348054Y-115780700D01* -X141891350Y-115780700D01* -X141999100Y-115672950D01* -X141999100Y-115019100D01* -X141979100Y-115019100D01* -X141979100Y-114969100D01* -X141999100Y-114969100D01* -X141999100Y-114315250D01* -X141891350Y-114207500D01* -X141875075Y-114207500D01* -X141941213Y-114010076D01* -X142000904Y-114121751D01* -X142000904Y-114121751D01* -G37* -X142000904Y-114121751D02* -X142109849Y-114254501D01* -X142049100Y-114315250D01* -X142049100Y-114969100D01* -X142069100Y-114969100D01* -X142069100Y-115019100D01* -X142049100Y-115019100D01* -X142049100Y-115672950D01* -X142156850Y-115780700D01* -X142379700Y-115780700D01* -X142379700Y-116184336D01* -X142355730Y-116184336D01* -X142311092Y-116168005D01* -X142088618Y-116133384D01* -X141863666Y-116142831D01* -X141692817Y-116184336D01* -X141312900Y-116184336D01* -X141209421Y-116194528D01* -X141348054Y-115780700D01* -X141891350Y-115780700D01* -X141999100Y-115672950D01* -X141999100Y-115019100D01* -X141979100Y-115019100D01* -X141979100Y-114969100D01* -X141999100Y-114969100D01* -X141999100Y-114315250D01* -X141891350Y-114207500D01* -X141875075Y-114207500D01* -X141941213Y-114010076D01* -X142000904Y-114121751D01* -G36* -X142812725Y-101386975D02* -X142924887Y-101479024D01* -X143052851Y-101547422D01* -X143191701Y-101589542D01* -X143336100Y-101603764D01* -X143836100Y-101603764D01* -X143980499Y-101589542D01* -X143986100Y-101587843D01* -X143991701Y-101589542D01* -X144136100Y-101603764D01* -X144636100Y-101603764D01* -X144780499Y-101589542D01* -X144786100Y-101587843D01* -X144791701Y-101589542D01* -X144936100Y-101603764D01* -X145436100Y-101603764D01* -X145580499Y-101589542D01* -X145586100Y-101587843D01* -X145591701Y-101589542D01* -X145736100Y-101603764D01* -X146236100Y-101603764D01* -X146380499Y-101589542D01* -X146386100Y-101587843D01* -X146391701Y-101589542D01* -X146536100Y-101603764D01* -X147036100Y-101603764D01* -X147102473Y-101597227D01* -X147095936Y-101663600D01* -X147095936Y-102163600D01* -X147110158Y-102307999D01* -X147111857Y-102313600D01* -X147110158Y-102319201D01* -X147095936Y-102463600D01* -X147095936Y-102963600D01* -X147110158Y-103107999D01* -X147111857Y-103113600D01* -X147110158Y-103119201D01* -X147095936Y-103263600D01* -X147095936Y-103763600D01* -X147110158Y-103907999D01* -X147111857Y-103913600D01* -X147110158Y-103919201D01* -X147095936Y-104063600D01* -X147095936Y-104563600D01* -X147110158Y-104707999D01* -X147111857Y-104713600D01* -X147110158Y-104719201D01* -X147095936Y-104863600D01* -X147095936Y-105363600D01* -X147110158Y-105507999D01* -X147152278Y-105646849D01* -X147220676Y-105774813D01* -X147312725Y-105886975D01* -X147345168Y-105913600D01* -X147312725Y-105940225D01* -X147220676Y-106052387D01* -X147152278Y-106180351D01* -X147110158Y-106319201D01* -X147095936Y-106463600D01* -X147095936Y-106963600D01* -X147110158Y-107107999D01* -X147111857Y-107113600D01* -X147110158Y-107119201D01* -X147095936Y-107263600D01* -X147095936Y-107763600D01* -X147110158Y-107907999D01* -X147111857Y-107913600D01* -X147110158Y-107919201D01* -X147095936Y-108063600D01* -X147095936Y-108563600D01* -X147110158Y-108707999D01* -X147111857Y-108713600D01* -X147110158Y-108719201D01* -X147095936Y-108863600D01* -X147095936Y-109363600D01* -X147110158Y-109507999D01* -X147111857Y-109513600D01* -X147110158Y-109519201D01* -X147095936Y-109663600D01* -X147095936Y-110163600D01* -X147102473Y-110229973D01* -X147036100Y-110223436D01* -X146536100Y-110223436D01* -X146391701Y-110237658D01* -X146386100Y-110239357D01* -X146380499Y-110237658D01* -X146236100Y-110223436D01* -X145736100Y-110223436D01* -X145591701Y-110237658D01* -X145586100Y-110239357D01* -X145580499Y-110237658D01* -X145436100Y-110223436D01* -X144936100Y-110223436D01* -X144791701Y-110237658D01* -X144786100Y-110239357D01* -X144780499Y-110237658D01* -X144636100Y-110223436D01* -X144136100Y-110223436D01* -X143991701Y-110237658D01* -X143986100Y-110239357D01* -X143980499Y-110237658D01* -X143836100Y-110223436D01* -X143336100Y-110223436D01* -X143191701Y-110237658D01* -X143186100Y-110239357D01* -X143180499Y-110237658D01* -X143036100Y-110223436D01* -X142536100Y-110223436D01* -X142391701Y-110237658D01* -X142252851Y-110279778D01* -X142124887Y-110348176D01* -X142012725Y-110440225D01* -X141986100Y-110472668D01* -X141959475Y-110440225D01* -X141847313Y-110348176D01* -X141719349Y-110279778D01* -X141580499Y-110237658D01* -X141436100Y-110223436D01* -X140936100Y-110223436D01* -X140791701Y-110237658D01* -X140786100Y-110239357D01* -X140780499Y-110237658D01* -X140636100Y-110223436D01* -X140136100Y-110223436D01* -X139991701Y-110237658D01* -X139986100Y-110239357D01* -X139980499Y-110237658D01* -X139836100Y-110223436D01* -X139336100Y-110223436D01* -X139191701Y-110237658D01* -X139186100Y-110239357D01* -X139180499Y-110237658D01* -X139036100Y-110223436D01* -X138536100Y-110223436D01* -X138469727Y-110229973D01* -X138476264Y-110163600D01* -X138476264Y-109663600D01* -X138462042Y-109519201D01* -X138460343Y-109513600D01* -X138462042Y-109507999D01* -X138476264Y-109363600D01* -X138476264Y-109215600D01* -X139627164Y-109215600D01* -X139752756Y-109341192D01* -X139977404Y-109491297D01* -X140227019Y-109594691D01* -X140492009Y-109647400D01* -X140762191Y-109647400D01* -X141027181Y-109594691D01* -X141276796Y-109491297D01* -X141501444Y-109341192D01* -X141692492Y-109150144D01* -X141842597Y-108925496D01* -X141945991Y-108675881D01* -X141998700Y-108410891D01* -X141998700Y-108140709D01* -X141945991Y-107875719D01* -X141842597Y-107626104D01* -X141692492Y-107401456D01* -X141501444Y-107210408D01* -X141276796Y-107060303D01* -X141027181Y-106956909D01* -X140855700Y-106922800D01* -X140855700Y-106921509D01* -X140802991Y-106656519D01* -X140699597Y-106406904D01* -X140549492Y-106182256D01* -X140358444Y-105991208D01* -X140133796Y-105841103D01* -X139884181Y-105737709D01* -X139657639Y-105692648D01* -X139833381Y-105657691D01* -X140082996Y-105554297D01* -X140307644Y-105404192D01* -X140498692Y-105213144D01* -X140648797Y-104988496D01* -X140752191Y-104738881D01* -X140804900Y-104473891D01* -X140804900Y-104203709D01* -X140752191Y-103938719D01* -X140648797Y-103689104D01* -X140498692Y-103464456D01* -X140307644Y-103273408D01* -X140082996Y-103123303D01* -X139833381Y-103019909D01* -X139568391Y-102967200D01* -X139458700Y-102967200D01* -X139458700Y-101833951D01* -X139462988Y-101776730D01* -X139453103Y-101695804D01* -X139445102Y-101614567D01* -X139441884Y-101603959D01* -X139441860Y-101603764D01* -X139836100Y-101603764D01* -X139980499Y-101589542D01* -X139986100Y-101587843D01* -X139991701Y-101589542D01* -X140136100Y-101603764D01* -X140636100Y-101603764D01* -X140780499Y-101589542D01* -X140786100Y-101587843D01* -X140791701Y-101589542D01* -X140936100Y-101603764D01* -X141436100Y-101603764D01* -X141580499Y-101589542D01* -X141586100Y-101587843D01* -X141591701Y-101589542D01* -X141736100Y-101603764D01* -X142236100Y-101603764D01* -X142380499Y-101589542D01* -X142519349Y-101547422D01* -X142647313Y-101479024D01* -X142759475Y-101386975D01* -X142786100Y-101354532D01* -X142812725Y-101386975D01* -X142812725Y-101386975D01* -G37* -X142812725Y-101386975D02* -X142924887Y-101479024D01* -X143052851Y-101547422D01* -X143191701Y-101589542D01* -X143336100Y-101603764D01* -X143836100Y-101603764D01* -X143980499Y-101589542D01* -X143986100Y-101587843D01* -X143991701Y-101589542D01* -X144136100Y-101603764D01* -X144636100Y-101603764D01* -X144780499Y-101589542D01* -X144786100Y-101587843D01* -X144791701Y-101589542D01* -X144936100Y-101603764D01* -X145436100Y-101603764D01* -X145580499Y-101589542D01* -X145586100Y-101587843D01* -X145591701Y-101589542D01* -X145736100Y-101603764D01* -X146236100Y-101603764D01* -X146380499Y-101589542D01* -X146386100Y-101587843D01* -X146391701Y-101589542D01* -X146536100Y-101603764D01* -X147036100Y-101603764D01* -X147102473Y-101597227D01* -X147095936Y-101663600D01* -X147095936Y-102163600D01* -X147110158Y-102307999D01* -X147111857Y-102313600D01* -X147110158Y-102319201D01* -X147095936Y-102463600D01* -X147095936Y-102963600D01* -X147110158Y-103107999D01* -X147111857Y-103113600D01* -X147110158Y-103119201D01* -X147095936Y-103263600D01* -X147095936Y-103763600D01* -X147110158Y-103907999D01* -X147111857Y-103913600D01* -X147110158Y-103919201D01* -X147095936Y-104063600D01* -X147095936Y-104563600D01* -X147110158Y-104707999D01* -X147111857Y-104713600D01* -X147110158Y-104719201D01* -X147095936Y-104863600D01* -X147095936Y-105363600D01* -X147110158Y-105507999D01* -X147152278Y-105646849D01* -X147220676Y-105774813D01* -X147312725Y-105886975D01* -X147345168Y-105913600D01* -X147312725Y-105940225D01* -X147220676Y-106052387D01* -X147152278Y-106180351D01* -X147110158Y-106319201D01* -X147095936Y-106463600D01* -X147095936Y-106963600D01* -X147110158Y-107107999D01* -X147111857Y-107113600D01* -X147110158Y-107119201D01* -X147095936Y-107263600D01* -X147095936Y-107763600D01* -X147110158Y-107907999D01* -X147111857Y-107913600D01* -X147110158Y-107919201D01* -X147095936Y-108063600D01* -X147095936Y-108563600D01* -X147110158Y-108707999D01* -X147111857Y-108713600D01* -X147110158Y-108719201D01* -X147095936Y-108863600D01* -X147095936Y-109363600D01* -X147110158Y-109507999D01* -X147111857Y-109513600D01* -X147110158Y-109519201D01* -X147095936Y-109663600D01* -X147095936Y-110163600D01* -X147102473Y-110229973D01* -X147036100Y-110223436D01* -X146536100Y-110223436D01* -X146391701Y-110237658D01* -X146386100Y-110239357D01* -X146380499Y-110237658D01* -X146236100Y-110223436D01* -X145736100Y-110223436D01* -X145591701Y-110237658D01* -X145586100Y-110239357D01* -X145580499Y-110237658D01* -X145436100Y-110223436D01* -X144936100Y-110223436D01* -X144791701Y-110237658D01* -X144786100Y-110239357D01* -X144780499Y-110237658D01* -X144636100Y-110223436D01* -X144136100Y-110223436D01* -X143991701Y-110237658D01* -X143986100Y-110239357D01* -X143980499Y-110237658D01* -X143836100Y-110223436D01* -X143336100Y-110223436D01* -X143191701Y-110237658D01* -X143186100Y-110239357D01* -X143180499Y-110237658D01* -X143036100Y-110223436D01* -X142536100Y-110223436D01* -X142391701Y-110237658D01* -X142252851Y-110279778D01* -X142124887Y-110348176D01* -X142012725Y-110440225D01* -X141986100Y-110472668D01* -X141959475Y-110440225D01* -X141847313Y-110348176D01* -X141719349Y-110279778D01* -X141580499Y-110237658D01* -X141436100Y-110223436D01* -X140936100Y-110223436D01* -X140791701Y-110237658D01* -X140786100Y-110239357D01* -X140780499Y-110237658D01* -X140636100Y-110223436D01* -X140136100Y-110223436D01* -X139991701Y-110237658D01* -X139986100Y-110239357D01* -X139980499Y-110237658D01* -X139836100Y-110223436D01* -X139336100Y-110223436D01* -X139191701Y-110237658D01* -X139186100Y-110239357D01* -X139180499Y-110237658D01* -X139036100Y-110223436D01* -X138536100Y-110223436D01* -X138469727Y-110229973D01* -X138476264Y-110163600D01* -X138476264Y-109663600D01* -X138462042Y-109519201D01* -X138460343Y-109513600D01* -X138462042Y-109507999D01* -X138476264Y-109363600D01* -X138476264Y-109215600D01* -X139627164Y-109215600D01* -X139752756Y-109341192D01* -X139977404Y-109491297D01* -X140227019Y-109594691D01* -X140492009Y-109647400D01* -X140762191Y-109647400D01* -X141027181Y-109594691D01* -X141276796Y-109491297D01* -X141501444Y-109341192D01* -X141692492Y-109150144D01* -X141842597Y-108925496D01* -X141945991Y-108675881D01* -X141998700Y-108410891D01* -X141998700Y-108140709D01* -X141945991Y-107875719D01* -X141842597Y-107626104D01* -X141692492Y-107401456D01* -X141501444Y-107210408D01* -X141276796Y-107060303D01* -X141027181Y-106956909D01* -X140855700Y-106922800D01* -X140855700Y-106921509D01* -X140802991Y-106656519D01* -X140699597Y-106406904D01* -X140549492Y-106182256D01* -X140358444Y-105991208D01* -X140133796Y-105841103D01* -X139884181Y-105737709D01* -X139657639Y-105692648D01* -X139833381Y-105657691D01* -X140082996Y-105554297D01* -X140307644Y-105404192D01* -X140498692Y-105213144D01* -X140648797Y-104988496D01* -X140752191Y-104738881D01* -X140804900Y-104473891D01* -X140804900Y-104203709D01* -X140752191Y-103938719D01* -X140648797Y-103689104D01* -X140498692Y-103464456D01* -X140307644Y-103273408D01* -X140082996Y-103123303D01* -X139833381Y-103019909D01* -X139568391Y-102967200D01* -X139458700Y-102967200D01* -X139458700Y-101833951D01* -X139462988Y-101776730D01* -X139453103Y-101695804D01* -X139445102Y-101614567D01* -X139441884Y-101603959D01* -X139441860Y-101603764D01* -X139836100Y-101603764D01* -X139980499Y-101589542D01* -X139986100Y-101587843D01* -X139991701Y-101589542D01* -X140136100Y-101603764D01* -X140636100Y-101603764D01* -X140780499Y-101589542D01* -X140786100Y-101587843D01* -X140791701Y-101589542D01* -X140936100Y-101603764D01* -X141436100Y-101603764D01* -X141580499Y-101589542D01* -X141586100Y-101587843D01* -X141591701Y-101589542D01* -X141736100Y-101603764D01* -X142236100Y-101603764D01* -X142380499Y-101589542D01* -X142519349Y-101547422D01* -X142647313Y-101479024D01* -X142759475Y-101386975D01* -X142786100Y-101354532D01* -X142812725Y-101386975D01* -G36* -X133761009Y-103856200D02* -X133776137Y-103856200D01* -X133943336Y-104069843D01* -X133943336Y-104656300D01* -X133957558Y-104800699D01* -X133999678Y-104939549D01* -X134068076Y-105067513D01* -X134160125Y-105179675D01* -X134252500Y-105255485D01* -X134252500Y-105780850D01* -X134360250Y-105888600D01* -X135014100Y-105888600D01* -X135014100Y-105868600D01* -X135064100Y-105868600D01* -X135064100Y-105888600D01* -X135084100Y-105888600D01* -X135084100Y-105938600D01* -X135064100Y-105938600D01* -X135064100Y-105958600D01* -X135014100Y-105958600D01* -X135014100Y-105938600D01* -X134360250Y-105938600D01* -X134252500Y-106046350D01* -X134252500Y-106667250D01* -X134269063Y-106750518D01* -X134301553Y-106828955D01* -X134348721Y-106899547D01* -X134408754Y-106959580D01* -X134428710Y-106972914D01* -X134373987Y-107027636D01* -X133728602Y-107027636D01* -X133792522Y-106908049D01* -X133834642Y-106769199D01* -X133848864Y-106624800D01* -X133848864Y-105202400D01* -X133834642Y-105058001D01* -X133792522Y-104919151D01* -X133724124Y-104791187D01* -X133632075Y-104679025D01* -X133539700Y-104603215D01* -X133539700Y-104077850D01* -X133431950Y-103970100D01* -X132778100Y-103970100D01* -X132778100Y-103990100D01* -X132728100Y-103990100D01* -X132728100Y-103970100D01* -X132708100Y-103970100D01* -X132708100Y-103920100D01* -X132728100Y-103920100D01* -X132728100Y-103900100D01* -X132778100Y-103900100D01* -X132778100Y-103920100D01* -X133431950Y-103920100D01* -X133539700Y-103812350D01* -X133539700Y-103812180D01* -X133761009Y-103856200D01* -X133761009Y-103856200D01* -G37* -X133761009Y-103856200D02* -X133776137Y-103856200D01* -X133943336Y-104069843D01* -X133943336Y-104656300D01* -X133957558Y-104800699D01* -X133999678Y-104939549D01* -X134068076Y-105067513D01* -X134160125Y-105179675D01* -X134252500Y-105255485D01* -X134252500Y-105780850D01* -X134360250Y-105888600D01* -X135014100Y-105888600D01* -X135014100Y-105868600D01* -X135064100Y-105868600D01* -X135064100Y-105888600D01* -X135084100Y-105888600D01* -X135084100Y-105938600D01* -X135064100Y-105938600D01* -X135064100Y-105958600D01* -X135014100Y-105958600D01* -X135014100Y-105938600D01* -X134360250Y-105938600D01* -X134252500Y-106046350D01* -X134252500Y-106667250D01* -X134269063Y-106750518D01* -X134301553Y-106828955D01* -X134348721Y-106899547D01* -X134408754Y-106959580D01* -X134428710Y-106972914D01* -X134373987Y-107027636D01* -X133728602Y-107027636D01* -X133792522Y-106908049D01* -X133834642Y-106769199D01* -X133848864Y-106624800D01* -X133848864Y-105202400D01* -X133834642Y-105058001D01* -X133792522Y-104919151D01* -X133724124Y-104791187D01* -X133632075Y-104679025D01* -X133539700Y-104603215D01* -X133539700Y-104077850D01* -X133431950Y-103970100D01* -X132778100Y-103970100D01* -X132778100Y-103990100D01* -X132728100Y-103990100D01* -X132728100Y-103970100D01* -X132708100Y-103970100D01* -X132708100Y-103920100D01* -X132728100Y-103920100D01* -X132728100Y-103900100D01* -X132778100Y-103900100D01* -X132778100Y-103920100D01* -X133431950Y-103920100D01* -X133539700Y-103812350D01* -X133539700Y-103812180D01* -X133761009Y-103856200D01* -G36* -X138558956Y-105404192D02* -X138783604Y-105554297D01* -X139033219Y-105657691D01* -X139259761Y-105702752D01* -X139084019Y-105737709D01* -X138834404Y-105841103D01* -X138609756Y-105991208D01* -X138420083Y-106180881D01* -X138419922Y-106180351D01* -X138351524Y-106052387D01* -X138259475Y-105940225D01* -X138227032Y-105913600D01* -X138259475Y-105886975D01* -X138351524Y-105774813D01* -X138419922Y-105646849D01* -X138462042Y-105507999D01* -X138476264Y-105363600D01* -X138476264Y-105321500D01* -X138558956Y-105404192D01* -X138558956Y-105404192D01* -G37* -X138558956Y-105404192D02* -X138783604Y-105554297D01* -X139033219Y-105657691D01* -X139259761Y-105702752D01* -X139084019Y-105737709D01* -X138834404Y-105841103D01* -X138609756Y-105991208D01* -X138420083Y-106180881D01* -X138419922Y-106180351D01* -X138351524Y-106052387D01* -X138259475Y-105940225D01* -X138227032Y-105913600D01* -X138259475Y-105886975D01* -X138351524Y-105774813D01* -X138419922Y-105646849D01* -X138462042Y-105507999D01* -X138476264Y-105363600D01* -X138476264Y-105321500D01* -X138558956Y-105404192D01* -G36* -X168439125Y-83431911D02* -X167941555Y-84176577D01* -X167598823Y-85004006D01* -X167424100Y-85882399D01* -X167424100Y-86778001D01* -X167598823Y-87656394D01* -X167941555Y-88483823D01* -X168439125Y-89228489D01* -X169072411Y-89861775D01* -X169817077Y-90359345D01* -X170644506Y-90702077D01* -X170876896Y-90748302D01* -X170724870Y-90900328D01* -X170545764Y-91168379D01* -X170543411Y-91174060D01* -X170343120Y-91091935D01* -X169491455Y-91943600D01* -X170343120Y-92795265D01* -X170543411Y-92713140D01* -X170545764Y-92718821D01* -X170724870Y-92986872D01* -X170751501Y-93013503D01* -X170751500Y-93413698D01* -X170724870Y-93440328D01* -X170545764Y-93708379D01* -X170543411Y-93714060D01* -X170343120Y-93631935D01* -X169491455Y-94483600D01* -X170343120Y-95335265D01* -X170543411Y-95253140D01* -X170545764Y-95258821D01* -X170724870Y-95526872D01* -X170751501Y-95553503D01* -X170751500Y-95953698D01* -X170724870Y-95980328D01* -X170545764Y-96248379D01* -X170543411Y-96254060D01* -X170343120Y-96171935D01* -X169491455Y-97023600D01* -X170343120Y-97875265D01* -X170543411Y-97793140D01* -X170545764Y-97798821D01* -X170724870Y-98066872D01* -X170751501Y-98093503D01* -X170751500Y-98493698D01* -X170724870Y-98520328D01* -X170545764Y-98788379D01* -X170543411Y-98794060D01* -X170343120Y-98711935D01* -X169491455Y-99563600D01* -X170343120Y-100415265D01* -X170543411Y-100333140D01* -X170545764Y-100338821D01* -X170724870Y-100606872D01* -X170952828Y-100834830D01* -X171220879Y-101013936D01* -X171518721Y-101137307D01* -X171834909Y-101200200D01* -X172157291Y-101200200D01* -X172473479Y-101137307D01* -X172771321Y-101013936D01* -X173039372Y-100834830D01* -X173066002Y-100808200D01* -X173164501Y-100808200D01* -X173164500Y-101866486D01* -X171323476Y-104107735D01* -X168287700Y-102192113D01* -X168287700Y-101844014D01* -X168424215Y-101639704D01* -X168552501Y-101329997D01* -X168617900Y-101001213D01* -X168617900Y-100665987D01* -X168579935Y-100475123D01* -X168604436Y-100450622D01* -X168690335Y-100660117D01* -X168918969Y-100788440D01* -X169168245Y-100869695D01* -X169428582Y-100900756D01* -X169689977Y-100880431D01* -X169942384Y-100809501D01* -X170176104Y-100690692D01* -X170221865Y-100660117D01* -X170307765Y-100450620D01* -X169456100Y-99598955D01* -X169441958Y-99613098D01* -X169406603Y-99577743D01* -X169420745Y-99563600D01* -X169406603Y-99549458D01* -X169441958Y-99514103D01* -X169456100Y-99528245D01* -X170307765Y-98676580D01* -X170221865Y-98467083D01* -X169993231Y-98338760D01* -X169855586Y-98293893D01* -X169942384Y-98269501D01* -X170176104Y-98150692D01* -X170221865Y-98120117D01* -X170307765Y-97910620D01* -X169456100Y-97058955D01* -X169441958Y-97073098D01* -X169406603Y-97037743D01* -X169420745Y-97023600D01* -X169406603Y-97009458D01* -X169441958Y-96974103D01* -X169456100Y-96988245D01* -X170307765Y-96136580D01* -X170221865Y-95927083D01* -X169993231Y-95798760D01* -X169855586Y-95753893D01* -X169942384Y-95729501D01* -X170176104Y-95610692D01* -X170221865Y-95580117D01* -X170307765Y-95370620D01* -X169456100Y-94518955D01* -X169441958Y-94533098D01* -X169406603Y-94497743D01* -X169420745Y-94483600D01* -X168569080Y-93631935D01* -X168359583Y-93717835D01* -X168231260Y-93946469D01* -X168150005Y-94195745D01* -X168118944Y-94456082D01* -X168126840Y-94557632D01* -X168000934Y-94431726D01* -X167855900Y-94334818D01* -X167855900Y-93260254D01* -X167860446Y-93214587D01* -X167855900Y-93167931D01* -X167855900Y-93167433D01* -X167851354Y-93121276D01* -X167842493Y-93030335D01* -X167842351Y-93029865D01* -X167842302Y-93029367D01* -X167815414Y-92940729D01* -X167788940Y-92853126D01* -X167788707Y-92852689D01* -X167788563Y-92852214D01* -X167777021Y-92830620D01* -X168604435Y-92830620D01* -X168690335Y-93040117D01* -X168918969Y-93168440D01* -X169056614Y-93213307D01* -X168969816Y-93237699D01* -X168736096Y-93356508D01* -X168690335Y-93387083D01* -X168604435Y-93596580D01* -X169456100Y-94448245D01* -X170307765Y-93596580D01* -X170221865Y-93387083D01* -X169993231Y-93258760D01* -X169855586Y-93213893D01* -X169942384Y-93189501D01* -X170176104Y-93070692D01* -X170221865Y-93040117D01* -X170307765Y-92830620D01* -X169456100Y-91978955D01* -X168604435Y-92830620D01* -X167777021Y-92830620D01* -X167745083Y-92770870D01* -X167723669Y-92730705D01* -X167723397Y-92730297D01* -X167701296Y-92688949D01* -X167672179Y-92653470D01* -X167180587Y-91916082D01* -X168118944Y-91916082D01* -X168139269Y-92177477D01* -X168210199Y-92429884D01* -X168329008Y-92663604D01* -X168359583Y-92709365D01* -X168569080Y-92795265D01* -X169420745Y-91943600D01* -X168569080Y-91091935D01* -X168359583Y-91177835D01* -X168231260Y-91406469D01* -X168150005Y-91655745D01* -X168118944Y-91916082D01* -X167180587Y-91916082D01* -X166607586Y-91056580D01* -X168604435Y-91056580D01* -X169456100Y-91908245D01* -X170307765Y-91056580D01* -X170221865Y-90847083D01* -X169993231Y-90718760D01* -X169743955Y-90637505D01* -X169483618Y-90606444D01* -X169222223Y-90626769D01* -X168969816Y-90697699D01* -X168736096Y-90816508D01* -X168690335Y-90847083D01* -X168604435Y-91056580D01* -X166607586Y-91056580D01* -X165860281Y-89935623D01* -X165890382Y-89862952D01* -X165950900Y-89558704D01* -X165950900Y-89248496D01* -X165890382Y-88944248D01* -X165771670Y-88657652D01* -X165599327Y-88399723D01* -X165379977Y-88180373D01* -X165122048Y-88008030D01* -X164835452Y-87889318D01* -X164531204Y-87828800D01* -X164220996Y-87828800D01* -X164008547Y-87871058D01* -X163978563Y-87772214D01* -X163916656Y-87656394D01* -X163891296Y-87608948D01* -X163803284Y-87501706D01* -X163803282Y-87501704D01* -X163773854Y-87465846D01* -X163737995Y-87436417D01* -X163168290Y-86866714D01* -X163138854Y-86830846D01* -X162995751Y-86713404D01* -X162832486Y-86626137D01* -X162655333Y-86572398D01* -X162517267Y-86558800D01* -X162517257Y-86558800D01* -X162471100Y-86554254D01* -X162424943Y-86558800D01* -X160331083Y-86558800D01* -X160321168Y-86557046D01* -X160238648Y-86558800D01* -X160202433Y-86558800D01* -X160192466Y-86559782D01* -X160136085Y-86560980D01* -X160100572Y-86568832D01* -X160064367Y-86572398D01* -X160010388Y-86588772D01* -X159955326Y-86600947D01* -X159922026Y-86615577D01* -X159887214Y-86626137D01* -X159837475Y-86652723D01* -X159785838Y-86675409D01* -X159756027Y-86696258D01* -X159723949Y-86713404D01* -X159680356Y-86749180D01* -X159634133Y-86781507D01* -X159608962Y-86807772D01* -X159580846Y-86830846D01* -X159545065Y-86874445D01* -X159538141Y-86881670D01* -X159515791Y-86910116D01* -X159463404Y-86973949D01* -X159458655Y-86982835D01* -X156546375Y-90689373D01* -X156529372Y-90672370D01* -X156261321Y-90493264D01* -X155963479Y-90369893D01* -X155647291Y-90307000D01* -X155324909Y-90307000D01* -X155008721Y-90369893D01* -X154710879Y-90493264D01* -X154442828Y-90672370D01* -X154216100Y-90899098D01* -X153989372Y-90672370D01* -X153721321Y-90493264D01* -X153423479Y-90369893D01* -X153107291Y-90307000D01* -X152784909Y-90307000D01* -X152468721Y-90369893D01* -X152170879Y-90493264D01* -X151902828Y-90672370D01* -X151676100Y-90899098D01* -X151449372Y-90672370D01* -X151181321Y-90493264D01* -X150883479Y-90369893D01* -X150567291Y-90307000D01* -X150244909Y-90307000D01* -X149928721Y-90369893D01* -X149644900Y-90487456D01* -X150652622Y-88472011D01* -X150880270Y-88426730D01* -X151176111Y-88304188D01* -X151442360Y-88126286D01* -X151668786Y-87899860D01* -X151846688Y-87633611D01* -X151969230Y-87337770D01* -X152031700Y-87023708D01* -X152031700Y-86703492D01* -X151969230Y-86389430D01* -X151846688Y-86093589D01* -X151668786Y-85827340D01* -X151442360Y-85600914D01* -X151176111Y-85423012D01* -X150880270Y-85300470D01* -X150566208Y-85238000D01* -X150245992Y-85238000D01* -X149931930Y-85300470D01* -X149636089Y-85423012D01* -X149369840Y-85600914D01* -X149143414Y-85827340D01* -X149136100Y-85838286D01* -X149128786Y-85827340D01* -X148902360Y-85600914D01* -X148636111Y-85423012D01* -X148340270Y-85300470D01* -X148026208Y-85238000D01* -X147705992Y-85238000D01* -X147391930Y-85300470D01* -X147096089Y-85423012D01* -X146829840Y-85600914D01* -X146603414Y-85827340D01* -X146596100Y-85838286D01* -X146588786Y-85827340D01* -X146362360Y-85600914D01* -X146096111Y-85423012D01* -X145800270Y-85300470D01* -X145486208Y-85238000D01* -X145165992Y-85238000D01* -X144851930Y-85300470D01* -X144556089Y-85423012D01* -X144289840Y-85600914D01* -X144063414Y-85827340D01* -X144056100Y-85838286D01* -X144048786Y-85827340D01* -X143822360Y-85600914D01* -X143556111Y-85423012D01* -X143260270Y-85300470D01* -X142946208Y-85238000D01* -X142625992Y-85238000D01* -X142311930Y-85300470D01* -X142016089Y-85423012D01* -X141749840Y-85600914D01* -X141523414Y-85827340D01* -X141516100Y-85838286D01* -X141508786Y-85827340D01* -X141282360Y-85600914D01* -X141016111Y-85423012D01* -X140720270Y-85300470D01* -X140406208Y-85238000D01* -X140085992Y-85238000D01* -X139771930Y-85300470D01* -X139476089Y-85423012D01* -X139209840Y-85600914D01* -X138983414Y-85827340D01* -X138976100Y-85838286D01* -X138968786Y-85827340D01* -X138742360Y-85600914D01* -X138476111Y-85423012D01* -X138180270Y-85300470D01* -X137866208Y-85238000D01* -X137545992Y-85238000D01* -X137231930Y-85300470D01* -X136936089Y-85423012D01* -X136669840Y-85600914D01* -X136443414Y-85827340D01* -X136436100Y-85838286D01* -X136428786Y-85827340D01* -X136202360Y-85600914D01* -X135936111Y-85423012D01* -X135640270Y-85300470D01* -X135326208Y-85238000D01* -X135005992Y-85238000D01* -X134691930Y-85300470D01* -X134396089Y-85423012D01* -X134129840Y-85600914D01* -X133903414Y-85827340D01* -X133896100Y-85838286D01* -X133888786Y-85827340D01* -X133662360Y-85600914D01* -X133396111Y-85423012D01* -X133100270Y-85300470D01* -X132786208Y-85238000D01* -X132465992Y-85238000D01* -X132151930Y-85300470D01* -X131856089Y-85423012D01* -X131589840Y-85600914D01* -X131363414Y-85827340D01* -X131356100Y-85838286D01* -X131348786Y-85827340D01* -X131122360Y-85600914D01* -X130856111Y-85423012D01* -X130560270Y-85300470D01* -X130246208Y-85238000D01* -X129925992Y-85238000D01* -X129611930Y-85300470D01* -X129450267Y-85367433D01* -X129377977Y-85004006D01* -X129035245Y-84176577D01* -X128537675Y-83431911D01* -X128420964Y-83315200D01* -X168555836Y-83315200D01* -X168439125Y-83431911D01* -X168439125Y-83431911D01* -G37* -X168439125Y-83431911D02* -X167941555Y-84176577D01* -X167598823Y-85004006D01* -X167424100Y-85882399D01* -X167424100Y-86778001D01* -X167598823Y-87656394D01* -X167941555Y-88483823D01* -X168439125Y-89228489D01* -X169072411Y-89861775D01* -X169817077Y-90359345D01* -X170644506Y-90702077D01* -X170876896Y-90748302D01* -X170724870Y-90900328D01* -X170545764Y-91168379D01* -X170543411Y-91174060D01* -X170343120Y-91091935D01* -X169491455Y-91943600D01* -X170343120Y-92795265D01* -X170543411Y-92713140D01* -X170545764Y-92718821D01* -X170724870Y-92986872D01* -X170751501Y-93013503D01* -X170751500Y-93413698D01* -X170724870Y-93440328D01* -X170545764Y-93708379D01* -X170543411Y-93714060D01* -X170343120Y-93631935D01* -X169491455Y-94483600D01* -X170343120Y-95335265D01* -X170543411Y-95253140D01* -X170545764Y-95258821D01* -X170724870Y-95526872D01* -X170751501Y-95553503D01* -X170751500Y-95953698D01* -X170724870Y-95980328D01* -X170545764Y-96248379D01* -X170543411Y-96254060D01* -X170343120Y-96171935D01* -X169491455Y-97023600D01* -X170343120Y-97875265D01* -X170543411Y-97793140D01* -X170545764Y-97798821D01* -X170724870Y-98066872D01* -X170751501Y-98093503D01* -X170751500Y-98493698D01* -X170724870Y-98520328D01* -X170545764Y-98788379D01* -X170543411Y-98794060D01* -X170343120Y-98711935D01* -X169491455Y-99563600D01* -X170343120Y-100415265D01* -X170543411Y-100333140D01* -X170545764Y-100338821D01* -X170724870Y-100606872D01* -X170952828Y-100834830D01* -X171220879Y-101013936D01* -X171518721Y-101137307D01* -X171834909Y-101200200D01* -X172157291Y-101200200D01* -X172473479Y-101137307D01* -X172771321Y-101013936D01* -X173039372Y-100834830D01* -X173066002Y-100808200D01* -X173164501Y-100808200D01* -X173164500Y-101866486D01* -X171323476Y-104107735D01* -X168287700Y-102192113D01* -X168287700Y-101844014D01* -X168424215Y-101639704D01* -X168552501Y-101329997D01* -X168617900Y-101001213D01* -X168617900Y-100665987D01* -X168579935Y-100475123D01* -X168604436Y-100450622D01* -X168690335Y-100660117D01* -X168918969Y-100788440D01* -X169168245Y-100869695D01* -X169428582Y-100900756D01* -X169689977Y-100880431D01* -X169942384Y-100809501D01* -X170176104Y-100690692D01* -X170221865Y-100660117D01* -X170307765Y-100450620D01* -X169456100Y-99598955D01* -X169441958Y-99613098D01* -X169406603Y-99577743D01* -X169420745Y-99563600D01* -X169406603Y-99549458D01* -X169441958Y-99514103D01* -X169456100Y-99528245D01* -X170307765Y-98676580D01* -X170221865Y-98467083D01* -X169993231Y-98338760D01* -X169855586Y-98293893D01* -X169942384Y-98269501D01* -X170176104Y-98150692D01* -X170221865Y-98120117D01* -X170307765Y-97910620D01* -X169456100Y-97058955D01* -X169441958Y-97073098D01* -X169406603Y-97037743D01* -X169420745Y-97023600D01* -X169406603Y-97009458D01* -X169441958Y-96974103D01* -X169456100Y-96988245D01* -X170307765Y-96136580D01* -X170221865Y-95927083D01* -X169993231Y-95798760D01* -X169855586Y-95753893D01* -X169942384Y-95729501D01* -X170176104Y-95610692D01* -X170221865Y-95580117D01* -X170307765Y-95370620D01* -X169456100Y-94518955D01* -X169441958Y-94533098D01* -X169406603Y-94497743D01* -X169420745Y-94483600D01* -X168569080Y-93631935D01* -X168359583Y-93717835D01* -X168231260Y-93946469D01* -X168150005Y-94195745D01* -X168118944Y-94456082D01* -X168126840Y-94557632D01* -X168000934Y-94431726D01* -X167855900Y-94334818D01* -X167855900Y-93260254D01* -X167860446Y-93214587D01* -X167855900Y-93167931D01* -X167855900Y-93167433D01* -X167851354Y-93121276D01* -X167842493Y-93030335D01* -X167842351Y-93029865D01* -X167842302Y-93029367D01* -X167815414Y-92940729D01* -X167788940Y-92853126D01* -X167788707Y-92852689D01* -X167788563Y-92852214D01* -X167777021Y-92830620D01* -X168604435Y-92830620D01* -X168690335Y-93040117D01* -X168918969Y-93168440D01* -X169056614Y-93213307D01* -X168969816Y-93237699D01* -X168736096Y-93356508D01* -X168690335Y-93387083D01* -X168604435Y-93596580D01* -X169456100Y-94448245D01* -X170307765Y-93596580D01* -X170221865Y-93387083D01* -X169993231Y-93258760D01* -X169855586Y-93213893D01* -X169942384Y-93189501D01* -X170176104Y-93070692D01* -X170221865Y-93040117D01* -X170307765Y-92830620D01* -X169456100Y-91978955D01* -X168604435Y-92830620D01* -X167777021Y-92830620D01* -X167745083Y-92770870D01* -X167723669Y-92730705D01* -X167723397Y-92730297D01* -X167701296Y-92688949D01* -X167672179Y-92653470D01* -X167180587Y-91916082D01* -X168118944Y-91916082D01* -X168139269Y-92177477D01* -X168210199Y-92429884D01* -X168329008Y-92663604D01* -X168359583Y-92709365D01* -X168569080Y-92795265D01* -X169420745Y-91943600D01* -X168569080Y-91091935D01* -X168359583Y-91177835D01* -X168231260Y-91406469D01* -X168150005Y-91655745D01* -X168118944Y-91916082D01* -X167180587Y-91916082D01* -X166607586Y-91056580D01* -X168604435Y-91056580D01* -X169456100Y-91908245D01* -X170307765Y-91056580D01* -X170221865Y-90847083D01* -X169993231Y-90718760D01* -X169743955Y-90637505D01* -X169483618Y-90606444D01* -X169222223Y-90626769D01* -X168969816Y-90697699D01* -X168736096Y-90816508D01* -X168690335Y-90847083D01* -X168604435Y-91056580D01* -X166607586Y-91056580D01* -X165860281Y-89935623D01* -X165890382Y-89862952D01* -X165950900Y-89558704D01* -X165950900Y-89248496D01* -X165890382Y-88944248D01* -X165771670Y-88657652D01* -X165599327Y-88399723D01* -X165379977Y-88180373D01* -X165122048Y-88008030D01* -X164835452Y-87889318D01* -X164531204Y-87828800D01* -X164220996Y-87828800D01* -X164008547Y-87871058D01* -X163978563Y-87772214D01* -X163916656Y-87656394D01* -X163891296Y-87608948D01* -X163803284Y-87501706D01* -X163803282Y-87501704D01* -X163773854Y-87465846D01* -X163737995Y-87436417D01* -X163168290Y-86866714D01* -X163138854Y-86830846D01* -X162995751Y-86713404D01* -X162832486Y-86626137D01* -X162655333Y-86572398D01* -X162517267Y-86558800D01* -X162517257Y-86558800D01* -X162471100Y-86554254D01* -X162424943Y-86558800D01* -X160331083Y-86558800D01* -X160321168Y-86557046D01* -X160238648Y-86558800D01* -X160202433Y-86558800D01* -X160192466Y-86559782D01* -X160136085Y-86560980D01* -X160100572Y-86568832D01* -X160064367Y-86572398D01* -X160010388Y-86588772D01* -X159955326Y-86600947D01* -X159922026Y-86615577D01* -X159887214Y-86626137D01* -X159837475Y-86652723D01* -X159785838Y-86675409D01* -X159756027Y-86696258D01* -X159723949Y-86713404D01* -X159680356Y-86749180D01* -X159634133Y-86781507D01* -X159608962Y-86807772D01* -X159580846Y-86830846D01* -X159545065Y-86874445D01* -X159538141Y-86881670D01* -X159515791Y-86910116D01* -X159463404Y-86973949D01* -X159458655Y-86982835D01* -X156546375Y-90689373D01* -X156529372Y-90672370D01* -X156261321Y-90493264D01* -X155963479Y-90369893D01* -X155647291Y-90307000D01* -X155324909Y-90307000D01* -X155008721Y-90369893D01* -X154710879Y-90493264D01* -X154442828Y-90672370D01* -X154216100Y-90899098D01* -X153989372Y-90672370D01* -X153721321Y-90493264D01* -X153423479Y-90369893D01* -X153107291Y-90307000D01* -X152784909Y-90307000D01* -X152468721Y-90369893D01* -X152170879Y-90493264D01* -X151902828Y-90672370D01* -X151676100Y-90899098D01* -X151449372Y-90672370D01* -X151181321Y-90493264D01* -X150883479Y-90369893D01* -X150567291Y-90307000D01* -X150244909Y-90307000D01* -X149928721Y-90369893D01* -X149644900Y-90487456D01* -X150652622Y-88472011D01* -X150880270Y-88426730D01* -X151176111Y-88304188D01* -X151442360Y-88126286D01* -X151668786Y-87899860D01* -X151846688Y-87633611D01* -X151969230Y-87337770D01* -X152031700Y-87023708D01* -X152031700Y-86703492D01* -X151969230Y-86389430D01* -X151846688Y-86093589D01* -X151668786Y-85827340D01* -X151442360Y-85600914D01* -X151176111Y-85423012D01* -X150880270Y-85300470D01* -X150566208Y-85238000D01* -X150245992Y-85238000D01* -X149931930Y-85300470D01* -X149636089Y-85423012D01* -X149369840Y-85600914D01* -X149143414Y-85827340D01* -X149136100Y-85838286D01* -X149128786Y-85827340D01* -X148902360Y-85600914D01* -X148636111Y-85423012D01* -X148340270Y-85300470D01* -X148026208Y-85238000D01* -X147705992Y-85238000D01* -X147391930Y-85300470D01* -X147096089Y-85423012D01* -X146829840Y-85600914D01* -X146603414Y-85827340D01* -X146596100Y-85838286D01* -X146588786Y-85827340D01* -X146362360Y-85600914D01* -X146096111Y-85423012D01* -X145800270Y-85300470D01* -X145486208Y-85238000D01* -X145165992Y-85238000D01* -X144851930Y-85300470D01* -X144556089Y-85423012D01* -X144289840Y-85600914D01* -X144063414Y-85827340D01* -X144056100Y-85838286D01* -X144048786Y-85827340D01* -X143822360Y-85600914D01* -X143556111Y-85423012D01* -X143260270Y-85300470D01* -X142946208Y-85238000D01* -X142625992Y-85238000D01* -X142311930Y-85300470D01* -X142016089Y-85423012D01* -X141749840Y-85600914D01* -X141523414Y-85827340D01* -X141516100Y-85838286D01* -X141508786Y-85827340D01* -X141282360Y-85600914D01* -X141016111Y-85423012D01* -X140720270Y-85300470D01* -X140406208Y-85238000D01* -X140085992Y-85238000D01* -X139771930Y-85300470D01* -X139476089Y-85423012D01* -X139209840Y-85600914D01* -X138983414Y-85827340D01* -X138976100Y-85838286D01* -X138968786Y-85827340D01* -X138742360Y-85600914D01* -X138476111Y-85423012D01* -X138180270Y-85300470D01* -X137866208Y-85238000D01* -X137545992Y-85238000D01* -X137231930Y-85300470D01* -X136936089Y-85423012D01* -X136669840Y-85600914D01* -X136443414Y-85827340D01* -X136436100Y-85838286D01* -X136428786Y-85827340D01* -X136202360Y-85600914D01* -X135936111Y-85423012D01* -X135640270Y-85300470D01* -X135326208Y-85238000D01* -X135005992Y-85238000D01* -X134691930Y-85300470D01* -X134396089Y-85423012D01* -X134129840Y-85600914D01* -X133903414Y-85827340D01* -X133896100Y-85838286D01* -X133888786Y-85827340D01* -X133662360Y-85600914D01* -X133396111Y-85423012D01* -X133100270Y-85300470D01* -X132786208Y-85238000D01* -X132465992Y-85238000D01* -X132151930Y-85300470D01* -X131856089Y-85423012D01* -X131589840Y-85600914D01* -X131363414Y-85827340D01* -X131356100Y-85838286D01* -X131348786Y-85827340D01* -X131122360Y-85600914D01* -X130856111Y-85423012D01* -X130560270Y-85300470D01* -X130246208Y-85238000D01* -X129925992Y-85238000D01* -X129611930Y-85300470D01* -X129450267Y-85367433D01* -X129377977Y-85004006D01* -X129035245Y-84176577D01* -X128537675Y-83431911D01* -X128420964Y-83315200D01* -X168555836Y-83315200D01* -X168439125Y-83431911D01* -G36* -X128009996Y-103135485D02* -X127731266Y-103321726D01* -X127494226Y-103558766D01* -X127465204Y-103602200D01* -X126263646Y-103602200D01* -X126042360Y-103380914D01* -X126031414Y-103373600D01* -X126042360Y-103366286D01* -X126268786Y-103139860D01* -X126336343Y-103038754D01* -X128259760Y-103032029D01* -X128009996Y-103135485D01* -X128009996Y-103135485D01* -G37* -X128009996Y-103135485D02* -X127731266Y-103321726D01* -X127494226Y-103558766D01* -X127465204Y-103602200D01* -X126263646Y-103602200D01* -X126042360Y-103380914D01* -X126031414Y-103373600D01* -X126042360Y-103366286D01* -X126268786Y-103139860D01* -X126336343Y-103038754D01* -X128259760Y-103032029D01* -X128009996Y-103135485D01* -G36* -X132015553Y-103029745D02* -X131983063Y-103108182D01* -X131966500Y-103191450D01* -X131966500Y-103460779D01* -X131902100Y-103454436D01* -X130302100Y-103454436D01* -X130157701Y-103468658D01* -X130073430Y-103494222D01* -X129900934Y-103321726D01* -X129622204Y-103135485D01* -X129363127Y-103028171D01* -X132022819Y-103018871D01* -X132015553Y-103029745D01* -X132015553Y-103029745D01* -G37* -X132015553Y-103029745D02* -X131983063Y-103108182D01* -X131966500Y-103191450D01* -X131966500Y-103460779D01* -X131902100Y-103454436D01* -X130302100Y-103454436D01* -X130157701Y-103468658D01* -X130073430Y-103494222D01* -X129900934Y-103321726D01* -X129622204Y-103135485D01* -X129363127Y-103028171D01* -X132022819Y-103018871D01* -X132015553Y-103029745D01* -G36* -X163152873Y-92947477D02* -X163372223Y-93166827D01* -X163630152Y-93339170D01* -X163738462Y-93384033D01* -X163688548Y-93409464D01* -X163646842Y-93437331D01* -X163568356Y-93640500D01* -X164376100Y-94448245D01* -X165183844Y-93640500D01* -X165105358Y-93437331D01* -X165011702Y-93384877D01* -X165122048Y-93339170D01* -X165379977Y-93166827D01* -X165599327Y-92947477D01* -X165604262Y-92940092D01* -X165976301Y-93498151D01* -X165976301Y-94334817D01* -X165831266Y-94431726D01* -X165637348Y-94625644D01* -X165651196Y-94508680D01* -X165631588Y-94259439D01* -X165563732Y-94018812D01* -X165450236Y-93796048D01* -X165422369Y-93754342D01* -X165219200Y-93675856D01* -X164411455Y-94483600D01* -X164425598Y-94497742D01* -X164390242Y-94533098D01* -X164376100Y-94518955D01* -X163568356Y-95326700D01* -X163646842Y-95529869D01* -X163864971Y-95652037D01* -X164102743Y-95729302D01* -X164351020Y-95758696D01* -X164600261Y-95739088D01* -X164840888Y-95671232D01* -X165063652Y-95557736D01* -X165105358Y-95529869D01* -X165183843Y-95326701D01* -X165252265Y-95395123D01* -X165214300Y-95585987D01* -X165214300Y-95921213D01* -X165279699Y-96249997D01* -X165407985Y-96559704D01* -X165544501Y-96764015D01* -X165544500Y-97283186D01* -X165407985Y-97487496D01* -X165279699Y-97797203D01* -X165214300Y-98125987D01* -X165214300Y-98461213D01* -X165279699Y-98789997D01* -X165407985Y-99099704D01* -X165544500Y-99304014D01* -X165544500Y-99402636D01* -X163508700Y-99402636D01* -X163364301Y-99416858D01* -X163225451Y-99458978D01* -X163097487Y-99527376D01* -X162985325Y-99619425D01* -X162893276Y-99731587D01* -X162824878Y-99859551D01* -X162782758Y-99998401D01* -X162768536Y-100142800D01* -X162768536Y-101379583D01* -X161396927Y-102357600D01* -X160744962Y-102357600D01* -X160747464Y-102332200D01* -X160747464Y-101621000D01* -X160733242Y-101476601D01* -X160691122Y-101337751D01* -X160622724Y-101209787D01* -X160530675Y-101097625D01* -X160418513Y-101005576D01* -X160290549Y-100937178D01* -X160151699Y-100895058D01* -X160007300Y-100880836D01* -X158836895Y-100880836D01* -X158909139Y-100786364D01* -X160007300Y-100786364D01* -X160151699Y-100772142D01* -X160290549Y-100730022D01* -X160418513Y-100661624D01* -X160530675Y-100569575D01* -X160622724Y-100457413D01* -X160691122Y-100329449D01* -X160733242Y-100190599D01* -X160747464Y-100046200D01* -X160747464Y-99335000D01* -X160733242Y-99190601D01* -X160691122Y-99051751D01* -X160671392Y-99014838D01* -X162126705Y-96031447D01* -X162295452Y-95997882D01* -X162582048Y-95879170D01* -X162839977Y-95706827D01* -X163059327Y-95487477D01* -X163231670Y-95229548D01* -X163276533Y-95121238D01* -X163301964Y-95171152D01* -X163329831Y-95212858D01* -X163533000Y-95291344D01* -X164340745Y-94483600D01* -X163533000Y-93675856D01* -X163329831Y-93754342D01* -X163277377Y-93847998D01* -X163231670Y-93737652D01* -X163059327Y-93479723D01* -X162839977Y-93260373D01* -X162769976Y-93213600D01* -X162839977Y-93166827D01* -X163059327Y-92947477D01* -X163106100Y-92877476D01* -X163152873Y-92947477D01* -X163152873Y-92947477D01* -G37* -X163152873Y-92947477D02* -X163372223Y-93166827D01* -X163630152Y-93339170D01* -X163738462Y-93384033D01* -X163688548Y-93409464D01* -X163646842Y-93437331D01* -X163568356Y-93640500D01* -X164376100Y-94448245D01* -X165183844Y-93640500D01* -X165105358Y-93437331D01* -X165011702Y-93384877D01* -X165122048Y-93339170D01* -X165379977Y-93166827D01* -X165599327Y-92947477D01* -X165604262Y-92940092D01* -X165976301Y-93498151D01* -X165976301Y-94334817D01* -X165831266Y-94431726D01* -X165637348Y-94625644D01* -X165651196Y-94508680D01* -X165631588Y-94259439D01* -X165563732Y-94018812D01* -X165450236Y-93796048D01* -X165422369Y-93754342D01* -X165219200Y-93675856D01* -X164411455Y-94483600D01* -X164425598Y-94497742D01* -X164390242Y-94533098D01* -X164376100Y-94518955D01* -X163568356Y-95326700D01* -X163646842Y-95529869D01* -X163864971Y-95652037D01* -X164102743Y-95729302D01* -X164351020Y-95758696D01* -X164600261Y-95739088D01* -X164840888Y-95671232D01* -X165063652Y-95557736D01* -X165105358Y-95529869D01* -X165183843Y-95326701D01* -X165252265Y-95395123D01* -X165214300Y-95585987D01* -X165214300Y-95921213D01* -X165279699Y-96249997D01* -X165407985Y-96559704D01* -X165544501Y-96764015D01* -X165544500Y-97283186D01* -X165407985Y-97487496D01* -X165279699Y-97797203D01* -X165214300Y-98125987D01* -X165214300Y-98461213D01* -X165279699Y-98789997D01* -X165407985Y-99099704D01* -X165544500Y-99304014D01* -X165544500Y-99402636D01* -X163508700Y-99402636D01* -X163364301Y-99416858D01* -X163225451Y-99458978D01* -X163097487Y-99527376D01* -X162985325Y-99619425D01* -X162893276Y-99731587D01* -X162824878Y-99859551D01* -X162782758Y-99998401D01* -X162768536Y-100142800D01* -X162768536Y-101379583D01* -X161396927Y-102357600D01* -X160744962Y-102357600D01* -X160747464Y-102332200D01* -X160747464Y-101621000D01* -X160733242Y-101476601D01* -X160691122Y-101337751D01* -X160622724Y-101209787D01* -X160530675Y-101097625D01* -X160418513Y-101005576D01* -X160290549Y-100937178D01* -X160151699Y-100895058D01* -X160007300Y-100880836D01* -X158836895Y-100880836D01* -X158909139Y-100786364D01* -X160007300Y-100786364D01* -X160151699Y-100772142D01* -X160290549Y-100730022D01* -X160418513Y-100661624D01* -X160530675Y-100569575D01* -X160622724Y-100457413D01* -X160691122Y-100329449D01* -X160733242Y-100190599D01* -X160747464Y-100046200D01* -X160747464Y-99335000D01* -X160733242Y-99190601D01* -X160691122Y-99051751D01* -X160671392Y-99014838D01* -X162126705Y-96031447D01* -X162295452Y-95997882D01* -X162582048Y-95879170D01* -X162839977Y-95706827D01* -X163059327Y-95487477D01* -X163231670Y-95229548D01* -X163276533Y-95121238D01* -X163301964Y-95171152D01* -X163329831Y-95212858D01* -X163533000Y-95291344D01* -X164340745Y-94483600D01* -X163533000Y-93675856D01* -X163329831Y-93754342D01* -X163277377Y-93847998D01* -X163231670Y-93737652D01* -X163059327Y-93479723D01* -X162839977Y-93260373D01* -X162769976Y-93213600D01* -X162839977Y-93166827D01* -X163059327Y-92947477D01* -X163106100Y-92877476D01* -X163152873Y-92947477D01* -G36* -X143471900Y-96237000D02* -X142918850Y-96237000D01* -X142811100Y-96344750D01* -X142811100Y-96998600D01* -X142831100Y-96998600D01* -X142831100Y-97048600D01* -X142811100Y-97048600D01* -X142811100Y-97702450D01* -X142891087Y-97782437D01* -X142822593Y-97879989D01* -X142815710Y-97888506D01* -X142737146Y-97726404D01* -X142761100Y-97702450D01* -X142761100Y-97048600D01* -X142741100Y-97048600D01* -X142741100Y-96998600D01* -X142761100Y-96998600D01* -X142761100Y-96344750D01* -X142653350Y-96237000D01* -X142374170Y-96237000D01* -X142508382Y-95847786D01* -X142562034Y-95864061D01* -X142786100Y-95886130D01* -X143010167Y-95864061D01* -X143111361Y-95833364D01* -X143471900Y-95833364D01* -X143471900Y-96237000D01* -X143471900Y-96237000D01* -G37* -X143471900Y-96237000D02* -X142918850Y-96237000D01* -X142811100Y-96344750D01* -X142811100Y-96998600D01* -X142831100Y-96998600D01* -X142831100Y-97048600D01* -X142811100Y-97048600D01* -X142811100Y-97702450D01* -X142891087Y-97782437D01* -X142822593Y-97879989D01* -X142815710Y-97888506D01* -X142737146Y-97726404D01* -X142761100Y-97702450D01* -X142761100Y-97048600D01* -X142741100Y-97048600D01* -X142741100Y-96998600D01* -X142761100Y-96998600D01* -X142761100Y-96344750D01* -X142653350Y-96237000D01* -X142374170Y-96237000D01* -X142508382Y-95847786D01* -X142562034Y-95864061D01* -X142786100Y-95886130D01* -X143010167Y-95864061D01* -X143111361Y-95833364D01* -X143471900Y-95833364D01* -X143471900Y-96237000D01* -G04 #@! TD* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Edge.Cuts.gbr b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Edge.Cuts.gbr deleted file mode 100644 index 2692d9b..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Edge.Cuts.gbr +++ /dev/null @@ -1,24 +0,0 @@ -G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* -G04 #@! TF.CreationDate,2019-04-02T23:20:26+04:00* -G04 #@! TF.ProjectId,M644_breakout_v1.2d,4d363434-5f62-4726-9561-6b6f75745f76,v1.2d* -G04 #@! TF.SameCoordinates,Original* -G04 #@! TF.FileFunction,Profile,NP* -%FSLAX46Y46*% -G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* -G04 Created by KiCad (PCBNEW (5.0.2)-1) date 02/04/2019 23:20:26* -%MOMM*% -%LPD*% -G01* -G04 APERTURE LIST* -%ADD10C,0.150000*% -G04 APERTURE END LIST* -D10* -X121196100Y-127503600D02* -X176060100Y-127503600D01* -X176060100Y-127503600D02* -X176060100Y-82503600D01* -X176060100Y-82503600D02* -X121196100Y-82503600D01* -X121196100Y-82503600D02* -X121196100Y-127503600D01* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-F.Mask.gbr b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-F.Mask.gbr deleted file mode 100644 index 18e899c..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-F.Mask.gbr +++ /dev/null @@ -1,3840 +0,0 @@ -G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* -G04 #@! TF.CreationDate,2019-04-02T23:20:26+04:00* -G04 #@! TF.ProjectId,M644_breakout_v1.2d,4d363434-5f62-4726-9561-6b6f75745f76,v1.2d* -G04 #@! TF.SameCoordinates,Original* -G04 #@! TF.FileFunction,Soldermask,Top* -G04 #@! TF.FilePolarity,Negative* -%FSLAX46Y46*% -G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* -G04 Created by KiCad (PCBNEW (5.0.2)-1) date 02/04/2019 23:20:26* -%MOMM*% -%LPD*% -G01* -G04 APERTURE LIST* -%ADD10C,0.100000*% -G04 APERTURE END LIST* -D10* -G36* -X130269445Y-124041858D02* -X130360229Y-124059916D01* -X130531262Y-124130760D01* -X130683109Y-124232221D01* -X130685190Y-124233612D01* -X130816088Y-124364510D01* -X130816090Y-124364513D01* -X130918940Y-124518438D01* -X130989784Y-124689471D01* -X131025900Y-124871038D01* -X131025900Y-125056162D01* -X130989784Y-125237729D01* -X130918940Y-125408762D01* -X130817479Y-125560609D01* -X130816088Y-125562690D01* -X130685190Y-125693588D01* -X130685187Y-125693590D01* -X130531262Y-125796440D01* -X130360229Y-125867284D01* -X130269446Y-125885342D01* -X130178664Y-125903400D01* -X129993536Y-125903400D01* -X129902754Y-125885342D01* -X129811971Y-125867284D01* -X129640938Y-125796440D01* -X129487013Y-125693590D01* -X129487010Y-125693588D01* -X129356112Y-125562690D01* -X129354721Y-125560609D01* -X129253260Y-125408762D01* -X129182416Y-125237729D01* -X129146300Y-125056162D01* -X129146300Y-124871038D01* -X129182416Y-124689471D01* -X129253260Y-124518438D01* -X129356110Y-124364513D01* -X129356112Y-124364510D01* -X129487010Y-124233612D01* -X129489091Y-124232221D01* -X129640938Y-124130760D01* -X129811971Y-124059916D01* -X129902755Y-124041858D01* -X129993536Y-124023800D01* -X130178664Y-124023800D01* -X130269445Y-124041858D01* -X130269445Y-124041858D01* -G37* -G36* -X158209445Y-124041858D02* -X158300229Y-124059916D01* -X158471262Y-124130760D01* -X158623109Y-124232221D01* -X158625190Y-124233612D01* -X158756088Y-124364510D01* -X158756090Y-124364513D01* -X158858940Y-124518438D01* -X158929784Y-124689471D01* -X158965900Y-124871038D01* -X158965900Y-125056162D01* -X158929784Y-125237729D01* -X158858940Y-125408762D01* -X158757479Y-125560609D01* -X158756088Y-125562690D01* -X158625190Y-125693588D01* -X158625187Y-125693590D01* -X158471262Y-125796440D01* -X158300229Y-125867284D01* -X158209446Y-125885342D01* -X158118664Y-125903400D01* -X157933536Y-125903400D01* -X157842754Y-125885342D01* -X157751971Y-125867284D01* -X157580938Y-125796440D01* -X157427013Y-125693590D01* -X157427010Y-125693588D01* -X157296112Y-125562690D01* -X157294721Y-125560609D01* -X157193260Y-125408762D01* -X157122416Y-125237729D01* -X157086300Y-125056162D01* -X157086300Y-124871038D01* -X157122416Y-124689471D01* -X157193260Y-124518438D01* -X157296110Y-124364513D01* -X157296112Y-124364510D01* -X157427010Y-124233612D01* -X157429091Y-124232221D01* -X157580938Y-124130760D01* -X157751971Y-124059916D01* -X157842755Y-124041858D01* -X157933536Y-124023800D01* -X158118664Y-124023800D01* -X158209445Y-124041858D01* -X158209445Y-124041858D01* -G37* -G36* -X155669445Y-124041858D02* -X155760229Y-124059916D01* -X155931262Y-124130760D01* -X156083109Y-124232221D01* -X156085190Y-124233612D01* -X156216088Y-124364510D01* -X156216090Y-124364513D01* -X156318940Y-124518438D01* -X156389784Y-124689471D01* -X156425900Y-124871038D01* -X156425900Y-125056162D01* -X156389784Y-125237729D01* -X156318940Y-125408762D01* -X156217479Y-125560609D01* -X156216088Y-125562690D01* -X156085190Y-125693588D01* -X156085187Y-125693590D01* -X155931262Y-125796440D01* -X155760229Y-125867284D01* -X155669446Y-125885342D01* -X155578664Y-125903400D01* -X155393536Y-125903400D01* -X155302754Y-125885342D01* -X155211971Y-125867284D01* -X155040938Y-125796440D01* -X154887013Y-125693590D01* -X154887010Y-125693588D01* -X154756112Y-125562690D01* -X154754721Y-125560609D01* -X154653260Y-125408762D01* -X154582416Y-125237729D01* -X154546300Y-125056162D01* -X154546300Y-124871038D01* -X154582416Y-124689471D01* -X154653260Y-124518438D01* -X154756110Y-124364513D01* -X154756112Y-124364510D01* -X154887010Y-124233612D01* -X154889091Y-124232221D01* -X155040938Y-124130760D01* -X155211971Y-124059916D01* -X155302755Y-124041858D01* -X155393536Y-124023800D01* -X155578664Y-124023800D01* -X155669445Y-124041858D01* -X155669445Y-124041858D01* -G37* -G36* -X153129445Y-124041858D02* -X153220229Y-124059916D01* -X153391262Y-124130760D01* -X153543109Y-124232221D01* -X153545190Y-124233612D01* -X153676088Y-124364510D01* -X153676090Y-124364513D01* -X153778940Y-124518438D01* -X153849784Y-124689471D01* -X153885900Y-124871038D01* -X153885900Y-125056162D01* -X153849784Y-125237729D01* -X153778940Y-125408762D01* -X153677479Y-125560609D01* -X153676088Y-125562690D01* -X153545190Y-125693588D01* -X153545187Y-125693590D01* -X153391262Y-125796440D01* -X153220229Y-125867284D01* -X153129446Y-125885342D01* -X153038664Y-125903400D01* -X152853536Y-125903400D01* -X152762754Y-125885342D01* -X152671971Y-125867284D01* -X152500938Y-125796440D01* -X152347013Y-125693590D01* -X152347010Y-125693588D01* -X152216112Y-125562690D01* -X152214721Y-125560609D01* -X152113260Y-125408762D01* -X152042416Y-125237729D01* -X152006300Y-125056162D01* -X152006300Y-124871038D01* -X152042416Y-124689471D01* -X152113260Y-124518438D01* -X152216110Y-124364513D01* -X152216112Y-124364510D01* -X152347010Y-124233612D01* -X152349091Y-124232221D01* -X152500938Y-124130760D01* -X152671971Y-124059916D01* -X152762755Y-124041858D01* -X152853536Y-124023800D01* -X153038664Y-124023800D01* -X153129445Y-124041858D01* -X153129445Y-124041858D01* -G37* -G36* -X150589445Y-124041858D02* -X150680229Y-124059916D01* -X150851262Y-124130760D01* -X151003109Y-124232221D01* -X151005190Y-124233612D01* -X151136088Y-124364510D01* -X151136090Y-124364513D01* -X151238940Y-124518438D01* -X151309784Y-124689471D01* -X151345900Y-124871038D01* -X151345900Y-125056162D01* -X151309784Y-125237729D01* -X151238940Y-125408762D01* -X151137479Y-125560609D01* -X151136088Y-125562690D01* -X151005190Y-125693588D01* -X151005187Y-125693590D01* -X150851262Y-125796440D01* -X150680229Y-125867284D01* -X150589446Y-125885342D01* -X150498664Y-125903400D01* -X150313536Y-125903400D01* -X150222754Y-125885342D01* -X150131971Y-125867284D01* -X149960938Y-125796440D01* -X149807013Y-125693590D01* -X149807010Y-125693588D01* -X149676112Y-125562690D01* -X149674721Y-125560609D01* -X149573260Y-125408762D01* -X149502416Y-125237729D01* -X149466300Y-125056162D01* -X149466300Y-124871038D01* -X149502416Y-124689471D01* -X149573260Y-124518438D01* -X149676110Y-124364513D01* -X149676112Y-124364510D01* -X149807010Y-124233612D01* -X149809091Y-124232221D01* -X149960938Y-124130760D01* -X150131971Y-124059916D01* -X150222755Y-124041858D01* -X150313536Y-124023800D01* -X150498664Y-124023800D01* -X150589445Y-124041858D01* -X150589445Y-124041858D01* -G37* -G36* -X148049445Y-124041858D02* -X148140229Y-124059916D01* -X148311262Y-124130760D01* -X148463109Y-124232221D01* -X148465190Y-124233612D01* -X148596088Y-124364510D01* -X148596090Y-124364513D01* -X148698940Y-124518438D01* -X148769784Y-124689471D01* -X148805900Y-124871038D01* -X148805900Y-125056162D01* -X148769784Y-125237729D01* -X148698940Y-125408762D01* -X148597479Y-125560609D01* -X148596088Y-125562690D01* -X148465190Y-125693588D01* -X148465187Y-125693590D01* -X148311262Y-125796440D01* -X148140229Y-125867284D01* -X148049446Y-125885342D01* -X147958664Y-125903400D01* -X147773536Y-125903400D01* -X147682754Y-125885342D01* -X147591971Y-125867284D01* -X147420938Y-125796440D01* -X147267013Y-125693590D01* -X147267010Y-125693588D01* -X147136112Y-125562690D01* -X147134721Y-125560609D01* -X147033260Y-125408762D01* -X146962416Y-125237729D01* -X146926300Y-125056162D01* -X146926300Y-124871038D01* -X146962416Y-124689471D01* -X147033260Y-124518438D01* -X147136110Y-124364513D01* -X147136112Y-124364510D01* -X147267010Y-124233612D01* -X147269091Y-124232221D01* -X147420938Y-124130760D01* -X147591971Y-124059916D01* -X147682755Y-124041858D01* -X147773536Y-124023800D01* -X147958664Y-124023800D01* -X148049445Y-124041858D01* -X148049445Y-124041858D01* -G37* -G36* -X145509445Y-124041858D02* -X145600229Y-124059916D01* -X145771262Y-124130760D01* -X145923109Y-124232221D01* -X145925190Y-124233612D01* -X146056088Y-124364510D01* -X146056090Y-124364513D01* -X146158940Y-124518438D01* -X146229784Y-124689471D01* -X146265900Y-124871038D01* -X146265900Y-125056162D01* -X146229784Y-125237729D01* -X146158940Y-125408762D01* -X146057479Y-125560609D01* -X146056088Y-125562690D01* -X145925190Y-125693588D01* -X145925187Y-125693590D01* -X145771262Y-125796440D01* -X145600229Y-125867284D01* -X145509446Y-125885342D01* -X145418664Y-125903400D01* -X145233536Y-125903400D01* -X145142754Y-125885342D01* -X145051971Y-125867284D01* -X144880938Y-125796440D01* -X144727013Y-125693590D01* -X144727010Y-125693588D01* -X144596112Y-125562690D01* -X144594721Y-125560609D01* -X144493260Y-125408762D01* -X144422416Y-125237729D01* -X144386300Y-125056162D01* -X144386300Y-124871038D01* -X144422416Y-124689471D01* -X144493260Y-124518438D01* -X144596110Y-124364513D01* -X144596112Y-124364510D01* -X144727010Y-124233612D01* -X144729091Y-124232221D01* -X144880938Y-124130760D01* -X145051971Y-124059916D01* -X145142755Y-124041858D01* -X145233536Y-124023800D01* -X145418664Y-124023800D01* -X145509445Y-124041858D01* -X145509445Y-124041858D01* -G37* -G36* -X140429445Y-124041858D02* -X140520229Y-124059916D01* -X140691262Y-124130760D01* -X140843109Y-124232221D01* -X140845190Y-124233612D01* -X140976088Y-124364510D01* -X140976090Y-124364513D01* -X141078940Y-124518438D01* -X141149784Y-124689471D01* -X141185900Y-124871038D01* -X141185900Y-125056162D01* -X141149784Y-125237729D01* -X141078940Y-125408762D01* -X140977479Y-125560609D01* -X140976088Y-125562690D01* -X140845190Y-125693588D01* -X140845187Y-125693590D01* -X140691262Y-125796440D01* -X140520229Y-125867284D01* -X140429446Y-125885342D01* -X140338664Y-125903400D01* -X140153536Y-125903400D01* -X140062754Y-125885342D01* -X139971971Y-125867284D01* -X139800938Y-125796440D01* -X139647013Y-125693590D01* -X139647010Y-125693588D01* -X139516112Y-125562690D01* -X139514721Y-125560609D01* -X139413260Y-125408762D01* -X139342416Y-125237729D01* -X139306300Y-125056162D01* -X139306300Y-124871038D01* -X139342416Y-124689471D01* -X139413260Y-124518438D01* -X139516110Y-124364513D01* -X139516112Y-124364510D01* -X139647010Y-124233612D01* -X139649091Y-124232221D01* -X139800938Y-124130760D01* -X139971971Y-124059916D01* -X140062755Y-124041858D01* -X140153536Y-124023800D01* -X140338664Y-124023800D01* -X140429445Y-124041858D01* -X140429445Y-124041858D01* -G37* -G36* -X142969445Y-124041858D02* -X143060229Y-124059916D01* -X143231262Y-124130760D01* -X143383109Y-124232221D01* -X143385190Y-124233612D01* -X143516088Y-124364510D01* -X143516090Y-124364513D01* -X143618940Y-124518438D01* -X143689784Y-124689471D01* -X143725900Y-124871038D01* -X143725900Y-125056162D01* -X143689784Y-125237729D01* -X143618940Y-125408762D01* -X143517479Y-125560609D01* -X143516088Y-125562690D01* -X143385190Y-125693588D01* -X143385187Y-125693590D01* -X143231262Y-125796440D01* -X143060229Y-125867284D01* -X142969446Y-125885342D01* -X142878664Y-125903400D01* -X142693536Y-125903400D01* -X142602754Y-125885342D01* -X142511971Y-125867284D01* -X142340938Y-125796440D01* -X142187013Y-125693590D01* -X142187010Y-125693588D01* -X142056112Y-125562690D01* -X142054721Y-125560609D01* -X141953260Y-125408762D01* -X141882416Y-125237729D01* -X141846300Y-125056162D01* -X141846300Y-124871038D01* -X141882416Y-124689471D01* -X141953260Y-124518438D01* -X142056110Y-124364513D01* -X142056112Y-124364510D01* -X142187010Y-124233612D01* -X142189091Y-124232221D01* -X142340938Y-124130760D01* -X142511971Y-124059916D01* -X142602755Y-124041858D01* -X142693536Y-124023800D01* -X142878664Y-124023800D01* -X142969445Y-124041858D01* -X142969445Y-124041858D01* -G37* -G36* -X132809445Y-124041858D02* -X132900229Y-124059916D01* -X133071262Y-124130760D01* -X133223109Y-124232221D01* -X133225190Y-124233612D01* -X133356088Y-124364510D01* -X133356090Y-124364513D01* -X133458940Y-124518438D01* -X133529784Y-124689471D01* -X133565900Y-124871038D01* -X133565900Y-125056162D01* -X133529784Y-125237729D01* -X133458940Y-125408762D01* -X133357479Y-125560609D01* -X133356088Y-125562690D01* -X133225190Y-125693588D01* -X133225187Y-125693590D01* -X133071262Y-125796440D01* -X132900229Y-125867284D01* -X132809446Y-125885342D01* -X132718664Y-125903400D01* -X132533536Y-125903400D01* -X132442754Y-125885342D01* -X132351971Y-125867284D01* -X132180938Y-125796440D01* -X132027013Y-125693590D01* -X132027010Y-125693588D01* -X131896112Y-125562690D01* -X131894721Y-125560609D01* -X131793260Y-125408762D01* -X131722416Y-125237729D01* -X131686300Y-125056162D01* -X131686300Y-124871038D01* -X131722416Y-124689471D01* -X131793260Y-124518438D01* -X131896110Y-124364513D01* -X131896112Y-124364510D01* -X132027010Y-124233612D01* -X132029091Y-124232221D01* -X132180938Y-124130760D01* -X132351971Y-124059916D01* -X132442755Y-124041858D01* -X132533536Y-124023800D01* -X132718664Y-124023800D01* -X132809445Y-124041858D01* -X132809445Y-124041858D01* -G37* -G36* -X137889445Y-124041858D02* -X137980229Y-124059916D01* -X138151262Y-124130760D01* -X138303109Y-124232221D01* -X138305190Y-124233612D01* -X138436088Y-124364510D01* -X138436090Y-124364513D01* -X138538940Y-124518438D01* -X138609784Y-124689471D01* -X138645900Y-124871038D01* -X138645900Y-125056162D01* -X138609784Y-125237729D01* -X138538940Y-125408762D01* -X138437479Y-125560609D01* -X138436088Y-125562690D01* -X138305190Y-125693588D01* -X138305187Y-125693590D01* -X138151262Y-125796440D01* -X137980229Y-125867284D01* -X137889446Y-125885342D01* -X137798664Y-125903400D01* -X137613536Y-125903400D01* -X137522754Y-125885342D01* -X137431971Y-125867284D01* -X137260938Y-125796440D01* -X137107013Y-125693590D01* -X137107010Y-125693588D01* -X136976112Y-125562690D01* -X136974721Y-125560609D01* -X136873260Y-125408762D01* -X136802416Y-125237729D01* -X136766300Y-125056162D01* -X136766300Y-124871038D01* -X136802416Y-124689471D01* -X136873260Y-124518438D01* -X136976110Y-124364513D01* -X136976112Y-124364510D01* -X137107010Y-124233612D01* -X137109091Y-124232221D01* -X137260938Y-124130760D01* -X137431971Y-124059916D01* -X137522755Y-124041858D01* -X137613536Y-124023800D01* -X137798664Y-124023800D01* -X137889445Y-124041858D01* -X137889445Y-124041858D01* -G37* -G36* -X135349445Y-124041858D02* -X135440229Y-124059916D01* -X135611262Y-124130760D01* -X135763109Y-124232221D01* -X135765190Y-124233612D01* -X135896088Y-124364510D01* -X135896090Y-124364513D01* -X135998940Y-124518438D01* -X136069784Y-124689471D01* -X136105900Y-124871038D01* -X136105900Y-125056162D01* -X136069784Y-125237729D01* -X135998940Y-125408762D01* -X135897479Y-125560609D01* -X135896088Y-125562690D01* -X135765190Y-125693588D01* -X135765187Y-125693590D01* -X135611262Y-125796440D01* -X135440229Y-125867284D01* -X135349446Y-125885342D01* -X135258664Y-125903400D01* -X135073536Y-125903400D01* -X134982754Y-125885342D01* -X134891971Y-125867284D01* -X134720938Y-125796440D01* -X134567013Y-125693590D01* -X134567010Y-125693588D01* -X134436112Y-125562690D01* -X134434721Y-125560609D01* -X134333260Y-125408762D01* -X134262416Y-125237729D01* -X134226300Y-125056162D01* -X134226300Y-124871038D01* -X134262416Y-124689471D01* -X134333260Y-124518438D01* -X134436110Y-124364513D01* -X134436112Y-124364510D01* -X134567010Y-124233612D01* -X134569091Y-124232221D01* -X134720938Y-124130760D01* -X134891971Y-124059916D01* -X134982755Y-124041858D01* -X135073536Y-124023800D01* -X135258664Y-124023800D01* -X135349445Y-124041858D01* -X135349445Y-124041858D01* -G37* -G36* -X174646543Y-124069119D02* -X174712727Y-124075637D01* -X174824197Y-124109451D01* -X174882567Y-124127157D01* -X175013808Y-124197308D01* -X175039091Y-124210822D01* -X175066858Y-124233610D01* -X175176286Y-124323414D01* -X175259548Y-124424871D01* -X175288878Y-124460609D01* -X175288879Y-124460611D01* -X175372543Y-124617133D01* -X175372543Y-124617134D01* -X175424063Y-124786973D01* -X175441459Y-124963600D01* -X175424063Y-125140227D01* -X175394487Y-125237727D01* -X175372543Y-125310067D01* -X175319788Y-125408763D01* -X175288878Y-125466591D01* -X175259548Y-125502329D01* -X175176286Y-125603786D01* -X175074829Y-125687048D01* -X175039091Y-125716378D01* -X175039089Y-125716379D01* -X174882567Y-125800043D01* -X174825953Y-125817216D01* -X174712727Y-125851563D01* -X174646542Y-125858082D01* -X174580360Y-125864600D01* -X174491840Y-125864600D01* -X174425658Y-125858082D01* -X174359473Y-125851563D01* -X174246247Y-125817216D01* -X174189633Y-125800043D01* -X174033111Y-125716379D01* -X174033109Y-125716378D01* -X173997371Y-125687048D01* -X173895914Y-125603786D01* -X173812652Y-125502329D01* -X173783322Y-125466591D01* -X173752412Y-125408763D01* -X173699657Y-125310067D01* -X173677713Y-125237727D01* -X173648137Y-125140227D01* -X173630741Y-124963600D01* -X173648137Y-124786973D01* -X173699657Y-124617134D01* -X173699657Y-124617133D01* -X173783321Y-124460611D01* -X173783322Y-124460609D01* -X173812652Y-124424871D01* -X173895914Y-124323414D01* -X174005342Y-124233610D01* -X174033109Y-124210822D01* -X174058392Y-124197308D01* -X174189633Y-124127157D01* -X174248003Y-124109451D01* -X174359473Y-124075637D01* -X174425657Y-124069119D01* -X174491840Y-124062600D01* -X174580360Y-124062600D01* -X174646543Y-124069119D01* -X174646543Y-124069119D01* -G37* -G36* -X172106543Y-124069119D02* -X172172727Y-124075637D01* -X172284197Y-124109451D01* -X172342567Y-124127157D01* -X172473808Y-124197308D01* -X172499091Y-124210822D01* -X172526858Y-124233610D01* -X172636286Y-124323414D01* -X172719548Y-124424871D01* -X172748878Y-124460609D01* -X172748879Y-124460611D01* -X172832543Y-124617133D01* -X172832543Y-124617134D01* -X172884063Y-124786973D01* -X172901459Y-124963600D01* -X172884063Y-125140227D01* -X172854487Y-125237727D01* -X172832543Y-125310067D01* -X172779788Y-125408763D01* -X172748878Y-125466591D01* -X172719548Y-125502329D01* -X172636286Y-125603786D01* -X172534829Y-125687048D01* -X172499091Y-125716378D01* -X172499089Y-125716379D01* -X172342567Y-125800043D01* -X172285953Y-125817216D01* -X172172727Y-125851563D01* -X172106542Y-125858082D01* -X172040360Y-125864600D01* -X171951840Y-125864600D01* -X171885658Y-125858082D01* -X171819473Y-125851563D01* -X171706247Y-125817216D01* -X171649633Y-125800043D01* -X171493111Y-125716379D01* -X171493109Y-125716378D01* -X171457371Y-125687048D01* -X171355914Y-125603786D01* -X171272652Y-125502329D01* -X171243322Y-125466591D01* -X171212412Y-125408763D01* -X171159657Y-125310067D01* -X171137713Y-125237727D01* -X171108137Y-125140227D01* -X171090741Y-124963600D01* -X171108137Y-124786973D01* -X171159657Y-124617134D01* -X171159657Y-124617133D01* -X171243321Y-124460611D01* -X171243322Y-124460609D01* -X171272652Y-124424871D01* -X171355914Y-124323414D01* -X171465342Y-124233610D01* -X171493109Y-124210822D01* -X171518392Y-124197308D01* -X171649633Y-124127157D01* -X171708003Y-124109451D01* -X171819473Y-124075637D01* -X171885657Y-124069119D01* -X171951840Y-124062600D01* -X172040360Y-124062600D01* -X172106543Y-124069119D01* -X172106543Y-124069119D01* -G37* -G36* -X163314949Y-120594152D02* -X163331579Y-120595790D01* -X163376165Y-120609315D01* -X163509928Y-120649892D01* -X163674296Y-120737749D01* -X163818366Y-120855984D01* -X163936601Y-121000054D01* -X164024458Y-121164422D01* -X164078560Y-121342772D01* -X164092250Y-121481769D01* -X164092250Y-123365431D01* -X164078560Y-123504428D01* -X164024458Y-123682778D01* -X163936601Y-123847146D01* -X163818366Y-123991216D01* -X163674296Y-124109451D01* -X163509927Y-124197308D01* -X163465377Y-124210822D01* -X163331578Y-124251410D01* -X163314948Y-124253048D01* -X163146100Y-124269678D01* -X162977251Y-124253048D01* -X162960621Y-124251410D01* -X162901950Y-124233612D01* -X162782272Y-124197308D01* -X162617904Y-124109451D01* -X162473834Y-123991216D01* -X162355599Y-123847146D01* -X162267742Y-123682777D01* -X162240691Y-123593602D01* -X162213640Y-123504428D01* -X162211684Y-123484570D01* -X162199950Y-123365430D01* -X162199950Y-121481776D01* -X162213641Y-121342771D01* -X162227166Y-121298185D01* -X162267743Y-121164422D01* -X162355600Y-121000054D01* -X162473835Y-120855984D01* -X162617905Y-120737749D01* -X162782273Y-120649892D01* -X162916036Y-120609315D01* -X162960622Y-120595790D01* -X162977252Y-120594152D01* -X163146100Y-120577522D01* -X163314949Y-120594152D01* -X163314949Y-120594152D01* -G37* -G36* -X168314949Y-120594152D02* -X168331579Y-120595790D01* -X168376165Y-120609315D01* -X168509928Y-120649892D01* -X168674296Y-120737749D01* -X168818366Y-120855984D01* -X168936601Y-121000054D01* -X169024458Y-121164422D01* -X169078560Y-121342772D01* -X169092250Y-121481769D01* -X169092250Y-123365431D01* -X169078560Y-123504428D01* -X169024458Y-123682778D01* -X168936601Y-123847146D01* -X168818366Y-123991216D01* -X168674296Y-124109451D01* -X168509927Y-124197308D01* -X168465377Y-124210822D01* -X168331578Y-124251410D01* -X168314948Y-124253048D01* -X168146100Y-124269678D01* -X167977251Y-124253048D01* -X167960621Y-124251410D01* -X167901950Y-124233612D01* -X167782272Y-124197308D01* -X167617904Y-124109451D01* -X167473834Y-123991216D01* -X167355599Y-123847146D01* -X167267742Y-123682777D01* -X167240691Y-123593602D01* -X167213640Y-123504428D01* -X167211684Y-123484570D01* -X167199950Y-123365430D01* -X167199950Y-121481776D01* -X167213641Y-121342771D01* -X167227166Y-121298185D01* -X167267743Y-121164422D01* -X167355600Y-121000054D01* -X167473835Y-120855984D01* -X167617905Y-120737749D01* -X167782273Y-120649892D01* -X167916036Y-120609315D01* -X167960622Y-120595790D01* -X167977252Y-120594152D01* -X168146100Y-120577522D01* -X168314949Y-120594152D01* -X168314949Y-120594152D01* -G37* -G36* -X153223438Y-121509338D02* -X153396473Y-121581012D01* -X153552200Y-121685065D01* -X153684635Y-121817500D01* -X153788688Y-121973227D01* -X153860362Y-122146262D01* -X153896900Y-122329954D01* -X153896900Y-122517246D01* -X153860362Y-122700938D01* -X153788688Y-122873973D01* -X153684635Y-123029700D01* -X153552200Y-123162135D01* -X153396473Y-123266188D01* -X153223438Y-123337862D01* -X153039746Y-123374400D01* -X152852454Y-123374400D01* -X152668762Y-123337862D01* -X152495727Y-123266188D01* -X152340000Y-123162135D01* -X152207565Y-123029700D01* -X152103512Y-122873973D01* -X152031838Y-122700938D01* -X151995300Y-122517246D01* -X151995300Y-122329954D01* -X152031838Y-122146262D01* -X152103512Y-121973227D01* -X152207565Y-121817500D01* -X152340000Y-121685065D01* -X152495727Y-121581012D01* -X152668762Y-121509338D01* -X152852454Y-121472800D01* -X153039746Y-121472800D01* -X153223438Y-121509338D01* -X153223438Y-121509338D01* -G37* -G36* -X150683438Y-121509338D02* -X150856473Y-121581012D01* -X151012200Y-121685065D01* -X151144635Y-121817500D01* -X151248688Y-121973227D01* -X151320362Y-122146262D01* -X151356900Y-122329954D01* -X151356900Y-122517246D01* -X151320362Y-122700938D01* -X151248688Y-122873973D01* -X151144635Y-123029700D01* -X151012200Y-123162135D01* -X150856473Y-123266188D01* -X150683438Y-123337862D01* -X150499746Y-123374400D01* -X150312454Y-123374400D01* -X150128762Y-123337862D01* -X149955727Y-123266188D01* -X149800000Y-123162135D01* -X149667565Y-123029700D01* -X149563512Y-122873973D01* -X149491838Y-122700938D01* -X149455300Y-122517246D01* -X149455300Y-122329954D01* -X149491838Y-122146262D01* -X149563512Y-121973227D01* -X149667565Y-121817500D01* -X149800000Y-121685065D01* -X149955727Y-121581012D01* -X150128762Y-121509338D01* -X150312454Y-121472800D01* -X150499746Y-121472800D01* -X150683438Y-121509338D01* -X150683438Y-121509338D01* -G37* -G36* -X148143438Y-121509338D02* -X148316473Y-121581012D01* -X148472200Y-121685065D01* -X148604635Y-121817500D01* -X148708688Y-121973227D01* -X148780362Y-122146262D01* -X148816900Y-122329954D01* -X148816900Y-122517246D01* -X148780362Y-122700938D01* -X148708688Y-122873973D01* -X148604635Y-123029700D01* -X148472200Y-123162135D01* -X148316473Y-123266188D01* -X148143438Y-123337862D01* -X147959746Y-123374400D01* -X147772454Y-123374400D01* -X147588762Y-123337862D01* -X147415727Y-123266188D01* -X147260000Y-123162135D01* -X147127565Y-123029700D01* -X147023512Y-122873973D01* -X146951838Y-122700938D01* -X146915300Y-122517246D01* -X146915300Y-122329954D01* -X146951838Y-122146262D01* -X147023512Y-121973227D01* -X147127565Y-121817500D01* -X147260000Y-121685065D01* -X147415727Y-121581012D01* -X147588762Y-121509338D01* -X147772454Y-121472800D01* -X147959746Y-121472800D01* -X148143438Y-121509338D01* -X148143438Y-121509338D01* -G37* -G36* -X174646543Y-121529119D02* -X174712727Y-121535637D01* -X174825953Y-121569984D01* -X174882567Y-121587157D01* -X175021187Y-121661252D01* -X175039091Y-121670822D01* -X175074829Y-121700152D01* -X175176286Y-121783414D01* -X175259548Y-121884871D01* -X175288878Y-121920609D01* -X175288879Y-121920611D01* -X175372543Y-122077133D01* -X175372543Y-122077134D01* -X175424063Y-122246973D01* -X175441459Y-122423600D01* -X175424063Y-122600227D01* -X175393513Y-122700938D01* -X175372543Y-122770067D01* -X175317004Y-122873971D01* -X175288878Y-122926591D01* -X175259548Y-122962329D01* -X175176286Y-123063786D01* -X175074829Y-123147048D01* -X175039091Y-123176378D01* -X175039089Y-123176379D01* -X174882567Y-123260043D01* -X174862309Y-123266188D01* -X174712727Y-123311563D01* -X174646543Y-123318081D01* -X174580360Y-123324600D01* -X174491840Y-123324600D01* -X174425657Y-123318081D01* -X174359473Y-123311563D01* -X174209891Y-123266188D01* -X174189633Y-123260043D01* -X174033111Y-123176379D01* -X174033109Y-123176378D01* -X173997371Y-123147048D01* -X173895914Y-123063786D01* -X173812652Y-122962329D01* -X173783322Y-122926591D01* -X173755196Y-122873971D01* -X173699657Y-122770067D01* -X173678687Y-122700938D01* -X173648137Y-122600227D01* -X173630741Y-122423600D01* -X173648137Y-122246973D01* -X173699657Y-122077134D01* -X173699657Y-122077133D01* -X173783321Y-121920611D01* -X173783322Y-121920609D01* -X173812652Y-121884871D01* -X173895914Y-121783414D01* -X173997371Y-121700152D01* -X174033109Y-121670822D01* -X174051013Y-121661252D01* -X174189633Y-121587157D01* -X174246247Y-121569984D01* -X174359473Y-121535637D01* -X174425657Y-121529119D01* -X174491840Y-121522600D01* -X174580360Y-121522600D01* -X174646543Y-121529119D01* -X174646543Y-121529119D01* -G37* -G36* -X172106543Y-121529119D02* -X172172727Y-121535637D01* -X172285953Y-121569984D01* -X172342567Y-121587157D01* -X172481187Y-121661252D01* -X172499091Y-121670822D01* -X172534829Y-121700152D01* -X172636286Y-121783414D01* -X172719548Y-121884871D01* -X172748878Y-121920609D01* -X172748879Y-121920611D01* -X172832543Y-122077133D01* -X172832543Y-122077134D01* -X172884063Y-122246973D01* -X172901459Y-122423600D01* -X172884063Y-122600227D01* -X172853513Y-122700938D01* -X172832543Y-122770067D01* -X172777004Y-122873971D01* -X172748878Y-122926591D01* -X172719548Y-122962329D01* -X172636286Y-123063786D01* -X172534829Y-123147048D01* -X172499091Y-123176378D01* -X172499089Y-123176379D01* -X172342567Y-123260043D01* -X172322309Y-123266188D01* -X172172727Y-123311563D01* -X172106543Y-123318081D01* -X172040360Y-123324600D01* -X171951840Y-123324600D01* -X171885657Y-123318081D01* -X171819473Y-123311563D01* -X171669891Y-123266188D01* -X171649633Y-123260043D01* -X171493111Y-123176379D01* -X171493109Y-123176378D01* -X171457371Y-123147048D01* -X171355914Y-123063786D01* -X171272652Y-122962329D01* -X171243322Y-122926591D01* -X171215196Y-122873971D01* -X171159657Y-122770067D01* -X171138687Y-122700938D01* -X171108137Y-122600227D01* -X171090741Y-122423600D01* -X171108137Y-122246973D01* -X171159657Y-122077134D01* -X171159657Y-122077133D01* -X171243321Y-121920611D01* -X171243322Y-121920609D01* -X171272652Y-121884871D01* -X171355914Y-121783414D01* -X171457371Y-121700152D01* -X171493109Y-121670822D01* -X171511013Y-121661252D01* -X171649633Y-121587157D01* -X171706247Y-121569984D01* -X171819473Y-121535637D01* -X171885657Y-121529119D01* -X171951840Y-121522600D01* -X172040360Y-121522600D01* -X172106543Y-121529119D01* -X172106543Y-121529119D01* -G37* -G36* -X174646542Y-118989118D02* -X174712727Y-118995637D01* -X174825953Y-119029984D01* -X174882567Y-119047157D01* -X175021187Y-119121252D01* -X175039091Y-119130822D01* -X175074829Y-119160152D01* -X175176286Y-119243414D01* -X175259548Y-119344871D01* -X175288878Y-119380609D01* -X175288879Y-119380611D01* -X175372543Y-119537133D01* -X175372543Y-119537134D01* -X175424063Y-119706973D01* -X175441459Y-119883600D01* -X175424063Y-120060227D01* -X175392887Y-120163000D01* -X175372543Y-120230067D01* -X175298448Y-120368687D01* -X175288878Y-120386591D01* -X175259548Y-120422329D01* -X175176286Y-120523786D01* -X175074829Y-120607048D01* -X175039091Y-120636378D01* -X175039089Y-120636379D01* -X174882567Y-120720043D01* -X174825953Y-120737216D01* -X174712727Y-120771563D01* -X174646543Y-120778081D01* -X174580360Y-120784600D01* -X174491840Y-120784600D01* -X174425657Y-120778081D01* -X174359473Y-120771563D01* -X174246247Y-120737216D01* -X174189633Y-120720043D01* -X174033111Y-120636379D01* -X174033109Y-120636378D01* -X173997371Y-120607048D01* -X173895914Y-120523786D01* -X173812652Y-120422329D01* -X173783322Y-120386591D01* -X173773752Y-120368687D01* -X173699657Y-120230067D01* -X173679313Y-120163000D01* -X173648137Y-120060227D01* -X173630741Y-119883600D01* -X173648137Y-119706973D01* -X173699657Y-119537134D01* -X173699657Y-119537133D01* -X173783321Y-119380611D01* -X173783322Y-119380609D01* -X173812652Y-119344871D01* -X173895914Y-119243414D01* -X173997371Y-119160152D01* -X174033109Y-119130822D01* -X174051013Y-119121252D01* -X174189633Y-119047157D01* -X174246247Y-119029984D01* -X174359473Y-118995637D01* -X174425658Y-118989118D01* -X174491840Y-118982600D01* -X174580360Y-118982600D01* -X174646542Y-118989118D01* -X174646542Y-118989118D01* -G37* -G36* -X172106542Y-118989118D02* -X172172727Y-118995637D01* -X172285953Y-119029984D01* -X172342567Y-119047157D01* -X172481187Y-119121252D01* -X172499091Y-119130822D01* -X172534829Y-119160152D01* -X172636286Y-119243414D01* -X172719548Y-119344871D01* -X172748878Y-119380609D01* -X172748879Y-119380611D01* -X172832543Y-119537133D01* -X172832543Y-119537134D01* -X172884063Y-119706973D01* -X172901459Y-119883600D01* -X172884063Y-120060227D01* -X172852887Y-120163000D01* -X172832543Y-120230067D01* -X172758448Y-120368687D01* -X172748878Y-120386591D01* -X172719548Y-120422329D01* -X172636286Y-120523786D01* -X172534829Y-120607048D01* -X172499091Y-120636378D01* -X172499089Y-120636379D01* -X172342567Y-120720043D01* -X172285953Y-120737216D01* -X172172727Y-120771563D01* -X172106543Y-120778081D01* -X172040360Y-120784600D01* -X171951840Y-120784600D01* -X171885657Y-120778081D01* -X171819473Y-120771563D01* -X171706247Y-120737216D01* -X171649633Y-120720043D01* -X171493111Y-120636379D01* -X171493109Y-120636378D01* -X171457371Y-120607048D01* -X171355914Y-120523786D01* -X171272652Y-120422329D01* -X171243322Y-120386591D01* -X171233752Y-120368687D01* -X171159657Y-120230067D01* -X171139313Y-120163000D01* -X171108137Y-120060227D01* -X171090741Y-119883600D01* -X171108137Y-119706973D01* -X171159657Y-119537134D01* -X171159657Y-119537133D01* -X171243321Y-119380611D01* -X171243322Y-119380609D01* -X171272652Y-119344871D01* -X171355914Y-119243414D01* -X171457371Y-119160152D01* -X171493109Y-119130822D01* -X171511013Y-119121252D01* -X171649633Y-119047157D01* -X171706247Y-119029984D01* -X171819473Y-118995637D01* -X171885658Y-118989118D01* -X171951840Y-118982600D01* -X172040360Y-118982600D01* -X172106542Y-118989118D01* -X172106542Y-118989118D01* -G37* -G36* -X158153100Y-120163000D02* -X156629100Y-120163000D01* -X156629100Y-119350200D01* -X158153100Y-119350200D01* -X158153100Y-120163000D01* -X158153100Y-120163000D01* -G37* -G36* -X152438100Y-120163000D02* -X150914100Y-120163000D01* -X150914100Y-119350200D01* -X152438100Y-119350200D01* -X152438100Y-120163000D01* -X152438100Y-120163000D01* -G37* -G36* -X127823438Y-116429338D02* -X127996473Y-116501012D01* -X128152200Y-116605065D01* -X128284635Y-116737500D01* -X128388688Y-116893227D01* -X128460362Y-117066262D01* -X128496900Y-117249954D01* -X128496900Y-117437246D01* -X128460362Y-117620938D01* -X128388688Y-117793973D01* -X128284635Y-117949700D01* -X128152200Y-118082135D01* -X127996473Y-118186188D01* -X127823438Y-118257862D01* -X127639746Y-118294400D01* -X127452454Y-118294400D01* -X127268762Y-118257862D01* -X127095727Y-118186188D01* -X126940000Y-118082135D01* -X126807565Y-117949700D01* -X126703512Y-117793973D01* -X126631838Y-117620938D01* -X126595300Y-117437246D01* -X126595300Y-117249954D01* -X126631838Y-117066262D01* -X126703512Y-116893227D01* -X126807565Y-116737500D01* -X126940000Y-116605065D01* -X127095727Y-116501012D01* -X127268762Y-116429338D01* -X127452454Y-116392800D01* -X127639746Y-116392800D01* -X127823438Y-116429338D01* -X127823438Y-116429338D01* -G37* -G36* -X125189446Y-116421858D02* -X125280229Y-116439916D01* -X125451262Y-116510760D01* -X125592399Y-116605065D01* -X125605190Y-116613612D01* -X125736088Y-116744510D01* -X125736090Y-116744513D01* -X125838940Y-116898438D01* -X125909784Y-117069471D01* -X125909784Y-117069473D01* -X125945900Y-117251036D01* -X125945900Y-117436164D01* -X125929179Y-117520225D01* -X125909784Y-117617729D01* -X125838940Y-117788762D01* -X125779981Y-117877000D01* -X125736088Y-117942690D01* -X125605190Y-118073588D01* -X125605187Y-118073590D01* -X125451262Y-118176440D01* -X125280229Y-118247284D01* -X125189445Y-118265342D01* -X125098664Y-118283400D01* -X124913536Y-118283400D01* -X124822755Y-118265342D01* -X124731971Y-118247284D01* -X124560938Y-118176440D01* -X124407013Y-118073590D01* -X124407010Y-118073588D01* -X124276112Y-117942690D01* -X124232219Y-117877000D01* -X124173260Y-117788762D01* -X124102416Y-117617729D01* -X124083021Y-117520225D01* -X124066300Y-117436164D01* -X124066300Y-117251036D01* -X124102416Y-117069473D01* -X124102416Y-117069471D01* -X124173260Y-116898438D01* -X124276110Y-116744513D01* -X124276112Y-116744510D01* -X124407010Y-116613612D01* -X124419801Y-116605065D01* -X124560938Y-116510760D01* -X124731971Y-116439916D01* -X124822754Y-116421858D01* -X124913536Y-116403800D01* -X125098664Y-116403800D01* -X125189446Y-116421858D01* -X125189446Y-116421858D01* -G37* -G36* -X172897100Y-118244600D02* -X171095100Y-118244600D01* -X171095100Y-116442600D01* -X172897100Y-116442600D01* -X172897100Y-118244600D01* -X172897100Y-118244600D01* -G37* -G36* -X174646542Y-116449118D02* -X174712727Y-116455637D01* -X174825953Y-116489984D01* -X174882567Y-116507157D01* -X175021187Y-116581252D01* -X175039091Y-116590822D01* -X175066858Y-116613610D01* -X175176286Y-116703414D01* -X175259548Y-116804871D01* -X175288878Y-116840609D01* -X175288879Y-116840611D01* -X175372543Y-116997133D01* -X175372543Y-116997134D01* -X175424063Y-117166973D01* -X175441459Y-117343600D01* -X175424063Y-117520227D01* -X175394487Y-117617727D01* -X175372543Y-117690067D01* -X175319788Y-117788763D01* -X175288878Y-117846591D01* -X175263922Y-117877000D01* -X175176286Y-117983786D01* -X175074829Y-118067048D01* -X175039091Y-118096378D01* -X175039089Y-118096379D01* -X174882567Y-118180043D01* -X174862309Y-118186188D01* -X174712727Y-118231563D01* -X174646542Y-118238082D01* -X174580360Y-118244600D01* -X174491840Y-118244600D01* -X174425658Y-118238082D01* -X174359473Y-118231563D01* -X174209891Y-118186188D01* -X174189633Y-118180043D01* -X174033111Y-118096379D01* -X174033109Y-118096378D01* -X173997371Y-118067048D01* -X173895914Y-117983786D01* -X173808278Y-117877000D01* -X173783322Y-117846591D01* -X173752412Y-117788763D01* -X173699657Y-117690067D01* -X173677713Y-117617727D01* -X173648137Y-117520227D01* -X173630741Y-117343600D01* -X173648137Y-117166973D01* -X173699657Y-116997134D01* -X173699657Y-116997133D01* -X173783321Y-116840611D01* -X173783322Y-116840609D01* -X173812652Y-116804871D01* -X173895914Y-116703414D01* -X174005342Y-116613610D01* -X174033109Y-116590822D01* -X174051013Y-116581252D01* -X174189633Y-116507157D01* -X174246247Y-116489984D01* -X174359473Y-116455637D01* -X174425658Y-116449118D01* -X174491840Y-116442600D01* -X174580360Y-116442600D01* -X174646542Y-116449118D01* -X174646542Y-116449118D01* -G37* -G36* -X152438100Y-117877000D02* -X150914100Y-117877000D01* -X150914100Y-117064200D01* -X152438100Y-117064200D01* -X152438100Y-117877000D01* -X152438100Y-117877000D01* -G37* -G36* -X158153100Y-117877000D02* -X156629100Y-117877000D01* -X156629100Y-117064200D01* -X158153100Y-117064200D01* -X158153100Y-117877000D01* -X158153100Y-117877000D01* -G37* -G36* -X125189446Y-113881858D02* -X125280229Y-113899916D01* -X125451262Y-113970760D01* -X125451263Y-113970761D01* -X125605190Y-114073612D01* -X125736088Y-114204510D01* -X125736090Y-114204513D01* -X125838940Y-114358438D01* -X125909784Y-114529471D01* -X125909784Y-114529473D01* -X125945900Y-114711036D01* -X125945900Y-114896164D01* -X125927842Y-114986945D01* -X125909784Y-115077729D01* -X125838940Y-115248762D01* -X125838939Y-115248763D01* -X125736088Y-115402690D01* -X125605190Y-115533588D01* -X125605187Y-115533590D01* -X125451262Y-115636440D01* -X125280229Y-115707284D01* -X125189445Y-115725342D01* -X125098664Y-115743400D01* -X124913536Y-115743400D01* -X124822755Y-115725342D01* -X124731971Y-115707284D01* -X124560938Y-115636440D01* -X124407013Y-115533590D01* -X124407010Y-115533588D01* -X124276112Y-115402690D01* -X124173261Y-115248763D01* -X124173260Y-115248762D01* -X124102416Y-115077729D01* -X124084358Y-114986945D01* -X124066300Y-114896164D01* -X124066300Y-114711036D01* -X124102416Y-114529473D01* -X124102416Y-114529471D01* -X124173260Y-114358438D01* -X124276110Y-114204513D01* -X124276112Y-114204510D01* -X124407010Y-114073612D01* -X124560937Y-113970761D01* -X124560938Y-113970760D01* -X124731971Y-113899916D01* -X124822754Y-113881858D01* -X124913536Y-113863800D01* -X125098664Y-113863800D01* -X125189446Y-113881858D01* -X125189446Y-113881858D01* -G37* -G36* -X174813438Y-113254338D02* -X174986473Y-113326012D01* -X175142200Y-113430065D01* -X175274635Y-113562500D01* -X175378688Y-113718227D01* -X175450362Y-113891262D01* -X175486900Y-114074954D01* -X175486900Y-114262246D01* -X175450362Y-114445938D01* -X175378688Y-114618973D01* -X175274635Y-114774700D01* -X175142200Y-114907135D01* -X174986473Y-115011188D01* -X174813438Y-115082862D01* -X174629746Y-115119400D01* -X174442454Y-115119400D01* -X174258762Y-115082862D01* -X174085727Y-115011188D01* -X173930000Y-114907135D01* -X173797565Y-114774700D01* -X173693512Y-114618973D01* -X173621838Y-114445938D01* -X173585300Y-114262246D01* -X173585300Y-114074954D01* -X173621838Y-113891262D01* -X173693512Y-113718227D01* -X173797565Y-113562500D01* -X173930000Y-113430065D01* -X174085727Y-113326012D01* -X174258762Y-113254338D01* -X174442454Y-113217800D01* -X174629746Y-113217800D01* -X174813438Y-113254338D01* -X174813438Y-113254338D01* -G37* -G36* -X172273438Y-113254338D02* -X172446473Y-113326012D01* -X172602200Y-113430065D01* -X172734635Y-113562500D01* -X172838688Y-113718227D01* -X172910362Y-113891262D01* -X172946900Y-114074954D01* -X172946900Y-114262246D01* -X172910362Y-114445938D01* -X172838688Y-114618973D01* -X172734635Y-114774700D01* -X172602200Y-114907135D01* -X172446473Y-115011188D01* -X172273438Y-115082862D01* -X172089746Y-115119400D01* -X171902454Y-115119400D01* -X171718762Y-115082862D01* -X171545727Y-115011188D01* -X171390000Y-114907135D01* -X171257565Y-114774700D01* -X171153512Y-114618973D01* -X171081838Y-114445938D01* -X171045300Y-114262246D01* -X171045300Y-114074954D01* -X171081838Y-113891262D01* -X171153512Y-113718227D01* -X171257565Y-113562500D01* -X171390000Y-113430065D01* -X171545727Y-113326012D01* -X171718762Y-113254338D01* -X171902454Y-113217800D01* -X172089746Y-113217800D01* -X172273438Y-113254338D01* -X172273438Y-113254338D01* -G37* -G36* -X129075412Y-111408764D02* -X129237198Y-111475778D01* -X129382807Y-111573071D01* -X129506629Y-111696893D01* -X129603922Y-111842502D01* -X129670936Y-112004288D01* -X129705100Y-112176041D01* -X129705100Y-112275000D01* -X129707502Y-112299386D01* -X129714615Y-112322835D01* -X129726166Y-112344446D01* -X129741712Y-112363388D01* -X129760654Y-112378934D01* -X129782265Y-112390485D01* -X129805714Y-112397598D01* -X129830100Y-112400000D01* -X131293300Y-112400000D01* -X131293300Y-114001600D01* -X129691700Y-114001600D01* -X129691700Y-112947012D01* -X129689298Y-112922626D01* -X129682185Y-112899177D01* -X129670634Y-112877566D01* -X129655088Y-112858624D01* -X129636146Y-112843078D01* -X129614535Y-112831527D01* -X129591086Y-112824414D01* -X129566700Y-112822012D01* -X129542314Y-112824414D01* -X129518865Y-112831527D01* -X129497254Y-112843078D01* -X129478312Y-112858624D01* -X129382807Y-112954129D01* -X129237198Y-113051422D01* -X129075412Y-113118436D01* -X128903659Y-113152600D01* -X128728541Y-113152600D01* -X128556788Y-113118436D01* -X128395002Y-113051422D01* -X128249393Y-112954129D01* -X128125571Y-112830307D01* -X128028278Y-112684698D01* -X127961264Y-112522912D01* -X127927100Y-112351159D01* -X127927100Y-112176041D01* -X127961264Y-112004288D01* -X128028278Y-111842502D01* -X128125571Y-111696893D01* -X128249393Y-111573071D01* -X128395002Y-111475778D01* -X128556788Y-111408764D01* -X128728541Y-111374600D01* -X128903659Y-111374600D01* -X129075412Y-111408764D01* -X129075412Y-111408764D01* -G37* -G36* -X125189445Y-111341858D02* -X125280229Y-111359916D01* -X125451262Y-111430760D01* -X125476095Y-111447353D01* -X125605190Y-111533612D01* -X125736088Y-111664510D01* -X125736090Y-111664513D01* -X125838940Y-111818438D01* -X125909784Y-111989471D01* -X125909784Y-111989473D01* -X125945900Y-112171036D01* -X125945900Y-112356164D01* -X125939073Y-112390485D01* -X125909784Y-112537729D01* -X125838940Y-112708762D01* -X125838939Y-112708763D01* -X125736088Y-112862690D01* -X125605190Y-112993588D01* -X125605187Y-112993590D01* -X125451262Y-113096440D01* -X125280229Y-113167284D01* -X125189446Y-113185342D01* -X125098664Y-113203400D01* -X124913536Y-113203400D01* -X124822754Y-113185342D01* -X124731971Y-113167284D01* -X124560938Y-113096440D01* -X124407013Y-112993590D01* -X124407010Y-112993588D01* -X124276112Y-112862690D01* -X124173261Y-112708763D01* -X124173260Y-112708762D01* -X124102416Y-112537729D01* -X124073127Y-112390485D01* -X124066300Y-112356164D01* -X124066300Y-112171036D01* -X124102416Y-111989473D01* -X124102416Y-111989471D01* -X124173260Y-111818438D01* -X124276110Y-111664513D01* -X124276112Y-111664510D01* -X124407010Y-111533612D01* -X124536105Y-111447353D01* -X124560938Y-111430760D01* -X124731971Y-111359916D01* -X124822755Y-111341858D01* -X124913536Y-111323800D01* -X125098664Y-111323800D01* -X125189445Y-111341858D01* -X125189445Y-111341858D01* -G37* -G36* -X172456828Y-110184720D02* -X172536437Y-110192561D01* -X172638579Y-110223546D01* -X172689651Y-110239038D01* -X172765125Y-110279380D01* -X172830852Y-110314512D01* -X172954617Y-110416083D01* -X173056188Y-110539848D01* -X173076814Y-110578436D01* -X173131662Y-110681049D01* -X173131662Y-110681050D01* -X173178139Y-110834263D01* -X173193832Y-110993600D01* -X173178139Y-111152937D01* -X173147154Y-111255079D01* -X173131662Y-111306151D01* -X173095075Y-111374600D01* -X173056188Y-111447352D01* -X172954617Y-111571117D01* -X172830852Y-111672688D01* -X172785562Y-111696896D01* -X172689651Y-111748162D01* -X172638579Y-111763654D01* -X172536437Y-111794639D01* -X172456828Y-111802480D01* -X172417024Y-111806400D01* -X170813176Y-111806400D01* -X170773372Y-111802480D01* -X170693763Y-111794639D01* -X170591621Y-111763654D01* -X170540549Y-111748162D01* -X170444638Y-111696896D01* -X170399348Y-111672688D01* -X170275583Y-111571117D01* -X170174012Y-111447352D01* -X170135125Y-111374600D01* -X170098538Y-111306151D01* -X170083046Y-111255079D01* -X170052061Y-111152937D01* -X170036368Y-110993600D01* -X170052061Y-110834263D01* -X170098538Y-110681050D01* -X170098538Y-110681049D01* -X170153386Y-110578436D01* -X170174012Y-110539848D01* -X170275583Y-110416083D01* -X170399348Y-110314512D01* -X170465075Y-110279380D01* -X170540549Y-110239038D01* -X170591621Y-110223546D01* -X170693763Y-110192561D01* -X170773372Y-110184720D01* -X170813176Y-110180800D01* -X172417024Y-110180800D01* -X172456828Y-110184720D01* -X172456828Y-110184720D01* -G37* -G36* -X157542043Y-110235275D02* -X157616678Y-110242626D01* -X157712436Y-110271674D01* -X157760316Y-110286198D01* -X157808599Y-110312006D01* -X157892692Y-110356955D01* -X158008722Y-110452178D01* -X158103945Y-110568208D01* -X158127673Y-110612600D01* -X158174702Y-110700584D01* -X158174702Y-110700585D01* -X158218274Y-110844222D01* -X158232986Y-110993600D01* -X158218274Y-111142978D01* -X158189226Y-111238736D01* -X158174702Y-111286616D01* -X158164260Y-111306151D01* -X158103945Y-111418992D01* -X158008722Y-111535022D01* -X157892692Y-111630245D01* -X157828581Y-111664513D01* -X157760316Y-111701002D01* -X157712436Y-111715526D01* -X157616678Y-111744574D01* -X157542043Y-111751925D01* -X157504727Y-111755600D01* -X156007473Y-111755600D01* -X155970157Y-111751925D01* -X155895522Y-111744574D01* -X155799764Y-111715526D01* -X155751884Y-111701002D01* -X155683619Y-111664513D01* -X155619508Y-111630245D01* -X155503478Y-111535022D01* -X155408255Y-111418992D01* -X155347940Y-111306151D01* -X155337498Y-111286616D01* -X155322974Y-111238736D01* -X155293926Y-111142978D01* -X155279214Y-110993600D01* -X155293926Y-110844222D01* -X155337498Y-110700585D01* -X155337498Y-110700584D01* -X155384527Y-110612600D01* -X155408255Y-110568208D01* -X155503478Y-110452178D01* -X155619508Y-110356955D01* -X155703601Y-110312006D01* -X155751884Y-110286198D01* -X155799764Y-110271674D01* -X155895522Y-110242626D01* -X155970157Y-110235275D01* -X156007473Y-110231600D01* -X157504727Y-110231600D01* -X157542043Y-110235275D01* -X157542043Y-110235275D01* -G37* -G36* -X125189445Y-108801858D02* -X125280229Y-108819916D01* -X125451262Y-108890760D01* -X125476095Y-108907353D01* -X125605190Y-108993612D01* -X125736088Y-109124510D01* -X125736090Y-109124513D01* -X125838940Y-109278438D01* -X125909784Y-109449471D01* -X125945900Y-109631038D01* -X125945900Y-109816162D01* -X125909784Y-109997729D01* -X125838940Y-110168762D01* -X125838939Y-110168763D01* -X125736088Y-110322690D01* -X125605190Y-110453588D01* -X125605187Y-110453590D01* -X125451262Y-110556440D01* -X125280229Y-110627284D01* -X125189446Y-110645342D01* -X125098664Y-110663400D01* -X124913536Y-110663400D01* -X124822754Y-110645342D01* -X124731971Y-110627284D01* -X124560938Y-110556440D01* -X124407013Y-110453590D01* -X124407010Y-110453588D01* -X124276112Y-110322690D01* -X124173261Y-110168763D01* -X124173260Y-110168762D01* -X124102416Y-109997729D01* -X124066300Y-109816162D01* -X124066300Y-109631038D01* -X124102416Y-109449471D01* -X124173260Y-109278438D01* -X124276110Y-109124513D01* -X124276112Y-109124510D01* -X124407010Y-108993612D01* -X124536105Y-108907353D01* -X124560938Y-108890760D01* -X124731971Y-108819916D01* -X124822755Y-108801858D01* -X124913536Y-108783800D01* -X125098664Y-108783800D01* -X125189445Y-108801858D01* -X125189445Y-108801858D01* -G37* -G36* -X129075412Y-108868764D02* -X129237198Y-108935778D01* -X129382807Y-109033071D01* -X129478312Y-109128576D01* -X129497254Y-109144122D01* -X129518865Y-109155673D01* -X129542314Y-109162786D01* -X129566700Y-109165188D01* -X129591086Y-109162786D01* -X129614535Y-109155673D01* -X129636146Y-109144122D01* -X129655088Y-109128576D01* -X129670634Y-109109634D01* -X129682185Y-109088023D01* -X129689298Y-109064574D01* -X129691700Y-109040188D01* -X129691700Y-108900000D01* -X131293300Y-108900000D01* -X131293300Y-110501600D01* -X129691700Y-110501600D01* -X129691700Y-110407012D01* -X129689298Y-110382626D01* -X129682185Y-110359177D01* -X129670634Y-110337566D01* -X129655088Y-110318624D01* -X129636146Y-110303078D01* -X129614535Y-110291527D01* -X129591086Y-110284414D01* -X129566700Y-110282012D01* -X129542314Y-110284414D01* -X129518865Y-110291527D01* -X129497254Y-110303078D01* -X129478312Y-110318624D01* -X129382807Y-110414129D01* -X129237198Y-110511422D01* -X129075412Y-110578436D01* -X128903659Y-110612600D01* -X128728541Y-110612600D01* -X128556788Y-110578436D01* -X128395002Y-110511422D01* -X128249393Y-110414129D01* -X128125571Y-110290307D01* -X128028278Y-110144698D01* -X127961264Y-109982912D01* -X127927100Y-109811159D01* -X127927100Y-109636041D01* -X127961264Y-109464288D01* -X128028278Y-109302502D01* -X128125571Y-109156893D01* -X128249393Y-109033071D01* -X128395002Y-108935778D01* -X128556788Y-108868764D01* -X128728541Y-108834600D01* -X128903659Y-108834600D01* -X129075412Y-108868764D01* -X129075412Y-108868764D01* -G37* -G36* -X172456828Y-107644720D02* -X172536437Y-107652561D01* -X172638579Y-107683546D01* -X172689651Y-107699038D01* -X172765125Y-107739380D01* -X172830852Y-107774512D01* -X172954617Y-107876083D01* -X173056188Y-107999848D01* -X173070267Y-108026188D01* -X173131662Y-108141049D01* -X173131662Y-108141050D01* -X173178139Y-108294263D01* -X173193832Y-108453600D01* -X173178139Y-108612937D01* -X173147154Y-108715079D01* -X173131662Y-108766151D01* -X173095075Y-108834600D01* -X173056188Y-108907352D01* -X172954617Y-109031117D01* -X172830852Y-109132688D01* -X172770049Y-109165188D01* -X172689651Y-109208162D01* -X172638579Y-109223654D01* -X172536437Y-109254639D01* -X172456828Y-109262480D01* -X172417024Y-109266400D01* -X170813176Y-109266400D01* -X170773372Y-109262480D01* -X170693763Y-109254639D01* -X170591621Y-109223654D01* -X170540549Y-109208162D01* -X170460151Y-109165188D01* -X170399348Y-109132688D01* -X170275583Y-109031117D01* -X170174012Y-108907352D01* -X170135125Y-108834600D01* -X170098538Y-108766151D01* -X170083046Y-108715079D01* -X170052061Y-108612937D01* -X170036368Y-108453600D01* -X170052061Y-108294263D01* -X170098538Y-108141050D01* -X170098538Y-108141049D01* -X170159933Y-108026188D01* -X170174012Y-107999848D01* -X170275583Y-107876083D01* -X170399348Y-107774512D01* -X170465075Y-107739380D01* -X170540549Y-107699038D01* -X170591621Y-107683546D01* -X170693763Y-107652561D01* -X170773372Y-107644720D01* -X170813176Y-107640800D01* -X172417024Y-107640800D01* -X172456828Y-107644720D01* -X172456828Y-107644720D01* -G37* -G36* -X127823438Y-106269338D02* -X127996473Y-106341012D01* -X128152200Y-106445065D01* -X128284635Y-106577500D01* -X128388688Y-106733227D01* -X128460362Y-106906262D01* -X128496900Y-107089954D01* -X128496900Y-107277246D01* -X128460362Y-107460938D01* -X128388688Y-107633973D01* -X128284635Y-107789700D01* -X128152200Y-107922135D01* -X127996473Y-108026188D01* -X127823438Y-108097862D01* -X127639746Y-108134400D01* -X127452454Y-108134400D01* -X127268762Y-108097862D01* -X127095727Y-108026188D01* -X126940000Y-107922135D01* -X126807565Y-107789700D01* -X126703512Y-107633973D01* -X126631838Y-107460938D01* -X126595300Y-107277246D01* -X126595300Y-107089954D01* -X126631838Y-106906262D01* -X126703512Y-106733227D01* -X126807565Y-106577500D01* -X126940000Y-106445065D01* -X127095727Y-106341012D01* -X127268762Y-106269338D01* -X127452454Y-106232800D01* -X127639746Y-106232800D01* -X127823438Y-106269338D01* -X127823438Y-106269338D01* -G37* -G36* -X125189446Y-106261858D02* -X125280229Y-106279916D01* -X125451262Y-106350760D01* -X125476095Y-106367353D01* -X125605190Y-106453612D01* -X125736088Y-106584510D01* -X125736090Y-106584513D01* -X125838940Y-106738438D01* -X125909784Y-106909471D01* -X125909784Y-106909473D01* -X125945900Y-107091036D01* -X125945900Y-107276164D01* -X125927842Y-107366946D01* -X125909784Y-107457729D01* -X125838940Y-107628762D01* -X125838939Y-107628763D01* -X125736088Y-107782690D01* -X125605190Y-107913588D01* -X125605187Y-107913590D01* -X125451262Y-108016440D01* -X125280229Y-108087284D01* -X125189446Y-108105342D01* -X125098664Y-108123400D01* -X124913536Y-108123400D01* -X124822754Y-108105342D01* -X124731971Y-108087284D01* -X124560938Y-108016440D01* -X124407013Y-107913590D01* -X124407010Y-107913588D01* -X124276112Y-107782690D01* -X124173261Y-107628763D01* -X124173260Y-107628762D01* -X124102416Y-107457729D01* -X124084358Y-107366945D01* -X124066300Y-107276164D01* -X124066300Y-107091036D01* -X124102416Y-106909473D01* -X124102416Y-106909471D01* -X124173260Y-106738438D01* -X124276110Y-106584513D01* -X124276112Y-106584510D01* -X124407010Y-106453612D01* -X124536105Y-106367353D01* -X124560938Y-106350760D01* -X124731971Y-106279916D01* -X124822754Y-106261858D01* -X124913536Y-106243800D01* -X125098664Y-106243800D01* -X125189446Y-106261858D01* -X125189446Y-106261858D01* -G37* -G36* -X172456828Y-105104720D02* -X172536437Y-105112561D01* -X172638579Y-105143546D01* -X172689651Y-105159038D01* -X172765125Y-105199380D01* -X172830852Y-105234512D01* -X172954617Y-105336083D01* -X173056188Y-105459848D01* -X173091320Y-105525575D01* -X173131662Y-105601049D01* -X173131662Y-105601050D01* -X173178139Y-105754263D01* -X173193832Y-105913600D01* -X173178139Y-106072937D01* -X173147154Y-106175079D01* -X173131662Y-106226151D01* -X173091320Y-106301625D01* -X173056188Y-106367352D01* -X172954617Y-106491117D01* -X172830852Y-106592688D01* -X172777880Y-106621002D01* -X172689651Y-106668162D01* -X172638579Y-106683654D01* -X172536437Y-106714639D01* -X172456828Y-106722480D01* -X172417024Y-106726400D01* -X170813176Y-106726400D01* -X170773372Y-106722480D01* -X170693763Y-106714639D01* -X170591621Y-106683654D01* -X170540549Y-106668162D01* -X170452320Y-106621002D01* -X170399348Y-106592688D01* -X170275583Y-106491117D01* -X170174012Y-106367352D01* -X170138880Y-106301625D01* -X170098538Y-106226151D01* -X170083046Y-106175079D01* -X170052061Y-106072937D01* -X170036368Y-105913600D01* -X170052061Y-105754263D01* -X170098538Y-105601050D01* -X170098538Y-105601049D01* -X170138880Y-105525575D01* -X170174012Y-105459848D01* -X170275583Y-105336083D01* -X170399348Y-105234512D01* -X170465075Y-105199380D01* -X170540549Y-105159038D01* -X170591621Y-105143546D01* -X170693763Y-105112561D01* -X170773372Y-105104720D01* -X170813176Y-105100800D01* -X172417024Y-105100800D01* -X172456828Y-105104720D01* -X172456828Y-105104720D01* -G37* -G36* -X157542043Y-105155275D02* -X157616678Y-105162626D01* -X157712436Y-105191674D01* -X157760316Y-105206198D01* -X157808599Y-105232006D01* -X157892692Y-105276955D01* -X158008722Y-105372178D01* -X158103945Y-105488208D01* -X158135522Y-105547284D01* -X158174702Y-105620584D01* -X158174702Y-105620585D01* -X158218274Y-105764222D01* -X158232986Y-105913600D01* -X158218274Y-106062978D01* -X158189226Y-106158736D01* -X158174702Y-106206616D01* -X158164260Y-106226151D01* -X158103945Y-106338992D01* -X158008722Y-106455022D01* -X157892692Y-106550245D01* -X157828581Y-106584513D01* -X157760316Y-106621002D01* -X157712436Y-106635526D01* -X157616678Y-106664574D01* -X157542043Y-106671925D01* -X157504727Y-106675600D01* -X156007473Y-106675600D01* -X155970157Y-106671925D01* -X155895522Y-106664574D01* -X155799764Y-106635526D01* -X155751884Y-106621002D01* -X155683619Y-106584513D01* -X155619508Y-106550245D01* -X155503478Y-106455022D01* -X155408255Y-106338992D01* -X155347940Y-106226151D01* -X155337498Y-106206616D01* -X155322974Y-106158736D01* -X155293926Y-106062978D01* -X155279214Y-105913600D01* -X155293926Y-105764222D01* -X155337498Y-105620585D01* -X155337498Y-105620584D01* -X155376678Y-105547284D01* -X155408255Y-105488208D01* -X155503478Y-105372178D01* -X155619508Y-105276955D01* -X155703601Y-105232006D01* -X155751884Y-105206198D01* -X155799764Y-105191674D01* -X155895522Y-105162626D01* -X155970157Y-105155275D01* -X156007473Y-105151600D01* -X157504727Y-105151600D01* -X157542043Y-105155275D01* -X157542043Y-105155275D01* -G37* -G36* -X125189446Y-103721858D02* -X125280229Y-103739916D01* -X125451262Y-103810760D01* -X125451263Y-103810761D01* -X125605190Y-103913612D01* -X125736088Y-104044510D01* -X125736090Y-104044513D01* -X125838940Y-104198438D01* -X125909784Y-104369471D01* -X125945900Y-104551038D01* -X125945900Y-104736162D01* -X125909784Y-104917729D01* -X125838940Y-105088762D01* -X125838939Y-105088763D01* -X125736088Y-105242690D01* -X125605190Y-105373588D01* -X125605187Y-105373590D01* -X125451262Y-105476440D01* -X125280229Y-105547284D01* -X125189446Y-105565342D01* -X125098664Y-105583400D01* -X124913536Y-105583400D01* -X124822754Y-105565342D01* -X124731971Y-105547284D01* -X124560938Y-105476440D01* -X124407013Y-105373590D01* -X124407010Y-105373588D01* -X124276112Y-105242690D01* -X124173261Y-105088763D01* -X124173260Y-105088762D01* -X124102416Y-104917729D01* -X124066300Y-104736162D01* -X124066300Y-104551038D01* -X124102416Y-104369471D01* -X124173260Y-104198438D01* -X124276110Y-104044513D01* -X124276112Y-104044510D01* -X124407010Y-103913612D01* -X124560937Y-103810761D01* -X124560938Y-103810760D01* -X124731971Y-103739916D01* -X124822755Y-103721858D01* -X124913536Y-103703800D01* -X125098664Y-103703800D01* -X125189446Y-103721858D01* -X125189446Y-103721858D01* -G37* -G36* -X125189446Y-101181858D02* -X125280229Y-101199916D01* -X125451262Y-101270760D01* -X125451263Y-101270761D01* -X125605190Y-101373612D01* -X125736088Y-101504510D01* -X125736090Y-101504513D01* -X125838940Y-101658438D01* -X125909784Y-101829471D01* -X125945900Y-102011038D01* -X125945900Y-102196162D01* -X125909784Y-102377729D01* -X125838940Y-102548762D01* -X125838939Y-102548763D01* -X125736088Y-102702690D01* -X125605190Y-102833588D01* -X125605187Y-102833590D01* -X125451262Y-102936440D01* -X125280229Y-103007284D01* -X125189446Y-103025342D01* -X125098664Y-103043400D01* -X124913536Y-103043400D01* -X124822754Y-103025342D01* -X124731971Y-103007284D01* -X124560938Y-102936440D01* -X124407013Y-102833590D01* -X124407010Y-102833588D01* -X124276112Y-102702690D01* -X124173261Y-102548763D01* -X124173260Y-102548762D01* -X124102416Y-102377729D01* -X124066300Y-102196162D01* -X124066300Y-102011038D01* -X124102416Y-101829471D01* -X124173260Y-101658438D01* -X124276110Y-101504513D01* -X124276112Y-101504510D01* -X124407010Y-101373612D01* -X124560937Y-101270761D01* -X124560938Y-101270760D01* -X124731971Y-101199916D01* -X124822754Y-101181858D01* -X124913536Y-101163800D01* -X125098664Y-101163800D01* -X125189446Y-101181858D01* -X125189446Y-101181858D01* -G37* -G36* -X172273438Y-98649338D02* -X172446473Y-98721012D01* -X172602200Y-98825065D01* -X172734635Y-98957500D01* -X172838688Y-99113227D01* -X172910362Y-99286262D01* -X172946900Y-99469954D01* -X172946900Y-99657246D01* -X172910362Y-99840938D01* -X172838688Y-100013973D01* -X172734635Y-100169700D01* -X172602200Y-100302135D01* -X172446473Y-100406188D01* -X172273438Y-100477862D01* -X172089746Y-100514400D01* -X171902454Y-100514400D01* -X171718762Y-100477862D01* -X171545727Y-100406188D01* -X171390000Y-100302135D01* -X171257565Y-100169700D01* -X171153512Y-100013973D01* -X171081838Y-99840938D01* -X171045300Y-99657246D01* -X171045300Y-99469954D01* -X171081838Y-99286262D01* -X171153512Y-99113227D01* -X171257565Y-98957500D01* -X171390000Y-98825065D01* -X171545727Y-98721012D01* -X171718762Y-98649338D01* -X171902454Y-98612800D01* -X172089746Y-98612800D01* -X172273438Y-98649338D01* -X172273438Y-98649338D01* -G37* -G36* -X169733438Y-98649338D02* -X169906473Y-98721012D01* -X170062200Y-98825065D01* -X170194635Y-98957500D01* -X170298688Y-99113227D01* -X170370362Y-99286262D01* -X170406900Y-99469954D01* -X170406900Y-99657246D01* -X170370362Y-99840938D01* -X170298688Y-100013973D01* -X170194635Y-100169700D01* -X170062200Y-100302135D01* -X169906473Y-100406188D01* -X169733438Y-100477862D01* -X169549746Y-100514400D01* -X169362454Y-100514400D01* -X169178762Y-100477862D01* -X169005727Y-100406188D01* -X168850000Y-100302135D01* -X168717565Y-100169700D01* -X168613512Y-100013973D01* -X168541838Y-99840938D01* -X168505300Y-99657246D01* -X168505300Y-99469954D01* -X168541838Y-99286262D01* -X168613512Y-99113227D01* -X168717565Y-98957500D01* -X168850000Y-98825065D01* -X169005727Y-98721012D01* -X169178762Y-98649338D01* -X169362454Y-98612800D01* -X169549746Y-98612800D01* -X169733438Y-98649338D01* -X169733438Y-98649338D01* -G37* -G36* -X125189445Y-98641858D02* -X125280229Y-98659916D01* -X125451262Y-98730760D01* -X125592399Y-98825065D01* -X125605190Y-98833612D01* -X125736088Y-98964510D01* -X125736090Y-98964513D01* -X125838940Y-99118438D01* -X125909784Y-99289471D01* -X125909784Y-99289473D01* -X125945900Y-99471036D01* -X125945900Y-99656164D01* -X125929179Y-99740225D01* -X125909784Y-99837729D01* -X125838940Y-100008762D01* -X125737479Y-100160609D01* -X125736088Y-100162690D01* -X125605190Y-100293588D01* -X125605187Y-100293590D01* -X125451262Y-100396440D01* -X125280229Y-100467284D01* -X125189445Y-100485342D01* -X125098664Y-100503400D01* -X124913536Y-100503400D01* -X124822755Y-100485342D01* -X124731971Y-100467284D01* -X124560938Y-100396440D01* -X124407013Y-100293590D01* -X124407010Y-100293588D01* -X124276112Y-100162690D01* -X124274721Y-100160609D01* -X124173260Y-100008762D01* -X124102416Y-99837729D01* -X124083021Y-99740225D01* -X124066300Y-99656164D01* -X124066300Y-99471036D01* -X124102416Y-99289473D01* -X124102416Y-99289471D01* -X124173260Y-99118438D01* -X124276110Y-98964513D01* -X124276112Y-98964510D01* -X124407010Y-98833612D01* -X124419801Y-98825065D01* -X124560938Y-98730760D01* -X124731971Y-98659916D01* -X124822755Y-98641858D01* -X124913536Y-98623800D01* -X125098664Y-98623800D01* -X125189445Y-98641858D01* -X125189445Y-98641858D01* -G37* -G36* -X128943100Y-100478000D02* -X127419100Y-100478000D01* -X127419100Y-99665200D01* -X128943100Y-99665200D01* -X128943100Y-100478000D01* -X128943100Y-100478000D01* -G37* -G36* -X174646543Y-98669119D02* -X174712727Y-98675637D01* -X174825953Y-98709984D01* -X174882567Y-98727157D01* -X175021187Y-98801252D01* -X175039091Y-98810822D01* -X175066858Y-98833610D01* -X175176286Y-98923414D01* -X175259548Y-99024871D01* -X175288878Y-99060609D01* -X175288879Y-99060611D01* -X175372543Y-99217133D01* -X175372543Y-99217134D01* -X175424063Y-99386973D01* -X175441459Y-99563600D01* -X175424063Y-99740227D01* -X175394487Y-99837727D01* -X175372543Y-99910067D01* -X175319788Y-100008763D01* -X175288878Y-100066591D01* -X175259548Y-100102329D01* -X175176286Y-100203786D01* -X175074829Y-100287048D01* -X175039091Y-100316378D01* -X175039089Y-100316379D01* -X174882567Y-100400043D01* -X174862309Y-100406188D01* -X174712727Y-100451563D01* -X174646543Y-100458081D01* -X174580360Y-100464600D01* -X174491840Y-100464600D01* -X174425657Y-100458081D01* -X174359473Y-100451563D01* -X174209891Y-100406188D01* -X174189633Y-100400043D01* -X174033111Y-100316379D01* -X174033109Y-100316378D01* -X173997371Y-100287048D01* -X173895914Y-100203786D01* -X173812652Y-100102329D01* -X173783322Y-100066591D01* -X173752412Y-100008763D01* -X173699657Y-99910067D01* -X173677713Y-99837727D01* -X173648137Y-99740227D01* -X173630741Y-99563600D01* -X173648137Y-99386973D01* -X173699657Y-99217134D01* -X173699657Y-99217133D01* -X173783321Y-99060611D01* -X173783322Y-99060609D01* -X173812652Y-99024871D01* -X173895914Y-98923414D01* -X174005342Y-98833610D01* -X174033109Y-98810822D01* -X174051013Y-98801252D01* -X174189633Y-98727157D01* -X174246247Y-98709984D01* -X174359473Y-98675637D01* -X174425657Y-98669119D01* -X174491840Y-98662600D01* -X174580360Y-98662600D01* -X174646543Y-98669119D01* -X174646543Y-98669119D01* -G37* -G36* -X132905500Y-99055600D02* -X132092700Y-99055600D01* -X132092700Y-97531600D01* -X132905500Y-97531600D01* -X132905500Y-99055600D01* -X132905500Y-99055600D01* -G37* -G36* -X130619500Y-99055600D02* -X129806700Y-99055600D01* -X129806700Y-97531600D01* -X130619500Y-97531600D01* -X130619500Y-99055600D01* -X130619500Y-99055600D01* -G37* -G36* -X128943100Y-98192000D02* -X127419100Y-98192000D01* -X127419100Y-97379200D01* -X128943100Y-97379200D01* -X128943100Y-98192000D01* -X128943100Y-98192000D01* -G37* -G36* -X150683438Y-96109338D02* -X150856473Y-96181012D01* -X151012200Y-96285065D01* -X151144635Y-96417500D01* -X151248688Y-96573227D01* -X151320362Y-96746262D01* -X151356900Y-96929954D01* -X151356900Y-97117246D01* -X151320362Y-97300938D01* -X151248688Y-97473973D01* -X151144635Y-97629700D01* -X151012200Y-97762135D01* -X150856473Y-97866188D01* -X150683438Y-97937862D01* -X150499746Y-97974400D01* -X150312454Y-97974400D01* -X150128762Y-97937862D01* -X149955727Y-97866188D01* -X149800000Y-97762135D01* -X149667565Y-97629700D01* -X149563512Y-97473973D01* -X149491838Y-97300938D01* -X149455300Y-97117246D01* -X149455300Y-96929954D01* -X149491838Y-96746262D01* -X149563512Y-96573227D01* -X149667565Y-96417500D01* -X149800000Y-96285065D01* -X149955727Y-96181012D01* -X150128762Y-96109338D01* -X150312454Y-96072800D01* -X150499746Y-96072800D01* -X150683438Y-96109338D01* -X150683438Y-96109338D01* -G37* -G36* -X153223438Y-96109338D02* -X153396473Y-96181012D01* -X153552200Y-96285065D01* -X153684635Y-96417500D01* -X153788688Y-96573227D01* -X153860362Y-96746262D01* -X153896900Y-96929954D01* -X153896900Y-97117246D01* -X153860362Y-97300938D01* -X153788688Y-97473973D01* -X153684635Y-97629700D01* -X153552200Y-97762135D01* -X153396473Y-97866188D01* -X153223438Y-97937862D01* -X153039746Y-97974400D01* -X152852454Y-97974400D01* -X152668762Y-97937862D01* -X152495727Y-97866188D01* -X152340000Y-97762135D01* -X152207565Y-97629700D01* -X152103512Y-97473973D01* -X152031838Y-97300938D01* -X151995300Y-97117246D01* -X151995300Y-96929954D01* -X152031838Y-96746262D01* -X152103512Y-96573227D01* -X152207565Y-96417500D01* -X152340000Y-96285065D01* -X152495727Y-96181012D01* -X152668762Y-96109338D01* -X152852454Y-96072800D01* -X153039746Y-96072800D01* -X153223438Y-96109338D01* -X153223438Y-96109338D01* -G37* -G36* -X155763438Y-96109338D02* -X155936473Y-96181012D01* -X156092200Y-96285065D01* -X156224635Y-96417500D01* -X156328688Y-96573227D01* -X156400362Y-96746262D01* -X156436900Y-96929954D01* -X156436900Y-97117246D01* -X156400362Y-97300938D01* -X156328688Y-97473973D01* -X156224635Y-97629700D01* -X156092200Y-97762135D01* -X155936473Y-97866188D01* -X155763438Y-97937862D01* -X155579746Y-97974400D01* -X155392454Y-97974400D01* -X155208762Y-97937862D01* -X155035727Y-97866188D01* -X154880000Y-97762135D01* -X154747565Y-97629700D01* -X154643512Y-97473973D01* -X154571838Y-97300938D01* -X154535300Y-97117246D01* -X154535300Y-96929954D01* -X154571838Y-96746262D01* -X154643512Y-96573227D01* -X154747565Y-96417500D01* -X154880000Y-96285065D01* -X155035727Y-96181012D01* -X155208762Y-96109338D01* -X155392454Y-96072800D01* -X155579746Y-96072800D01* -X155763438Y-96109338D01* -X155763438Y-96109338D01* -G37* -G36* -X172273438Y-96109338D02* -X172446473Y-96181012D01* -X172602200Y-96285065D01* -X172734635Y-96417500D01* -X172838688Y-96573227D01* -X172910362Y-96746262D01* -X172946900Y-96929954D01* -X172946900Y-97117246D01* -X172910362Y-97300938D01* -X172838688Y-97473973D01* -X172734635Y-97629700D01* -X172602200Y-97762135D01* -X172446473Y-97866188D01* -X172273438Y-97937862D01* -X172089746Y-97974400D01* -X171902454Y-97974400D01* -X171718762Y-97937862D01* -X171545727Y-97866188D01* -X171390000Y-97762135D01* -X171257565Y-97629700D01* -X171153512Y-97473973D01* -X171081838Y-97300938D01* -X171045300Y-97117246D01* -X171045300Y-96929954D01* -X171081838Y-96746262D01* -X171153512Y-96573227D01* -X171257565Y-96417500D01* -X171390000Y-96285065D01* -X171545727Y-96181012D01* -X171718762Y-96109338D01* -X171902454Y-96072800D01* -X172089746Y-96072800D01* -X172273438Y-96109338D01* -X172273438Y-96109338D01* -G37* -G36* -X169733438Y-96109338D02* -X169906473Y-96181012D01* -X170062200Y-96285065D01* -X170194635Y-96417500D01* -X170298688Y-96573227D01* -X170370362Y-96746262D01* -X170406900Y-96929954D01* -X170406900Y-97117246D01* -X170370362Y-97300938D01* -X170298688Y-97473973D01* -X170194635Y-97629700D01* -X170062200Y-97762135D01* -X169906473Y-97866188D01* -X169733438Y-97937862D01* -X169549746Y-97974400D01* -X169362454Y-97974400D01* -X169178762Y-97937862D01* -X169005727Y-97866188D01* -X168850000Y-97762135D01* -X168717565Y-97629700D01* -X168613512Y-97473973D01* -X168541838Y-97300938D01* -X168505300Y-97117246D01* -X168505300Y-96929954D01* -X168541838Y-96746262D01* -X168613512Y-96573227D01* -X168717565Y-96417500D01* -X168850000Y-96285065D01* -X169005727Y-96181012D01* -X169178762Y-96109338D01* -X169362454Y-96072800D01* -X169549746Y-96072800D01* -X169733438Y-96109338D01* -X169733438Y-96109338D01* -G37* -G36* -X125189445Y-96101858D02* -X125280229Y-96119916D01* -X125451262Y-96190760D01* -X125592399Y-96285065D01* -X125605190Y-96293612D01* -X125736088Y-96424510D01* -X125736090Y-96424513D01* -X125838940Y-96578438D01* -X125909784Y-96749471D01* -X125909784Y-96749473D01* -X125945900Y-96931036D01* -X125945900Y-97116164D01* -X125929179Y-97200225D01* -X125909784Y-97297729D01* -X125838940Y-97468762D01* -X125796953Y-97531600D01* -X125736088Y-97622690D01* -X125605190Y-97753588D01* -X125605187Y-97753590D01* -X125451262Y-97856440D01* -X125280229Y-97927284D01* -X125189446Y-97945342D01* -X125098664Y-97963400D01* -X124913536Y-97963400D01* -X124822754Y-97945342D01* -X124731971Y-97927284D01* -X124560938Y-97856440D01* -X124407013Y-97753590D01* -X124407010Y-97753588D01* -X124276112Y-97622690D01* -X124215247Y-97531600D01* -X124173260Y-97468762D01* -X124102416Y-97297729D01* -X124083021Y-97200225D01* -X124066300Y-97116164D01* -X124066300Y-96931036D01* -X124102416Y-96749473D01* -X124102416Y-96749471D01* -X124173260Y-96578438D01* -X124276110Y-96424513D01* -X124276112Y-96424510D01* -X124407010Y-96293612D01* -X124419801Y-96285065D01* -X124560938Y-96190760D01* -X124731971Y-96119916D01* -X124822754Y-96101858D01* -X124913536Y-96083800D01* -X125098664Y-96083800D01* -X125189445Y-96101858D01* -X125189445Y-96101858D01* -G37* -G36* -X174646543Y-96129119D02* -X174712727Y-96135637D01* -X174825953Y-96169984D01* -X174882567Y-96187157D01* -X175021187Y-96261252D01* -X175039091Y-96270822D01* -X175066858Y-96293610D01* -X175176286Y-96383414D01* -X175259548Y-96484871D01* -X175288878Y-96520609D01* -X175288879Y-96520611D01* -X175372543Y-96677133D01* -X175372543Y-96677134D01* -X175424063Y-96846973D01* -X175441459Y-97023600D01* -X175424063Y-97200227D01* -X175394487Y-97297727D01* -X175372543Y-97370067D01* -X175319788Y-97468763D01* -X175288878Y-97526591D01* -X175284767Y-97531600D01* -X175176286Y-97663786D01* -X175074829Y-97747048D01* -X175039091Y-97776378D01* -X175039089Y-97776379D01* -X174882567Y-97860043D01* -X174862309Y-97866188D01* -X174712727Y-97911563D01* -X174646542Y-97918082D01* -X174580360Y-97924600D01* -X174491840Y-97924600D01* -X174425658Y-97918082D01* -X174359473Y-97911563D01* -X174209891Y-97866188D01* -X174189633Y-97860043D01* -X174033111Y-97776379D01* -X174033109Y-97776378D01* -X173997371Y-97747048D01* -X173895914Y-97663786D01* -X173787433Y-97531600D01* -X173783322Y-97526591D01* -X173752412Y-97468763D01* -X173699657Y-97370067D01* -X173677713Y-97297727D01* -X173648137Y-97200227D01* -X173630741Y-97023600D01* -X173648137Y-96846973D01* -X173699657Y-96677134D01* -X173699657Y-96677133D01* -X173783321Y-96520611D01* -X173783322Y-96520609D01* -X173812652Y-96484871D01* -X173895914Y-96383414D01* -X174005342Y-96293610D01* -X174033109Y-96270822D01* -X174051013Y-96261252D01* -X174189633Y-96187157D01* -X174246247Y-96169984D01* -X174359473Y-96135637D01* -X174425658Y-96129118D01* -X174491840Y-96122600D01* -X174580360Y-96122600D01* -X174646543Y-96129119D01* -X174646543Y-96129119D01* -G37* -G36* -X150683438Y-93569338D02* -X150856473Y-93641012D01* -X151012200Y-93745065D01* -X151144635Y-93877500D01* -X151248688Y-94033227D01* -X151320362Y-94206262D01* -X151356900Y-94389954D01* -X151356900Y-94577246D01* -X151320362Y-94760938D01* -X151248688Y-94933973D01* -X151144635Y-95089700D01* -X151012200Y-95222135D01* -X150856473Y-95326188D01* -X150683438Y-95397862D01* -X150499746Y-95434400D01* -X150312454Y-95434400D01* -X150128762Y-95397862D01* -X149955727Y-95326188D01* -X149800000Y-95222135D01* -X149667565Y-95089700D01* -X149563512Y-94933973D01* -X149491838Y-94760938D01* -X149455300Y-94577246D01* -X149455300Y-94389954D01* -X149491838Y-94206262D01* -X149563512Y-94033227D01* -X149667565Y-93877500D01* -X149800000Y-93745065D01* -X149955727Y-93641012D01* -X150128762Y-93569338D01* -X150312454Y-93532800D01* -X150499746Y-93532800D01* -X150683438Y-93569338D01* -X150683438Y-93569338D01* -G37* -G36* -X153223438Y-93569338D02* -X153396473Y-93641012D01* -X153552200Y-93745065D01* -X153684635Y-93877500D01* -X153788688Y-94033227D01* -X153860362Y-94206262D01* -X153896900Y-94389954D01* -X153896900Y-94577246D01* -X153860362Y-94760938D01* -X153788688Y-94933973D01* -X153684635Y-95089700D01* -X153552200Y-95222135D01* -X153396473Y-95326188D01* -X153223438Y-95397862D01* -X153039746Y-95434400D01* -X152852454Y-95434400D01* -X152668762Y-95397862D01* -X152495727Y-95326188D01* -X152340000Y-95222135D01* -X152207565Y-95089700D01* -X152103512Y-94933973D01* -X152031838Y-94760938D01* -X151995300Y-94577246D01* -X151995300Y-94389954D01* -X152031838Y-94206262D01* -X152103512Y-94033227D01* -X152207565Y-93877500D01* -X152340000Y-93745065D01* -X152495727Y-93641012D01* -X152668762Y-93569338D01* -X152852454Y-93532800D01* -X153039746Y-93532800D01* -X153223438Y-93569338D01* -X153223438Y-93569338D01* -G37* -G36* -X155763438Y-93569338D02* -X155936473Y-93641012D01* -X156092200Y-93745065D01* -X156224635Y-93877500D01* -X156328688Y-94033227D01* -X156400362Y-94206262D01* -X156436900Y-94389954D01* -X156436900Y-94577246D01* -X156400362Y-94760938D01* -X156328688Y-94933973D01* -X156224635Y-95089700D01* -X156092200Y-95222135D01* -X155936473Y-95326188D01* -X155763438Y-95397862D01* -X155579746Y-95434400D01* -X155392454Y-95434400D01* -X155208762Y-95397862D01* -X155035727Y-95326188D01* -X154880000Y-95222135D01* -X154747565Y-95089700D01* -X154643512Y-94933973D01* -X154571838Y-94760938D01* -X154535300Y-94577246D01* -X154535300Y-94389954D01* -X154571838Y-94206262D01* -X154643512Y-94033227D01* -X154747565Y-93877500D01* -X154880000Y-93745065D01* -X155035727Y-93641012D01* -X155208762Y-93569338D01* -X155392454Y-93532800D01* -X155579746Y-93532800D01* -X155763438Y-93569338D01* -X155763438Y-93569338D01* -G37* -G36* -X172273438Y-93569338D02* -X172446473Y-93641012D01* -X172602200Y-93745065D01* -X172734635Y-93877500D01* -X172838688Y-94033227D01* -X172910362Y-94206262D01* -X172946900Y-94389954D01* -X172946900Y-94577246D01* -X172910362Y-94760938D01* -X172838688Y-94933973D01* -X172734635Y-95089700D01* -X172602200Y-95222135D01* -X172446473Y-95326188D01* -X172273438Y-95397862D01* -X172089746Y-95434400D01* -X171902454Y-95434400D01* -X171718762Y-95397862D01* -X171545727Y-95326188D01* -X171390000Y-95222135D01* -X171257565Y-95089700D01* -X171153512Y-94933973D01* -X171081838Y-94760938D01* -X171045300Y-94577246D01* -X171045300Y-94389954D01* -X171081838Y-94206262D01* -X171153512Y-94033227D01* -X171257565Y-93877500D01* -X171390000Y-93745065D01* -X171545727Y-93641012D01* -X171718762Y-93569338D01* -X171902454Y-93532800D01* -X172089746Y-93532800D01* -X172273438Y-93569338D01* -X172273438Y-93569338D01* -G37* -G36* -X169733438Y-93569338D02* -X169906473Y-93641012D01* -X170062200Y-93745065D01* -X170194635Y-93877500D01* -X170298688Y-94033227D01* -X170370362Y-94206262D01* -X170406900Y-94389954D01* -X170406900Y-94577246D01* -X170370362Y-94760938D01* -X170298688Y-94933973D01* -X170194635Y-95089700D01* -X170062200Y-95222135D01* -X169906473Y-95326188D01* -X169733438Y-95397862D01* -X169549746Y-95434400D01* -X169362454Y-95434400D01* -X169178762Y-95397862D01* -X169005727Y-95326188D01* -X168850000Y-95222135D01* -X168717565Y-95089700D01* -X168613512Y-94933973D01* -X168541838Y-94760938D01* -X168505300Y-94577246D01* -X168505300Y-94389954D01* -X168541838Y-94206262D01* -X168613512Y-94033227D01* -X168717565Y-93877500D01* -X168850000Y-93745065D01* -X169005727Y-93641012D01* -X169178762Y-93569338D01* -X169362454Y-93532800D01* -X169549746Y-93532800D01* -X169733438Y-93569338D01* -X169733438Y-93569338D01* -G37* -G36* -X174646542Y-93589118D02* -X174712727Y-93595637D01* -X174821932Y-93628764D01* -X174882567Y-93647157D01* -X174973529Y-93695778D01* -X175039091Y-93730822D01* -X175074829Y-93760152D01* -X175176286Y-93843414D01* -X175236590Y-93916896D01* -X175288878Y-93980609D01* -X175288879Y-93980611D01* -X175372543Y-94137133D01* -X175372543Y-94137134D01* -X175424063Y-94306973D01* -X175441459Y-94483600D01* -X175424063Y-94660227D01* -X175398981Y-94742912D01* -X175372543Y-94830067D01* -X175332651Y-94904698D01* -X175288878Y-94986591D01* -X175259548Y-95022329D01* -X175176286Y-95123786D01* -X175074829Y-95207048D01* -X175039091Y-95236378D01* -X175039089Y-95236379D01* -X174882567Y-95320043D01* -X174862309Y-95326188D01* -X174712727Y-95371563D01* -X174646542Y-95378082D01* -X174580360Y-95384600D01* -X174491840Y-95384600D01* -X174425657Y-95378081D01* -X174359473Y-95371563D01* -X174209891Y-95326188D01* -X174189633Y-95320043D01* -X174033111Y-95236379D01* -X174033109Y-95236378D01* -X173997371Y-95207048D01* -X173895914Y-95123786D01* -X173812652Y-95022329D01* -X173783322Y-94986591D01* -X173739549Y-94904698D01* -X173699657Y-94830067D01* -X173673219Y-94742912D01* -X173648137Y-94660227D01* -X173630741Y-94483600D01* -X173648137Y-94306973D01* -X173699657Y-94137134D01* -X173699657Y-94137133D01* -X173783321Y-93980611D01* -X173783322Y-93980609D01* -X173835610Y-93916896D01* -X173895914Y-93843414D01* -X173997371Y-93760152D01* -X174033109Y-93730822D01* -X174098671Y-93695778D01* -X174189633Y-93647157D01* -X174250268Y-93628764D01* -X174359473Y-93595637D01* -X174425658Y-93589118D01* -X174491840Y-93582600D01* -X174580360Y-93582600D01* -X174646542Y-93589118D01* -X174646542Y-93589118D01* -G37* -G36* -X164635412Y-93628764D02* -X164797198Y-93695778D01* -X164942807Y-93793071D01* -X165066629Y-93916893D01* -X165163922Y-94062502D01* -X165230936Y-94224288D01* -X165265100Y-94396041D01* -X165265100Y-94571159D01* -X165230936Y-94742912D01* -X165163922Y-94904698D01* -X165066629Y-95050307D01* -X164942807Y-95174129D01* -X164797198Y-95271422D01* -X164664981Y-95326188D01* -X164635412Y-95338436D01* -X164463659Y-95372600D01* -X164288541Y-95372600D01* -X164116788Y-95338436D01* -X164087219Y-95326188D01* -X163955002Y-95271422D01* -X163809393Y-95174129D01* -X163685571Y-95050307D01* -X163588278Y-94904698D01* -X163521264Y-94742912D01* -X163487100Y-94571159D01* -X163487100Y-94396041D01* -X163521264Y-94224288D01* -X163588278Y-94062502D01* -X163685571Y-93916893D01* -X163809393Y-93793071D01* -X163955002Y-93695778D01* -X164116788Y-93628764D01* -X164288541Y-93594600D01* -X164463659Y-93594600D01* -X164635412Y-93628764D01* -X164635412Y-93628764D01* -G37* -G36* -X162095412Y-93628764D02* -X162257198Y-93695778D01* -X162402807Y-93793071D01* -X162526629Y-93916893D01* -X162623922Y-94062502D01* -X162690936Y-94224288D01* -X162725100Y-94396041D01* -X162725100Y-94571159D01* -X162690936Y-94742912D01* -X162623922Y-94904698D01* -X162526629Y-95050307D01* -X162402807Y-95174129D01* -X162257198Y-95271422D01* -X162095412Y-95338436D01* -X161923659Y-95372600D01* -X161748541Y-95372600D01* -X161576788Y-95338436D01* -X161415002Y-95271422D01* -X161269393Y-95174129D01* -X161145571Y-95050307D01* -X161048278Y-94904698D01* -X160981264Y-94742912D01* -X160947100Y-94571159D01* -X160947100Y-94396041D01* -X160981264Y-94224288D01* -X161048278Y-94062502D01* -X161145571Y-93916893D01* -X161269393Y-93793071D01* -X161415002Y-93695778D01* -X161576788Y-93628764D01* -X161748541Y-93594600D01* -X161923659Y-93594600D01* -X162095412Y-93628764D01* -X162095412Y-93628764D01* -G37* -G36* -X130376900Y-94394400D02* -X128575300Y-94394400D01* -X128575300Y-93292800D01* -X130376900Y-93292800D01* -X130376900Y-94394400D01* -X130376900Y-94394400D01* -G37* -G36* -X136676900Y-94394400D02* -X134875300Y-94394400D01* -X134875300Y-93292800D01* -X136676900Y-93292800D01* -X136676900Y-94394400D01* -X136676900Y-94394400D01* -G37* -G36* -X155763438Y-91029338D02* -X155936473Y-91101012D01* -X156092200Y-91205065D01* -X156224635Y-91337500D01* -X156328688Y-91493227D01* -X156400362Y-91666262D01* -X156436900Y-91849954D01* -X156436900Y-92037246D01* -X156400362Y-92220938D01* -X156328688Y-92393973D01* -X156224635Y-92549700D01* -X156092200Y-92682135D01* -X155936473Y-92786188D01* -X155763438Y-92857862D01* -X155579746Y-92894400D01* -X155392454Y-92894400D01* -X155208762Y-92857862D01* -X155035727Y-92786188D01* -X154880000Y-92682135D01* -X154747565Y-92549700D01* -X154643512Y-92393973D01* -X154571838Y-92220938D01* -X154535300Y-92037246D01* -X154535300Y-91849954D01* -X154571838Y-91666262D01* -X154643512Y-91493227D01* -X154747565Y-91337500D01* -X154880000Y-91205065D01* -X155035727Y-91101012D01* -X155208762Y-91029338D01* -X155392454Y-90992800D01* -X155579746Y-90992800D01* -X155763438Y-91029338D01* -X155763438Y-91029338D01* -G37* -G36* -X153223438Y-91029338D02* -X153396473Y-91101012D01* -X153552200Y-91205065D01* -X153684635Y-91337500D01* -X153788688Y-91493227D01* -X153860362Y-91666262D01* -X153896900Y-91849954D01* -X153896900Y-92037246D01* -X153860362Y-92220938D01* -X153788688Y-92393973D01* -X153684635Y-92549700D01* -X153552200Y-92682135D01* -X153396473Y-92786188D01* -X153223438Y-92857862D01* -X153039746Y-92894400D01* -X152852454Y-92894400D01* -X152668762Y-92857862D01* -X152495727Y-92786188D01* -X152340000Y-92682135D01* -X152207565Y-92549700D01* -X152103512Y-92393973D01* -X152031838Y-92220938D01* -X151995300Y-92037246D01* -X151995300Y-91849954D01* -X152031838Y-91666262D01* -X152103512Y-91493227D01* -X152207565Y-91337500D01* -X152340000Y-91205065D01* -X152495727Y-91101012D01* -X152668762Y-91029338D01* -X152852454Y-90992800D01* -X153039746Y-90992800D01* -X153223438Y-91029338D01* -X153223438Y-91029338D01* -G37* -G36* -X150683438Y-91029338D02* -X150856473Y-91101012D01* -X151012200Y-91205065D01* -X151144635Y-91337500D01* -X151248688Y-91493227D01* -X151320362Y-91666262D01* -X151356900Y-91849954D01* -X151356900Y-92037246D01* -X151320362Y-92220938D01* -X151248688Y-92393973D01* -X151144635Y-92549700D01* -X151012200Y-92682135D01* -X150856473Y-92786188D01* -X150683438Y-92857862D01* -X150499746Y-92894400D01* -X150312454Y-92894400D01* -X150128762Y-92857862D01* -X149955727Y-92786188D01* -X149800000Y-92682135D01* -X149667565Y-92549700D01* -X149563512Y-92393973D01* -X149491838Y-92220938D01* -X149455300Y-92037246D01* -X149455300Y-91849954D01* -X149491838Y-91666262D01* -X149563512Y-91493227D01* -X149667565Y-91337500D01* -X149800000Y-91205065D01* -X149955727Y-91101012D01* -X150128762Y-91029338D01* -X150312454Y-90992800D01* -X150499746Y-90992800D01* -X150683438Y-91029338D01* -X150683438Y-91029338D01* -G37* -G36* -X172273438Y-91029338D02* -X172446473Y-91101012D01* -X172602200Y-91205065D01* -X172734635Y-91337500D01* -X172838688Y-91493227D01* -X172910362Y-91666262D01* -X172946900Y-91849954D01* -X172946900Y-92037246D01* -X172910362Y-92220938D01* -X172838688Y-92393973D01* -X172734635Y-92549700D01* -X172602200Y-92682135D01* -X172446473Y-92786188D01* -X172273438Y-92857862D01* -X172089746Y-92894400D01* -X171902454Y-92894400D01* -X171718762Y-92857862D01* -X171545727Y-92786188D01* -X171390000Y-92682135D01* -X171257565Y-92549700D01* -X171153512Y-92393973D01* -X171081838Y-92220938D01* -X171045300Y-92037246D01* -X171045300Y-91849954D01* -X171081838Y-91666262D01* -X171153512Y-91493227D01* -X171257565Y-91337500D01* -X171390000Y-91205065D01* -X171545727Y-91101012D01* -X171718762Y-91029338D01* -X171902454Y-90992800D01* -X172089746Y-90992800D01* -X172273438Y-91029338D01* -X172273438Y-91029338D01* -G37* -G36* -X169733438Y-91029338D02* -X169906473Y-91101012D01* -X170062200Y-91205065D01* -X170194635Y-91337500D01* -X170298688Y-91493227D01* -X170370362Y-91666262D01* -X170406900Y-91849954D01* -X170406900Y-92037246D01* -X170370362Y-92220938D01* -X170298688Y-92393973D01* -X170194635Y-92549700D01* -X170062200Y-92682135D01* -X169906473Y-92786188D01* -X169733438Y-92857862D01* -X169549746Y-92894400D01* -X169362454Y-92894400D01* -X169178762Y-92857862D01* -X169005727Y-92786188D01* -X168850000Y-92682135D01* -X168717565Y-92549700D01* -X168613512Y-92393973D01* -X168541838Y-92220938D01* -X168505300Y-92037246D01* -X168505300Y-91849954D01* -X168541838Y-91666262D01* -X168613512Y-91493227D01* -X168717565Y-91337500D01* -X168850000Y-91205065D01* -X169005727Y-91101012D01* -X169178762Y-91029338D01* -X169362454Y-90992800D01* -X169549746Y-90992800D01* -X169733438Y-91029338D01* -X169733438Y-91029338D01* -G37* -G36* -X175437100Y-92844600D02* -X173635100Y-92844600D01* -X173635100Y-91042600D01* -X175437100Y-91042600D01* -X175437100Y-92844600D01* -X175437100Y-92844600D01* -G37* -G36* -X162095412Y-91088764D02* -X162257198Y-91155778D01* -X162402807Y-91253071D01* -X162526629Y-91376893D01* -X162623922Y-91522502D01* -X162690936Y-91684288D01* -X162725100Y-91856041D01* -X162725100Y-92031159D01* -X162690936Y-92202912D01* -X162623922Y-92364698D01* -X162526629Y-92510307D01* -X162402807Y-92634129D01* -X162257198Y-92731422D01* -X162124981Y-92786188D01* -X162095412Y-92798436D01* -X161923659Y-92832600D01* -X161748541Y-92832600D01* -X161576788Y-92798436D01* -X161547219Y-92786188D01* -X161415002Y-92731422D01* -X161269393Y-92634129D01* -X161145571Y-92510307D01* -X161048278Y-92364698D01* -X160981264Y-92202912D01* -X160947100Y-92031159D01* -X160947100Y-91856041D01* -X160981264Y-91684288D01* -X161048278Y-91522502D01* -X161145571Y-91376893D01* -X161269393Y-91253071D01* -X161415002Y-91155778D01* -X161576788Y-91088764D01* -X161748541Y-91054600D01* -X161923659Y-91054600D01* -X162095412Y-91088764D01* -X162095412Y-91088764D01* -G37* -G36* -X164635412Y-91088764D02* -X164797198Y-91155778D01* -X164942807Y-91253071D01* -X165066629Y-91376893D01* -X165163922Y-91522502D01* -X165230936Y-91684288D01* -X165265100Y-91856041D01* -X165265100Y-92031159D01* -X165230936Y-92202912D01* -X165163922Y-92364698D01* -X165066629Y-92510307D01* -X164942807Y-92634129D01* -X164797198Y-92731422D01* -X164635412Y-92798436D01* -X164463659Y-92832600D01* -X164288541Y-92832600D01* -X164116788Y-92798436D01* -X163955002Y-92731422D01* -X163809393Y-92634129D01* -X163685571Y-92510307D01* -X163588278Y-92364698D01* -X163521264Y-92202912D01* -X163487100Y-92031159D01* -X163487100Y-91856041D01* -X163521264Y-91684288D01* -X163588278Y-91522502D01* -X163685571Y-91376893D01* -X163809393Y-91253071D01* -X163955002Y-91155778D01* -X164116788Y-91088764D01* -X164288541Y-91054600D01* -X164463659Y-91054600D01* -X164635412Y-91088764D01* -X164635412Y-91088764D01* -G37* -G36* -X136676900Y-90594400D02* -X134875300Y-90594400D01* -X134875300Y-89492800D01* -X136676900Y-89492800D01* -X136676900Y-90594400D01* -X136676900Y-90594400D01* -G37* -G36* -X130376900Y-90594400D02* -X128575300Y-90594400D01* -X128575300Y-89492800D01* -X130376900Y-89492800D01* -X130376900Y-90594400D01* -X130376900Y-90594400D01* -G37* -G36* -X164635412Y-88548764D02* -X164797198Y-88615778D01* -X164942807Y-88713071D01* -X165066629Y-88836893D01* -X165163922Y-88982502D01* -X165230936Y-89144288D01* -X165265100Y-89316041D01* -X165265100Y-89491159D01* -X165230936Y-89662912D01* -X165163922Y-89824698D01* -X165066629Y-89970307D01* -X164942807Y-90094129D01* -X164797198Y-90191422D01* -X164635412Y-90258436D01* -X164463659Y-90292600D01* -X164288541Y-90292600D01* -X164116788Y-90258436D01* -X163955002Y-90191422D01* -X163809393Y-90094129D01* -X163685571Y-89970307D01* -X163588278Y-89824698D01* -X163521264Y-89662912D01* -X163487100Y-89491159D01* -X163487100Y-89316041D01* -X163521264Y-89144288D01* -X163588278Y-88982502D01* -X163685571Y-88836893D01* -X163809393Y-88713071D01* -X163955002Y-88615778D01* -X164116788Y-88548764D01* -X164288541Y-88514600D01* -X164463659Y-88514600D01* -X164635412Y-88548764D01* -X164635412Y-88548764D01* -G37* -G36* -X162095412Y-88548764D02* -X162257198Y-88615778D01* -X162402807Y-88713071D01* -X162526629Y-88836893D01* -X162623922Y-88982502D01* -X162690936Y-89144288D01* -X162725100Y-89316041D01* -X162725100Y-89491159D01* -X162690936Y-89662912D01* -X162623922Y-89824698D01* -X162526629Y-89970307D01* -X162402807Y-90094129D01* -X162257198Y-90191422D01* -X162095412Y-90258436D01* -X161923659Y-90292600D01* -X161748541Y-90292600D01* -X161576788Y-90258436D01* -X161415002Y-90191422D01* -X161269393Y-90094129D01* -X161145571Y-89970307D01* -X161048278Y-89824698D01* -X160981264Y-89662912D01* -X160947100Y-89491159D01* -X160947100Y-89316041D01* -X160981264Y-89144288D01* -X161048278Y-88982502D01* -X161145571Y-88836893D01* -X161269393Y-88713071D01* -X161415002Y-88615778D01* -X161576788Y-88548764D01* -X161748541Y-88514600D01* -X161923659Y-88514600D01* -X162095412Y-88548764D01* -X162095412Y-88548764D01* -G37* -G36* -X140429445Y-85941858D02* -X140520229Y-85959916D01* -X140691262Y-86030760D01* -X140691263Y-86030761D01* -X140845190Y-86133612D01* -X140976088Y-86264510D01* -X140976090Y-86264513D01* -X141078940Y-86418438D01* -X141149784Y-86589471D01* -X141185900Y-86771038D01* -X141185900Y-86956162D01* -X141149784Y-87137729D01* -X141078940Y-87308762D01* -X141078939Y-87308763D01* -X140976088Y-87462690D01* -X140845190Y-87593588D01* -X140845187Y-87593590D01* -X140691262Y-87696440D01* -X140520229Y-87767284D01* -X140429445Y-87785342D01* -X140338664Y-87803400D01* -X140153536Y-87803400D01* -X140062755Y-87785342D01* -X139971971Y-87767284D01* -X139800938Y-87696440D01* -X139647013Y-87593590D01* -X139647010Y-87593588D01* -X139516112Y-87462690D01* -X139413261Y-87308763D01* -X139413260Y-87308762D01* -X139342416Y-87137729D01* -X139306300Y-86956162D01* -X139306300Y-86771038D01* -X139342416Y-86589471D01* -X139413260Y-86418438D01* -X139516110Y-86264513D01* -X139516112Y-86264510D01* -X139647010Y-86133612D01* -X139800937Y-86030761D01* -X139800938Y-86030760D01* -X139971971Y-85959916D01* -X140062755Y-85941858D01* -X140153536Y-85923800D01* -X140338664Y-85923800D01* -X140429445Y-85941858D01* -X140429445Y-85941858D01* -G37* -G36* -X150589445Y-85941858D02* -X150680229Y-85959916D01* -X150851262Y-86030760D01* -X150851263Y-86030761D01* -X151005190Y-86133612D01* -X151136088Y-86264510D01* -X151136090Y-86264513D01* -X151238940Y-86418438D01* -X151309784Y-86589471D01* -X151345900Y-86771038D01* -X151345900Y-86956162D01* -X151309784Y-87137729D01* -X151238940Y-87308762D01* -X151238939Y-87308763D01* -X151136088Y-87462690D01* -X151005190Y-87593588D01* -X151005187Y-87593590D01* -X150851262Y-87696440D01* -X150680229Y-87767284D01* -X150589445Y-87785342D01* -X150498664Y-87803400D01* -X150313536Y-87803400D01* -X150222755Y-87785342D01* -X150131971Y-87767284D01* -X149960938Y-87696440D01* -X149807013Y-87593590D01* -X149807010Y-87593588D01* -X149676112Y-87462690D01* -X149573261Y-87308763D01* -X149573260Y-87308762D01* -X149502416Y-87137729D01* -X149466300Y-86956162D01* -X149466300Y-86771038D01* -X149502416Y-86589471D01* -X149573260Y-86418438D01* -X149676110Y-86264513D01* -X149676112Y-86264510D01* -X149807010Y-86133612D01* -X149960937Y-86030761D01* -X149960938Y-86030760D01* -X150131971Y-85959916D01* -X150222755Y-85941858D01* -X150313536Y-85923800D01* -X150498664Y-85923800D01* -X150589445Y-85941858D01* -X150589445Y-85941858D01* -G37* -G36* -X148049445Y-85941858D02* -X148140229Y-85959916D01* -X148311262Y-86030760D01* -X148311263Y-86030761D01* -X148465190Y-86133612D01* -X148596088Y-86264510D01* -X148596090Y-86264513D01* -X148698940Y-86418438D01* -X148769784Y-86589471D01* -X148805900Y-86771038D01* -X148805900Y-86956162D01* -X148769784Y-87137729D01* -X148698940Y-87308762D01* -X148698939Y-87308763D01* -X148596088Y-87462690D01* -X148465190Y-87593588D01* -X148465187Y-87593590D01* -X148311262Y-87696440D01* -X148140229Y-87767284D01* -X148049445Y-87785342D01* -X147958664Y-87803400D01* -X147773536Y-87803400D01* -X147682755Y-87785342D01* -X147591971Y-87767284D01* -X147420938Y-87696440D01* -X147267013Y-87593590D01* -X147267010Y-87593588D01* -X147136112Y-87462690D01* -X147033261Y-87308763D01* -X147033260Y-87308762D01* -X146962416Y-87137729D01* -X146926300Y-86956162D01* -X146926300Y-86771038D01* -X146962416Y-86589471D01* -X147033260Y-86418438D01* -X147136110Y-86264513D01* -X147136112Y-86264510D01* -X147267010Y-86133612D01* -X147420937Y-86030761D01* -X147420938Y-86030760D01* -X147591971Y-85959916D01* -X147682755Y-85941858D01* -X147773536Y-85923800D01* -X147958664Y-85923800D01* -X148049445Y-85941858D01* -X148049445Y-85941858D01* -G37* -G36* -X145509445Y-85941858D02* -X145600229Y-85959916D01* -X145771262Y-86030760D01* -X145771263Y-86030761D01* -X145925190Y-86133612D01* -X146056088Y-86264510D01* -X146056090Y-86264513D01* -X146158940Y-86418438D01* -X146229784Y-86589471D01* -X146265900Y-86771038D01* -X146265900Y-86956162D01* -X146229784Y-87137729D01* -X146158940Y-87308762D01* -X146158939Y-87308763D01* -X146056088Y-87462690D01* -X145925190Y-87593588D01* -X145925187Y-87593590D01* -X145771262Y-87696440D01* -X145600229Y-87767284D01* -X145509445Y-87785342D01* -X145418664Y-87803400D01* -X145233536Y-87803400D01* -X145142755Y-87785342D01* -X145051971Y-87767284D01* -X144880938Y-87696440D01* -X144727013Y-87593590D01* -X144727010Y-87593588D01* -X144596112Y-87462690D01* -X144493261Y-87308763D01* -X144493260Y-87308762D01* -X144422416Y-87137729D01* -X144386300Y-86956162D01* -X144386300Y-86771038D01* -X144422416Y-86589471D01* -X144493260Y-86418438D01* -X144596110Y-86264513D01* -X144596112Y-86264510D01* -X144727010Y-86133612D01* -X144880937Y-86030761D01* -X144880938Y-86030760D01* -X145051971Y-85959916D01* -X145142755Y-85941858D01* -X145233536Y-85923800D01* -X145418664Y-85923800D01* -X145509445Y-85941858D01* -X145509445Y-85941858D01* -G37* -G36* -X142969445Y-85941858D02* -X143060229Y-85959916D01* -X143231262Y-86030760D01* -X143231263Y-86030761D01* -X143385190Y-86133612D01* -X143516088Y-86264510D01* -X143516090Y-86264513D01* -X143618940Y-86418438D01* -X143689784Y-86589471D01* -X143725900Y-86771038D01* -X143725900Y-86956162D01* -X143689784Y-87137729D01* -X143618940Y-87308762D01* -X143618939Y-87308763D01* -X143516088Y-87462690D01* -X143385190Y-87593588D01* -X143385187Y-87593590D01* -X143231262Y-87696440D01* -X143060229Y-87767284D01* -X142969445Y-87785342D01* -X142878664Y-87803400D01* -X142693536Y-87803400D01* -X142602755Y-87785342D01* -X142511971Y-87767284D01* -X142340938Y-87696440D01* -X142187013Y-87593590D01* -X142187010Y-87593588D01* -X142056112Y-87462690D01* -X141953261Y-87308763D01* -X141953260Y-87308762D01* -X141882416Y-87137729D01* -X141846300Y-86956162D01* -X141846300Y-86771038D01* -X141882416Y-86589471D01* -X141953260Y-86418438D01* -X142056110Y-86264513D01* -X142056112Y-86264510D01* -X142187010Y-86133612D01* -X142340937Y-86030761D01* -X142340938Y-86030760D01* -X142511971Y-85959916D01* -X142602755Y-85941858D01* -X142693536Y-85923800D01* -X142878664Y-85923800D01* -X142969445Y-85941858D01* -X142969445Y-85941858D01* -G37* -G36* -X130269445Y-85941858D02* -X130360229Y-85959916D01* -X130531262Y-86030760D01* -X130531263Y-86030761D01* -X130685190Y-86133612D01* -X130816088Y-86264510D01* -X130816090Y-86264513D01* -X130918940Y-86418438D01* -X130989784Y-86589471D01* -X131025900Y-86771038D01* -X131025900Y-86956162D01* -X130989784Y-87137729D01* -X130918940Y-87308762D01* -X130918939Y-87308763D01* -X130816088Y-87462690D01* -X130685190Y-87593588D01* -X130685187Y-87593590D01* -X130531262Y-87696440D01* -X130360229Y-87767284D01* -X130269445Y-87785342D01* -X130178664Y-87803400D01* -X129993536Y-87803400D01* -X129902755Y-87785342D01* -X129811971Y-87767284D01* -X129640938Y-87696440D01* -X129487013Y-87593590D01* -X129487010Y-87593588D01* -X129356112Y-87462690D01* -X129253261Y-87308763D01* -X129253260Y-87308762D01* -X129182416Y-87137729D01* -X129146300Y-86956162D01* -X129146300Y-86771038D01* -X129182416Y-86589471D01* -X129253260Y-86418438D01* -X129356110Y-86264513D01* -X129356112Y-86264510D01* -X129487010Y-86133612D01* -X129640937Y-86030761D01* -X129640938Y-86030760D01* -X129811971Y-85959916D01* -X129902755Y-85941858D01* -X129993536Y-85923800D01* -X130178664Y-85923800D01* -X130269445Y-85941858D01* -X130269445Y-85941858D01* -G37* -G36* -X132809445Y-85941858D02* -X132900229Y-85959916D01* -X133071262Y-86030760D01* -X133071263Y-86030761D01* -X133225190Y-86133612D01* -X133356088Y-86264510D01* -X133356090Y-86264513D01* -X133458940Y-86418438D01* -X133529784Y-86589471D01* -X133565900Y-86771038D01* -X133565900Y-86956162D01* -X133529784Y-87137729D01* -X133458940Y-87308762D01* -X133458939Y-87308763D01* -X133356088Y-87462690D01* -X133225190Y-87593588D01* -X133225187Y-87593590D01* -X133071262Y-87696440D01* -X132900229Y-87767284D01* -X132809445Y-87785342D01* -X132718664Y-87803400D01* -X132533536Y-87803400D01* -X132442755Y-87785342D01* -X132351971Y-87767284D01* -X132180938Y-87696440D01* -X132027013Y-87593590D01* -X132027010Y-87593588D01* -X131896112Y-87462690D01* -X131793261Y-87308763D01* -X131793260Y-87308762D01* -X131722416Y-87137729D01* -X131686300Y-86956162D01* -X131686300Y-86771038D01* -X131722416Y-86589471D01* -X131793260Y-86418438D01* -X131896110Y-86264513D01* -X131896112Y-86264510D01* -X132027010Y-86133612D01* -X132180937Y-86030761D01* -X132180938Y-86030760D01* -X132351971Y-85959916D01* -X132442755Y-85941858D01* -X132533536Y-85923800D01* -X132718664Y-85923800D01* -X132809445Y-85941858D01* -X132809445Y-85941858D01* -G37* -G36* -X135349445Y-85941858D02* -X135440229Y-85959916D01* -X135611262Y-86030760D01* -X135611263Y-86030761D01* -X135765190Y-86133612D01* -X135896088Y-86264510D01* -X135896090Y-86264513D01* -X135998940Y-86418438D01* -X136069784Y-86589471D01* -X136105900Y-86771038D01* -X136105900Y-86956162D01* -X136069784Y-87137729D01* -X135998940Y-87308762D01* -X135998939Y-87308763D01* -X135896088Y-87462690D01* -X135765190Y-87593588D01* -X135765187Y-87593590D01* -X135611262Y-87696440D01* -X135440229Y-87767284D01* -X135349445Y-87785342D01* -X135258664Y-87803400D01* -X135073536Y-87803400D01* -X134982755Y-87785342D01* -X134891971Y-87767284D01* -X134720938Y-87696440D01* -X134567013Y-87593590D01* -X134567010Y-87593588D01* -X134436112Y-87462690D01* -X134333261Y-87308763D01* -X134333260Y-87308762D01* -X134262416Y-87137729D01* -X134226300Y-86956162D01* -X134226300Y-86771038D01* -X134262416Y-86589471D01* -X134333260Y-86418438D01* -X134436110Y-86264513D01* -X134436112Y-86264510D01* -X134567010Y-86133612D01* -X134720937Y-86030761D01* -X134720938Y-86030760D01* -X134891971Y-85959916D01* -X134982755Y-85941858D01* -X135073536Y-85923800D01* -X135258664Y-85923800D01* -X135349445Y-85941858D01* -X135349445Y-85941858D01* -G37* -G36* -X137889445Y-85941858D02* -X137980229Y-85959916D01* -X138151262Y-86030760D01* -X138151263Y-86030761D01* -X138305190Y-86133612D01* -X138436088Y-86264510D01* -X138436090Y-86264513D01* -X138538940Y-86418438D01* -X138609784Y-86589471D01* -X138645900Y-86771038D01* -X138645900Y-86956162D01* -X138609784Y-87137729D01* -X138538940Y-87308762D01* -X138538939Y-87308763D01* -X138436088Y-87462690D01* -X138305190Y-87593588D01* -X138305187Y-87593590D01* -X138151262Y-87696440D01* -X137980229Y-87767284D01* -X137889445Y-87785342D01* -X137798664Y-87803400D01* -X137613536Y-87803400D01* -X137522755Y-87785342D01* -X137431971Y-87767284D01* -X137260938Y-87696440D01* -X137107013Y-87593590D01* -X137107010Y-87593588D01* -X136976112Y-87462690D01* -X136873261Y-87308763D01* -X136873260Y-87308762D01* -X136802416Y-87137729D01* -X136766300Y-86956162D01* -X136766300Y-86771038D01* -X136802416Y-86589471D01* -X136873260Y-86418438D01* -X136976110Y-86264513D01* -X136976112Y-86264510D01* -X137107010Y-86133612D01* -X137260937Y-86030761D01* -X137260938Y-86030760D01* -X137431971Y-85959916D01* -X137522755Y-85941858D01* -X137613536Y-85923800D01* -X137798664Y-85923800D01* -X137889445Y-85941858D01* -X137889445Y-85941858D01* -G37* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-F.SilkS.gbr b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-F.SilkS.gbr deleted file mode 100644 index bd0628f..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-F.SilkS.gbr +++ /dev/null @@ -1,2095 +0,0 @@ -G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* -G04 #@! TF.CreationDate,2019-04-02T23:20:26+04:00* -G04 #@! TF.ProjectId,M644_breakout_v1.2d,4d363434-5f62-4726-9561-6b6f75745f76,v1.2d* -G04 #@! TF.SameCoordinates,Original* -G04 #@! TF.FileFunction,Legend,Top* -G04 #@! TF.FilePolarity,Positive* -%FSLAX46Y46*% -G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* -G04 Created by KiCad (PCBNEW (5.0.2)-1) date 02/04/2019 23:20:26* -%MOMM*% -%LPD*% -G01* -G04 APERTURE LIST* -%ADD10C,0.609600*% -%ADD11C,0.406400*% -%ADD12C,0.320040*% -%ADD13C,0.256032*% -%ADD14C,0.213360*% -%ADD15C,0.100000*% -%ADD16C,0.076200*% -%ADD17C,0.152400*% -%ADD18C,0.127000*% -%ADD19C,0.050800*% -%ADD20C,0.254000*% -%ADD21C,0.120000*% -%ADD22C,0.200000*% -%ADD23C,0.300000*% -G04 APERTURE END LIST* -D10* -X157925100Y-87828800D02* -G75* -G03X157925100Y-87828800I-483200J0D01* -G01* -D11* -X174835000Y-111882600D02* -G75* -G03X174835000Y-111882600I-425900J0D01* -G01* -D12* -X126975192Y-104694566D02* -X126975192Y-103005466D01* -X127538226Y-104211966D01* -X128101259Y-103005466D01* -X128101259Y-104694566D01* -X129629492Y-103005466D02* -X129307759Y-103005466D01* -X129146892Y-103085900D01* -X129066459Y-103166333D01* -X128905592Y-103407633D01* -X128825159Y-103729366D01* -X128825159Y-104372833D01* -X128905592Y-104533700D01* -X128986026Y-104614133D01* -X129146892Y-104694566D01* -X129468626Y-104694566D01* -X129629492Y-104614133D01* -X129709926Y-104533700D01* -X129790359Y-104372833D01* -X129790359Y-103970666D01* -X129709926Y-103809800D01* -X129629492Y-103729366D01* -X129468626Y-103648933D01* -X129146892Y-103648933D01* -X128986026Y-103729366D01* -X128905592Y-103809800D01* -X128825159Y-103970666D01* -X131238159Y-103568500D02* -X131238159Y-104694566D01* -X130835992Y-102925033D02* -X130433826Y-104131533D01* -X131479459Y-104131533D01* -X132846826Y-103568500D02* -X132846826Y-104694566D01* -X132444659Y-102925033D02* -X132042492Y-104131533D01* -X133088126Y-104131533D01* -X134938092Y-102925033D02* -X133490292Y-105096733D01* -X135501126Y-104694566D02* -X135501126Y-103005466D01* -X136064159Y-104211966D01* -X136627192Y-103005466D01* -X136627192Y-104694566D01* -X138316292Y-104694566D02* -X137351092Y-104694566D01* -X137833692Y-104694566D02* -X137833692Y-103005466D01* -X137672826Y-103246766D01* -X137511959Y-103407633D01* -X137351092Y-103488066D01* -X138959759Y-103166333D02* -X139040192Y-103085900D01* -X139201059Y-103005466D01* -X139603226Y-103005466D01* -X139764092Y-103085900D01* -X139844526Y-103166333D01* -X139924959Y-103327200D01* -X139924959Y-103488066D01* -X139844526Y-103729366D01* -X138879326Y-104694566D01* -X139924959Y-104694566D01* -X140890159Y-103729366D02* -X140729292Y-103648933D01* -X140648859Y-103568500D01* -X140568426Y-103407633D01* -X140568426Y-103327200D01* -X140648859Y-103166333D01* -X140729292Y-103085900D01* -X140890159Y-103005466D01* -X141211892Y-103005466D01* -X141372759Y-103085900D01* -X141453192Y-103166333D01* -X141533626Y-103327200D01* -X141533626Y-103407633D01* -X141453192Y-103568500D01* -X141372759Y-103648933D01* -X141211892Y-103729366D01* -X140890159Y-103729366D01* -X140729292Y-103809800D01* -X140648859Y-103890233D01* -X140568426Y-104051100D01* -X140568426Y-104372833D01* -X140648859Y-104533700D01* -X140729292Y-104614133D01* -X140890159Y-104694566D01* -X141211892Y-104694566D01* -X141372759Y-104614133D01* -X141453192Y-104533700D01* -X141533626Y-104372833D01* -X141533626Y-104051100D01* -X141453192Y-103890233D01* -X141372759Y-103809800D01* -X141211892Y-103729366D01* -X142981426Y-103568500D02* -X142981426Y-104694566D01* -X142579259Y-102925033D02* -X142177092Y-104131533D01* -X143222726Y-104131533D01* -X144992259Y-103568500D02* -X145394426Y-104694566D01* -X145796592Y-103568500D01* -X147324826Y-104694566D02* -X146359626Y-104694566D01* -X146842226Y-104694566D02* -X146842226Y-103005466D01* -X146681359Y-103246766D01* -X146520492Y-103407633D01* -X146359626Y-103488066D01* -X148048726Y-104533700D02* -X148129159Y-104614133D01* -X148048726Y-104694566D01* -X147968292Y-104614133D01* -X148048726Y-104533700D01* -X148048726Y-104694566D01* -X148772626Y-103166333D02* -X148853059Y-103085900D01* -X149013926Y-103005466D01* -X149416092Y-103005466D01* -X149576959Y-103085900D01* -X149657392Y-103166333D01* -X149737826Y-103327200D01* -X149737826Y-103488066D01* -X149657392Y-103729366D01* -X148692192Y-104694566D01* -X149737826Y-104694566D01* -X151185626Y-104694566D02* -X151185626Y-103005466D01* -X151185626Y-104614133D02* -X151024759Y-104694566D01* -X150703026Y-104694566D01* -X150542159Y-104614133D01* -X150461726Y-104533700D01* -X150381292Y-104372833D01* -X150381292Y-103890233D01* -X150461726Y-103729366D01* -X150542159Y-103648933D01* -X150703026Y-103568500D01* -X151024759Y-103568500D01* -X151185626Y-103648933D01* -X138959759Y-106341333D02* -X139040192Y-106260900D01* -X139201059Y-106180466D01* -X139603226Y-106180466D01* -X139764092Y-106260900D01* -X139844526Y-106341333D01* -X139924959Y-106502200D01* -X139924959Y-106663066D01* -X139844526Y-106904366D01* -X138879326Y-107869566D01* -X139924959Y-107869566D01* -X141372759Y-106180466D02* -X141051026Y-106180466D01* -X140890159Y-106260900D01* -X140809726Y-106341333D01* -X140648859Y-106582633D01* -X140568426Y-106904366D01* -X140568426Y-107547833D01* -X140648859Y-107708700D01* -X140729292Y-107789133D01* -X140890159Y-107869566D01* -X141211892Y-107869566D01* -X141372759Y-107789133D01* -X141453192Y-107708700D01* -X141533626Y-107547833D01* -X141533626Y-107145666D01* -X141453192Y-106984800D01* -X141372759Y-106904366D01* -X141211892Y-106823933D01* -X140890159Y-106823933D01* -X140729292Y-106904366D01* -X140648859Y-106984800D01* -X140568426Y-107145666D01* -X143464026Y-106100033D02* -X142016226Y-108271733D01* -X144348792Y-106180466D02* -X144509659Y-106180466D01* -X144670526Y-106260900D01* -X144750959Y-106341333D01* -X144831392Y-106502200D01* -X144911826Y-106823933D01* -X144911826Y-107226100D01* -X144831392Y-107547833D01* -X144750959Y-107708700D01* -X144670526Y-107789133D01* -X144509659Y-107869566D01* -X144348792Y-107869566D01* -X144187926Y-107789133D01* -X144107492Y-107708700D01* -X144027059Y-107547833D01* -X143946626Y-107226100D01* -X143946626Y-106823933D01* -X144027059Y-106502200D01* -X144107492Y-106341333D01* -X144187926Y-106260900D01* -X144348792Y-106180466D01* -X146520492Y-107869566D02* -X145555292Y-107869566D01* -X146037892Y-107869566D02* -X146037892Y-106180466D01* -X145877026Y-106421766D01* -X145716159Y-106582633D01* -X145555292Y-106663066D01* -X148450892Y-106100033D02* -X147003092Y-108271733D01* -X149898692Y-107869566D02* -X148933492Y-107869566D01* -X149416092Y-107869566D02* -X149416092Y-106180466D01* -X149255226Y-106421766D01* -X149094359Y-106582633D01* -X148933492Y-106663066D01* -X150703026Y-107869566D02* -X151024759Y-107869566D01* -X151185626Y-107789133D01* -X151266059Y-107708700D01* -X151426926Y-107467400D01* -X151507359Y-107145666D01* -X151507359Y-106502200D01* -X151426926Y-106341333D01* -X151346492Y-106260900D01* -X151185626Y-106180466D01* -X150863892Y-106180466D01* -X150703026Y-106260900D01* -X150622592Y-106341333D01* -X150542159Y-106502200D01* -X150542159Y-106904366D01* -X150622592Y-107065233D01* -X150703026Y-107145666D01* -X150863892Y-107226100D01* -X151185626Y-107226100D01* -X151346492Y-107145666D01* -X151426926Y-107065233D01* -X151507359Y-106904366D01* -D13* -X160202033Y-120011074D02* -X159558566Y-120461500D01* -X160202033Y-120783234D02* -X158850753Y-120783234D01* -X158850753Y-120268460D01* -X158915100Y-120139767D01* -X158979446Y-120075420D01* -X159108140Y-120011074D01* -X159301180Y-120011074D01* -X159429873Y-120075420D01* -X159494220Y-120139767D01* -X159558566Y-120268460D01* -X159558566Y-120783234D01* -X158850753Y-119560647D02* -X160202033Y-118659794D01* -X158850753Y-118659794D02* -X160202033Y-119560647D01* -X158850753Y-117887634D02* -X158850753Y-117758940D01* -X158915100Y-117630247D01* -X158979446Y-117565900D01* -X159108140Y-117501554D01* -X159365526Y-117437207D01* -X159687260Y-117437207D01* -X159944646Y-117501554D01* -X160073340Y-117565900D01* -X160137686Y-117630247D01* -X160202033Y-117758940D01* -X160202033Y-117887634D01* -X160137686Y-118016327D01* -X160073340Y-118080674D01* -X159944646Y-118145020D01* -X159687260Y-118209367D01* -X159365526Y-118209367D01* -X159108140Y-118145020D01* -X158979446Y-118080674D01* -X158915100Y-118016327D01* -X158850753Y-117887634D01* -X154786753Y-121035540D02* -X154786753Y-120263380D01* -X156138033Y-120649460D02* -X154786753Y-120649460D01* -X154786753Y-119941647D02* -X156138033Y-119040794D01* -X154786753Y-119040794D02* -X156138033Y-119941647D01* -X154786753Y-118268634D02* -X154786753Y-118139940D01* -X154851100Y-118011247D01* -X154915446Y-117946900D01* -X155044140Y-117882554D01* -X155301526Y-117818207D01* -X155623260Y-117818207D01* -X155880646Y-117882554D01* -X156009340Y-117946900D01* -X156073686Y-118011247D01* -X156138033Y-118139940D01* -X156138033Y-118268634D01* -X156073686Y-118397327D01* -X156009340Y-118461674D01* -X155880646Y-118526020D01* -X155623260Y-118590367D01* -X155301526Y-118590367D01* -X155044140Y-118526020D01* -X154915446Y-118461674D01* -X154851100Y-118397327D01* -X154786753Y-118268634D01* -X148944753Y-120857740D02* -X148944753Y-120085580D01* -X150296033Y-120471660D02* -X148944753Y-120471660D01* -X148944753Y-119763847D02* -X150296033Y-118862994D01* -X148944753Y-118862994D02* -X150296033Y-119763847D01* -X150296033Y-117640407D02* -X150296033Y-118412567D01* -X150296033Y-118026487D02* -X148944753Y-118026487D01* -X149137793Y-118155180D01* -X149266486Y-118283874D01* -X149330833Y-118412567D01* -X154278753Y-119893285D02* -X153635286Y-120343712D01* -X154278753Y-120665445D02* -X152927473Y-120665445D01* -X152927473Y-120150672D01* -X152991820Y-120021979D01* -X153056166Y-119957632D01* -X153184860Y-119893285D01* -X153377900Y-119893285D01* -X153506593Y-119957632D01* -X153570940Y-120021979D01* -X153635286Y-120150672D01* -X153635286Y-120665445D01* -X152927473Y-119442859D02* -X154278753Y-118542005D01* -X152927473Y-118542005D02* -X154278753Y-119442859D01* -X154278753Y-117319419D02* -X154278753Y-118091579D01* -X154278753Y-117705499D02* -X152927473Y-117705499D01* -X153120513Y-117834192D01* -X153249206Y-117962885D01* -X153313553Y-118091579D01* -X146912753Y-121018607D02* -X148264033Y-120117754D01* -X146912753Y-120117754D02* -X148264033Y-121018607D01* -X148135340Y-118830820D02* -X148199686Y-118895167D01* -X148264033Y-119088207D01* -X148264033Y-119216900D01* -X148199686Y-119409940D01* -X148070993Y-119538634D01* -X147942300Y-119602980D01* -X147684913Y-119667327D01* -X147491873Y-119667327D01* -X147234486Y-119602980D01* -X147105793Y-119538634D01* -X146977100Y-119409940D01* -X146912753Y-119216900D01* -X146912753Y-119088207D01* -X146977100Y-118895167D01* -X147041446Y-118830820D01* -X148264033Y-118251700D02* -X146912753Y-118251700D01* -X148264033Y-117479540D02* -X147491873Y-118058660D01* -X146912753Y-117479540D02* -X147684913Y-118251700D01* -X148264033Y-116192607D02* -X148264033Y-116964767D01* -X148264033Y-116578687D02* -X146912753Y-116578687D01* -X147105793Y-116707380D01* -X147234486Y-116836074D01* -X147298833Y-116964767D01* -X139546753Y-93891407D02* -X140898033Y-92990554D01* -X139546753Y-92990554D02* -X140898033Y-93891407D01* -X140769340Y-91703620D02* -X140833686Y-91767967D01* -X140898033Y-91961007D01* -X140898033Y-92089700D01* -X140833686Y-92282740D01* -X140704993Y-92411434D01* -X140576300Y-92475780D01* -X140318913Y-92540127D01* -X140125873Y-92540127D01* -X139868486Y-92475780D01* -X139739793Y-92411434D01* -X139611100Y-92282740D01* -X139546753Y-92089700D01* -X139546753Y-91961007D01* -X139611100Y-91767967D01* -X139675446Y-91703620D01* -X140898033Y-91124500D02* -X139546753Y-91124500D01* -X140898033Y-90352340D02* -X140125873Y-90931460D01* -X139546753Y-90352340D02* -X140318913Y-91124500D01* -X139546753Y-89515834D02* -X139546753Y-89387140D01* -X139611100Y-89258447D01* -X139675446Y-89194100D01* -X139804140Y-89129754D01* -X140061526Y-89065407D01* -X140383260Y-89065407D01* -X140640646Y-89129754D01* -X140769340Y-89194100D01* -X140833686Y-89258447D01* -X140898033Y-89387140D01* -X140898033Y-89515834D01* -X140833686Y-89644527D01* -X140769340Y-89708874D01* -X140640646Y-89773220D01* -X140383260Y-89837567D01* -X140061526Y-89837567D01* -X139804140Y-89773220D01* -X139675446Y-89708874D01* -X139611100Y-89644527D01* -X139546753Y-89515834D01* -X138212406Y-122761792D02* -X138276753Y-122568752D01* -X138276753Y-122247019D01* -X138212406Y-122118325D01* -X138148060Y-122053979D01* -X138019366Y-121989632D01* -X137890673Y-121989632D01* -X137761980Y-122053979D01* -X137697633Y-122118325D01* -X137633286Y-122247019D01* -X137568940Y-122504405D01* -X137504593Y-122633099D01* -X137440246Y-122697445D01* -X137311553Y-122761792D01* -X137182860Y-122761792D01* -X137054166Y-122697445D01* -X136989820Y-122633099D01* -X136925473Y-122504405D01* -X136925473Y-122182672D01* -X136989820Y-121989632D01* -X138148060Y-120638352D02* -X138212406Y-120702699D01* -X138276753Y-120895739D01* -X138276753Y-121024432D01* -X138212406Y-121217472D01* -X138083713Y-121346165D01* -X137955020Y-121410512D01* -X137697633Y-121474859D01* -X137504593Y-121474859D01* -X137247206Y-121410512D01* -X137118513Y-121346165D01* -X136989820Y-121217472D01* -X136925473Y-121024432D01* -X136925473Y-120895739D01* -X136989820Y-120702699D01* -X137054166Y-120638352D01* -X138276753Y-119415765D02* -X138276753Y-120059232D01* -X136925473Y-120059232D01* -X135626686Y-123030287D02* -X135691033Y-122837247D01* -X135691033Y-122515514D01* -X135626686Y-122386820D01* -X135562340Y-122322474D01* -X135433646Y-122258127D01* -X135304953Y-122258127D01* -X135176260Y-122322474D01* -X135111913Y-122386820D01* -X135047566Y-122515514D01* -X134983220Y-122772900D01* -X134918873Y-122901594D01* -X134854526Y-122965940D01* -X134725833Y-123030287D01* -X134597140Y-123030287D01* -X134468446Y-122965940D01* -X134404100Y-122901594D01* -X134339753Y-122772900D01* -X134339753Y-122451167D01* -X134404100Y-122258127D01* -X135691033Y-121679007D02* -X134339753Y-121679007D01* -X134339753Y-121357274D01* -X134404100Y-121164234D01* -X134532793Y-121035540D01* -X134661486Y-120971194D01* -X134918873Y-120906847D01* -X135111913Y-120906847D01* -X135369300Y-120971194D01* -X135497993Y-121035540D01* -X135626686Y-121164234D01* -X135691033Y-121357274D01* -X135691033Y-121679007D01* -X135304953Y-120392074D02* -X135304953Y-119748607D01* -X135691033Y-120520767D02* -X134339753Y-120070340D01* -X135691033Y-119619914D01* -X173811353Y-102657794D02* -X173811353Y-103301260D01* -X174454820Y-103365607D01* -X174390473Y-103301260D01* -X174326126Y-103172567D01* -X174326126Y-102850834D01* -X174390473Y-102722140D01* -X174454820Y-102657794D01* -X174583513Y-102593447D01* -X174905246Y-102593447D01* -X175033940Y-102657794D01* -X175098286Y-102722140D01* -X175162633Y-102850834D01* -X175162633Y-103172567D01* -X175098286Y-103301260D01* -X175033940Y-103365607D01* -X173811353Y-102207367D02* -X175162633Y-101756940D01* -X173811353Y-101306514D01* -X167604067Y-115992320D02* -X167475374Y-115927973D01* -X167282334Y-115927973D01* -X167089294Y-115992320D01* -X166960600Y-116121013D01* -X166896254Y-116249706D01* -X166831907Y-116507093D01* -X166831907Y-116700133D01* -X166896254Y-116957520D01* -X166960600Y-117086213D01* -X167089294Y-117214906D01* -X167282334Y-117279253D01* -X167411027Y-117279253D01* -X167604067Y-117214906D01* -X167668414Y-117150560D01* -X167668414Y-116700133D01* -X167411027Y-116700133D01* -X168247534Y-117279253D02* -X168247534Y-115927973D01* -X169019694Y-117279253D01* -X169019694Y-115927973D01* -X169663160Y-117279253D02* -X169663160Y-115927973D01* -X169984894Y-115927973D01* -X170177934Y-115992320D01* -X170306627Y-116121013D01* -X170370974Y-116249706D01* -X170435320Y-116507093D01* -X170435320Y-116700133D01* -X170370974Y-116957520D01* -X170306627Y-117086213D01* -X170177934Y-117214906D01* -X169984894Y-117279253D01* -X169663160Y-117279253D01* -D14* -X122603260Y-106673737D02* -X122603260Y-105644190D01* -X123118033Y-106158964D02* -X122088486Y-106158964D01* -X121766753Y-104357257D02* -X121766753Y-105000724D01* -X122410220Y-105065070D01* -X122345873Y-105000724D01* -X122281526Y-104872030D01* -X122281526Y-104550297D01* -X122345873Y-104421604D01* -X122410220Y-104357257D01* -X122538913Y-104292910D01* -X122860646Y-104292910D01* -X122989340Y-104357257D01* -X123053686Y-104421604D01* -X123118033Y-104550297D01* -X123118033Y-104872030D01* -X123053686Y-105000724D01* -X122989340Y-105065070D01* -X121766753Y-103906830D02* -X123118033Y-103456404D01* -X121766753Y-103005977D01* -D13* -X121876820Y-110153232D02* -X121812473Y-110281925D01* -X121812473Y-110474965D01* -X121876820Y-110668005D01* -X122005513Y-110796699D01* -X122134206Y-110861045D01* -X122391593Y-110925392D01* -X122584633Y-110925392D01* -X122842020Y-110861045D01* -X122970713Y-110796699D01* -X123099406Y-110668005D01* -X123163753Y-110474965D01* -X123163753Y-110346272D01* -X123099406Y-110153232D01* -X123035060Y-110088885D01* -X122584633Y-110088885D01* -X122584633Y-110346272D01* -X123163753Y-109509765D02* -X121812473Y-109509765D01* -X123163753Y-108737605D01* -X121812473Y-108737605D01* -X123163753Y-108094139D02* -X121812473Y-108094139D01* -X121812473Y-107772405D01* -X121876820Y-107579365D01* -X122005513Y-107450672D01* -X122134206Y-107386325D01* -X122391593Y-107321979D01* -X122584633Y-107321979D01* -X122842020Y-107386325D01* -X122970713Y-107450672D01* -X123099406Y-107579365D01* -X123163753Y-107772405D01* -X123163753Y-108094139D01* -X143893065Y-92468533D02* -X143893065Y-91117253D01* -X144343492Y-92082453D01* -X144793919Y-91117253D01* -X144793919Y-92468533D01* -X145694772Y-91117253D02* -X145952159Y-91117253D01* -X146080852Y-91181600D01* -X146209545Y-91310293D01* -X146273892Y-91567680D01* -X146273892Y-92018106D01* -X146209545Y-92275493D01* -X146080852Y-92404186D01* -X145952159Y-92468533D01* -X145694772Y-92468533D01* -X145566079Y-92404186D01* -X145437385Y-92275493D01* -X145373039Y-92018106D01* -X145373039Y-91567680D01* -X145437385Y-91310293D01* -X145566079Y-91181600D01* -X145694772Y-91117253D01* -X146788665Y-92404186D02* -X146981705Y-92468533D01* -X147303439Y-92468533D01* -X147432132Y-92404186D01* -X147496479Y-92339840D01* -X147560825Y-92211146D01* -X147560825Y-92082453D01* -X147496479Y-91953760D01* -X147432132Y-91889413D01* -X147303439Y-91825066D01* -X147046052Y-91760720D01* -X146917359Y-91696373D01* -X146853012Y-91632026D01* -X146788665Y-91503333D01* -X146788665Y-91374640D01* -X146853012Y-91245946D01* -X146917359Y-91181600D01* -X147046052Y-91117253D01* -X147367785Y-91117253D01* -X147560825Y-91181600D01* -X148139945Y-92468533D02* -X148139945Y-91117253D01* -X143893065Y-95008533D02* -X143893065Y-93657253D01* -X144343492Y-94622453D01* -X144793919Y-93657253D01* -X144793919Y-95008533D01* -X145437385Y-95008533D02* -X145437385Y-93657253D01* -X146016505Y-94944186D02* -X146209545Y-95008533D01* -X146531279Y-95008533D01* -X146659972Y-94944186D01* -X146724319Y-94879840D01* -X146788665Y-94751146D01* -X146788665Y-94622453D01* -X146724319Y-94493760D01* -X146659972Y-94429413D01* -X146531279Y-94365066D01* -X146273892Y-94300720D01* -X146145199Y-94236373D01* -X146080852Y-94172026D01* -X146016505Y-94043333D01* -X146016505Y-93914640D01* -X146080852Y-93785946D01* -X146145199Y-93721600D01* -X146273892Y-93657253D01* -X146595625Y-93657253D01* -X146788665Y-93721600D01* -X147625172Y-93657253D02* -X147882559Y-93657253D01* -X148011252Y-93721600D01* -X148139945Y-93850293D01* -X148204292Y-94107680D01* -X148204292Y-94558106D01* -X148139945Y-94815493D01* -X148011252Y-94944186D01* -X147882559Y-95008533D01* -X147625172Y-95008533D01* -X147496479Y-94944186D01* -X147367785Y-94815493D01* -X147303439Y-94558106D01* -X147303439Y-94107680D01* -X147367785Y-93850293D01* -X147496479Y-93721600D01* -X147625172Y-93657253D01* -X144729572Y-97738186D02* -X144922612Y-97802533D01* -X145244345Y-97802533D01* -X145373039Y-97738186D01* -X145437385Y-97673840D01* -X145501732Y-97545146D01* -X145501732Y-97416453D01* -X145437385Y-97287760D01* -X145373039Y-97223413D01* -X145244345Y-97159066D01* -X144986959Y-97094720D01* -X144858265Y-97030373D01* -X144793919Y-96966026D01* -X144729572Y-96837333D01* -X144729572Y-96708640D01* -X144793919Y-96579946D01* -X144858265Y-96515600D01* -X144986959Y-96451253D01* -X145308692Y-96451253D01* -X145501732Y-96515600D01* -X146853012Y-97673840D02* -X146788665Y-97738186D01* -X146595625Y-97802533D01* -X146466932Y-97802533D01* -X146273892Y-97738186D01* -X146145199Y-97609493D01* -X146080852Y-97480800D01* -X146016505Y-97223413D01* -X146016505Y-97030373D01* -X146080852Y-96772986D01* -X146145199Y-96644293D01* -X146273892Y-96515600D01* -X146466932Y-96451253D01* -X146595625Y-96451253D01* -X146788665Y-96515600D01* -X146853012Y-96579946D01* -X147432132Y-97802533D02* -X147432132Y-96451253D01* -X148204292Y-97802533D02* -X147625172Y-97030373D01* -X148204292Y-96451253D02* -X147432132Y-97223413D01* -X166642254Y-114986480D02* -X167671800Y-114986480D01* -X167157027Y-115501253D02* -X167157027Y-114471706D01* -X168379614Y-115501253D02* -X168637000Y-115501253D01* -X168765694Y-115436906D01* -X168830040Y-115372560D01* -X168958734Y-115179520D01* -X169023080Y-114922133D01* -X169023080Y-114407360D01* -X168958734Y-114278666D01* -X168894387Y-114214320D01* -X168765694Y-114149973D01* -X168508307Y-114149973D01* -X168379614Y-114214320D01* -X168315267Y-114278666D01* -X168250920Y-114407360D01* -X168250920Y-114729093D01* -X168315267Y-114857786D01* -X168379614Y-114922133D01* -X168508307Y-114986480D01* -X168765694Y-114986480D01* -X168894387Y-114922133D01* -X168958734Y-114857786D01* -X169023080Y-114729093D01* -X169409160Y-114149973D02* -X169859587Y-115501253D01* -X170310014Y-114149973D01* -D15* -G04 #@! TO.C,LED1_SMD1* -G36* -X130317500Y-111450800D02* -X130667500Y-111450800D01* -X130667500Y-111100800D01* -X130317500Y-111100800D01* -X130317500Y-111450800D01* -G37* -G36* -X131017500Y-111100800D02* -X131342500Y-111100800D01* -X131342500Y-110675800D01* -X131017500Y-110675800D01* -X131017500Y-111100800D01* -G37* -G36* -X129642500Y-111100800D02* -X129967500Y-111100800D01* -X129967500Y-110675800D01* -X129642500Y-110675800D01* -X129642500Y-111100800D01* -G37* -D16* -G04 #@! TO.C,SW1/PC5* -X133491100Y-91943600D02* -G75* -G03X133491100Y-91943600I-865000J0D01* -G01* -X133626100Y-91943600D02* -G75* -G03X133626100Y-91943600I-1000000J0D01* -G01* -X130981100Y-90947800D02* -X131630300Y-90298600D01* -X130981100Y-92939400D02* -X130981100Y-90947800D01* -X133621900Y-90298600D02* -X134271100Y-90947800D01* -X131630300Y-90298600D02* -X133621900Y-90298600D01* -X134271100Y-92939400D02* -X133621900Y-93588600D01* -X134271100Y-90947800D02* -X134271100Y-92939400D01* -X131630300Y-93588600D02* -X130981100Y-92939400D01* -X133621900Y-93588600D02* -X131630300Y-93588600D01* -X130814100Y-90878600D02* -X131561100Y-90131600D01* -X130814100Y-93008600D02* -X130814100Y-90878600D01* -X133691100Y-90131600D02* -X134438100Y-90878600D01* -X131561100Y-90131600D02* -X133691100Y-90131600D01* -X134438100Y-93008600D02* -X133691100Y-93755600D01* -X134438100Y-90878600D02* -X134438100Y-93008600D01* -X131561100Y-93755600D02* -X130814100Y-93008600D01* -X133691100Y-93755600D02* -X131561100Y-93755600D01* -D17* -X130126100Y-90810100D02* -X130445100Y-90810100D01* -X130126100Y-93077100D02* -X130126100Y-90810100D01* -X130444100Y-93077100D02* -X130126100Y-93077100D01* -X130444100Y-93077100D02* -X130444100Y-90725300D01* -X130444100Y-93161900D02* -X130444100Y-93077100D01* -X135126100Y-93077100D02* -X134807100Y-93077100D01* -X135126100Y-90810100D02* -X135126100Y-93077100D01* -X134808100Y-90810100D02* -X135126100Y-90810100D01* -X134808100Y-90810100D02* -X134808100Y-93161900D01* -X134808100Y-90725300D02* -X134808100Y-90810100D01* -X133759600Y-89443600D02* -X133759600Y-89762600D01* -X131492600Y-89443600D02* -X133759600Y-89443600D01* -X131492600Y-89761600D02* -X131492600Y-89443600D01* -X131492600Y-89761600D02* -X133844400Y-89761600D01* -X131407800Y-89761600D02* -X131492600Y-89761600D01* -X131492600Y-94443600D02* -X131492600Y-94124600D01* -X133759600Y-94443600D02* -X131492600Y-94443600D01* -X133759600Y-94125600D02* -X133759600Y-94443600D01* -X134808100Y-93161900D02* -X133844400Y-94125600D01* -X133844400Y-89761600D02* -X134808100Y-90725300D01* -X130444100Y-90725300D02* -X131407800Y-89761600D01* -X131407800Y-94125600D02* -X130444100Y-93161900D01* -X133759600Y-94125600D02* -X131407800Y-94125600D01* -X133844400Y-94125600D02* -X133759600Y-94125600D01* -D15* -G04 #@! TO.C,IC2* -G36* -X170345100Y-105024600D02* -X170345100Y-103119600D01* -X169837100Y-103119600D01* -X169837100Y-105024600D01* -X170345100Y-105024600D01* -G37* -G36* -X170345100Y-107564600D02* -X170345100Y-106802600D01* -X169837100Y-106802600D01* -X169837100Y-107564600D01* -X170345100Y-107564600D01* -G37* -G36* -X170345100Y-110104600D02* -X170345100Y-109342600D01* -X169837100Y-109342600D01* -X169837100Y-110104600D01* -X170345100Y-110104600D01* -G37* -G36* -X170345100Y-113787600D02* -X170345100Y-111882600D01* -X169837100Y-111882600D01* -X169837100Y-113787600D01* -X170345100Y-113787600D01* -G37* -G36* -X169837100Y-113787600D02* -X169837100Y-103119600D01* -X169075100Y-103119600D01* -X169075100Y-113787600D01* -X169837100Y-113787600D01* -G37* -D18* -X173037500Y-112949400D02* -G75* -G03X173037500Y-112949400I-254000J0D01* -G01* -X173139100Y-113406600D02* -X170218100Y-113533600D01* -X173139100Y-113406600D02* -X173393100Y-113152600D01* -X173393100Y-103754600D02* -X173393100Y-113152600D01* -X173393100Y-103754600D02* -X173139100Y-103500600D01* -X170218100Y-103373600D02* -X173139100Y-103500600D01* -D17* -G04 #@! TO.C,SV1* -X158661100Y-88133600D02* -X158661100Y-84323600D01* -X158661100Y-88133600D02* -X158788100Y-88133600D01* -X158788100Y-89403600D02* -X158788100Y-88133600D01* -X158788100Y-89403600D02* -X158661100Y-89403600D01* -X158661100Y-89911600D02* -X158661100Y-89403600D01* -X159677100Y-89911600D02* -X158661100Y-89911600D01* -D19* -X159677100Y-85339600D02* -X159677100Y-89911600D01* -X166535100Y-85339600D02* -X159677100Y-85339600D01* -X166535100Y-98547600D02* -X166535100Y-85339600D01* -X159677100Y-98547600D02* -X166535100Y-98547600D01* -X159677100Y-93975600D02* -X159677100Y-98547600D01* -D17* -X159677100Y-93975600D02* -X158661100Y-93975600D01* -X159931100Y-93975600D02* -X159677100Y-93975600D01* -X159931100Y-98293600D02* -X159931100Y-93975600D01* -X158661100Y-93975600D02* -X158661100Y-89911600D01* -X158661100Y-99563600D02* -X158661100Y-93975600D01* -X167551100Y-86863600D02* -X167551100Y-91308600D01* -X167805100Y-86863600D02* -X167551100Y-86863600D01* -X167805100Y-85593600D02* -X167551100Y-85593600D01* -X167805100Y-86863600D02* -X167805100Y-85593600D01* -X167805100Y-91308600D02* -X167551100Y-91308600D01* -X167551100Y-92578600D02* -X167551100Y-97023600D01* -X167805100Y-92578600D02* -X167551100Y-92578600D01* -X167805100Y-92578600D02* -X167805100Y-91308600D01* -X167551100Y-98293600D02* -X167551100Y-99563600D01* -X167551100Y-97023600D02* -X167805100Y-97023600D01* -X167805100Y-98293600D02* -X167805100Y-97023600D01* -X167551100Y-98293600D02* -X167805100Y-98293600D01* -X159931100Y-89911600D02* -X159677100Y-89911600D01* -X159931100Y-89911600D02* -X159931100Y-85593600D01* -X159931100Y-89911600D02* -X160693100Y-89911600D01* -X160693100Y-93975600D02* -X160693100Y-89911600D01* -X160693100Y-93975600D02* -X159931100Y-93975600D01* -X167551100Y-84323600D02* -X158661100Y-84323600D01* -X158661100Y-99563600D02* -X167551100Y-99563600D01* -X167551100Y-84323600D02* -X167551100Y-85593600D01* -X166281100Y-85593600D02* -X159931100Y-85593600D01* -X159931100Y-98293600D02* -X166281100Y-98293600D01* -X166281100Y-85593600D02* -X166281100Y-98293600D01* -G04 #@! TO.C,JP3* -X130721100Y-123693600D02* -X131356100Y-124328600D01* -X129451100Y-123693600D02* -X130721100Y-123693600D01* -X128816100Y-124328600D02* -X129451100Y-123693600D01* -X128816100Y-125598600D02* -X128816100Y-124328600D01* -X129451100Y-126233600D02* -X128816100Y-125598600D01* -X130721100Y-126233600D02* -X129451100Y-126233600D01* -X131356100Y-125598600D02* -X130721100Y-126233600D01* -X157391100Y-123693600D02* -X158661100Y-123693600D01* -X159296100Y-124328600D02* -X158661100Y-123693600D01* -X158661100Y-126233600D02* -X159296100Y-125598600D01* -X159296100Y-125598600D02* -X159296100Y-124328600D01* -X156121100Y-123693600D02* -X156756100Y-124328600D01* -X154851100Y-123693600D02* -X156121100Y-123693600D01* -X154216100Y-124328600D02* -X154851100Y-123693600D01* -X154216100Y-125598600D02* -X154216100Y-124328600D01* -X154851100Y-126233600D02* -X154216100Y-125598600D01* -X156121100Y-126233600D02* -X154851100Y-126233600D01* -X156756100Y-125598600D02* -X156121100Y-126233600D01* -X156756100Y-124328600D02* -X157391100Y-123693600D01* -X156756100Y-125598600D02* -X156756100Y-124328600D01* -X157391100Y-126233600D02* -X156756100Y-125598600D01* -X158661100Y-126233600D02* -X157391100Y-126233600D01* -X149771100Y-123693600D02* -X151041100Y-123693600D01* -X151676100Y-124328600D02* -X151041100Y-123693600D01* -X151041100Y-126233600D02* -X151676100Y-125598600D01* -X153581100Y-123693600D02* -X154216100Y-124328600D01* -X152311100Y-123693600D02* -X153581100Y-123693600D01* -X151676100Y-124328600D02* -X152311100Y-123693600D01* -X151676100Y-125598600D02* -X151676100Y-124328600D01* -X152311100Y-126233600D02* -X151676100Y-125598600D01* -X153581100Y-126233600D02* -X152311100Y-126233600D01* -X154216100Y-125598600D02* -X153581100Y-126233600D01* -X148501100Y-123693600D02* -X149136100Y-124328600D01* -X147231100Y-123693600D02* -X148501100Y-123693600D01* -X146596100Y-124328600D02* -X147231100Y-123693600D01* -X146596100Y-125598600D02* -X146596100Y-124328600D01* -X147231100Y-126233600D02* -X146596100Y-125598600D01* -X148501100Y-126233600D02* -X147231100Y-126233600D01* -X149136100Y-125598600D02* -X148501100Y-126233600D01* -X149136100Y-124328600D02* -X149771100Y-123693600D01* -X149136100Y-125598600D02* -X149136100Y-124328600D01* -X149771100Y-126233600D02* -X149136100Y-125598600D01* -X151041100Y-126233600D02* -X149771100Y-126233600D01* -X142151100Y-123693600D02* -X143421100Y-123693600D01* -X144056100Y-124328600D02* -X143421100Y-123693600D01* -X143421100Y-126233600D02* -X144056100Y-125598600D01* -X145961100Y-123693600D02* -X146596100Y-124328600D01* -X144691100Y-123693600D02* -X145961100Y-123693600D01* -X144056100Y-124328600D02* -X144691100Y-123693600D01* -X144056100Y-125598600D02* -X144056100Y-124328600D01* -X144691100Y-126233600D02* -X144056100Y-125598600D01* -X145961100Y-126233600D02* -X144691100Y-126233600D01* -X146596100Y-125598600D02* -X145961100Y-126233600D01* -X140881100Y-123693600D02* -X141516100Y-124328600D01* -X139611100Y-123693600D02* -X140881100Y-123693600D01* -X138976100Y-124328600D02* -X139611100Y-123693600D01* -X138976100Y-125598600D02* -X138976100Y-124328600D01* -X139611100Y-126233600D02* -X138976100Y-125598600D01* -X140881100Y-126233600D02* -X139611100Y-126233600D01* -X141516100Y-125598600D02* -X140881100Y-126233600D01* -X141516100Y-124328600D02* -X142151100Y-123693600D01* -X141516100Y-125598600D02* -X141516100Y-124328600D01* -X142151100Y-126233600D02* -X141516100Y-125598600D01* -X143421100Y-126233600D02* -X142151100Y-126233600D01* -X134531100Y-123693600D02* -X135801100Y-123693600D01* -X136436100Y-124328600D02* -X135801100Y-123693600D01* -X135801100Y-126233600D02* -X136436100Y-125598600D01* -X138341100Y-123693600D02* -X138976100Y-124328600D01* -X137071100Y-123693600D02* -X138341100Y-123693600D01* -X136436100Y-124328600D02* -X137071100Y-123693600D01* -X136436100Y-125598600D02* -X136436100Y-124328600D01* -X137071100Y-126233600D02* -X136436100Y-125598600D01* -X138341100Y-126233600D02* -X137071100Y-126233600D01* -X138976100Y-125598600D02* -X138341100Y-126233600D01* -X133261100Y-123693600D02* -X133896100Y-124328600D01* -X131991100Y-123693600D02* -X133261100Y-123693600D01* -X131356100Y-124328600D02* -X131991100Y-123693600D01* -X131356100Y-125598600D02* -X131356100Y-124328600D01* -X131991100Y-126233600D02* -X131356100Y-125598600D01* -X133261100Y-126233600D02* -X131991100Y-126233600D01* -X133896100Y-125598600D02* -X133261100Y-126233600D01* -X133896100Y-124328600D02* -X134531100Y-123693600D01* -X133896100Y-125598600D02* -X133896100Y-124328600D01* -X134531100Y-126233600D02* -X133896100Y-125598600D01* -X135801100Y-126233600D02* -X134531100Y-126233600D01* -D20* -G04 #@! TO.C,LED1* -X130848100Y-110993600D02* -G75* -G02X129824300Y-112757900I-2032000J-56D01* -G01* -X130128700Y-109442400D02* -G75* -G02X130848100Y-110993600I-1312600J-1551163D01* -G01* -X126784100Y-110993600D02* -G75* -G03X127859900Y-112786500I2032000J60D01* -G01* -X127515200Y-109432600D02* -G75* -G03X126784100Y-110993600I1300900J-1560988D01* -G01* -D17* -X130340100Y-110993600D02* -G75* -G02X129751700Y-112196600I-1524000J8D01* -G01* -X129751700Y-109790600D02* -G75* -G02X130340100Y-110993600I-935600J-1203008D01* -G01* -X127292100Y-110993600D02* -G75* -G03X127901700Y-112212800I1524000J0D01* -G01* -X127930299Y-109753500D02* -G75* -G03X127292100Y-110993600I885801J-1240134D01* -G01* -D18* -G04 #@! TO.C,JP1* -X151676100Y-85593600D02* -X151676100Y-88133600D01* -X128816100Y-85593600D02* -X151676100Y-85593600D01* -X128816100Y-88133600D02* -X128816100Y-85593600D01* -X151676100Y-88133600D02* -X128816100Y-88133600D01* -G04 #@! TO.C,JP2* -X123736100Y-95753600D02* -X126276100Y-95753600D01* -X123736100Y-118613600D02* -X123736100Y-95753600D01* -X126276100Y-118613600D02* -X123736100Y-118613600D01* -X126276100Y-95753600D02* -X126276100Y-118613600D01* -D17* -G04 #@! TO.C,X2* -X163650300Y-125903400D02* -G75* -G03X163650300Y-125903400I-508000J0D01* -G01* -X168654100Y-125903400D02* -G75* -G03X168654100Y-125903400I-508000J0D01* -G01* -X160653100Y-127224600D02* -X160653100Y-120620600D01* -X170635100Y-127224600D02* -X170635100Y-127427600D01* -X170635100Y-127224600D02* -X160653100Y-127224600D01* -X160653100Y-120620600D02* -X160653100Y-118232600D01* -X170635100Y-120620600D02* -X170635100Y-127224600D01* -X162253100Y-120620600D02* -X160653100Y-120620600D01* -X167257100Y-120620600D02* -X164031100Y-120620600D01* -X170635100Y-120620600D02* -X169035100Y-120620600D01* -X170635100Y-118232600D02* -X170635100Y-120620600D01* -X160653100Y-127427600D02* -X170635100Y-127427600D01* -X160653100Y-127427600D02* -X160653100Y-127224600D01* -X170635100Y-118232600D02* -X160653100Y-118232600D01* -G04 #@! TO.C,JP4* -X151041100Y-98293600D02* -X149771100Y-98293600D01* -X149136100Y-97658600D02* -X149771100Y-98293600D01* -X149771100Y-95753600D02* -X149136100Y-96388600D01* -X149136100Y-96388600D02* -X149136100Y-97658600D01* -X151676100Y-97658600D02* -X151041100Y-98293600D01* -X151676100Y-96388600D02* -X151676100Y-97658600D01* -X151041100Y-95753600D02* -X151676100Y-96388600D01* -X149771100Y-95753600D02* -X151041100Y-95753600D01* -G04 #@! TO.C,JP5* -X153581100Y-98293600D02* -X152311100Y-98293600D01* -X151676100Y-97658600D02* -X152311100Y-98293600D01* -X152311100Y-95753600D02* -X151676100Y-96388600D01* -X151676100Y-96388600D02* -X151676100Y-97658600D01* -X154216100Y-97658600D02* -X153581100Y-98293600D01* -X154216100Y-96388600D02* -X154216100Y-97658600D01* -X153581100Y-95753600D02* -X154216100Y-96388600D01* -X152311100Y-95753600D02* -X153581100Y-95753600D01* -G04 #@! TO.C,JP6* -X153581100Y-95753600D02* -X152311100Y-95753600D01* -X151676100Y-95118600D02* -X152311100Y-95753600D01* -X152311100Y-93213600D02* -X151676100Y-93848600D01* -X151676100Y-93848600D02* -X151676100Y-95118600D01* -X154216100Y-95118600D02* -X153581100Y-95753600D01* -X154216100Y-93848600D02* -X154216100Y-95118600D01* -X153581100Y-93213600D02* -X154216100Y-93848600D01* -X152311100Y-93213600D02* -X153581100Y-93213600D01* -G04 #@! TO.C,JP7* -X151041100Y-95753600D02* -X149771100Y-95753600D01* -X149136100Y-95118600D02* -X149771100Y-95753600D01* -X149771100Y-93213600D02* -X149136100Y-93848600D01* -X149136100Y-93848600D02* -X149136100Y-95118600D01* -X151676100Y-95118600D02* -X151041100Y-95753600D01* -X151676100Y-93848600D02* -X151676100Y-95118600D01* -X151041100Y-93213600D02* -X151676100Y-93848600D01* -X149771100Y-93213600D02* -X151041100Y-93213600D01* -G04 #@! TO.C,JP8* -X151041100Y-93213600D02* -X149771100Y-93213600D01* -X149136100Y-92578600D02* -X149771100Y-93213600D01* -X149771100Y-90673600D02* -X149136100Y-91308600D01* -X149136100Y-91308600D02* -X149136100Y-92578600D01* -X151676100Y-92578600D02* -X151041100Y-93213600D01* -X151676100Y-91308600D02* -X151676100Y-92578600D01* -X151041100Y-90673600D02* -X151676100Y-91308600D01* -X149771100Y-90673600D02* -X151041100Y-90673600D01* -G04 #@! TO.C,JP9* -X153581100Y-93213600D02* -X152311100Y-93213600D01* -X151676100Y-92578600D02* -X152311100Y-93213600D01* -X152311100Y-90673600D02* -X151676100Y-91308600D01* -X151676100Y-91308600D02* -X151676100Y-92578600D01* -X154216100Y-92578600D02* -X153581100Y-93213600D01* -X154216100Y-91308600D02* -X154216100Y-92578600D01* -X153581100Y-90673600D02* -X154216100Y-91308600D01* -X152311100Y-90673600D02* -X153581100Y-90673600D01* -G04 #@! TO.C,JP11* -X156121100Y-98293600D02* -X154851100Y-98293600D01* -X154216100Y-97658600D02* -X154851100Y-98293600D01* -X154851100Y-95753600D02* -X154216100Y-96388600D01* -X154216100Y-96388600D02* -X154216100Y-97658600D01* -X156756100Y-97658600D02* -X156121100Y-98293600D01* -X156756100Y-96388600D02* -X156756100Y-97658600D01* -X156121100Y-95753600D02* -X156756100Y-96388600D01* -X154851100Y-95753600D02* -X156121100Y-95753600D01* -G04 #@! TO.C,JP12* -X156121100Y-95753600D02* -X154851100Y-95753600D01* -X154216100Y-95118600D02* -X154851100Y-95753600D01* -X154851100Y-93213600D02* -X154216100Y-93848600D01* -X154216100Y-93848600D02* -X154216100Y-95118600D01* -X156756100Y-95118600D02* -X156121100Y-95753600D01* -X156756100Y-93848600D02* -X156756100Y-95118600D01* -X156121100Y-93213600D02* -X156756100Y-93848600D01* -X154851100Y-93213600D02* -X156121100Y-93213600D01* -G04 #@! TO.C,JP13* -X156121100Y-93213600D02* -X154851100Y-93213600D01* -X154216100Y-92578600D02* -X154851100Y-93213600D01* -X154851100Y-90673600D02* -X154216100Y-91308600D01* -X154216100Y-91308600D02* -X154216100Y-92578600D01* -X156756100Y-92578600D02* -X156121100Y-93213600D01* -X156756100Y-91308600D02* -X156756100Y-92578600D01* -X156121100Y-90673600D02* -X156756100Y-91308600D01* -X154851100Y-90673600D02* -X156121100Y-90673600D01* -G04 #@! TO.C,JP14* -X172631100Y-93213600D02* -X171361100Y-93213600D01* -X170726100Y-92578600D02* -X171361100Y-93213600D01* -X171361100Y-90673600D02* -X170726100Y-91308600D01* -X170726100Y-91308600D02* -X170726100Y-92578600D01* -X173266100Y-92578600D02* -X172631100Y-93213600D01* -X173266100Y-91308600D02* -X173266100Y-92578600D01* -X172631100Y-90673600D02* -X173266100Y-91308600D01* -X171361100Y-90673600D02* -X172631100Y-90673600D01* -G04 #@! TO.C,JP15* -X172631100Y-95753600D02* -X171361100Y-95753600D01* -X170726100Y-95118600D02* -X171361100Y-95753600D01* -X171361100Y-93213600D02* -X170726100Y-93848600D01* -X170726100Y-93848600D02* -X170726100Y-95118600D01* -X173266100Y-95118600D02* -X172631100Y-95753600D01* -X173266100Y-93848600D02* -X173266100Y-95118600D01* -X172631100Y-93213600D02* -X173266100Y-93848600D01* -X171361100Y-93213600D02* -X172631100Y-93213600D01* -G04 #@! TO.C,JP16* -X172631100Y-98293600D02* -X171361100Y-98293600D01* -X170726100Y-97658600D02* -X171361100Y-98293600D01* -X171361100Y-95753600D02* -X170726100Y-96388600D01* -X170726100Y-96388600D02* -X170726100Y-97658600D01* -X173266100Y-97658600D02* -X172631100Y-98293600D01* -X173266100Y-96388600D02* -X173266100Y-97658600D01* -X172631100Y-95753600D02* -X173266100Y-96388600D01* -X171361100Y-95753600D02* -X172631100Y-95753600D01* -G04 #@! TO.C,JP17* -X172631100Y-100833600D02* -X171361100Y-100833600D01* -X170726100Y-100198600D02* -X171361100Y-100833600D01* -X171361100Y-98293600D02* -X170726100Y-98928600D01* -X170726100Y-98928600D02* -X170726100Y-100198600D01* -X173266100Y-100198600D02* -X172631100Y-100833600D01* -X173266100Y-98928600D02* -X173266100Y-100198600D01* -X172631100Y-98293600D02* -X173266100Y-98928600D01* -X171361100Y-98293600D02* -X172631100Y-98293600D01* -G04 #@! TO.C,JP19* -X170091100Y-93213600D02* -X168821100Y-93213600D01* -X168186100Y-92578600D02* -X168821100Y-93213600D01* -X168821100Y-90673600D02* -X168186100Y-91308600D01* -X168186100Y-91308600D02* -X168186100Y-92578600D01* -X170726100Y-92578600D02* -X170091100Y-93213600D01* -X170726100Y-91308600D02* -X170726100Y-92578600D01* -X170091100Y-90673600D02* -X170726100Y-91308600D01* -X168821100Y-90673600D02* -X170091100Y-90673600D01* -G04 #@! TO.C,JP20* -X170091100Y-95753600D02* -X168821100Y-95753600D01* -X168186100Y-95118600D02* -X168821100Y-95753600D01* -X168821100Y-93213600D02* -X168186100Y-93848600D01* -X168186100Y-93848600D02* -X168186100Y-95118600D01* -X170726100Y-95118600D02* -X170091100Y-95753600D01* -X170726100Y-93848600D02* -X170726100Y-95118600D01* -X170091100Y-93213600D02* -X170726100Y-93848600D01* -X168821100Y-93213600D02* -X170091100Y-93213600D01* -G04 #@! TO.C,JP21* -X170091100Y-98293600D02* -X168821100Y-98293600D01* -X168186100Y-97658600D02* -X168821100Y-98293600D01* -X168821100Y-95753600D02* -X168186100Y-96388600D01* -X168186100Y-96388600D02* -X168186100Y-97658600D01* -X170726100Y-97658600D02* -X170091100Y-98293600D01* -X170726100Y-96388600D02* -X170726100Y-97658600D01* -X170091100Y-95753600D02* -X170726100Y-96388600D01* -X168821100Y-95753600D02* -X170091100Y-95753600D01* -G04 #@! TO.C,JP22* -X170091100Y-100833600D02* -X168821100Y-100833600D01* -X168186100Y-100198600D02* -X168821100Y-100833600D01* -X168821100Y-98293600D02* -X168186100Y-98928600D01* -X168186100Y-98928600D02* -X168186100Y-100198600D01* -X170726100Y-100198600D02* -X170091100Y-100833600D01* -X170726100Y-98928600D02* -X170726100Y-100198600D01* -X170091100Y-98293600D02* -X170726100Y-98928600D01* -X168821100Y-98293600D02* -X170091100Y-98293600D01* -G04 #@! TO.C,JP24* -X153581100Y-123693600D02* -X152311100Y-123693600D01* -X151676100Y-123058600D02* -X152311100Y-123693600D01* -X152311100Y-121153600D02* -X151676100Y-121788600D01* -X151676100Y-121788600D02* -X151676100Y-123058600D01* -X154216100Y-123058600D02* -X153581100Y-123693600D01* -X154216100Y-121788600D02* -X154216100Y-123058600D01* -X153581100Y-121153600D02* -X154216100Y-121788600D01* -X152311100Y-121153600D02* -X153581100Y-121153600D01* -G04 #@! TO.C,JP25* -X151041100Y-123693600D02* -X149771100Y-123693600D01* -X149136100Y-123058600D02* -X149771100Y-123693600D01* -X149771100Y-121153600D02* -X149136100Y-121788600D01* -X149136100Y-121788600D02* -X149136100Y-123058600D01* -X151676100Y-123058600D02* -X151041100Y-123693600D01* -X151676100Y-121788600D02* -X151676100Y-123058600D01* -X151041100Y-121153600D02* -X151676100Y-121788600D01* -X149771100Y-121153600D02* -X151041100Y-121153600D01* -G04 #@! TO.C,JP26* -X148501100Y-123693600D02* -X147231100Y-123693600D01* -X146596100Y-123058600D02* -X147231100Y-123693600D01* -X147231100Y-121153600D02* -X146596100Y-121788600D01* -X146596100Y-121788600D02* -X146596100Y-123058600D01* -X149136100Y-123058600D02* -X148501100Y-123693600D01* -X149136100Y-121788600D02* -X149136100Y-123058600D01* -X148501100Y-121153600D02* -X149136100Y-121788600D01* -X147231100Y-121153600D02* -X148501100Y-121153600D01* -G04 #@! TO.C,JP27* -X128181100Y-108453600D02* -X126911100Y-108453600D01* -X126276100Y-107818600D02* -X126911100Y-108453600D01* -X126911100Y-105913600D02* -X126276100Y-106548600D01* -X126276100Y-106548600D02* -X126276100Y-107818600D01* -X128816100Y-107818600D02* -X128181100Y-108453600D01* -X128816100Y-106548600D02* -X128816100Y-107818600D01* -X128181100Y-105913600D02* -X128816100Y-106548600D01* -X126911100Y-105913600D02* -X128181100Y-105913600D01* -G04 #@! TO.C,JP28* -X128181100Y-118613600D02* -X126911100Y-118613600D01* -X126276100Y-117978600D02* -X126911100Y-118613600D01* -X126911100Y-116073600D02* -X126276100Y-116708600D01* -X126276100Y-116708600D02* -X126276100Y-117978600D01* -X128816100Y-117978600D02* -X128181100Y-118613600D01* -X128816100Y-116708600D02* -X128816100Y-117978600D01* -X128181100Y-116073600D02* -X128816100Y-116708600D01* -X126911100Y-116073600D02* -X128181100Y-116073600D01* -G04 #@! TO.C,JP10* -X172631100Y-115438600D02* -X171361100Y-115438600D01* -X170726100Y-114803600D02* -X171361100Y-115438600D01* -X171361100Y-112898600D02* -X170726100Y-113533600D01* -X170726100Y-113533600D02* -X170726100Y-114803600D01* -X173266100Y-114803600D02* -X172631100Y-115438600D01* -X173266100Y-113533600D02* -X173266100Y-114803600D01* -X172631100Y-112898600D02* -X173266100Y-113533600D01* -X171361100Y-112898600D02* -X172631100Y-112898600D01* -G04 #@! TO.C,JP29* -X175171100Y-115438600D02* -X173901100Y-115438600D01* -X173266100Y-114803600D02* -X173901100Y-115438600D01* -X173901100Y-112898600D02* -X173266100Y-113533600D01* -X173266100Y-113533600D02* -X173266100Y-114803600D01* -X175806100Y-114803600D02* -X175171100Y-115438600D01* -X175806100Y-113533600D02* -X175806100Y-114803600D01* -X175171100Y-112898600D02* -X175806100Y-113533600D01* -X173901100Y-112898600D02* -X175171100Y-112898600D01* -D21* -G04 #@! TO.C,REF\002A\002A* -X170666100Y-126293600D02* -X175866100Y-126293600D01* -X170666100Y-118613600D02* -X170666100Y-126293600D01* -X175866100Y-116013600D02* -X175866100Y-126293600D01* -X170666100Y-118613600D02* -X173266100Y-118613600D01* -X173266100Y-118613600D02* -X173266100Y-116013600D01* -X173266100Y-116013600D02* -X175866100Y-116013600D01* -X170666100Y-117343600D02* -X170666100Y-116013600D01* -X170666100Y-116013600D02* -X171996100Y-116013600D01* -X173206100Y-100893600D02* -X175866100Y-100893600D01* -X173206100Y-93213600D02* -X173206100Y-100893600D01* -X175866100Y-93213600D02* -X175866100Y-100893600D01* -X173206100Y-93213600D02* -X175866100Y-93213600D01* -X173206100Y-91943600D02* -X173206100Y-90613600D01* -X173206100Y-90613600D02* -X174536100Y-90613600D01* -G04 #@! TD* -G04 #@! TO.C,SW1/PC5* -D22* -X127262957Y-96017695D02* -X127435314Y-96075147D01* -X127722576Y-96075147D01* -X127837480Y-96017695D01* -X127894933Y-95960242D01* -X127952385Y-95845338D01* -X127952385Y-95730433D01* -X127894933Y-95615528D01* -X127837480Y-95558076D01* -X127722576Y-95500623D01* -X127492766Y-95443171D01* -X127377861Y-95385719D01* -X127320409Y-95328266D01* -X127262957Y-95213361D01* -X127262957Y-95098457D01* -X127320409Y-94983552D01* -X127377861Y-94926100D01* -X127492766Y-94868647D01* -X127780028Y-94868647D01* -X127952385Y-94926100D01* -X128354552Y-94868647D02* -X128641814Y-96075147D01* -X128871623Y-95213361D01* -X129101433Y-96075147D01* -X129388695Y-94868647D01* -X130480290Y-96075147D02* -X129790861Y-96075147D01* -X130135576Y-96075147D02* -X130135576Y-94868647D01* -X130020671Y-95041004D01* -X129905766Y-95155909D01* -X129790861Y-95213361D01* -X131859147Y-94811195D02* -X130825004Y-96362409D01* -X132261314Y-96075147D02* -X132261314Y-94868647D01* -X132720933Y-94868647D01* -X132835838Y-94926100D01* -X132893290Y-94983552D01* -X132950742Y-95098457D01* -X132950742Y-95270814D01* -X132893290Y-95385719D01* -X132835838Y-95443171D01* -X132720933Y-95500623D01* -X132261314Y-95500623D01* -X134157242Y-95960242D02* -X134099790Y-96017695D01* -X133927433Y-96075147D01* -X133812528Y-96075147D01* -X133640171Y-96017695D01* -X133525266Y-95902790D01* -X133467814Y-95787885D01* -X133410361Y-95558076D01* -X133410361Y-95385719D01* -X133467814Y-95155909D01* -X133525266Y-95041004D01* -X133640171Y-94926100D01* -X133812528Y-94868647D01* -X133927433Y-94868647D01* -X134099790Y-94926100D01* -X134157242Y-94983552D01* -X135248838Y-94868647D02* -X134674314Y-94868647D01* -X134616861Y-95443171D01* -X134674314Y-95385719D01* -X134789219Y-95328266D01* -X135076480Y-95328266D01* -X135191385Y-95385719D01* -X135248838Y-95443171D01* -X135306290Y-95558076D01* -X135306290Y-95845338D01* -X135248838Y-95960242D01* -X135191385Y-96017695D01* -X135076480Y-96075147D01* -X134789219Y-96075147D01* -X134674314Y-96017695D01* -X134616861Y-95960242D01* -G04 #@! TO.C,IC2* -X175062847Y-106897738D02* -X173856347Y-106897738D01* -X174947942Y-105633785D02* -X175005395Y-105691238D01* -X175062847Y-105863595D01* -X175062847Y-105978500D01* -X175005395Y-106150857D01* -X174890490Y-106265761D01* -X174775585Y-106323214D01* -X174545776Y-106380666D01* -X174373419Y-106380666D01* -X174143609Y-106323214D01* -X174028704Y-106265761D01* -X173913800Y-106150857D01* -X173856347Y-105978500D01* -X173856347Y-105863595D01* -X173913800Y-105691238D01* -X173971252Y-105633785D01* -X173971252Y-105174166D02* -X173913800Y-105116714D01* -X173856347Y-105001809D01* -X173856347Y-104714547D01* -X173913800Y-104599642D01* -X173971252Y-104542190D01* -X174086157Y-104484738D01* -X174201061Y-104484738D01* -X174373419Y-104542190D01* -X175062847Y-105231619D01* -X175062847Y-104484738D01* -G04 #@! TO.C,SV1* -D23* -X154186733Y-86199133D02* -X154428033Y-86279566D01* -X154830200Y-86279566D01* -X154991066Y-86199133D01* -X155071500Y-86118700D01* -X155151933Y-85957833D01* -X155151933Y-85796966D01* -X155071500Y-85636100D01* -X154991066Y-85555666D01* -X154830200Y-85475233D01* -X154508466Y-85394800D01* -X154347600Y-85314366D01* -X154267166Y-85233933D01* -X154186733Y-85073066D01* -X154186733Y-84912200D01* -X154267166Y-84751333D01* -X154347600Y-84670900D01* -X154508466Y-84590466D01* -X154910633Y-84590466D01* -X155151933Y-84670900D01* -X155634533Y-84590466D02* -X156197566Y-86279566D01* -X156760600Y-84590466D01* -X158208400Y-86279566D02* -X157243200Y-86279566D01* -X157725800Y-86279566D02* -X157725800Y-84590466D01* -X157564933Y-84831766D01* -X157404066Y-84992633D01* -X157243200Y-85073066D01* -D18* -X162592052Y-86551240D02* -X162534600Y-86493788D01* -X162477147Y-86378883D01* -X162477147Y-86091621D01* -X162534600Y-85976716D01* -X162592052Y-85919264D01* -X162706957Y-85861811D01* -X162821861Y-85861811D01* -X162994219Y-85919264D01* -X163683647Y-86608692D01* -X163683647Y-85861811D01* -X161143647Y-85861811D02* -X161143647Y-86551240D01* -X161143647Y-86206526D02* -X159937147Y-86206526D01* -X160109504Y-86321430D01* -X160224409Y-86436335D01* -X160281861Y-86551240D01* -G04 #@! TO.C,R3* -D22* -X128741690Y-102177547D02* -X128339523Y-101603023D01* -X128052261Y-102177547D02* -X128052261Y-100971047D01* -X128511880Y-100971047D01* -X128626785Y-101028500D01* -X128684238Y-101085952D01* -X128741690Y-101200857D01* -X128741690Y-101373214D01* -X128684238Y-101488119D01* -X128626785Y-101545571D01* -X128511880Y-101603023D01* -X128052261Y-101603023D01* -X129143857Y-100971047D02* -X129890738Y-100971047D01* -X129488571Y-101430666D01* -X129660928Y-101430666D01* -X129775833Y-101488119D01* -X129833285Y-101545571D01* -X129890738Y-101660476D01* -X129890738Y-101947738D01* -X129833285Y-102062642D01* -X129775833Y-102120095D01* -X129660928Y-102177547D01* -X129316214Y-102177547D01* -X129201309Y-102120095D01* -X129143857Y-102062642D01* -G04 #@! TO.C,R4* -X158057547Y-115733309D02* -X157483023Y-116135476D01* -X158057547Y-116422738D02* -X156851047Y-116422738D01* -X156851047Y-115963119D01* -X156908500Y-115848214D01* -X156965952Y-115790761D01* -X157080857Y-115733309D01* -X157253214Y-115733309D01* -X157368119Y-115790761D01* -X157425571Y-115848214D01* -X157483023Y-115963119D01* -X157483023Y-116422738D01* -X157253214Y-114699166D02* -X158057547Y-114699166D01* -X156793595Y-114986428D02* -X157655380Y-115273690D01* -X157655380Y-114526809D01* -G04 #@! TO.C,R5* -X152342547Y-115733309D02* -X151768023Y-116135476D01* -X152342547Y-116422738D02* -X151136047Y-116422738D01* -X151136047Y-115963119D01* -X151193500Y-115848214D01* -X151250952Y-115790761D01* -X151365857Y-115733309D01* -X151538214Y-115733309D01* -X151653119Y-115790761D01* -X151710571Y-115848214D01* -X151768023Y-115963119D01* -X151768023Y-116422738D01* -X151136047Y-114641714D02* -X151136047Y-115216238D01* -X151710571Y-115273690D01* -X151653119Y-115216238D01* -X151595666Y-115101333D01* -X151595666Y-114814071D01* -X151653119Y-114699166D01* -X151710571Y-114641714D01* -X151825476Y-114584261D01* -X152112738Y-114584261D01* -X152227642Y-114641714D01* -X152285095Y-114699166D01* -X152342547Y-114814071D01* -X152342547Y-115101333D01* -X152285095Y-115216238D01* -X152227642Y-115273690D01* -G04 #@! TO.C,R6* -X133746142Y-100458647D02* -X133343976Y-99884123D01* -X133056714Y-100458647D02* -X133056714Y-99252147D01* -X133516333Y-99252147D01* -X133631238Y-99309600D01* -X133688690Y-99367052D01* -X133746142Y-99481957D01* -X133746142Y-99654314D01* -X133688690Y-99769219D01* -X133631238Y-99826671D01* -X133516333Y-99884123D01* -X133056714Y-99884123D01* -X134780285Y-99252147D02* -X134550476Y-99252147D01* -X134435571Y-99309600D01* -X134378119Y-99367052D01* -X134263214Y-99539409D01* -X134205761Y-99769219D01* -X134205761Y-100228838D01* -X134263214Y-100343742D01* -X134320666Y-100401195D01* -X134435571Y-100458647D01* -X134665380Y-100458647D01* -X134780285Y-100401195D01* -X134837738Y-100343742D01* -X134895190Y-100228838D01* -X134895190Y-99941576D01* -X134837738Y-99826671D01* -X134780285Y-99769219D01* -X134665380Y-99711766D01* -X134435571Y-99711766D01* -X134320666Y-99769219D01* -X134263214Y-99826671D01* -X134205761Y-99941576D01* -G04 #@! TO.C,LED1* -X132197952Y-113544047D02* -X131623428Y-113544047D01* -X131623428Y-112337547D01* -X132600119Y-112912071D02* -X133002285Y-112912071D01* -X133174642Y-113544047D02* -X132600119Y-113544047D01* -X132600119Y-112337547D01* -X133174642Y-112337547D01* -X133691714Y-113544047D02* -X133691714Y-112337547D01* -X133978976Y-112337547D01* -X134151333Y-112395000D01* -X134266238Y-112509904D01* -X134323690Y-112624809D01* -X134381142Y-112854619D01* -X134381142Y-113026976D01* -X134323690Y-113256785D01* -X134266238Y-113371690D01* -X134151333Y-113486595D01* -X133978976Y-113544047D01* -X133691714Y-113544047D01* -X135530190Y-113544047D02* -X134840761Y-113544047D01* -X135185476Y-113544047D02* -X135185476Y-112337547D01* -X135070571Y-112509904D01* -X134955666Y-112624809D01* -X134840761Y-112682261D01* -G04 #@! TO.C,X2* -X161612361Y-116016147D02* -X162416695Y-117222647D01* -X162416695Y-116016147D02* -X161612361Y-117222647D01* -X162818861Y-116131052D02* -X162876314Y-116073600D01* -X162991219Y-116016147D01* -X163278480Y-116016147D01* -X163393385Y-116073600D01* -X163450838Y-116131052D01* -X163508290Y-116245957D01* -X163508290Y-116360861D01* -X163450838Y-116533219D01* -X162761409Y-117222647D01* -X163508290Y-117222647D01* -D18* -X165537459Y-123179552D02* -X165594911Y-123122100D01* -X165709816Y-123064647D01* -X165997078Y-123064647D01* -X166111983Y-123122100D01* -X166169435Y-123179552D01* -X166226888Y-123294457D01* -X166226888Y-123409361D01* -X166169435Y-123581719D01* -X165480007Y-124271147D01* -X166226888Y-124271147D01* -X171179888Y-124271147D02* -X170490459Y-124271147D01* -X170835173Y-124271147D02* -X170835173Y-123064647D01* -X170720269Y-123237004D01* -X170605364Y-123351909D01* -X170490459Y-123409361D01* -G04 #@! TD* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-NPTH.drl b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-NPTH.drl deleted file mode 100644 index aa4f633..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-NPTH.drl +++ /dev/null @@ -1,10 +0,0 @@ -M48 -;DRILL file {KiCad (5.0.2)-1} date 02/04/2019 23:22:12 -;FORMAT={-:-/ absolute / metric / decimal} -FMAT,2 -METRIC,TZ -% -G90 -G05 -T0 -M30 diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-PTH.drl b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-PTH.drl deleted file mode 100644 index 83b4dd9..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-PTH.drl +++ /dev/null @@ -1,185 +0,0 @@ -M48 -;DRILL file {KiCad (5.0.2)-1} date 02/04/2019 23:22:12 -;FORMAT={-:-/ absolute / metric / decimal} -FMAT,2 -METRIC,TZ -T1C0.400 -T2C0.600 -T3C0.700 -T4C0.813 -T5C0.900 -T6C0.914 -T7C1.000 -T8C1.016 -T9C1.194 -T10C3.200 -% -G90 -G05 -T1 -X122.466Y-95.754 -X122.466Y-99.564 -X122.466Y-103.374 -X122.466Y-107.184 -X122.466Y-112.264 -X122.466Y-117.344 -X125.006Y-93.214 -X127.546Y-91.459 -X129.578Y-121.408 -X131.991Y-95.373 -X132.626Y-84.324 -X137.198Y-99.056 -X138.976Y-84.324 -X142.659Y-103.374 -X142.659Y-105.914 -X142.659Y-108.454 -X145.326Y-103.374 -X145.326Y-105.914 -X145.326Y-108.454 -X146.596Y-84.324 -X148.501Y-112.264 -X149.009Y-115.312 -X154.089Y-104.263 -X154.216Y-84.324 -X154.978Y-107.819 -X156.756Y-104.009 -X156.883Y-88.769 -X157.899Y-108.454 -X159.296Y-116.074 -X161.836Y-84.324 -X161.836Y-113.534 -X162.09Y-99.183 -X162.471Y-116.074 -X163.754Y-96.262 -X164.376Y-113.534 -X164.884Y-104.771 -X165.646Y-85.594 -X165.646Y-116.074 -X165.646Y-119.884 -X165.646Y-122.424 -X168.186Y-108.454 -X170.091Y-123.059 -X170.091Y-124.964 -X170.726Y-102.104 -X174.536Y-107.184 -T2 -X133.896Y-102.485 -X139.433Y-104.339 -X139.484Y-107.057 -X140.627Y-108.276 -X150.533Y-99.691 -X151.93Y-100.58 -T3 -X128.816Y-104.644 -X141.516Y-119.249 -X142.786Y-93.214 -X162.154Y-100.834 -X162.154Y-108.454 -X166.916Y-95.754 -X166.916Y-98.294 -X166.916Y-100.834 -X156.756Y-105.914 -X156.756Y-110.994 -T4 -X128.816Y-109.724 -X128.816Y-112.264 -T5 -X171.996Y-117.344 -X171.996Y-119.884 -X171.996Y-122.424 -X171.996Y-124.964 -X174.536Y-91.944 -X174.536Y-94.484 -X174.536Y-97.024 -X174.536Y-99.564 -X174.536Y-117.344 -X174.536Y-119.884 -X174.536Y-122.424 -X174.536Y-124.964 -X155.486Y-91.944 -X152.946Y-122.424 -X152.946Y-97.024 -X171.996Y-94.484 -X147.866Y-122.424 -X150.406Y-94.484 -X171.996Y-99.564 -X127.546Y-117.344 -X152.946Y-91.944 -X169.456Y-94.484 -X174.536Y-114.169 -X155.486Y-94.484 -X169.456Y-99.564 -X150.406Y-97.024 -X171.996Y-91.944 -X150.406Y-122.424 -X152.946Y-94.484 -X171.996Y-97.024 -X127.546Y-107.184 -X150.406Y-91.944 -X169.456Y-91.944 -X171.996Y-114.169 -X155.486Y-97.024 -X169.456Y-97.024 -T6 -X161.836Y-89.404 -X161.836Y-91.944 -X161.836Y-94.484 -X164.376Y-89.404 -X164.376Y-91.944 -X164.376Y-94.484 -T7 -X174.536Y-91.944 -X174.536Y-94.484 -X174.536Y-97.024 -X174.536Y-99.564 -X171.996Y-117.344 -X171.996Y-119.884 -X171.996Y-122.424 -X171.996Y-124.964 -X174.536Y-117.344 -X174.536Y-119.884 -X174.536Y-122.424 -X174.536Y-124.964 -T8 -X125.006Y-97.024 -X125.006Y-99.564 -X125.006Y-102.104 -X125.006Y-104.644 -X125.006Y-107.184 -X125.006Y-109.724 -X125.006Y-112.264 -X125.006Y-114.804 -X125.006Y-117.344 -X171.615Y-105.914 -X171.615Y-108.454 -X171.615Y-110.994 -X130.086Y-124.964 -X132.626Y-124.964 -X135.166Y-124.964 -X137.706Y-124.964 -X140.246Y-124.964 -X142.786Y-124.964 -X145.326Y-124.964 -X147.866Y-124.964 -X150.406Y-124.964 -X152.946Y-124.964 -X155.486Y-124.964 -X158.026Y-124.964 -X130.086Y-86.864 -X132.626Y-86.864 -X135.166Y-86.864 -X137.706Y-86.864 -X140.246Y-86.864 -X142.786Y-86.864 -X145.326Y-86.864 -X147.866Y-86.864 -X150.406Y-86.864 -T9 -X163.146Y-122.424 -X168.146Y-122.424 -T10 -X125.006Y-86.33 -X125.006Y-123.694 -X171.971Y-86.33 -T0 -M30 diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Top.gbr b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Top.gbr deleted file mode 100644 index e7b553d..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-a_factory_gerbers/M644_breakout_v1.2d-Top.gbr +++ /dev/null @@ -1,3732 +0,0 @@ -G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* -G04 #@! TF.CreationDate,2019-04-02T23:20:26+04:00* -G04 #@! TF.ProjectId,M644_breakout_v1.2d,4d363434-5f62-4726-9561-6b6f75745f76,v1.2d* -G04 #@! TF.SameCoordinates,Original* -G04 #@! TF.FileFunction,Copper,L1,Top* -G04 #@! TF.FilePolarity,Positive* -%FSLAX46Y46*% -G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* -G04 Created by KiCad (PCBNEW (5.0.2)-1) date 02/04/2019 23:20:26* -%MOMM*% -%LPD*% -G01* -G04 APERTURE LIST* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD10R,1.500000X1.500000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD11R,1.700000X1.000000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD12O,3.048000X1.524000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD13C,1.676400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD14C,1.778000*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD15R,1.422400X0.711200*% -G04 #@! TD* -G04 #@! TA.AperFunction,SMDPad,CuDef* -%ADD16R,0.711200X1.422400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD17O,2.844800X1.422400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD18O,1.790700X3.581400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD19C,1.800000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD20R,1.700000X1.700000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ComponentPad* -%ADD21O,1.700000X1.700000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD22C,7.620000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD23C,1.930400*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD24C,0.800000*% -G04 #@! TD* -G04 #@! TA.AperFunction,ViaPad* -%ADD25C,1.270000*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD26C,0.406400*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD27C,0.812800*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD28C,1.016000*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD29C,0.609600*% -G04 #@! TD* -G04 #@! TA.AperFunction,Conductor* -%ADD30C,0.254000*% -G04 #@! TD* -G04 APERTURE END LIST* -D10* -G04 #@! TO.P,LED1_SMD1,A* -G04 #@! TO.N,Net-(LED1-PadA)* -X130492500Y-113200800D03* -G04 #@! TO.P,LED1_SMD1,C* -G04 #@! TO.N,GND* -X130492500Y-109700800D03* -G04 #@! TD* -D11* -G04 #@! TO.P,SW1/PC5,4* -G04 #@! TO.N,GND* -X129476100Y-90043600D03* -G04 #@! TO.P,SW1/PC5,3* -X135776100Y-90043600D03* -G04 #@! TO.P,SW1/PC5,2* -G04 #@! TO.N,Net-(R3-PadP$1)* -X129476100Y-93843600D03* -G04 #@! TO.P,SW1/PC5,1* -X135776100Y-93843600D03* -G04 #@! TD* -D12* -G04 #@! TO.P,IC2,3* -G04 #@! TO.N,VCC* -X171615100Y-105913600D03* -G04 #@! TO.P,IC2,2* -G04 #@! TO.N,GND* -X171615100Y-108453600D03* -G04 #@! TO.P,IC2,1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X171615100Y-110993600D03* -G04 #@! TD* -D13* -G04 #@! TO.P,SV1,6* -G04 #@! TO.N,GND* -X164376100Y-94483600D03* -G04 #@! TO.P,SV1,5* -G04 #@! TO.N,/RESET* -X161836100Y-94483600D03* -G04 #@! TO.P,SV1,4* -G04 #@! TO.N,/MOSI* -X164376100Y-91943600D03* -G04 #@! TO.P,SV1,3* -G04 #@! TO.N,/SCK* -X161836100Y-91943600D03* -G04 #@! TO.P,SV1,2* -G04 #@! TO.N,VCC* -X164376100Y-89403600D03* -G04 #@! TO.P,SV1,1* -G04 #@! TO.N,/MISO* -X161836100Y-89403600D03* -G04 #@! TD* -D14* -G04 #@! TO.P,JP3,12* -G04 #@! TO.N,/PC3* -X130086100Y-124963600D03* -G04 #@! TO.P,JP3,11* -G04 #@! TO.N,/PC2* -X132626100Y-124963600D03* -G04 #@! TO.P,JP3,10* -G04 #@! TO.N,/PC1* -X135166100Y-124963600D03* -G04 #@! TO.P,JP3,9* -G04 #@! TO.N,/PC0* -X137706100Y-124963600D03* -G04 #@! TO.P,JP3,8* -G04 #@! TO.N,/PD7* -X140246100Y-124963600D03* -G04 #@! TO.P,JP3,7* -G04 #@! TO.N,/PD6* -X142786100Y-124963600D03* -G04 #@! TO.P,JP3,6* -G04 #@! TO.N,/PD5* -X145326100Y-124963600D03* -G04 #@! TO.P,JP3,5* -G04 #@! TO.N,/PD4* -X147866100Y-124963600D03* -G04 #@! TO.P,JP3,4* -G04 #@! TO.N,/PD3'* -X150406100Y-124963600D03* -G04 #@! TO.P,JP3,3* -G04 #@! TO.N,/PD2* -X152946100Y-124963600D03* -G04 #@! TO.P,JP3,2* -G04 #@! TO.N,/PD1'* -X155486100Y-124963600D03* -G04 #@! TO.P,JP3,1* -G04 #@! TO.N,/PD0* -X158026100Y-124963600D03* -G04 #@! TD* -D15* -G04 #@! TO.P,R3,P$2* -G04 #@! TO.N,/PC5* -X128181100Y-100071600D03* -G04 #@! TO.P,R3,P$1* -G04 #@! TO.N,Net-(R3-PadP$1)* -X128181100Y-97785600D03* -G04 #@! TD* -G04 #@! TO.P,R4,P$2* -G04 #@! TO.N,VCC* -X157391100Y-117470600D03* -G04 #@! TO.P,R4,P$1* -G04 #@! TO.N,/PD0* -X157391100Y-119756600D03* -G04 #@! TD* -G04 #@! TO.P,R5,P$2* -G04 #@! TO.N,VCC* -X151676100Y-117470600D03* -G04 #@! TO.P,R5,P$1* -G04 #@! TO.N,/PD2* -X151676100Y-119756600D03* -G04 #@! TD* -D16* -G04 #@! TO.P,R6,P$2* -G04 #@! TO.N,/PC5* -X130213100Y-98293600D03* -G04 #@! TO.P,R6,P$1* -G04 #@! TO.N,VCC* -X132499100Y-98293600D03* -G04 #@! TD* -D17* -G04 #@! TO.P,Q1,2* -G04 #@! TO.N,Net-(C1-PadP$1)* -X156756100Y-105913600D03* -G04 #@! TO.P,Q1,1* -G04 #@! TO.N,Net-(C2-PadP$1)* -X156756100Y-110993600D03* -G04 #@! TD* -D13* -G04 #@! TO.P,LED1,K* -G04 #@! TO.N,GND* -X128816100Y-109723600D03* -G04 #@! TO.P,LED1,A* -G04 #@! TO.N,Net-(LED1-PadA)* -X128816100Y-112263600D03* -G04 #@! TD* -D14* -G04 #@! TO.P,JP1,9* -G04 #@! TO.N,/PA3* -X130086100Y-86863600D03* -G04 #@! TO.P,JP1,8* -G04 #@! TO.N,/PA2* -X132626100Y-86863600D03* -G04 #@! TO.P,JP1,7* -G04 #@! TO.N,/PA1* -X135166100Y-86863600D03* -G04 #@! TO.P,JP1,6* -G04 #@! TO.N,/PA0* -X137706100Y-86863600D03* -G04 #@! TO.P,JP1,5* -G04 #@! TO.N,/PB0* -X140246100Y-86863600D03* -G04 #@! TO.P,JP1,4* -G04 #@! TO.N,/PB1* -X142786100Y-86863600D03* -G04 #@! TO.P,JP1,3* -G04 #@! TO.N,/PB2* -X145326100Y-86863600D03* -G04 #@! TO.P,JP1,2* -G04 #@! TO.N,/PB3* -X147866100Y-86863600D03* -G04 #@! TO.P,JP1,1* -G04 #@! TO.N,/PB4* -X150406100Y-86863600D03* -G04 #@! TD* -G04 #@! TO.P,JP2,9* -G04 #@! TO.N,/PC6* -X125006100Y-117343600D03* -G04 #@! TO.P,JP2,8* -G04 #@! TO.N,/PC7* -X125006100Y-114803600D03* -G04 #@! TO.P,JP2,7* -G04 #@! TO.N,/PA7* -X125006100Y-112263600D03* -G04 #@! TO.P,JP2,6* -G04 #@! TO.N,GND* -X125006100Y-109723600D03* -G04 #@! TO.P,JP2,5* -G04 #@! TO.N,/AREF* -X125006100Y-107183600D03* -G04 #@! TO.P,JP2,4* -G04 #@! TO.N,VCC* -X125006100Y-104643600D03* -G04 #@! TO.P,JP2,3* -G04 #@! TO.N,/PA5* -X125006100Y-102103600D03* -G04 #@! TO.P,JP2,2* -G04 #@! TO.N,/PA4* -X125006100Y-99563600D03* -G04 #@! TO.P,JP2,1* -G04 #@! TO.N,/PA6* -X125006100Y-97023600D03* -G04 #@! TD* -D18* -G04 #@! TO.P,X2,2* -G04 #@! TO.N,Net-(D1-PadA)* -X163146100Y-122423600D03* -G04 #@! TO.P,X2,1* -G04 #@! TO.N,GND* -X168146100Y-122423600D03* -G04 #@! TD* -D19* -G04 #@! TO.P,JP4,1* -G04 #@! TO.N,/SCK* -X150406100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP5,1* -G04 #@! TO.N,/SCK* -X152946100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP6,1* -G04 #@! TO.N,/MISO* -X152946100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP7,1* -G04 #@! TO.N,/MISO* -X150406100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP8,1* -G04 #@! TO.N,/MOSI* -X150406100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP9,1* -G04 #@! TO.N,/MOSI* -X152946100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP11,1* -G04 #@! TO.N,/SCK* -X155486100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP12,1* -G04 #@! TO.N,/MISO* -X155486100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP13,1* -G04 #@! TO.N,/MOSI* -X155486100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP14,1* -G04 #@! TO.N,VCC* -X171996100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP15,1* -G04 #@! TO.N,VCC* -X171996100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP16,1* -G04 #@! TO.N,VCC* -X171996100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP17,1* -G04 #@! TO.N,VCC* -X171996100Y-99563600D03* -G04 #@! TD* -G04 #@! TO.P,JP19,1* -G04 #@! TO.N,GND* -X169456100Y-91943600D03* -G04 #@! TD* -G04 #@! TO.P,JP20,1* -G04 #@! TO.N,GND* -X169456100Y-94483600D03* -G04 #@! TD* -G04 #@! TO.P,JP21,1* -G04 #@! TO.N,GND* -X169456100Y-97023600D03* -G04 #@! TD* -G04 #@! TO.P,JP22,1* -G04 #@! TO.N,GND* -X169456100Y-99563600D03* -G04 #@! TD* -G04 #@! TO.P,JP24,1* -G04 #@! TO.N,/PD2* -X152946100Y-122423600D03* -G04 #@! TD* -G04 #@! TO.P,JP25,1* -G04 #@! TO.N,/PD3'* -X150406100Y-122423600D03* -G04 #@! TD* -G04 #@! TO.P,JP26,1* -G04 #@! TO.N,/PD4* -X147866100Y-122423600D03* -G04 #@! TD* -G04 #@! TO.P,JP27,1* -G04 #@! TO.N,/PC5* -X127546100Y-107183600D03* -G04 #@! TD* -G04 #@! TO.P,JP28,1* -G04 #@! TO.N,/PC4* -X127546100Y-117343600D03* -G04 #@! TD* -G04 #@! TO.P,JP10,1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X171996100Y-114168600D03* -G04 #@! TD* -G04 #@! TO.P,JP29,1* -G04 #@! TO.N,Net-(C4-PadP$1)* -X174536100Y-114168600D03* -G04 #@! TD* -D20* -G04 #@! TO.P,REF\002A\002A,1* -G04 #@! TO.N,GND* -X171996100Y-117343600D03* -D21* -G04 #@! TO.P,REF\002A\002A,2* -X174536100Y-117343600D03* -G04 #@! TO.P,REF\002A\002A,3* -X171996100Y-119883600D03* -G04 #@! TO.P,REF\002A\002A,4* -X174536100Y-119883600D03* -G04 #@! TO.P,REF\002A\002A,5* -X171996100Y-122423600D03* -G04 #@! TO.P,REF\002A\002A,6* -X174536100Y-122423600D03* -G04 #@! TO.P,REF\002A\002A,7* -X171996100Y-124963600D03* -G04 #@! TO.P,REF\002A\002A,8* -X174536100Y-124963600D03* -G04 #@! TD* -D20* -G04 #@! TO.P,REF\002A\002A,1* -G04 #@! TO.N,VCC* -X174536100Y-91943600D03* -D21* -G04 #@! TO.P,REF\002A\002A,2* -X174536100Y-94483600D03* -G04 #@! TO.P,REF\002A\002A,3* -X174536100Y-97023600D03* -G04 #@! TO.P,REF\002A\002A,4* -X174536100Y-99563600D03* -G04 #@! TD* -D22* -G04 #@! TO.N,* -X125006100Y-86330200D03* -X125006100Y-123693600D03* -X171970700Y-86330200D03* -D23* -G04 #@! TO.N,GND* -X174536100Y-119883600D03* -X174536100Y-122423600D03* -X174536100Y-124963600D03* -X174536100Y-117343600D03* -X162153600Y-108453600D03* -X162153600Y-100833600D03* -X171996100Y-124963600D03* -X171996100Y-122423600D03* -X171996100Y-119883600D03* -X171996100Y-117343600D03* -D24* -X170091100Y-124963600D03* -X170091100Y-123058600D03* -X165646100Y-122423600D03* -X165646100Y-119883600D03* -X165646100Y-116073600D03* -X162471100Y-116073600D03* -X159296100Y-116073600D03* -X164376100Y-113533600D03* -X161836100Y-113533600D03* -X168186100Y-108453600D03* -X170726100Y-102103600D03* -X174536100Y-107183600D03* -X157899100Y-108453600D03* -X164884100Y-104770600D03* -X156756100Y-104008600D03* -X163753800Y-96261600D03* -X162090100Y-99182600D03* -X165646100Y-85593600D03* -X161836100Y-84323600D03* -X154216100Y-84323600D03* -X146596100Y-84323600D03* -X138976100Y-84323600D03* -X132626100Y-84323600D03* -X145326100Y-108453600D03* -X142659100Y-108453600D03* -X142659100Y-105913600D03* -X142659100Y-103373600D03* -X145326100Y-103373600D03* -X145326100Y-105913600D03* -X127546100Y-91459194D03* -X125006100Y-93213600D03* -X122466100Y-95753600D03* -X122466100Y-99563600D03* -X122466100Y-103373600D03* -X122466100Y-107183600D03* -X122466100Y-112263600D03* -X122466100Y-117343600D03* -X129578100Y-121407600D03* -X148501100Y-112263600D03* -X149009100Y-115311600D03* -X131991100Y-95372600D03* -X154089100Y-104262600D03* -X154978100Y-107818600D03* -X137198100Y-99055600D03* -X156883100Y-88768600D03* -D23* -G04 #@! TO.N,VCC* -X142786100Y-93213600D03* -X141516100Y-119248600D03* -X128816100Y-104643600D03* -X166916100Y-100833600D03* -X166916100Y-98293600D03* -X166916100Y-95753600D03* -X174536100Y-94483600D03* -X174536100Y-97023600D03* -X174536100Y-99563600D03* -X174536100Y-91943600D03* -D25* -G04 #@! TO.N,/PA7* -X139433300Y-104338800D03* -G04 #@! TO.N,/AREF* -X133896100Y-102484600D03* -G04 #@! TO.N,/PC7* -X139484100Y-107056600D03* -G04 #@! TO.N,/PC6* -X140627100Y-108275800D03* -G04 #@! TO.N,/MISO* -X151930100Y-100579600D03* -G04 #@! TO.N,/MOSI* -X150533100Y-99690600D03* -G04 #@! TD* -D26* -G04 #@! TO.N,GND* -X162153600Y-108453600D02* -X162153600Y-100833600D01* -X122466100Y-108453600D02* -X122466100Y-103373600D01* -X122466100Y-92073600D02* -X123104000Y-91438600D01* -X122466100Y-108453600D02* -X125006100Y-109723600D01* -D27* -X171615100Y-108453600D02* -X170726100Y-108453600D01* -D28* -X170726100Y-108453600D02* -X168821100Y-107183600D01* -X168821100Y-107183600D02* -X168821100Y-104008600D01* -X168821100Y-104008600D02* -X169456100Y-103373600D01* -X169456100Y-103373600D02* -X169456100Y-99563600D01* -X169456100Y-99563600D02* -X169456100Y-97023600D01* -X169456100Y-97023600D02* -X169456100Y-94483600D01* -X169456100Y-94483600D02* -X169456100Y-91943600D01* -D29* -X128816100Y-109726200D02* -X130492500Y-109700800D01* -X128816100Y-109723600D02* -X128816100Y-109726200D01* -D26* -X135776100Y-90043600D02* -X129476100Y-90043600D01* -X127710506Y-91459194D02* -X127546100Y-91459194D01* -X129126100Y-90043600D02* -X127710506Y-91459194D01* -X129476100Y-90043600D02* -X129126100Y-90043600D01* -X123104000Y-91438600D02* -X127546100Y-91459194D01* -X127546100Y-91459194D02* -X127546100Y-91459194D01* -X122466100Y-95753600D02* -X122466100Y-92073600D01* -X122466100Y-98293600D02* -X122466100Y-95753600D01* -X122466100Y-103373600D02* -X122466100Y-98293600D01* -D29* -G04 #@! TO.N,VCC* -X166916100Y-95753600D02* -X166916100Y-91943600D01* -X165646100Y-87498600D02* -X165730400Y-87498600D01* -X128816100Y-104643600D02* -X134531100Y-97658600D01* -X166916100Y-100833600D02* -X166916100Y-102103600D01* -X166916100Y-102103600D02* -X166916100Y-102738600D01* -X166916100Y-102738600D02* -X166916100Y-107183600D01* -X166916100Y-107183600D02* -X164376100Y-110358600D01* -X164376100Y-110358600D02* -X162471100Y-110358600D01* -X162471100Y-110358600D02* -X157391100Y-113533600D01* -X157391100Y-113533600D02* -X151676100Y-113533600D01* -X151676100Y-113533600D02* -X145961100Y-113533600D01* -X145961100Y-113533600D02* -X141516100Y-119248600D01* -D26* -X151676100Y-113533600D02* -X151676100Y-117470600D01* -X157391100Y-113533600D02* -X157391100Y-117470600D01* -X134531100Y-97658600D02* -X133896100Y-98293600D01* -X133896100Y-98293600D02* -X132499100Y-98293600D01* -D29* -X166916100Y-91943600D02* -X166916100Y-88768600D01* -X166916100Y-88768600D02* -X165646100Y-87498600D01* -X142786100Y-90038600D02* -X142786100Y-93213600D01* -X143548100Y-89149600D02* -X142786100Y-90038600D01* -X150914100Y-89149600D02* -X143548100Y-89149600D01* -X165646100Y-87498600D02* -X153581100Y-87498600D01* -X153581100Y-87498600D02* -X150914100Y-89149600D01* -X165646100Y-98293600D02* -X166916100Y-98293600D01* -X165011100Y-97658600D02* -X165646100Y-98293600D01* -X159296100Y-97658600D02* -X165011100Y-97658600D01* -X158534100Y-96896600D02* -X159296100Y-97658600D01* -X158534100Y-92959600D02* -X158534100Y-96896600D01* -X156502100Y-90165600D02* -X158534100Y-92959600D01* -X134531100Y-97658600D02* -X141516100Y-97658600D01* -X141516100Y-97531600D02* -X148882100Y-90165600D01* -X141516100Y-97658600D02* -X141516100Y-97531600D01* -X148882100Y-90165600D02* -X156502100Y-90165600D01* -X164376100Y-110358600D02* -X164376100Y-110358600D01* -D26* -G04 #@! TO.N,/PA7* -X125006100Y-112263600D02* -X127571500Y-114575000D01* -X127571500Y-114575000D02* -X131381500Y-114575000D01* -X131381500Y-114575000D02* -X139433300Y-104338800D01* -G04 #@! TO.N,/AREF* -X125006100Y-107183600D02* -X127038100Y-108453600D01* -X127038100Y-108453600D02* -X130721100Y-108453600D01* -X130721100Y-108453600D02* -X133896100Y-102484600D01* -G04 #@! TO.N,/PC7* -X132575300Y-114625800D02* -X139484100Y-107056600D01* -X126250700Y-115895800D02* -X125006100Y-114803600D01* -X126250700Y-115895800D02* -X131330700Y-115895800D01* -X131330700Y-115895800D02* -X132575300Y-114625800D01* -G04 #@! TO.N,/PC6* -X131071875Y-119121600D02* -X140627100Y-108275800D01* -X125006100Y-117343600D02* -X128054100Y-119121600D01* -X128054100Y-119121600D02* -X131071875Y-119121600D01* -G04 #@! TO.N,/PC5* -X128181100Y-100833600D02* -X128181100Y-100071600D01* -X128181100Y-100833600D02* -X129895600Y-100833600D01* -X129895600Y-100833600D02* -X130213100Y-100516100D01* -X130213100Y-100516100D02* -X130213100Y-98293600D01* -X127292100Y-105659600D02* -X127546100Y-107183600D01* -X128181100Y-100833600D02* -X127292100Y-101722600D01* -X127292100Y-101722600D02* -X127292100Y-105659600D01* -G04 #@! TO.N,/PD2* -X152946100Y-124963600D02* -X152946100Y-123058600D01* -X152946100Y-122423600D02* -X152946100Y-123058600D01* -X152946100Y-122423600D02* -X151676100Y-121153600D01* -X151676100Y-121153600D02* -X151676100Y-119756600D01* -G04 #@! TO.N,/PD0* -X158026100Y-124963600D02* -X157391100Y-122423600D01* -X157391100Y-122423600D02* -X157391100Y-119756600D01* -G04 #@! TO.N,/MISO* -X153846099Y-95383599D02* -X152946100Y-94483600D01* -X154230499Y-95767999D02* -X153846099Y-95383599D01* -X154230499Y-95739201D02* -X154230499Y-95767999D01* -X155486100Y-94483600D02* -X154230499Y-95739201D01* -X154230499Y-98279201D02* -X151930100Y-100579600D01* -X154230499Y-95767999D02* -X154230499Y-98279201D01* -G04 #@! TO.N,/MOSI* -X152046101Y-92843599D02* -X152946100Y-91943600D01* -X151661701Y-93227999D02* -X152046101Y-92843599D01* -X151661701Y-98561999D02* -X151661701Y-93227999D01* -X150533100Y-99690600D02* -X151661701Y-98561999D01* -X151306099Y-92872397D02* -X151661701Y-93227999D01* -X151306099Y-92843599D02* -X151306099Y-92872397D01* -X150406100Y-91943600D02* -X151306099Y-92843599D01* -D29* -G04 #@! TO.N,Net-(LED1-PadA)* -X130286700Y-113099200D02* -X130492500Y-113200800D01* -X129451100Y-112263600D02* -X130286700Y-113099200D01* -X128816100Y-112263600D02* -X129451100Y-112263600D01* -D26* -G04 #@! TO.N,Net-(R3-PadP$1)* -X128181100Y-97785600D02* -X128181100Y-97043600D01* -X128181100Y-97043600D02* -X129476100Y-95113600D01* -X129476100Y-95113600D02* -X129476100Y-93843600D01* -X129476100Y-93843600D02* -X135776100Y-93843600D01* -G04 #@! TD* -D30* -G04 #@! TO.N,GND* -G36* -X168202411Y-83812310D02* -X167525700Y-85446034D01* -X167525700Y-87214366D01* -X168202411Y-88848090D01* -X169452810Y-90098489D01* -X171020878Y-90748005D01* -X170694790Y-91074093D01* -X170686662Y-91093715D01* -X170536259Y-91043046D01* -X169635705Y-91943600D01* -X170536259Y-92844154D01* -X170686662Y-92793485D01* -X170694790Y-92813107D01* -X171095283Y-93213600D01* -X170694790Y-93614093D01* -X170686662Y-93633715D01* -X170536259Y-93583046D01* -X169635705Y-94483600D01* -X170536259Y-95384154D01* -X170686662Y-95333485D01* -X170694790Y-95353107D01* -X171095283Y-95753600D01* -X170694790Y-96154093D01* -X170686662Y-96173715D01* -X170536259Y-96123046D01* -X169635705Y-97023600D01* -X170536259Y-97924154D01* -X170686662Y-97873485D01* -X170694790Y-97893107D01* -X171095283Y-98293600D01* -X170694790Y-98694093D01* -X170686662Y-98713715D01* -X170536259Y-98663046D01* -X169635705Y-99563600D01* -X170536259Y-100464154D01* -X170686662Y-100413485D01* -X170694790Y-100433107D01* -X171126593Y-100864910D01* -X171690770Y-101098600D01* -X172301430Y-101098600D01* -X172865607Y-100864910D01* -X173219996Y-100510521D01* -X173629659Y-100920184D01* -X174217800Y-101163800D01* -X174854400Y-101163800D01* -X175044100Y-101085224D01* -X175044100Y-112717549D01* -X174841430Y-112633600D01* -X174230770Y-112633600D01* -X173666593Y-112867290D01* -X173266100Y-113267783D01* -X172865607Y-112867290D01* -X172301430Y-112633600D01* -X171690770Y-112633600D01* -X171126593Y-112867290D01* -X170694790Y-113299093D01* -X170461100Y-113863270D01* -X170461100Y-114473930D01* -X170694790Y-115038107D01* -X171126593Y-115469910D01* -X171690770Y-115703600D01* -X172301430Y-115703600D01* -X172865607Y-115469910D01* -X173266100Y-115069417D01* -X173666593Y-115469910D01* -X174230770Y-115703600D01* -X174841430Y-115703600D01* -X175044100Y-115619651D01* -X175044100Y-115973078D01* -X174892992Y-115902114D01* -X174663100Y-116022781D01* -X174663100Y-117216600D01* -X174683100Y-117216600D01* -X174683100Y-117470600D01* -X174663100Y-117470600D01* -X174663100Y-119756600D01* -X174683100Y-119756600D01* -X174683100Y-120010600D01* -X174663100Y-120010600D01* -X174663100Y-122296600D01* -X174683100Y-122296600D01* -X174683100Y-122550600D01* -X174663100Y-122550600D01* -X174663100Y-124836600D01* -X174683100Y-124836600D01* -X174683100Y-125090600D01* -X174663100Y-125090600D01* -X174663100Y-126284419D01* -X174892992Y-126405086D01* -X175044100Y-126334122D01* -X175044100Y-126741600D01* -X128244279Y-126741600D01* -X128774389Y-126211490D01* -X128892817Y-125925579D01* -X129222823Y-126255585D01* -X129782958Y-126487600D01* -X130389242Y-126487600D01* -X130949377Y-126255585D01* -X131356100Y-125848862D01* -X131762823Y-126255585D01* -X132322958Y-126487600D01* -X132929242Y-126487600D01* -X133489377Y-126255585D01* -X133896100Y-125848862D01* -X134302823Y-126255585D01* -X134862958Y-126487600D01* -X135469242Y-126487600D01* -X136029377Y-126255585D01* -X136436100Y-125848862D01* -X136842823Y-126255585D01* -X137402958Y-126487600D01* -X138009242Y-126487600D01* -X138569377Y-126255585D01* -X138976100Y-125848862D01* -X139382823Y-126255585D01* -X139942958Y-126487600D01* -X140549242Y-126487600D01* -X141109377Y-126255585D01* -X141516100Y-125848862D01* -X141922823Y-126255585D01* -X142482958Y-126487600D01* -X143089242Y-126487600D01* -X143649377Y-126255585D01* -X144056100Y-125848862D01* -X144462823Y-126255585D01* -X145022958Y-126487600D01* -X145629242Y-126487600D01* -X146189377Y-126255585D01* -X146596100Y-125848862D01* -X147002823Y-126255585D01* -X147562958Y-126487600D01* -X148169242Y-126487600D01* -X148729377Y-126255585D01* -X149136100Y-125848862D01* -X149542823Y-126255585D01* -X150102958Y-126487600D01* -X150709242Y-126487600D01* -X151269377Y-126255585D01* -X151676100Y-125848862D01* -X152082823Y-126255585D01* -X152642958Y-126487600D01* -X153249242Y-126487600D01* -X153809377Y-126255585D01* -X154216100Y-125848862D01* -X154622823Y-126255585D01* -X155182958Y-126487600D01* -X155789242Y-126487600D01* -X156349377Y-126255585D01* -X156756100Y-125848862D01* -X157162823Y-126255585D01* -X157722958Y-126487600D01* -X158329242Y-126487600D01* -X158889377Y-126255585D01* -X159318085Y-125826877D01* -X159527836Y-125320490D01* -X170554624Y-125320490D01* -X170724455Y-125730524D01* -X171114742Y-126158783D01* -X171639208Y-126405086D01* -X171869100Y-126284419D01* -X171869100Y-125090600D01* -X172123100Y-125090600D01* -X172123100Y-126284419D01* -X172352992Y-126405086D01* -X172877458Y-126158783D01* -X173266100Y-125732329D01* -X173654742Y-126158783D01* -X174179208Y-126405086D01* -X174409100Y-126284419D01* -X174409100Y-125090600D01* -X172123100Y-125090600D01* -X171869100Y-125090600D01* -X170675945Y-125090600D01* -X170554624Y-125320490D01* -X159527836Y-125320490D01* -X159550100Y-125266742D01* -X159550100Y-124660458D01* -X159318085Y-124100323D01* -X158889377Y-123671615D01* -X158529872Y-123522704D01* -X158516615Y-123469674D01* -X161615750Y-123469674D01* -X161704542Y-123916062D01* -X162042779Y-124422271D01* -X162548987Y-124760508D01* -X163146100Y-124879281D01* -X163743212Y-124760508D01* -X164249421Y-124422271D01* -X164587658Y-123916063D01* -X164676450Y-123469675D01* -X164676450Y-122550600D01* -X166615750Y-122550600D01* -X166615750Y-123445950D01* -X166780842Y-124021922D01* -X167153782Y-124490873D01* -X167677793Y-124781409D01* -X167782090Y-124805378D01* -X168019100Y-124684658D01* -X168019100Y-122550600D01* -X168273100Y-122550600D01* -X168273100Y-124684658D01* -X168510110Y-124805378D01* -X168614407Y-124781409D01* -X169138418Y-124490873D01* -X169511358Y-124021922D01* -X169676450Y-123445950D01* -X169676450Y-122780490D01* -X170554624Y-122780490D01* -X170724455Y-123190524D01* -X171114742Y-123618783D01* -X171274054Y-123693600D01* -X171114742Y-123768417D01* -X170724455Y-124196676D01* -X170554624Y-124606710D01* -X170675945Y-124836600D01* -X171869100Y-124836600D01* -X171869100Y-122550600D01* -X172123100Y-122550600D01* -X172123100Y-124836600D01* -X174409100Y-124836600D01* -X174409100Y-122550600D01* -X172123100Y-122550600D01* -X171869100Y-122550600D01* -X170675945Y-122550600D01* -X170554624Y-122780490D01* -X169676450Y-122780490D01* -X169676450Y-122550600D01* -X168273100Y-122550600D01* -X168019100Y-122550600D01* -X166615750Y-122550600D01* -X164676450Y-122550600D01* -X164676450Y-121401250D01* -X166615750Y-121401250D01* -X166615750Y-122296600D01* -X168019100Y-122296600D01* -X168019100Y-120162542D01* -X168273100Y-120162542D01* -X168273100Y-122296600D01* -X169676450Y-122296600D01* -X169676450Y-121401250D01* -X169511358Y-120825278D01* -X169138418Y-120356327D01* -X168929495Y-120240490D01* -X170554624Y-120240490D01* -X170724455Y-120650524D01* -X171114742Y-121078783D01* -X171274054Y-121153600D01* -X171114742Y-121228417D01* -X170724455Y-121656676D01* -X170554624Y-122066710D01* -X170675945Y-122296600D01* -X171869100Y-122296600D01* -X171869100Y-120010600D01* -X172123100Y-120010600D01* -X172123100Y-122296600D01* -X174409100Y-122296600D01* -X174409100Y-120010600D01* -X172123100Y-120010600D01* -X171869100Y-120010600D01* -X170675945Y-120010600D01* -X170554624Y-120240490D01* -X168929495Y-120240490D01* -X168614407Y-120065791D01* -X168510110Y-120041822D01* -X168273100Y-120162542D01* -X168019100Y-120162542D01* -X167782090Y-120041822D01* -X167677793Y-120065791D01* -X167153782Y-120356327D01* -X166780842Y-120825278D01* -X166615750Y-121401250D01* -X164676450Y-121401250D01* -X164676450Y-121377525D01* -X164587658Y-120931137D01* -X164249421Y-120424929D01* -X163743213Y-120086692D01* -X163146100Y-119967919D01* -X162548988Y-120086692D01* -X162042780Y-120424929D01* -X161704543Y-120931137D01* -X161615751Y-121377525D01* -X161615750Y-123469674D01* -X158516615Y-123469674D01* -X158229300Y-122320414D01* -X158229300Y-120734378D01* -X158350065Y-120710357D01* -X158560109Y-120570009D01* -X158700457Y-120359965D01* -X158749740Y-120112200D01* -X158749740Y-119401000D01* -X158700457Y-119153235D01* -X158560109Y-118943191D01* -X158350065Y-118802843D01* -X158102300Y-118753560D01* -X156679900Y-118753560D01* -X156432135Y-118802843D01* -X156222091Y-118943191D01* -X156081743Y-119153235D01* -X156032460Y-119401000D01* -X156032460Y-120112200D01* -X156081743Y-120359965D01* -X156222091Y-120570009D01* -X156432135Y-120710357D01* -X156552901Y-120734379D01* -X156552900Y-122277963D01* -X156545787Y-122297814D01* -X156552900Y-122443966D01* -X156552900Y-122506153D01* -X156556907Y-122526297D01* -X156557905Y-122546804D01* -X156572982Y-122607111D01* -X156601533Y-122750648D01* -X156613250Y-122768184D01* -X156903851Y-123930587D01* -X156756100Y-124078338D01* -X156349377Y-123671615D01* -X155789242Y-123439600D01* -X155182958Y-123439600D01* -X154622823Y-123671615D01* -X154216100Y-124078338D01* -X153839140Y-123701378D01* -X154247410Y-123293107D01* -X154481100Y-122728930D01* -X154481100Y-122118270D01* -X154247410Y-121554093D01* -X153815607Y-121122290D01* -X153251430Y-120888600D01* -X152640770Y-120888600D01* -X152609462Y-120901568D01* -X152514300Y-120806407D01* -X152514300Y-120734378D01* -X152635065Y-120710357D01* -X152845109Y-120570009D01* -X152985457Y-120359965D01* -X153034740Y-120112200D01* -X153034740Y-119401000D01* -X152985457Y-119153235D01* -X152845109Y-118943191D01* -X152635065Y-118802843D01* -X152387300Y-118753560D01* -X150964900Y-118753560D01* -X150717135Y-118802843D01* -X150507091Y-118943191D01* -X150366743Y-119153235D01* -X150317460Y-119401000D01* -X150317460Y-120112200D01* -X150366743Y-120359965D01* -X150507091Y-120570009D01* -X150717135Y-120710357D01* -X150837900Y-120734378D01* -X150837900Y-120940986D01* -X150711430Y-120888600D01* -X150100770Y-120888600D01* -X149536593Y-121122290D01* -X149136100Y-121522783D01* -X148735607Y-121122290D01* -X148171430Y-120888600D01* -X147560770Y-120888600D01* -X146996593Y-121122290D01* -X146564790Y-121554093D01* -X146331100Y-122118270D01* -X146331100Y-122728930D01* -X146564790Y-123293107D01* -X146973061Y-123701378D01* -X146596100Y-124078338D01* -X146189377Y-123671615D01* -X145629242Y-123439600D01* -X145022958Y-123439600D01* -X144462823Y-123671615D01* -X144056100Y-124078338D01* -X143649377Y-123671615D01* -X143089242Y-123439600D01* -X142482958Y-123439600D01* -X141922823Y-123671615D01* -X141516100Y-124078338D01* -X141109377Y-123671615D01* -X140549242Y-123439600D01* -X139942958Y-123439600D01* -X139382823Y-123671615D01* -X138976100Y-124078338D01* -X138569377Y-123671615D01* -X138009242Y-123439600D01* -X137402958Y-123439600D01* -X136842823Y-123671615D01* -X136436100Y-124078338D01* -X136029377Y-123671615D01* -X135469242Y-123439600D01* -X134862958Y-123439600D01* -X134302823Y-123671615D01* -X133896100Y-124078338D01* -X133489377Y-123671615D01* -X132929242Y-123439600D01* -X132322958Y-123439600D01* -X131762823Y-123671615D01* -X131356100Y-124078338D01* -X130949377Y-123671615D01* -X130389242Y-123439600D01* -X129782958Y-123439600D01* -X129451100Y-123577060D01* -X129451100Y-122809434D01* -X128774389Y-121175710D01* -X127523990Y-119925311D01* -X125890266Y-119248600D01* -X124121934Y-119248600D01* -X122488210Y-119925311D01* -X121958100Y-120455421D01* -X121958100Y-109485565D01* -X123470584Y-109485565D01* -X123496377Y-110091300D01* -X123678561Y-110531133D01* -X123933904Y-110616191D01* -X124826495Y-109723600D01* -X123933904Y-108831009D01* -X123678561Y-108916067D01* -X123470584Y-109485565D01* -X121958100Y-109485565D01* -X121958100Y-89568379D01* -X122488210Y-90098489D01* -X124121934Y-90775200D01* -X125890266Y-90775200D01* -X126966642Y-90329350D01* -X127991100Y-90329350D01* -X127991100Y-90669909D01* -X128087773Y-90903298D01* -X128266401Y-91081927D01* -X128499790Y-91178600D01* -X129190350Y-91178600D01* -X129349100Y-91019850D01* -X129349100Y-90170600D01* -X129603100Y-90170600D01* -X129603100Y-91019850D01* -X129761850Y-91178600D01* -X130452410Y-91178600D01* -X130685799Y-91081927D01* -X130864427Y-90903298D01* -X130961100Y-90669909D01* -X130961100Y-90329350D01* -X134291100Y-90329350D01* -X134291100Y-90669909D01* -X134387773Y-90903298D01* -X134566401Y-91081927D01* -X134799790Y-91178600D01* -X135490350Y-91178600D01* -X135649100Y-91019850D01* -X135649100Y-90170600D01* -X135903100Y-90170600D01* -X135903100Y-91019850D01* -X136061850Y-91178600D01* -X136752410Y-91178600D01* -X136985799Y-91081927D01* -X137164427Y-90903298D01* -X137261100Y-90669909D01* -X137261100Y-90329350D01* -X137102350Y-90170600D01* -X135903100Y-90170600D01* -X135649100Y-90170600D01* -X134449850Y-90170600D01* -X134291100Y-90329350D01* -X130961100Y-90329350D01* -X130802350Y-90170600D01* -X129603100Y-90170600D01* -X129349100Y-90170600D01* -X128149850Y-90170600D01* -X127991100Y-90329350D01* -X126966642Y-90329350D01* -X127523990Y-90098489D01* -X127991100Y-89631379D01* -X127991100Y-89757850D01* -X128149850Y-89916600D01* -X129349100Y-89916600D01* -X129349100Y-89067350D01* -X129603100Y-89067350D01* -X129603100Y-89916600D01* -X130802350Y-89916600D01* -X130961100Y-89757850D01* -X130961100Y-89417291D01* -X134291100Y-89417291D01* -X134291100Y-89757850D01* -X134449850Y-89916600D01* -X135649100Y-89916600D01* -X135649100Y-89067350D01* -X135903100Y-89067350D01* -X135903100Y-89916600D01* -X137102350Y-89916600D01* -X137261100Y-89757850D01* -X137261100Y-89417291D01* -X137164427Y-89183902D01* -X136985799Y-89005273D01* -X136752410Y-88908600D01* -X136061850Y-88908600D01* -X135903100Y-89067350D01* -X135649100Y-89067350D01* -X135490350Y-88908600D01* -X134799790Y-88908600D01* -X134566401Y-89005273D01* -X134387773Y-89183902D01* -X134291100Y-89417291D01* -X130961100Y-89417291D01* -X130864427Y-89183902D01* -X130685799Y-89005273D01* -X130452410Y-88908600D01* -X129761850Y-88908600D01* -X129603100Y-89067350D01* -X129349100Y-89067350D01* -X129190350Y-88908600D01* -X128713879Y-88908600D01* -X128774389Y-88848090D01* -X129108562Y-88041324D01* -X129222823Y-88155585D01* -X129782958Y-88387600D01* -X130389242Y-88387600D01* -X130949377Y-88155585D01* -X131356100Y-87748862D01* -X131762823Y-88155585D01* -X132322958Y-88387600D01* -X132929242Y-88387600D01* -X133489377Y-88155585D01* -X133896100Y-87748862D01* -X134302823Y-88155585D01* -X134862958Y-88387600D01* -X135469242Y-88387600D01* -X136029377Y-88155585D01* -X136436100Y-87748862D01* -X136842823Y-88155585D01* -X137402958Y-88387600D01* -X138009242Y-88387600D01* -X138569377Y-88155585D01* -X138976100Y-87748862D01* -X139382823Y-88155585D01* -X139942958Y-88387600D01* -X140549242Y-88387600D01* -X141109377Y-88155585D01* -X141516100Y-87748862D01* -X141922823Y-88155585D01* -X142482958Y-88387600D01* -X142996777Y-88387600D01* -X142995963Y-88388239D01* -X142870543Y-88472043D01* -X142797944Y-88580695D01* -X142156596Y-89328935D01* -X142108543Y-89361043D01* -X142035941Y-89469699D01* -X142012315Y-89497263D01* -X141984637Y-89546481D01* -X141900828Y-89671910D01* -X141893563Y-89708433D01* -X141875313Y-89740886D01* -X141857320Y-89890639D01* -X141846300Y-89946042D01* -X141846300Y-89982361D01* -X141830713Y-90112091D01* -X141846300Y-90167735D01* -X141846301Y-91890374D01* -X141429516Y-92307159D01* -X141185900Y-92895300D01* -X141185900Y-93531900D01* -X141429516Y-94120041D01* -X141879659Y-94570184D01* -X142467800Y-94813800D01* -X142904823Y-94813800D01* -X140999823Y-96718800D01* -X134576553Y-96718800D01* -X134435754Y-96705145D01* -X134301786Y-96746002D01* -X134164409Y-96773328D01* -X134124291Y-96800134D01* -X134078140Y-96814209D01* -X133969997Y-96903231D01* -X133853543Y-96981043D01* -X133774953Y-97098661D01* -X133483075Y-97455400D01* -X133476878Y-97455400D01* -X133452857Y-97334635D01* -X133312509Y-97124591D01* -X133102465Y-96984243D01* -X132854700Y-96934960D01* -X132143500Y-96934960D01* -X131895735Y-96984243D01* -X131685691Y-97124591D01* -X131545343Y-97334635D01* -X131496060Y-97582400D01* -X131496060Y-99004800D01* -X131545343Y-99252565D01* -X131685691Y-99462609D01* -X131785984Y-99529623D01* -X131051300Y-100427571D01* -X131051300Y-99425507D01* -X131166857Y-99252565D01* -X131216140Y-99004800D01* -X131216140Y-97582400D01* -X131166857Y-97334635D01* -X131026509Y-97124591D01* -X130816465Y-96984243D01* -X130568700Y-96934960D01* -X129857500Y-96934960D01* -X129609735Y-96984243D01* -X129435813Y-97100455D01* -X129350109Y-96972191D01* -X129272991Y-96920662D01* -X130079707Y-95718376D01* -X130080408Y-95717908D01* -X130172488Y-95580100D01* -X130218131Y-95512077D01* -X130218447Y-95511319D01* -X130265667Y-95440649D01* -X130281929Y-95358895D01* -X130313974Y-95281953D01* -X130314139Y-95196965D01* -X130314300Y-95196154D01* -X130314300Y-95113676D01* -X130314538Y-94991040D01* -X130326100Y-94991040D01* -X130573865Y-94941757D01* -X130783909Y-94801409D01* -X130863830Y-94681800D01* -X134388370Y-94681800D01* -X134468291Y-94801409D01* -X134678335Y-94941757D01* -X134926100Y-94991040D01* -X136626100Y-94991040D01* -X136873865Y-94941757D01* -X137083909Y-94801409D01* -X137224257Y-94591365D01* -X137273540Y-94343600D01* -X137273540Y-93343600D01* -X137224257Y-93095835D01* -X137083909Y-92885791D01* -X136873865Y-92745443D01* -X136626100Y-92696160D01* -X134926100Y-92696160D01* -X134678335Y-92745443D01* -X134468291Y-92885791D01* -X134388370Y-93005400D01* -X130863830Y-93005400D01* -X130783909Y-92885791D01* -X130573865Y-92745443D01* -X130326100Y-92696160D01* -X128626100Y-92696160D01* -X128378335Y-92745443D01* -X128168291Y-92885791D01* -X128027943Y-93095835D01* -X127978660Y-93343600D01* -X127978660Y-94343600D01* -X128027943Y-94591365D01* -X128168291Y-94801409D01* -X128378335Y-94941757D01* -X128558019Y-94977498D01* -X127577493Y-96438825D01* -X127576793Y-96439292D01* -X127484812Y-96576951D01* -X127439069Y-96645124D01* -X127438753Y-96645883D01* -X127391534Y-96716551D01* -X127375273Y-96798301D01* -X127373873Y-96801661D01* -X127222135Y-96831843D01* -X127012091Y-96972191D01* -X126871743Y-97182235D01* -X126822460Y-97430000D01* -X126822460Y-98141200D01* -X126871743Y-98388965D01* -X127012091Y-98599009D01* -X127222135Y-98739357D01* -X127469900Y-98788640D01* -X128892300Y-98788640D01* -X129140065Y-98739357D01* -X129210060Y-98692587D01* -X129210060Y-99004800D01* -X129246721Y-99189109D01* -X129140065Y-99117843D01* -X128892300Y-99068560D01* -X127469900Y-99068560D01* -X127222135Y-99117843D01* -X127012091Y-99258191D01* -X126871743Y-99468235D01* -X126822460Y-99716000D01* -X126822460Y-100427200D01* -X126871743Y-100674965D01* -X126984937Y-100844370D01* -X126757778Y-101071528D01* -X126687792Y-101118292D01* -X126502533Y-101395552D01* -X126457065Y-101624135D01* -X126298085Y-101240323D01* -X125891362Y-100833600D01* -X126298085Y-100426877D01* -X126530100Y-99866742D01* -X126530100Y-99260458D01* -X126298085Y-98700323D01* -X125891362Y-98293600D01* -X126298085Y-97886877D01* -X126530100Y-97326742D01* -X126530100Y-96720458D01* -X126298085Y-96160323D01* -X125869377Y-95731615D01* -X125309242Y-95499600D01* -X124702958Y-95499600D01* -X124142823Y-95731615D01* -X123714115Y-96160323D01* -X123482100Y-96720458D01* -X123482100Y-97326742D01* -X123714115Y-97886877D01* -X124120838Y-98293600D01* -X123714115Y-98700323D01* -X123482100Y-99260458D01* -X123482100Y-99866742D01* -X123714115Y-100426877D01* -X124120838Y-100833600D01* -X123714115Y-101240323D01* -X123482100Y-101800458D01* -X123482100Y-102406742D01* -X123714115Y-102966877D01* -X124120838Y-103373600D01* -X123714115Y-103780323D01* -X123482100Y-104340458D01* -X123482100Y-104946742D01* -X123714115Y-105506877D01* -X124120838Y-105913600D01* -X123714115Y-106320323D01* -X123482100Y-106880458D01* -X123482100Y-107486742D01* -X123714115Y-108046877D01* -X124142823Y-108475585D01* -X124168530Y-108486233D01* -X124113509Y-108651404D01* -X125006100Y-109543995D01* -X125020243Y-109529853D01* -X125199848Y-109709458D01* -X125185705Y-109723600D01* -X126078296Y-110616191D01* -X126333639Y-110531133D01* -X126541616Y-109961635D01* -X126515823Y-109355900D01* -X126381531Y-109031689D01* -X126583038Y-109157631D01* -X126711051Y-109243167D01* -X126806230Y-109262099D01* -X126896967Y-109296486D01* -X127050814Y-109291800D01* -X127405656Y-109291800D01* -X127331123Y-109497697D01* -X127357711Y-110083169D01* -X127530610Y-110500583D01* -X127780687Y-110579408D01* -X128636495Y-109723600D01* -X128622353Y-109709458D01* -X128801958Y-109529853D01* -X128816100Y-109543995D01* -X128830243Y-109529853D01* -X129009848Y-109709458D01* -X128995705Y-109723600D01* -X129009848Y-109737743D01* -X128830243Y-109917348D01* -X128816100Y-109903205D01* -X127960292Y-110759013D01* -X128034033Y-110992962D01* -X127981599Y-111014681D01* -X127567181Y-111429099D01* -X127342900Y-111970562D01* -X127342900Y-112556638D01* -X127567181Y-113098101D01* -X127981599Y-113512519D01* -X128523062Y-113736800D01* -X127893411Y-113736800D01* -X126530100Y-112508471D01* -X126530100Y-111960458D01* -X126298085Y-111400323D01* -X125869377Y-110971615D01* -X125843670Y-110960967D01* -X125898691Y-110795796D01* -X125006100Y-109903205D01* -X124113509Y-110795796D01* -X124168530Y-110960967D01* -X124142823Y-110971615D01* -X123714115Y-111400323D01* -X123482100Y-111960458D01* -X123482100Y-112566742D01* -X123714115Y-113126877D01* -X124120838Y-113533600D01* -X123714115Y-113940323D01* -X123482100Y-114500458D01* -X123482100Y-115106742D01* -X123714115Y-115666877D01* -X124120838Y-116073600D01* -X123714115Y-116480323D01* -X123482100Y-117040458D01* -X123482100Y-117646742D01* -X123714115Y-118206877D01* -X124142823Y-118635585D01* -X124702958Y-118867600D01* -X125309242Y-118867600D01* -X125686949Y-118711149D01* -X127609686Y-119832746D01* -X127727051Y-119911167D01* -X127834847Y-119932609D01* -X127938758Y-119968401D01* -X128079640Y-119959800D01* -X131015988Y-119959800D01* -X131125830Y-119974515D01* -X131261359Y-119938530D01* -X131398924Y-119911167D01* -X131421677Y-119895964D01* -X131448120Y-119888943D01* -X131559570Y-119803827D01* -X131676183Y-119725908D01* -X131737758Y-119633754D01* -X140625316Y-109545800D01* -X140879719Y-109545800D01* -X141346497Y-109352454D01* -X141703754Y-108995197D01* -X141897100Y-108528419D01* -X141897100Y-108023181D01* -X141703754Y-107556403D01* -X141346497Y-107199146D01* -X140879719Y-107005800D01* -X140754100Y-107005800D01* -X140754100Y-106803981D01* -X140560754Y-106337203D01* -X140203497Y-105979946D01* -X140043324Y-105913600D01* -X154672327Y-105913600D01* -X154776808Y-106438861D01* -X155074344Y-106884156D01* -X155519639Y-107181692D01* -X155912314Y-107259800D01* -X157599886Y-107259800D01* -X157992561Y-107181692D01* -X158437856Y-106884156D01* -X158735392Y-106438861D01* -X158839873Y-105913600D01* -X158735392Y-105388339D01* -X158437856Y-104943044D01* -X157992561Y-104645508D01* -X157599886Y-104567400D01* -X155912314Y-104567400D01* -X155519639Y-104645508D01* -X155074344Y-104943044D01* -X154776808Y-105388339D01* -X154672327Y-105913600D01* -X140043324Y-105913600D01* -X139736719Y-105786600D01* -X139360899Y-105786600D01* -X139500757Y-105608800D01* -X139685919Y-105608800D01* -X140152697Y-105415454D01* -X140509954Y-105058197D01* -X140703300Y-104591419D01* -X140703300Y-104086181D01* -X140509954Y-103619403D01* -X140152697Y-103262146D01* -X139685919Y-103068800D01* -X139180681Y-103068800D01* -X138713903Y-103262146D01* -X138356646Y-103619403D01* -X138163300Y-104086181D01* -X138163300Y-104591419D01* -X138164973Y-104595458D01* -X131889940Y-112572867D01* -X131889940Y-112450800D01* -X131840657Y-112203035D01* -X131700309Y-111992991D01* -X131490265Y-111852643D01* -X131242500Y-111803360D01* -X130319937Y-111803360D01* -X130181087Y-111664510D01* -X130132262Y-111591438D01* -X130065019Y-111429099D01* -X129721720Y-111085800D01* -X130206750Y-111085800D01* -X130365500Y-110927050D01* -X130365500Y-109827800D01* -X130619500Y-109827800D01* -X130619500Y-110927050D01* -X130778250Y-111085800D01* -X131368809Y-111085800D01* -X131602198Y-110989127D01* -X131780827Y-110810499D01* -X131877500Y-110577110D01* -X131877500Y-109986550D01* -X131718750Y-109827800D01* -X130619500Y-109827800D01* -X130365500Y-109827800D01* -X130345500Y-109827800D01* -X130345500Y-109573800D01* -X130365500Y-109573800D01* -X130365500Y-109553800D01* -X130619500Y-109553800D01* -X130619500Y-109573800D01* -X131718750Y-109573800D01* -X131877500Y-109415050D01* -X131877500Y-108824490D01* -X131780827Y-108591101D01* -X131661065Y-108471339D01* -X134175974Y-103743311D01* -X134615497Y-103561254D01* -X134972754Y-103203997D01* -X135166100Y-102737219D01* -X135166100Y-102231981D01* -X134972754Y-101765203D01* -X134615497Y-101407946D01* -X134148719Y-101214600D01* -X133643481Y-101214600D01* -X133176703Y-101407946D01* -X132819446Y-101765203D01* -X132626100Y-102231981D01* -X132626100Y-102737219D01* -X132707630Y-102934050D01* -X130217550Y-107615400D01* -X129028714Y-107615400D01* -X129081100Y-107488930D01* -X129081100Y-106878270D01* -X128847410Y-106314093D01* -X128777117Y-106243800D01* -X129134400Y-106243800D01* -X129722541Y-106000184D01* -X130172684Y-105550041D01* -X130416300Y-104961900D01* -X130416300Y-104325300D01* -X130374121Y-104223470D01* -X134976452Y-98598400D01* -X141423541Y-98598400D01* -X141516100Y-98616811D01* -X141608659Y-98598400D01* -X141882791Y-98543872D01* -X142193657Y-98336157D01* -X142401372Y-98025291D01* -X142413759Y-97963018D01* -X148964858Y-91411919D01* -X148871100Y-91638270D01* -X148871100Y-92248930D01* -X149104790Y-92813107D01* -X149505283Y-93213600D01* -X149104790Y-93614093D01* -X148871100Y-94178270D01* -X148871100Y-94788930D01* -X149104790Y-95353107D01* -X149505283Y-95753600D01* -X149104790Y-96154093D01* -X148871100Y-96718270D01* -X148871100Y-97328930D01* -X149104790Y-97893107D01* -X149536593Y-98324910D01* -X150024045Y-98526819D01* -X149813703Y-98613946D01* -X149456446Y-98971203D01* -X149263100Y-99437981D01* -X149263100Y-99943219D01* -X149456446Y-100409997D01* -X149813703Y-100767254D01* -X150280481Y-100960600D01* -X150713277Y-100960600D01* -X150853446Y-101298997D01* -X151210703Y-101656254D01* -X151677481Y-101849600D01* -X152182719Y-101849600D01* -X152649497Y-101656254D01* -X153006754Y-101298997D01* -X153200100Y-100832219D01* -X153200100Y-100494993D01* -X154764823Y-98930271D01* -X154834807Y-98883509D01* -X155020066Y-98606250D01* -X155041056Y-98500728D01* -X155180770Y-98558600D01* -X155791430Y-98558600D01* -X156355607Y-98324910D01* -X156787410Y-97893107D01* -X157021100Y-97328930D01* -X157021100Y-96718270D01* -X156787410Y-96154093D01* -X156386917Y-95753600D01* -X156787410Y-95353107D01* -X157021100Y-94788930D01* -X157021100Y-94178270D01* -X156787410Y-93614093D01* -X156386917Y-93213600D01* -X156787410Y-92813107D01* -X156960896Y-92394276D01* -X157594300Y-93265208D01* -X157594301Y-96804041D01* -X157575890Y-96896600D01* -X157648829Y-97263292D01* -X157804112Y-97495689D01* -X157804115Y-97495692D01* -X157856544Y-97574157D01* -X157935008Y-97626585D01* -X158566114Y-98257692D01* -X158618543Y-98336157D01* -X158697008Y-98388586D01* -X158697010Y-98388588D01* -X158838968Y-98483441D01* -X158929409Y-98543872D01* -X159203541Y-98598400D01* -X159203546Y-98598400D01* -X159296100Y-98616810D01* -X159388654Y-98598400D01* -X164621823Y-98598400D01* -X164916114Y-98892692D01* -X164968543Y-98971157D01* -X165047008Y-99023586D01* -X165047010Y-99023588D01* -X165188073Y-99117843D01* -X165279409Y-99178872D01* -X165553541Y-99233400D01* -X165553546Y-99233400D01* -X165602640Y-99243165D01* -X165923075Y-99563600D01* -X165559516Y-99927159D01* -X165315900Y-100515300D01* -X165315900Y-101151900D01* -X165559516Y-101740041D01* -X165976300Y-102156825D01* -X165976300Y-102646042D01* -X165976301Y-106853935D01* -X163924410Y-109418800D01* -X162485348Y-109418800D01* -X162312860Y-109413546D01* -X162211124Y-109452101D01* -X162104409Y-109473328D01* -X161960890Y-109569224D01* -X158659325Y-111632703D01* -X158735392Y-111518861D01* -X158839873Y-110993600D01* -X158735392Y-110468339D01* -X158437856Y-110023044D01* -X157992561Y-109725508D01* -X157599886Y-109647400D01* -X155912314Y-109647400D01* -X155519639Y-109725508D01* -X155074344Y-110023044D01* -X154776808Y-110468339D01* -X154672327Y-110993600D01* -X154776808Y-111518861D01* -X155074344Y-111964156D01* -X155519639Y-112261692D01* -X155912314Y-112339800D01* -X157527971Y-112339800D01* -X157121571Y-112593800D01* -X145994917Y-112593800D01* -X145842248Y-112582790D01* -X145720379Y-112623271D01* -X145594409Y-112648328D01* -X145544451Y-112681709D01* -X145487435Y-112700648D01* -X145390323Y-112784694D01* -X145283543Y-112856043D01* -X145198500Y-112983318D01* -X141570105Y-117648400D01* -X141197800Y-117648400D01* -X140609659Y-117892016D01* -X140159516Y-118342159D01* -X139915900Y-118930300D01* -X139915900Y-119566900D01* -X140159516Y-120155041D01* -X140609659Y-120605184D01* -X141197800Y-120848800D01* -X141834400Y-120848800D01* -X142422541Y-120605184D01* -X142872684Y-120155041D01* -X143116300Y-119566900D01* -X143116300Y-118930300D01* -X143059992Y-118794362D01* -X146420740Y-114473400D01* -X150837900Y-114473400D01* -X150837901Y-116492821D01* -X150717135Y-116516843D01* -X150507091Y-116657191D01* -X150366743Y-116867235D01* -X150317460Y-117115000D01* -X150317460Y-117826200D01* -X150366743Y-118073965D01* -X150507091Y-118284009D01* -X150717135Y-118424357D01* -X150964900Y-118473640D01* -X152387300Y-118473640D01* -X152635065Y-118424357D01* -X152845109Y-118284009D01* -X152985457Y-118073965D01* -X153034740Y-117826200D01* -X153034740Y-117115000D01* -X152985457Y-116867235D01* -X152845109Y-116657191D01* -X152635065Y-116516843D01* -X152514300Y-116492822D01* -X152514300Y-114473400D01* -X156552900Y-114473400D01* -X156552901Y-116492821D01* -X156432135Y-116516843D01* -X156222091Y-116657191D01* -X156081743Y-116867235D01* -X156032460Y-117115000D01* -X156032460Y-117826200D01* -X156081743Y-118073965D01* -X156222091Y-118284009D01* -X156432135Y-118424357D01* -X156679900Y-118473640D01* -X158102300Y-118473640D01* -X158350065Y-118424357D01* -X158560109Y-118284009D01* -X158700457Y-118073965D01* -X158749740Y-117826200D01* -X158749740Y-117629350D01* -X170511100Y-117629350D01* -X170511100Y-118319910D01* -X170607773Y-118553299D01* -X170786402Y-118731927D01* -X170995978Y-118818736D01* -X170724455Y-119116676D01* -X170554624Y-119526710D01* -X170675945Y-119756600D01* -X171869100Y-119756600D01* -X171869100Y-117470600D01* -X172123100Y-117470600D01* -X172123100Y-119756600D01* -X174409100Y-119756600D01* -X174409100Y-117470600D01* -X172123100Y-117470600D01* -X171869100Y-117470600D01* -X170669850Y-117470600D01* -X170511100Y-117629350D01* -X158749740Y-117629350D01* -X158749740Y-117115000D01* -X158700457Y-116867235D01* -X158560109Y-116657191D01* -X158350065Y-116516843D01* -X158229300Y-116492822D01* -X158229300Y-116367290D01* -X170511100Y-116367290D01* -X170511100Y-117057850D01* -X170669850Y-117216600D01* -X171869100Y-117216600D01* -X171869100Y-116017350D01* -X172123100Y-116017350D01* -X172123100Y-117216600D01* -X174409100Y-117216600D01* -X174409100Y-116022781D01* -X174179208Y-115902114D01* -X173654742Y-116148417D01* -X173473030Y-116347808D01* -X173384427Y-116133901D01* -X173205798Y-115955273D01* -X172972409Y-115858600D01* -X172281850Y-115858600D01* -X172123100Y-116017350D01* -X171869100Y-116017350D01* -X171710350Y-115858600D01* -X171019791Y-115858600D01* -X170786402Y-115955273D01* -X170607773Y-116133901D01* -X170511100Y-116367290D01* -X158229300Y-116367290D01* -X158229300Y-114117981D01* -X162740631Y-111298400D01* -X164335827Y-111298400D01* -X164481916Y-111310949D01* -X164610484Y-111270189D01* -X164742791Y-111243872D01* -X164787294Y-111214136D01* -X164838311Y-111197962D01* -X164941502Y-111111097D01* -X165053657Y-111036157D01* -X165082092Y-110993600D01* -X169428732Y-110993600D01* -X169537156Y-111538682D01* -X169845920Y-112000780D01* -X170308018Y-112309544D01* -X170715512Y-112390600D01* -X172514688Y-112390600D01* -X172922182Y-112309544D01* -X173384280Y-112000780D01* -X173693044Y-111538682D01* -X173801468Y-110993600D01* -X173693044Y-110448518D01* -X173384280Y-109986420D01* -X172973611Y-109712020D01* -X173029041Y-109695659D01* -X173454730Y-109351626D01* -X173716360Y-108870877D01* -X173731320Y-108796670D01* -X173608820Y-108580600D01* -X171742100Y-108580600D01* -X171742100Y-108600600D01* -X171488100Y-108600600D01* -X171488100Y-108580600D01* -X169621380Y-108580600D01* -X169498880Y-108796670D01* -X169513840Y-108870877D01* -X169775470Y-109351626D01* -X170201159Y-109695659D01* -X170256589Y-109712020D01* -X169845920Y-109986420D01* -X169537156Y-110448518D01* -X169428732Y-110993600D01* -X165082092Y-110993600D01* -X165135127Y-110914229D01* -X167559127Y-107884229D01* -X167593657Y-107861157D01* -X167675125Y-107739231D01* -X167707781Y-107698412D01* -X167726431Y-107662447D01* -X167801372Y-107550291D01* -X167811813Y-107497799D01* -X167836451Y-107450288D01* -X167847995Y-107315901D01* -X167855900Y-107276159D01* -X167855900Y-107223873D01* -X167868449Y-107077784D01* -X167855900Y-107038201D01* -X167855900Y-105913600D01* -X169428732Y-105913600D01* -X169537156Y-106458682D01* -X169845920Y-106920780D01* -X170256589Y-107195180D01* -X170201159Y-107211541D01* -X169775470Y-107555574D01* -X169513840Y-108036323D01* -X169498880Y-108110530D01* -X169621380Y-108326600D01* -X171488100Y-108326600D01* -X171488100Y-108306600D01* -X171742100Y-108306600D01* -X171742100Y-108326600D01* -X173608820Y-108326600D01* -X173731320Y-108110530D01* -X173716360Y-108036323D01* -X173454730Y-107555574D01* -X173029041Y-107211541D01* -X172973611Y-107195180D01* -X173384280Y-106920780D01* -X173693044Y-106458682D01* -X173801468Y-105913600D01* -X173693044Y-105368518D01* -X173384280Y-104906420D01* -X172922182Y-104597656D01* -X172514688Y-104516600D01* -X170715512Y-104516600D01* -X170308018Y-104597656D01* -X169845920Y-104906420D01* -X169537156Y-105368518D01* -X169428732Y-105913600D01* -X167855900Y-105913600D01* -X167855900Y-102156825D01* -X168272684Y-101740041D01* -X168516300Y-101151900D01* -X168516300Y-100683008D01* -X168555547Y-100643761D01* -X168641952Y-100900243D01* -X169215436Y-101110058D01* -X169825560Y-101084439D01* -X170270248Y-100900243D01* -X170356654Y-100643759D01* -X169456100Y-99743205D01* -X169441958Y-99757348D01* -X169262353Y-99577743D01* -X169276495Y-99563600D01* -X169262353Y-99549458D01* -X169441958Y-99369853D01* -X169456100Y-99383995D01* -X170356654Y-98483441D01* -X170292699Y-98293600D01* -X170356654Y-98103759D01* -X169456100Y-97203205D01* -X169441958Y-97217348D01* -X169262353Y-97037743D01* -X169276495Y-97023600D01* -X169262353Y-97009458D01* -X169441958Y-96829853D01* -X169456100Y-96843995D01* -X170356654Y-95943441D01* -X170292699Y-95753600D01* -X170356654Y-95563759D01* -X169456100Y-94663205D01* -X169441958Y-94677348D01* -X169262353Y-94497743D01* -X169276495Y-94483600D01* -X168375941Y-93583046D01* -X168119457Y-93669452D01* -X167909642Y-94242936D01* -X167920213Y-94494688D01* -X167855900Y-94430375D01* -X167855900Y-93023759D01* -X168555546Y-93023759D01* -X168619501Y-93213600D01* -X168555546Y-93403441D01* -X169456100Y-94303995D01* -X170356654Y-93403441D01* -X170292699Y-93213600D01* -X170356654Y-93023759D01* -X169456100Y-92123205D01* -X168555546Y-93023759D01* -X167855900Y-93023759D01* -X167855900Y-91702936D01* -X167909642Y-91702936D01* -X167935261Y-92313060D01* -X168119457Y-92757748D01* -X168375941Y-92844154D01* -X169276495Y-91943600D01* -X168375941Y-91043046D01* -X168119457Y-91129452D01* -X167909642Y-91702936D01* -X167855900Y-91702936D01* -X167855900Y-90863441D01* -X168555546Y-90863441D01* -X169456100Y-91763995D01* -X170356654Y-90863441D01* -X170270248Y-90606957D01* -X169696764Y-90397142D01* -X169086640Y-90422761D01* -X168641952Y-90606957D01* -X168555546Y-90863441D01* -X167855900Y-90863441D01* -X167855900Y-88861153D01* -X167874310Y-88768599D01* -X167855900Y-88676045D01* -X167855900Y-88676041D01* -X167801372Y-88401909D01* -X167699175Y-88248961D01* -X167646087Y-88169509D01* -X167646086Y-88169508D01* -X167593657Y-88091043D01* -X167515192Y-88038614D01* -X166617456Y-87140879D01* -X166615672Y-87131909D01* -X166407957Y-86821043D01* -X166097091Y-86613328D01* -X165822959Y-86558800D01* -X165738654Y-86558800D01* -X165646100Y-86540390D01* -X165553546Y-86558800D01* -X153597386Y-86558800D01* -X153426917Y-86552875D01* -X153323111Y-86591706D01* -X153214409Y-86613328D01* -X153072581Y-86708095D01* -X151791615Y-87501074D01* -X151930100Y-87166742D01* -X151930100Y-86560458D01* -X151698085Y-86000323D01* -X151269377Y-85571615D01* -X150709242Y-85339600D01* -X150102958Y-85339600D01* -X149542823Y-85571615D01* -X149136100Y-85978338D01* -X148729377Y-85571615D01* -X148169242Y-85339600D01* -X147562958Y-85339600D01* -X147002823Y-85571615D01* -X146596100Y-85978338D01* -X146189377Y-85571615D01* -X145629242Y-85339600D01* -X145022958Y-85339600D01* -X144462823Y-85571615D01* -X144056100Y-85978338D01* -X143649377Y-85571615D01* -X143089242Y-85339600D01* -X142482958Y-85339600D01* -X141922823Y-85571615D01* -X141516100Y-85978338D01* -X141109377Y-85571615D01* -X140549242Y-85339600D01* -X139942958Y-85339600D01* -X139382823Y-85571615D01* -X138976100Y-85978338D01* -X138569377Y-85571615D01* -X138009242Y-85339600D01* -X137402958Y-85339600D01* -X136842823Y-85571615D01* -X136436100Y-85978338D01* -X136029377Y-85571615D01* -X135469242Y-85339600D01* -X134862958Y-85339600D01* -X134302823Y-85571615D01* -X133896100Y-85978338D01* -X133489377Y-85571615D01* -X132929242Y-85339600D01* -X132322958Y-85339600D01* -X131762823Y-85571615D01* -X131356100Y-85978338D01* -X130949377Y-85571615D01* -X130389242Y-85339600D01* -X129782958Y-85339600D01* -X129451100Y-85477060D01* -X129451100Y-85446034D01* -X128774389Y-83812310D01* -X128175679Y-83213600D01* -X168801121Y-83213600D01* -X168202411Y-83812310D01* -X168202411Y-83812310D01* -G37* -X168202411Y-83812310D02* -X167525700Y-85446034D01* -X167525700Y-87214366D01* -X168202411Y-88848090D01* -X169452810Y-90098489D01* -X171020878Y-90748005D01* -X170694790Y-91074093D01* -X170686662Y-91093715D01* -X170536259Y-91043046D01* -X169635705Y-91943600D01* -X170536259Y-92844154D01* -X170686662Y-92793485D01* -X170694790Y-92813107D01* -X171095283Y-93213600D01* -X170694790Y-93614093D01* -X170686662Y-93633715D01* -X170536259Y-93583046D01* -X169635705Y-94483600D01* -X170536259Y-95384154D01* -X170686662Y-95333485D01* -X170694790Y-95353107D01* -X171095283Y-95753600D01* -X170694790Y-96154093D01* -X170686662Y-96173715D01* -X170536259Y-96123046D01* -X169635705Y-97023600D01* -X170536259Y-97924154D01* -X170686662Y-97873485D01* -X170694790Y-97893107D01* -X171095283Y-98293600D01* -X170694790Y-98694093D01* -X170686662Y-98713715D01* -X170536259Y-98663046D01* -X169635705Y-99563600D01* -X170536259Y-100464154D01* -X170686662Y-100413485D01* -X170694790Y-100433107D01* -X171126593Y-100864910D01* -X171690770Y-101098600D01* -X172301430Y-101098600D01* -X172865607Y-100864910D01* -X173219996Y-100510521D01* -X173629659Y-100920184D01* -X174217800Y-101163800D01* -X174854400Y-101163800D01* -X175044100Y-101085224D01* -X175044100Y-112717549D01* -X174841430Y-112633600D01* -X174230770Y-112633600D01* -X173666593Y-112867290D01* -X173266100Y-113267783D01* -X172865607Y-112867290D01* -X172301430Y-112633600D01* -X171690770Y-112633600D01* -X171126593Y-112867290D01* -X170694790Y-113299093D01* -X170461100Y-113863270D01* -X170461100Y-114473930D01* -X170694790Y-115038107D01* -X171126593Y-115469910D01* -X171690770Y-115703600D01* -X172301430Y-115703600D01* -X172865607Y-115469910D01* -X173266100Y-115069417D01* -X173666593Y-115469910D01* -X174230770Y-115703600D01* -X174841430Y-115703600D01* -X175044100Y-115619651D01* -X175044100Y-115973078D01* -X174892992Y-115902114D01* -X174663100Y-116022781D01* -X174663100Y-117216600D01* -X174683100Y-117216600D01* -X174683100Y-117470600D01* -X174663100Y-117470600D01* -X174663100Y-119756600D01* -X174683100Y-119756600D01* -X174683100Y-120010600D01* -X174663100Y-120010600D01* -X174663100Y-122296600D01* -X174683100Y-122296600D01* -X174683100Y-122550600D01* -X174663100Y-122550600D01* -X174663100Y-124836600D01* -X174683100Y-124836600D01* -X174683100Y-125090600D01* -X174663100Y-125090600D01* -X174663100Y-126284419D01* -X174892992Y-126405086D01* -X175044100Y-126334122D01* -X175044100Y-126741600D01* -X128244279Y-126741600D01* -X128774389Y-126211490D01* -X128892817Y-125925579D01* -X129222823Y-126255585D01* -X129782958Y-126487600D01* -X130389242Y-126487600D01* -X130949377Y-126255585D01* -X131356100Y-125848862D01* -X131762823Y-126255585D01* -X132322958Y-126487600D01* -X132929242Y-126487600D01* -X133489377Y-126255585D01* -X133896100Y-125848862D01* -X134302823Y-126255585D01* -X134862958Y-126487600D01* -X135469242Y-126487600D01* -X136029377Y-126255585D01* -X136436100Y-125848862D01* -X136842823Y-126255585D01* -X137402958Y-126487600D01* -X138009242Y-126487600D01* -X138569377Y-126255585D01* -X138976100Y-125848862D01* -X139382823Y-126255585D01* -X139942958Y-126487600D01* -X140549242Y-126487600D01* -X141109377Y-126255585D01* -X141516100Y-125848862D01* -X141922823Y-126255585D01* -X142482958Y-126487600D01* -X143089242Y-126487600D01* -X143649377Y-126255585D01* -X144056100Y-125848862D01* -X144462823Y-126255585D01* -X145022958Y-126487600D01* -X145629242Y-126487600D01* -X146189377Y-126255585D01* -X146596100Y-125848862D01* -X147002823Y-126255585D01* -X147562958Y-126487600D01* -X148169242Y-126487600D01* -X148729377Y-126255585D01* -X149136100Y-125848862D01* -X149542823Y-126255585D01* -X150102958Y-126487600D01* -X150709242Y-126487600D01* -X151269377Y-126255585D01* -X151676100Y-125848862D01* -X152082823Y-126255585D01* -X152642958Y-126487600D01* -X153249242Y-126487600D01* -X153809377Y-126255585D01* -X154216100Y-125848862D01* -X154622823Y-126255585D01* -X155182958Y-126487600D01* -X155789242Y-126487600D01* -X156349377Y-126255585D01* -X156756100Y-125848862D01* -X157162823Y-126255585D01* -X157722958Y-126487600D01* -X158329242Y-126487600D01* -X158889377Y-126255585D01* -X159318085Y-125826877D01* -X159527836Y-125320490D01* -X170554624Y-125320490D01* -X170724455Y-125730524D01* -X171114742Y-126158783D01* -X171639208Y-126405086D01* -X171869100Y-126284419D01* -X171869100Y-125090600D01* -X172123100Y-125090600D01* -X172123100Y-126284419D01* -X172352992Y-126405086D01* -X172877458Y-126158783D01* -X173266100Y-125732329D01* -X173654742Y-126158783D01* -X174179208Y-126405086D01* -X174409100Y-126284419D01* -X174409100Y-125090600D01* -X172123100Y-125090600D01* -X171869100Y-125090600D01* -X170675945Y-125090600D01* -X170554624Y-125320490D01* -X159527836Y-125320490D01* -X159550100Y-125266742D01* -X159550100Y-124660458D01* -X159318085Y-124100323D01* -X158889377Y-123671615D01* -X158529872Y-123522704D01* -X158516615Y-123469674D01* -X161615750Y-123469674D01* -X161704542Y-123916062D01* -X162042779Y-124422271D01* -X162548987Y-124760508D01* -X163146100Y-124879281D01* -X163743212Y-124760508D01* -X164249421Y-124422271D01* -X164587658Y-123916063D01* -X164676450Y-123469675D01* -X164676450Y-122550600D01* -X166615750Y-122550600D01* -X166615750Y-123445950D01* -X166780842Y-124021922D01* -X167153782Y-124490873D01* -X167677793Y-124781409D01* -X167782090Y-124805378D01* -X168019100Y-124684658D01* -X168019100Y-122550600D01* -X168273100Y-122550600D01* -X168273100Y-124684658D01* -X168510110Y-124805378D01* -X168614407Y-124781409D01* -X169138418Y-124490873D01* -X169511358Y-124021922D01* -X169676450Y-123445950D01* -X169676450Y-122780490D01* -X170554624Y-122780490D01* -X170724455Y-123190524D01* -X171114742Y-123618783D01* -X171274054Y-123693600D01* -X171114742Y-123768417D01* -X170724455Y-124196676D01* -X170554624Y-124606710D01* -X170675945Y-124836600D01* -X171869100Y-124836600D01* -X171869100Y-122550600D01* -X172123100Y-122550600D01* -X172123100Y-124836600D01* -X174409100Y-124836600D01* -X174409100Y-122550600D01* -X172123100Y-122550600D01* -X171869100Y-122550600D01* -X170675945Y-122550600D01* -X170554624Y-122780490D01* -X169676450Y-122780490D01* -X169676450Y-122550600D01* -X168273100Y-122550600D01* -X168019100Y-122550600D01* -X166615750Y-122550600D01* -X164676450Y-122550600D01* -X164676450Y-121401250D01* -X166615750Y-121401250D01* -X166615750Y-122296600D01* -X168019100Y-122296600D01* -X168019100Y-120162542D01* -X168273100Y-120162542D01* -X168273100Y-122296600D01* -X169676450Y-122296600D01* -X169676450Y-121401250D01* -X169511358Y-120825278D01* -X169138418Y-120356327D01* -X168929495Y-120240490D01* -X170554624Y-120240490D01* -X170724455Y-120650524D01* -X171114742Y-121078783D01* -X171274054Y-121153600D01* -X171114742Y-121228417D01* -X170724455Y-121656676D01* -X170554624Y-122066710D01* -X170675945Y-122296600D01* -X171869100Y-122296600D01* -X171869100Y-120010600D01* -X172123100Y-120010600D01* -X172123100Y-122296600D01* -X174409100Y-122296600D01* -X174409100Y-120010600D01* -X172123100Y-120010600D01* -X171869100Y-120010600D01* -X170675945Y-120010600D01* -X170554624Y-120240490D01* -X168929495Y-120240490D01* -X168614407Y-120065791D01* -X168510110Y-120041822D01* -X168273100Y-120162542D01* -X168019100Y-120162542D01* -X167782090Y-120041822D01* -X167677793Y-120065791D01* -X167153782Y-120356327D01* -X166780842Y-120825278D01* -X166615750Y-121401250D01* -X164676450Y-121401250D01* -X164676450Y-121377525D01* -X164587658Y-120931137D01* -X164249421Y-120424929D01* -X163743213Y-120086692D01* -X163146100Y-119967919D01* -X162548988Y-120086692D01* -X162042780Y-120424929D01* -X161704543Y-120931137D01* -X161615751Y-121377525D01* -X161615750Y-123469674D01* -X158516615Y-123469674D01* -X158229300Y-122320414D01* -X158229300Y-120734378D01* -X158350065Y-120710357D01* -X158560109Y-120570009D01* -X158700457Y-120359965D01* -X158749740Y-120112200D01* -X158749740Y-119401000D01* -X158700457Y-119153235D01* -X158560109Y-118943191D01* -X158350065Y-118802843D01* -X158102300Y-118753560D01* -X156679900Y-118753560D01* -X156432135Y-118802843D01* -X156222091Y-118943191D01* -X156081743Y-119153235D01* -X156032460Y-119401000D01* -X156032460Y-120112200D01* -X156081743Y-120359965D01* -X156222091Y-120570009D01* -X156432135Y-120710357D01* -X156552901Y-120734379D01* -X156552900Y-122277963D01* -X156545787Y-122297814D01* -X156552900Y-122443966D01* -X156552900Y-122506153D01* -X156556907Y-122526297D01* -X156557905Y-122546804D01* -X156572982Y-122607111D01* -X156601533Y-122750648D01* -X156613250Y-122768184D01* -X156903851Y-123930587D01* -X156756100Y-124078338D01* -X156349377Y-123671615D01* -X155789242Y-123439600D01* -X155182958Y-123439600D01* -X154622823Y-123671615D01* -X154216100Y-124078338D01* -X153839140Y-123701378D01* -X154247410Y-123293107D01* -X154481100Y-122728930D01* -X154481100Y-122118270D01* -X154247410Y-121554093D01* -X153815607Y-121122290D01* -X153251430Y-120888600D01* -X152640770Y-120888600D01* -X152609462Y-120901568D01* -X152514300Y-120806407D01* -X152514300Y-120734378D01* -X152635065Y-120710357D01* -X152845109Y-120570009D01* -X152985457Y-120359965D01* -X153034740Y-120112200D01* -X153034740Y-119401000D01* -X152985457Y-119153235D01* -X152845109Y-118943191D01* -X152635065Y-118802843D01* -X152387300Y-118753560D01* -X150964900Y-118753560D01* -X150717135Y-118802843D01* -X150507091Y-118943191D01* -X150366743Y-119153235D01* -X150317460Y-119401000D01* -X150317460Y-120112200D01* -X150366743Y-120359965D01* -X150507091Y-120570009D01* -X150717135Y-120710357D01* -X150837900Y-120734378D01* -X150837900Y-120940986D01* -X150711430Y-120888600D01* -X150100770Y-120888600D01* -X149536593Y-121122290D01* -X149136100Y-121522783D01* -X148735607Y-121122290D01* -X148171430Y-120888600D01* -X147560770Y-120888600D01* -X146996593Y-121122290D01* -X146564790Y-121554093D01* -X146331100Y-122118270D01* -X146331100Y-122728930D01* -X146564790Y-123293107D01* -X146973061Y-123701378D01* -X146596100Y-124078338D01* -X146189377Y-123671615D01* -X145629242Y-123439600D01* -X145022958Y-123439600D01* -X144462823Y-123671615D01* -X144056100Y-124078338D01* -X143649377Y-123671615D01* -X143089242Y-123439600D01* -X142482958Y-123439600D01* -X141922823Y-123671615D01* -X141516100Y-124078338D01* -X141109377Y-123671615D01* -X140549242Y-123439600D01* -X139942958Y-123439600D01* -X139382823Y-123671615D01* -X138976100Y-124078338D01* -X138569377Y-123671615D01* -X138009242Y-123439600D01* -X137402958Y-123439600D01* -X136842823Y-123671615D01* -X136436100Y-124078338D01* -X136029377Y-123671615D01* -X135469242Y-123439600D01* -X134862958Y-123439600D01* -X134302823Y-123671615D01* -X133896100Y-124078338D01* -X133489377Y-123671615D01* -X132929242Y-123439600D01* -X132322958Y-123439600D01* -X131762823Y-123671615D01* -X131356100Y-124078338D01* -X130949377Y-123671615D01* -X130389242Y-123439600D01* -X129782958Y-123439600D01* -X129451100Y-123577060D01* -X129451100Y-122809434D01* -X128774389Y-121175710D01* -X127523990Y-119925311D01* -X125890266Y-119248600D01* -X124121934Y-119248600D01* -X122488210Y-119925311D01* -X121958100Y-120455421D01* -X121958100Y-109485565D01* -X123470584Y-109485565D01* -X123496377Y-110091300D01* -X123678561Y-110531133D01* -X123933904Y-110616191D01* -X124826495Y-109723600D01* -X123933904Y-108831009D01* -X123678561Y-108916067D01* -X123470584Y-109485565D01* -X121958100Y-109485565D01* -X121958100Y-89568379D01* -X122488210Y-90098489D01* -X124121934Y-90775200D01* -X125890266Y-90775200D01* -X126966642Y-90329350D01* -X127991100Y-90329350D01* -X127991100Y-90669909D01* -X128087773Y-90903298D01* -X128266401Y-91081927D01* -X128499790Y-91178600D01* -X129190350Y-91178600D01* -X129349100Y-91019850D01* -X129349100Y-90170600D01* -X129603100Y-90170600D01* -X129603100Y-91019850D01* -X129761850Y-91178600D01* -X130452410Y-91178600D01* -X130685799Y-91081927D01* -X130864427Y-90903298D01* -X130961100Y-90669909D01* -X130961100Y-90329350D01* -X134291100Y-90329350D01* -X134291100Y-90669909D01* -X134387773Y-90903298D01* -X134566401Y-91081927D01* -X134799790Y-91178600D01* -X135490350Y-91178600D01* -X135649100Y-91019850D01* -X135649100Y-90170600D01* -X135903100Y-90170600D01* -X135903100Y-91019850D01* -X136061850Y-91178600D01* -X136752410Y-91178600D01* -X136985799Y-91081927D01* -X137164427Y-90903298D01* -X137261100Y-90669909D01* -X137261100Y-90329350D01* -X137102350Y-90170600D01* -X135903100Y-90170600D01* -X135649100Y-90170600D01* -X134449850Y-90170600D01* -X134291100Y-90329350D01* -X130961100Y-90329350D01* -X130802350Y-90170600D01* -X129603100Y-90170600D01* -X129349100Y-90170600D01* -X128149850Y-90170600D01* -X127991100Y-90329350D01* -X126966642Y-90329350D01* -X127523990Y-90098489D01* -X127991100Y-89631379D01* -X127991100Y-89757850D01* -X128149850Y-89916600D01* -X129349100Y-89916600D01* -X129349100Y-89067350D01* -X129603100Y-89067350D01* -X129603100Y-89916600D01* -X130802350Y-89916600D01* -X130961100Y-89757850D01* -X130961100Y-89417291D01* -X134291100Y-89417291D01* -X134291100Y-89757850D01* -X134449850Y-89916600D01* -X135649100Y-89916600D01* -X135649100Y-89067350D01* -X135903100Y-89067350D01* -X135903100Y-89916600D01* -X137102350Y-89916600D01* -X137261100Y-89757850D01* -X137261100Y-89417291D01* -X137164427Y-89183902D01* -X136985799Y-89005273D01* -X136752410Y-88908600D01* -X136061850Y-88908600D01* -X135903100Y-89067350D01* -X135649100Y-89067350D01* -X135490350Y-88908600D01* -X134799790Y-88908600D01* -X134566401Y-89005273D01* -X134387773Y-89183902D01* -X134291100Y-89417291D01* -X130961100Y-89417291D01* -X130864427Y-89183902D01* -X130685799Y-89005273D01* -X130452410Y-88908600D01* -X129761850Y-88908600D01* -X129603100Y-89067350D01* -X129349100Y-89067350D01* -X129190350Y-88908600D01* -X128713879Y-88908600D01* -X128774389Y-88848090D01* -X129108562Y-88041324D01* -X129222823Y-88155585D01* -X129782958Y-88387600D01* -X130389242Y-88387600D01* -X130949377Y-88155585D01* -X131356100Y-87748862D01* -X131762823Y-88155585D01* -X132322958Y-88387600D01* -X132929242Y-88387600D01* -X133489377Y-88155585D01* -X133896100Y-87748862D01* -X134302823Y-88155585D01* -X134862958Y-88387600D01* -X135469242Y-88387600D01* -X136029377Y-88155585D01* -X136436100Y-87748862D01* -X136842823Y-88155585D01* -X137402958Y-88387600D01* -X138009242Y-88387600D01* -X138569377Y-88155585D01* -X138976100Y-87748862D01* -X139382823Y-88155585D01* -X139942958Y-88387600D01* -X140549242Y-88387600D01* -X141109377Y-88155585D01* -X141516100Y-87748862D01* -X141922823Y-88155585D01* -X142482958Y-88387600D01* -X142996777Y-88387600D01* -X142995963Y-88388239D01* -X142870543Y-88472043D01* -X142797944Y-88580695D01* -X142156596Y-89328935D01* -X142108543Y-89361043D01* -X142035941Y-89469699D01* -X142012315Y-89497263D01* -X141984637Y-89546481D01* -X141900828Y-89671910D01* -X141893563Y-89708433D01* -X141875313Y-89740886D01* -X141857320Y-89890639D01* -X141846300Y-89946042D01* -X141846300Y-89982361D01* -X141830713Y-90112091D01* -X141846300Y-90167735D01* -X141846301Y-91890374D01* -X141429516Y-92307159D01* -X141185900Y-92895300D01* -X141185900Y-93531900D01* -X141429516Y-94120041D01* -X141879659Y-94570184D01* -X142467800Y-94813800D01* -X142904823Y-94813800D01* -X140999823Y-96718800D01* -X134576553Y-96718800D01* -X134435754Y-96705145D01* -X134301786Y-96746002D01* -X134164409Y-96773328D01* -X134124291Y-96800134D01* -X134078140Y-96814209D01* -X133969997Y-96903231D01* -X133853543Y-96981043D01* -X133774953Y-97098661D01* -X133483075Y-97455400D01* -X133476878Y-97455400D01* -X133452857Y-97334635D01* -X133312509Y-97124591D01* -X133102465Y-96984243D01* -X132854700Y-96934960D01* -X132143500Y-96934960D01* -X131895735Y-96984243D01* -X131685691Y-97124591D01* -X131545343Y-97334635D01* -X131496060Y-97582400D01* -X131496060Y-99004800D01* -X131545343Y-99252565D01* -X131685691Y-99462609D01* -X131785984Y-99529623D01* -X131051300Y-100427571D01* -X131051300Y-99425507D01* -X131166857Y-99252565D01* -X131216140Y-99004800D01* -X131216140Y-97582400D01* -X131166857Y-97334635D01* -X131026509Y-97124591D01* -X130816465Y-96984243D01* -X130568700Y-96934960D01* -X129857500Y-96934960D01* -X129609735Y-96984243D01* -X129435813Y-97100455D01* -X129350109Y-96972191D01* -X129272991Y-96920662D01* -X130079707Y-95718376D01* -X130080408Y-95717908D01* -X130172488Y-95580100D01* -X130218131Y-95512077D01* -X130218447Y-95511319D01* -X130265667Y-95440649D01* -X130281929Y-95358895D01* -X130313974Y-95281953D01* -X130314139Y-95196965D01* -X130314300Y-95196154D01* -X130314300Y-95113676D01* -X130314538Y-94991040D01* -X130326100Y-94991040D01* -X130573865Y-94941757D01* -X130783909Y-94801409D01* -X130863830Y-94681800D01* -X134388370Y-94681800D01* -X134468291Y-94801409D01* -X134678335Y-94941757D01* -X134926100Y-94991040D01* -X136626100Y-94991040D01* -X136873865Y-94941757D01* -X137083909Y-94801409D01* -X137224257Y-94591365D01* -X137273540Y-94343600D01* -X137273540Y-93343600D01* -X137224257Y-93095835D01* -X137083909Y-92885791D01* -X136873865Y-92745443D01* -X136626100Y-92696160D01* -X134926100Y-92696160D01* -X134678335Y-92745443D01* -X134468291Y-92885791D01* -X134388370Y-93005400D01* -X130863830Y-93005400D01* -X130783909Y-92885791D01* -X130573865Y-92745443D01* -X130326100Y-92696160D01* -X128626100Y-92696160D01* -X128378335Y-92745443D01* -X128168291Y-92885791D01* -X128027943Y-93095835D01* -X127978660Y-93343600D01* -X127978660Y-94343600D01* -X128027943Y-94591365D01* -X128168291Y-94801409D01* -X128378335Y-94941757D01* -X128558019Y-94977498D01* -X127577493Y-96438825D01* -X127576793Y-96439292D01* -X127484812Y-96576951D01* -X127439069Y-96645124D01* -X127438753Y-96645883D01* -X127391534Y-96716551D01* -X127375273Y-96798301D01* -X127373873Y-96801661D01* -X127222135Y-96831843D01* -X127012091Y-96972191D01* -X126871743Y-97182235D01* -X126822460Y-97430000D01* -X126822460Y-98141200D01* -X126871743Y-98388965D01* -X127012091Y-98599009D01* -X127222135Y-98739357D01* -X127469900Y-98788640D01* -X128892300Y-98788640D01* -X129140065Y-98739357D01* -X129210060Y-98692587D01* -X129210060Y-99004800D01* -X129246721Y-99189109D01* -X129140065Y-99117843D01* -X128892300Y-99068560D01* -X127469900Y-99068560D01* -X127222135Y-99117843D01* -X127012091Y-99258191D01* -X126871743Y-99468235D01* -X126822460Y-99716000D01* -X126822460Y-100427200D01* -X126871743Y-100674965D01* -X126984937Y-100844370D01* -X126757778Y-101071528D01* -X126687792Y-101118292D01* -X126502533Y-101395552D01* -X126457065Y-101624135D01* -X126298085Y-101240323D01* -X125891362Y-100833600D01* -X126298085Y-100426877D01* -X126530100Y-99866742D01* -X126530100Y-99260458D01* -X126298085Y-98700323D01* -X125891362Y-98293600D01* -X126298085Y-97886877D01* -X126530100Y-97326742D01* -X126530100Y-96720458D01* -X126298085Y-96160323D01* -X125869377Y-95731615D01* -X125309242Y-95499600D01* -X124702958Y-95499600D01* -X124142823Y-95731615D01* -X123714115Y-96160323D01* -X123482100Y-96720458D01* -X123482100Y-97326742D01* -X123714115Y-97886877D01* -X124120838Y-98293600D01* -X123714115Y-98700323D01* -X123482100Y-99260458D01* -X123482100Y-99866742D01* -X123714115Y-100426877D01* -X124120838Y-100833600D01* -X123714115Y-101240323D01* -X123482100Y-101800458D01* -X123482100Y-102406742D01* -X123714115Y-102966877D01* -X124120838Y-103373600D01* -X123714115Y-103780323D01* -X123482100Y-104340458D01* -X123482100Y-104946742D01* -X123714115Y-105506877D01* -X124120838Y-105913600D01* -X123714115Y-106320323D01* -X123482100Y-106880458D01* -X123482100Y-107486742D01* -X123714115Y-108046877D01* -X124142823Y-108475585D01* -X124168530Y-108486233D01* -X124113509Y-108651404D01* -X125006100Y-109543995D01* -X125020243Y-109529853D01* -X125199848Y-109709458D01* -X125185705Y-109723600D01* -X126078296Y-110616191D01* -X126333639Y-110531133D01* -X126541616Y-109961635D01* -X126515823Y-109355900D01* -X126381531Y-109031689D01* -X126583038Y-109157631D01* -X126711051Y-109243167D01* -X126806230Y-109262099D01* -X126896967Y-109296486D01* -X127050814Y-109291800D01* -X127405656Y-109291800D01* -X127331123Y-109497697D01* -X127357711Y-110083169D01* -X127530610Y-110500583D01* -X127780687Y-110579408D01* -X128636495Y-109723600D01* -X128622353Y-109709458D01* -X128801958Y-109529853D01* -X128816100Y-109543995D01* -X128830243Y-109529853D01* -X129009848Y-109709458D01* -X128995705Y-109723600D01* -X129009848Y-109737743D01* -X128830243Y-109917348D01* -X128816100Y-109903205D01* -X127960292Y-110759013D01* -X128034033Y-110992962D01* -X127981599Y-111014681D01* -X127567181Y-111429099D01* -X127342900Y-111970562D01* -X127342900Y-112556638D01* -X127567181Y-113098101D01* -X127981599Y-113512519D01* -X128523062Y-113736800D01* -X127893411Y-113736800D01* -X126530100Y-112508471D01* -X126530100Y-111960458D01* -X126298085Y-111400323D01* -X125869377Y-110971615D01* -X125843670Y-110960967D01* -X125898691Y-110795796D01* -X125006100Y-109903205D01* -X124113509Y-110795796D01* -X124168530Y-110960967D01* -X124142823Y-110971615D01* -X123714115Y-111400323D01* -X123482100Y-111960458D01* -X123482100Y-112566742D01* -X123714115Y-113126877D01* -X124120838Y-113533600D01* -X123714115Y-113940323D01* -X123482100Y-114500458D01* -X123482100Y-115106742D01* -X123714115Y-115666877D01* -X124120838Y-116073600D01* -X123714115Y-116480323D01* -X123482100Y-117040458D01* -X123482100Y-117646742D01* -X123714115Y-118206877D01* -X124142823Y-118635585D01* -X124702958Y-118867600D01* -X125309242Y-118867600D01* -X125686949Y-118711149D01* -X127609686Y-119832746D01* -X127727051Y-119911167D01* -X127834847Y-119932609D01* -X127938758Y-119968401D01* -X128079640Y-119959800D01* -X131015988Y-119959800D01* -X131125830Y-119974515D01* -X131261359Y-119938530D01* -X131398924Y-119911167D01* -X131421677Y-119895964D01* -X131448120Y-119888943D01* -X131559570Y-119803827D01* -X131676183Y-119725908D01* -X131737758Y-119633754D01* -X140625316Y-109545800D01* -X140879719Y-109545800D01* -X141346497Y-109352454D01* -X141703754Y-108995197D01* -X141897100Y-108528419D01* -X141897100Y-108023181D01* -X141703754Y-107556403D01* -X141346497Y-107199146D01* -X140879719Y-107005800D01* -X140754100Y-107005800D01* -X140754100Y-106803981D01* -X140560754Y-106337203D01* -X140203497Y-105979946D01* -X140043324Y-105913600D01* -X154672327Y-105913600D01* -X154776808Y-106438861D01* -X155074344Y-106884156D01* -X155519639Y-107181692D01* -X155912314Y-107259800D01* -X157599886Y-107259800D01* -X157992561Y-107181692D01* -X158437856Y-106884156D01* -X158735392Y-106438861D01* -X158839873Y-105913600D01* -X158735392Y-105388339D01* -X158437856Y-104943044D01* -X157992561Y-104645508D01* -X157599886Y-104567400D01* -X155912314Y-104567400D01* -X155519639Y-104645508D01* -X155074344Y-104943044D01* -X154776808Y-105388339D01* -X154672327Y-105913600D01* -X140043324Y-105913600D01* -X139736719Y-105786600D01* -X139360899Y-105786600D01* -X139500757Y-105608800D01* -X139685919Y-105608800D01* -X140152697Y-105415454D01* -X140509954Y-105058197D01* -X140703300Y-104591419D01* -X140703300Y-104086181D01* -X140509954Y-103619403D01* -X140152697Y-103262146D01* -X139685919Y-103068800D01* -X139180681Y-103068800D01* -X138713903Y-103262146D01* -X138356646Y-103619403D01* -X138163300Y-104086181D01* -X138163300Y-104591419D01* -X138164973Y-104595458D01* -X131889940Y-112572867D01* -X131889940Y-112450800D01* -X131840657Y-112203035D01* -X131700309Y-111992991D01* -X131490265Y-111852643D01* -X131242500Y-111803360D01* -X130319937Y-111803360D01* -X130181087Y-111664510D01* -X130132262Y-111591438D01* -X130065019Y-111429099D01* -X129721720Y-111085800D01* -X130206750Y-111085800D01* -X130365500Y-110927050D01* -X130365500Y-109827800D01* -X130619500Y-109827800D01* -X130619500Y-110927050D01* -X130778250Y-111085800D01* -X131368809Y-111085800D01* -X131602198Y-110989127D01* -X131780827Y-110810499D01* -X131877500Y-110577110D01* -X131877500Y-109986550D01* -X131718750Y-109827800D01* -X130619500Y-109827800D01* -X130365500Y-109827800D01* -X130345500Y-109827800D01* -X130345500Y-109573800D01* -X130365500Y-109573800D01* -X130365500Y-109553800D01* -X130619500Y-109553800D01* -X130619500Y-109573800D01* -X131718750Y-109573800D01* -X131877500Y-109415050D01* -X131877500Y-108824490D01* -X131780827Y-108591101D01* -X131661065Y-108471339D01* -X134175974Y-103743311D01* -X134615497Y-103561254D01* -X134972754Y-103203997D01* -X135166100Y-102737219D01* -X135166100Y-102231981D01* -X134972754Y-101765203D01* -X134615497Y-101407946D01* -X134148719Y-101214600D01* -X133643481Y-101214600D01* -X133176703Y-101407946D01* -X132819446Y-101765203D01* -X132626100Y-102231981D01* -X132626100Y-102737219D01* -X132707630Y-102934050D01* -X130217550Y-107615400D01* -X129028714Y-107615400D01* -X129081100Y-107488930D01* -X129081100Y-106878270D01* -X128847410Y-106314093D01* -X128777117Y-106243800D01* -X129134400Y-106243800D01* -X129722541Y-106000184D01* -X130172684Y-105550041D01* -X130416300Y-104961900D01* -X130416300Y-104325300D01* -X130374121Y-104223470D01* -X134976452Y-98598400D01* -X141423541Y-98598400D01* -X141516100Y-98616811D01* -X141608659Y-98598400D01* -X141882791Y-98543872D01* -X142193657Y-98336157D01* -X142401372Y-98025291D01* -X142413759Y-97963018D01* -X148964858Y-91411919D01* -X148871100Y-91638270D01* -X148871100Y-92248930D01* -X149104790Y-92813107D01* -X149505283Y-93213600D01* -X149104790Y-93614093D01* -X148871100Y-94178270D01* -X148871100Y-94788930D01* -X149104790Y-95353107D01* -X149505283Y-95753600D01* -X149104790Y-96154093D01* -X148871100Y-96718270D01* -X148871100Y-97328930D01* -X149104790Y-97893107D01* -X149536593Y-98324910D01* -X150024045Y-98526819D01* -X149813703Y-98613946D01* -X149456446Y-98971203D01* -X149263100Y-99437981D01* -X149263100Y-99943219D01* -X149456446Y-100409997D01* -X149813703Y-100767254D01* -X150280481Y-100960600D01* -X150713277Y-100960600D01* -X150853446Y-101298997D01* -X151210703Y-101656254D01* -X151677481Y-101849600D01* -X152182719Y-101849600D01* -X152649497Y-101656254D01* -X153006754Y-101298997D01* -X153200100Y-100832219D01* -X153200100Y-100494993D01* -X154764823Y-98930271D01* -X154834807Y-98883509D01* -X155020066Y-98606250D01* -X155041056Y-98500728D01* -X155180770Y-98558600D01* -X155791430Y-98558600D01* -X156355607Y-98324910D01* -X156787410Y-97893107D01* -X157021100Y-97328930D01* -X157021100Y-96718270D01* -X156787410Y-96154093D01* -X156386917Y-95753600D01* -X156787410Y-95353107D01* -X157021100Y-94788930D01* -X157021100Y-94178270D01* -X156787410Y-93614093D01* -X156386917Y-93213600D01* -X156787410Y-92813107D01* -X156960896Y-92394276D01* -X157594300Y-93265208D01* -X157594301Y-96804041D01* -X157575890Y-96896600D01* -X157648829Y-97263292D01* -X157804112Y-97495689D01* -X157804115Y-97495692D01* -X157856544Y-97574157D01* -X157935008Y-97626585D01* -X158566114Y-98257692D01* -X158618543Y-98336157D01* -X158697008Y-98388586D01* -X158697010Y-98388588D01* -X158838968Y-98483441D01* -X158929409Y-98543872D01* -X159203541Y-98598400D01* -X159203546Y-98598400D01* -X159296100Y-98616810D01* -X159388654Y-98598400D01* -X164621823Y-98598400D01* -X164916114Y-98892692D01* -X164968543Y-98971157D01* -X165047008Y-99023586D01* -X165047010Y-99023588D01* -X165188073Y-99117843D01* -X165279409Y-99178872D01* -X165553541Y-99233400D01* -X165553546Y-99233400D01* -X165602640Y-99243165D01* -X165923075Y-99563600D01* -X165559516Y-99927159D01* -X165315900Y-100515300D01* -X165315900Y-101151900D01* -X165559516Y-101740041D01* -X165976300Y-102156825D01* -X165976300Y-102646042D01* -X165976301Y-106853935D01* -X163924410Y-109418800D01* -X162485348Y-109418800D01* -X162312860Y-109413546D01* -X162211124Y-109452101D01* -X162104409Y-109473328D01* -X161960890Y-109569224D01* -X158659325Y-111632703D01* -X158735392Y-111518861D01* -X158839873Y-110993600D01* -X158735392Y-110468339D01* -X158437856Y-110023044D01* -X157992561Y-109725508D01* -X157599886Y-109647400D01* -X155912314Y-109647400D01* -X155519639Y-109725508D01* -X155074344Y-110023044D01* -X154776808Y-110468339D01* -X154672327Y-110993600D01* -X154776808Y-111518861D01* -X155074344Y-111964156D01* -X155519639Y-112261692D01* -X155912314Y-112339800D01* -X157527971Y-112339800D01* -X157121571Y-112593800D01* -X145994917Y-112593800D01* -X145842248Y-112582790D01* -X145720379Y-112623271D01* -X145594409Y-112648328D01* -X145544451Y-112681709D01* -X145487435Y-112700648D01* -X145390323Y-112784694D01* -X145283543Y-112856043D01* -X145198500Y-112983318D01* -X141570105Y-117648400D01* -X141197800Y-117648400D01* -X140609659Y-117892016D01* -X140159516Y-118342159D01* -X139915900Y-118930300D01* -X139915900Y-119566900D01* -X140159516Y-120155041D01* -X140609659Y-120605184D01* -X141197800Y-120848800D01* -X141834400Y-120848800D01* -X142422541Y-120605184D01* -X142872684Y-120155041D01* -X143116300Y-119566900D01* -X143116300Y-118930300D01* -X143059992Y-118794362D01* -X146420740Y-114473400D01* -X150837900Y-114473400D01* -X150837901Y-116492821D01* -X150717135Y-116516843D01* -X150507091Y-116657191D01* -X150366743Y-116867235D01* -X150317460Y-117115000D01* -X150317460Y-117826200D01* -X150366743Y-118073965D01* -X150507091Y-118284009D01* -X150717135Y-118424357D01* -X150964900Y-118473640D01* -X152387300Y-118473640D01* -X152635065Y-118424357D01* -X152845109Y-118284009D01* -X152985457Y-118073965D01* -X153034740Y-117826200D01* -X153034740Y-117115000D01* -X152985457Y-116867235D01* -X152845109Y-116657191D01* -X152635065Y-116516843D01* -X152514300Y-116492822D01* -X152514300Y-114473400D01* -X156552900Y-114473400D01* -X156552901Y-116492821D01* -X156432135Y-116516843D01* -X156222091Y-116657191D01* -X156081743Y-116867235D01* -X156032460Y-117115000D01* -X156032460Y-117826200D01* -X156081743Y-118073965D01* -X156222091Y-118284009D01* -X156432135Y-118424357D01* -X156679900Y-118473640D01* -X158102300Y-118473640D01* -X158350065Y-118424357D01* -X158560109Y-118284009D01* -X158700457Y-118073965D01* -X158749740Y-117826200D01* -X158749740Y-117629350D01* -X170511100Y-117629350D01* -X170511100Y-118319910D01* -X170607773Y-118553299D01* -X170786402Y-118731927D01* -X170995978Y-118818736D01* -X170724455Y-119116676D01* -X170554624Y-119526710D01* -X170675945Y-119756600D01* -X171869100Y-119756600D01* -X171869100Y-117470600D01* -X172123100Y-117470600D01* -X172123100Y-119756600D01* -X174409100Y-119756600D01* -X174409100Y-117470600D01* -X172123100Y-117470600D01* -X171869100Y-117470600D01* -X170669850Y-117470600D01* -X170511100Y-117629350D01* -X158749740Y-117629350D01* -X158749740Y-117115000D01* -X158700457Y-116867235D01* -X158560109Y-116657191D01* -X158350065Y-116516843D01* -X158229300Y-116492822D01* -X158229300Y-116367290D01* -X170511100Y-116367290D01* -X170511100Y-117057850D01* -X170669850Y-117216600D01* -X171869100Y-117216600D01* -X171869100Y-116017350D01* -X172123100Y-116017350D01* -X172123100Y-117216600D01* -X174409100Y-117216600D01* -X174409100Y-116022781D01* -X174179208Y-115902114D01* -X173654742Y-116148417D01* -X173473030Y-116347808D01* -X173384427Y-116133901D01* -X173205798Y-115955273D01* -X172972409Y-115858600D01* -X172281850Y-115858600D01* -X172123100Y-116017350D01* -X171869100Y-116017350D01* -X171710350Y-115858600D01* -X171019791Y-115858600D01* -X170786402Y-115955273D01* -X170607773Y-116133901D01* -X170511100Y-116367290D01* -X158229300Y-116367290D01* -X158229300Y-114117981D01* -X162740631Y-111298400D01* -X164335827Y-111298400D01* -X164481916Y-111310949D01* -X164610484Y-111270189D01* -X164742791Y-111243872D01* -X164787294Y-111214136D01* -X164838311Y-111197962D01* -X164941502Y-111111097D01* -X165053657Y-111036157D01* -X165082092Y-110993600D01* -X169428732Y-110993600D01* -X169537156Y-111538682D01* -X169845920Y-112000780D01* -X170308018Y-112309544D01* -X170715512Y-112390600D01* -X172514688Y-112390600D01* -X172922182Y-112309544D01* -X173384280Y-112000780D01* -X173693044Y-111538682D01* -X173801468Y-110993600D01* -X173693044Y-110448518D01* -X173384280Y-109986420D01* -X172973611Y-109712020D01* -X173029041Y-109695659D01* -X173454730Y-109351626D01* -X173716360Y-108870877D01* -X173731320Y-108796670D01* -X173608820Y-108580600D01* -X171742100Y-108580600D01* -X171742100Y-108600600D01* -X171488100Y-108600600D01* -X171488100Y-108580600D01* -X169621380Y-108580600D01* -X169498880Y-108796670D01* -X169513840Y-108870877D01* -X169775470Y-109351626D01* -X170201159Y-109695659D01* -X170256589Y-109712020D01* -X169845920Y-109986420D01* -X169537156Y-110448518D01* -X169428732Y-110993600D01* -X165082092Y-110993600D01* -X165135127Y-110914229D01* -X167559127Y-107884229D01* -X167593657Y-107861157D01* -X167675125Y-107739231D01* -X167707781Y-107698412D01* -X167726431Y-107662447D01* -X167801372Y-107550291D01* -X167811813Y-107497799D01* -X167836451Y-107450288D01* -X167847995Y-107315901D01* -X167855900Y-107276159D01* -X167855900Y-107223873D01* -X167868449Y-107077784D01* -X167855900Y-107038201D01* -X167855900Y-105913600D01* -X169428732Y-105913600D01* -X169537156Y-106458682D01* -X169845920Y-106920780D01* -X170256589Y-107195180D01* -X170201159Y-107211541D01* -X169775470Y-107555574D01* -X169513840Y-108036323D01* -X169498880Y-108110530D01* -X169621380Y-108326600D01* -X171488100Y-108326600D01* -X171488100Y-108306600D01* -X171742100Y-108306600D01* -X171742100Y-108326600D01* -X173608820Y-108326600D01* -X173731320Y-108110530D01* -X173716360Y-108036323D01* -X173454730Y-107555574D01* -X173029041Y-107211541D01* -X172973611Y-107195180D01* -X173384280Y-106920780D01* -X173693044Y-106458682D01* -X173801468Y-105913600D01* -X173693044Y-105368518D01* -X173384280Y-104906420D01* -X172922182Y-104597656D01* -X172514688Y-104516600D01* -X170715512Y-104516600D01* -X170308018Y-104597656D01* -X169845920Y-104906420D01* -X169537156Y-105368518D01* -X169428732Y-105913600D01* -X167855900Y-105913600D01* -X167855900Y-102156825D01* -X168272684Y-101740041D01* -X168516300Y-101151900D01* -X168516300Y-100683008D01* -X168555547Y-100643761D01* -X168641952Y-100900243D01* -X169215436Y-101110058D01* -X169825560Y-101084439D01* -X170270248Y-100900243D01* -X170356654Y-100643759D01* -X169456100Y-99743205D01* -X169441958Y-99757348D01* -X169262353Y-99577743D01* -X169276495Y-99563600D01* -X169262353Y-99549458D01* -X169441958Y-99369853D01* -X169456100Y-99383995D01* -X170356654Y-98483441D01* -X170292699Y-98293600D01* -X170356654Y-98103759D01* -X169456100Y-97203205D01* -X169441958Y-97217348D01* -X169262353Y-97037743D01* -X169276495Y-97023600D01* -X169262353Y-97009458D01* -X169441958Y-96829853D01* -X169456100Y-96843995D01* -X170356654Y-95943441D01* -X170292699Y-95753600D01* -X170356654Y-95563759D01* -X169456100Y-94663205D01* -X169441958Y-94677348D01* -X169262353Y-94497743D01* -X169276495Y-94483600D01* -X168375941Y-93583046D01* -X168119457Y-93669452D01* -X167909642Y-94242936D01* -X167920213Y-94494688D01* -X167855900Y-94430375D01* -X167855900Y-93023759D01* -X168555546Y-93023759D01* -X168619501Y-93213600D01* -X168555546Y-93403441D01* -X169456100Y-94303995D01* -X170356654Y-93403441D01* -X170292699Y-93213600D01* -X170356654Y-93023759D01* -X169456100Y-92123205D01* -X168555546Y-93023759D01* -X167855900Y-93023759D01* -X167855900Y-91702936D01* -X167909642Y-91702936D01* -X167935261Y-92313060D01* -X168119457Y-92757748D01* -X168375941Y-92844154D01* -X169276495Y-91943600D01* -X168375941Y-91043046D01* -X168119457Y-91129452D01* -X167909642Y-91702936D01* -X167855900Y-91702936D01* -X167855900Y-90863441D01* -X168555546Y-90863441D01* -X169456100Y-91763995D01* -X170356654Y-90863441D01* -X170270248Y-90606957D01* -X169696764Y-90397142D01* -X169086640Y-90422761D01* -X168641952Y-90606957D01* -X168555546Y-90863441D01* -X167855900Y-90863441D01* -X167855900Y-88861153D01* -X167874310Y-88768599D01* -X167855900Y-88676045D01* -X167855900Y-88676041D01* -X167801372Y-88401909D01* -X167699175Y-88248961D01* -X167646087Y-88169509D01* -X167646086Y-88169508D01* -X167593657Y-88091043D01* -X167515192Y-88038614D01* -X166617456Y-87140879D01* -X166615672Y-87131909D01* -X166407957Y-86821043D01* -X166097091Y-86613328D01* -X165822959Y-86558800D01* -X165738654Y-86558800D01* -X165646100Y-86540390D01* -X165553546Y-86558800D01* -X153597386Y-86558800D01* -X153426917Y-86552875D01* -X153323111Y-86591706D01* -X153214409Y-86613328D01* -X153072581Y-86708095D01* -X151791615Y-87501074D01* -X151930100Y-87166742D01* -X151930100Y-86560458D01* -X151698085Y-86000323D01* -X151269377Y-85571615D01* -X150709242Y-85339600D01* -X150102958Y-85339600D01* -X149542823Y-85571615D01* -X149136100Y-85978338D01* -X148729377Y-85571615D01* -X148169242Y-85339600D01* -X147562958Y-85339600D01* -X147002823Y-85571615D01* -X146596100Y-85978338D01* -X146189377Y-85571615D01* -X145629242Y-85339600D01* -X145022958Y-85339600D01* -X144462823Y-85571615D01* -X144056100Y-85978338D01* -X143649377Y-85571615D01* -X143089242Y-85339600D01* -X142482958Y-85339600D01* -X141922823Y-85571615D01* -X141516100Y-85978338D01* -X141109377Y-85571615D01* -X140549242Y-85339600D01* -X139942958Y-85339600D01* -X139382823Y-85571615D01* -X138976100Y-85978338D01* -X138569377Y-85571615D01* -X138009242Y-85339600D01* -X137402958Y-85339600D01* -X136842823Y-85571615D01* -X136436100Y-85978338D01* -X136029377Y-85571615D01* -X135469242Y-85339600D01* -X134862958Y-85339600D01* -X134302823Y-85571615D01* -X133896100Y-85978338D01* -X133489377Y-85571615D01* -X132929242Y-85339600D01* -X132322958Y-85339600D01* -X131762823Y-85571615D01* -X131356100Y-85978338D01* -X130949377Y-85571615D01* -X130389242Y-85339600D01* -X129782958Y-85339600D01* -X129451100Y-85477060D01* -X129451100Y-85446034D01* -X128774389Y-83812310D01* -X128175679Y-83213600D01* -X168801121Y-83213600D01* -X168202411Y-83812310D01* -G36* -X160587181Y-88569099D02* -X160362900Y-89110562D01* -X160362900Y-89696638D01* -X160587181Y-90238101D01* -X161001599Y-90652519D01* -X161052493Y-90673600D01* -X161001599Y-90694681D01* -X160587181Y-91109099D01* -X160362900Y-91650562D01* -X160362900Y-92236638D01* -X160587181Y-92778101D01* -X161001599Y-93192519D01* -X161052493Y-93213600D01* -X161001599Y-93234681D01* -X160587181Y-93649099D01* -X160362900Y-94190562D01* -X160362900Y-94776638D01* -X160587181Y-95318101D01* -X161001599Y-95732519D01* -X161543062Y-95956800D01* -X162129138Y-95956800D01* -X162670601Y-95732519D01* -X163085019Y-95318101D01* -X163106738Y-95265667D01* -X163340687Y-95339408D01* -X164196495Y-94483600D01* -X163340687Y-93627792D01* -X163106738Y-93701533D01* -X163085019Y-93649099D01* -X162670601Y-93234681D01* -X162619707Y-93213600D01* -X162670601Y-93192519D01* -X163085019Y-92778101D01* -X163106100Y-92727207D01* -X163127181Y-92778101D01* -X163541599Y-93192519D01* -X163594033Y-93214238D01* -X163520292Y-93448187D01* -X164376100Y-94303995D01* -X165231908Y-93448187D01* -X165158167Y-93214238D01* -X165210601Y-93192519D01* -X165625019Y-92778101D01* -X165849300Y-92236638D01* -X165849300Y-91650562D01* -X165625019Y-91109099D01* -X165210601Y-90694681D01* -X165159707Y-90673600D01* -X165210601Y-90652519D01* -X165625019Y-90238101D01* -X165849300Y-89696638D01* -X165849300Y-89110562D01* -X165792955Y-88974532D01* -X165976301Y-89157879D01* -X165976300Y-92036158D01* -X165976301Y-92036163D01* -X165976300Y-94430375D01* -X165853957Y-94552718D01* -X165834489Y-94124031D01* -X165661590Y-93706617D01* -X165411513Y-93627792D01* -X164555705Y-94483600D01* -X164569848Y-94497743D01* -X164390243Y-94677348D01* -X164376100Y-94663205D01* -X163520292Y-95519013D01* -X163599117Y-95769090D01* -X164150197Y-95968577D01* -X164735669Y-95941989D01* -X165153083Y-95769090D01* -X165231907Y-95519015D01* -X165315900Y-95603008D01* -X165315900Y-96071900D01* -X165559516Y-96660041D01* -X165923075Y-97023600D01* -X165814126Y-97132549D01* -X165741087Y-97059510D01* -X165688657Y-96981043D01* -X165377791Y-96773328D01* -X165103659Y-96718800D01* -X165103654Y-96718800D01* -X165011100Y-96700390D01* -X164918546Y-96718800D01* -X159685378Y-96718800D01* -X159473900Y-96507323D01* -X159473900Y-93127190D01* -X159480584Y-93109045D01* -X159473900Y-92940964D01* -X159473900Y-92867041D01* -X159470226Y-92848570D01* -X159465728Y-92735464D01* -X159434097Y-92666937D01* -X159419372Y-92592909D01* -X159356483Y-92498789D01* -X159348591Y-92481692D01* -X159305118Y-92421917D01* -X159211657Y-92282043D01* -X159195578Y-92271299D01* -X157273132Y-89627938D01* -X157179657Y-89488043D01* -X157085536Y-89425153D01* -X157002374Y-89348352D01* -X156931550Y-89322262D01* -X156868791Y-89280328D01* -X156757758Y-89258242D01* -X156651544Y-89219116D01* -X156483464Y-89225800D01* -X152576496Y-89225800D01* -X153848451Y-88438400D01* -X160717880Y-88438400D01* -X160587181Y-88569099D01* -X160587181Y-88569099D01* -G37* -X160587181Y-88569099D02* -X160362900Y-89110562D01* -X160362900Y-89696638D01* -X160587181Y-90238101D01* -X161001599Y-90652519D01* -X161052493Y-90673600D01* -X161001599Y-90694681D01* -X160587181Y-91109099D01* -X160362900Y-91650562D01* -X160362900Y-92236638D01* -X160587181Y-92778101D01* -X161001599Y-93192519D01* -X161052493Y-93213600D01* -X161001599Y-93234681D01* -X160587181Y-93649099D01* -X160362900Y-94190562D01* -X160362900Y-94776638D01* -X160587181Y-95318101D01* -X161001599Y-95732519D01* -X161543062Y-95956800D01* -X162129138Y-95956800D01* -X162670601Y-95732519D01* -X163085019Y-95318101D01* -X163106738Y-95265667D01* -X163340687Y-95339408D01* -X164196495Y-94483600D01* -X163340687Y-93627792D01* -X163106738Y-93701533D01* -X163085019Y-93649099D01* -X162670601Y-93234681D01* -X162619707Y-93213600D01* -X162670601Y-93192519D01* -X163085019Y-92778101D01* -X163106100Y-92727207D01* -X163127181Y-92778101D01* -X163541599Y-93192519D01* -X163594033Y-93214238D01* -X163520292Y-93448187D01* -X164376100Y-94303995D01* -X165231908Y-93448187D01* -X165158167Y-93214238D01* -X165210601Y-93192519D01* -X165625019Y-92778101D01* -X165849300Y-92236638D01* -X165849300Y-91650562D01* -X165625019Y-91109099D01* -X165210601Y-90694681D01* -X165159707Y-90673600D01* -X165210601Y-90652519D01* -X165625019Y-90238101D01* -X165849300Y-89696638D01* -X165849300Y-89110562D01* -X165792955Y-88974532D01* -X165976301Y-89157879D01* -X165976300Y-92036158D01* -X165976301Y-92036163D01* -X165976300Y-94430375D01* -X165853957Y-94552718D01* -X165834489Y-94124031D01* -X165661590Y-93706617D01* -X165411513Y-93627792D01* -X164555705Y-94483600D01* -X164569848Y-94497743D01* -X164390243Y-94677348D01* -X164376100Y-94663205D01* -X163520292Y-95519013D01* -X163599117Y-95769090D01* -X164150197Y-95968577D01* -X164735669Y-95941989D01* -X165153083Y-95769090D01* -X165231907Y-95519015D01* -X165315900Y-95603008D01* -X165315900Y-96071900D01* -X165559516Y-96660041D01* -X165923075Y-97023600D01* -X165814126Y-97132549D01* -X165741087Y-97059510D01* -X165688657Y-96981043D01* -X165377791Y-96773328D01* -X165103659Y-96718800D01* -X165103654Y-96718800D01* -X165011100Y-96700390D01* -X164918546Y-96718800D01* -X159685378Y-96718800D01* -X159473900Y-96507323D01* -X159473900Y-93127190D01* -X159480584Y-93109045D01* -X159473900Y-92940964D01* -X159473900Y-92867041D01* -X159470226Y-92848570D01* -X159465728Y-92735464D01* -X159434097Y-92666937D01* -X159419372Y-92592909D01* -X159356483Y-92498789D01* -X159348591Y-92481692D01* -X159305118Y-92421917D01* -X159211657Y-92282043D01* -X159195578Y-92271299D01* -X157273132Y-89627938D01* -X157179657Y-89488043D01* -X157085536Y-89425153D01* -X157002374Y-89348352D01* -X156931550Y-89322262D01* -X156868791Y-89280328D01* -X156757758Y-89258242D01* -X156651544Y-89219116D01* -X156483464Y-89225800D01* -X152576496Y-89225800D01* -X153848451Y-88438400D01* -X160717880Y-88438400D01* -X160587181Y-88569099D01* -G04 #@! TD* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-eagle-import.dcm b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-eagle-import.dcm deleted file mode 100644 index 5dd71cb..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d-eagle-import.dcm +++ /dev/null @@ -1,3 +0,0 @@ -EESchema-DOCLIB Version 2.0 -# -#End Doc Library diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.kicad_pcb b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.kicad_pcb deleted file mode 100644 index fc9a777..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.kicad_pcb +++ /dev/null @@ -1,4096 +0,0 @@ -(kicad_pcb (version 20171130) (host pcbnew "(5.0.2)-1") - - (general - (thickness 1.6) - (drawings 119) - (tracks 556) - (zones 0) - (modules 62) - (nets 46) - ) - - (page A4) - (title_block - (title "M644/M1284 breakout board") - (date 2019-04-02) - (rev v1.2d) - (company "(c) Ibragimov M. Russia Togliatty") - ) - - (layers - (0 Top signal) - (31 Bottom signal) - (32 B.Adhes user) - (33 F.Adhes user) - (34 B.Paste user) - (35 F.Paste user) - (36 B.SilkS user) - (37 F.SilkS user) - (38 B.Mask user) - (39 F.Mask user) - (40 Dwgs.User user) - (41 Cmts.User user) - (42 Eco1.User user) - (43 Eco2.User user) - (44 Edge.Cuts user) - (45 Margin user) - (46 B.CrtYd user) - (47 F.CrtYd user) - (48 B.Fab user) - (49 F.Fab user) - ) - - (setup - (last_trace_width 1.016) - (user_trace_width 0.4064) - (user_trace_width 0.6096) - (user_trace_width 1.016) - (trace_clearance 0.1524) - (zone_clearance 0.508) - (zone_45_only no) - (trace_min 0.2) - (segment_width 0.2) - (edge_width 0.15) - (via_size 0.8) - (via_drill 0.4) - (via_min_size 0.4) - (via_min_drill 0.3) - (uvia_size 0.3) - (uvia_drill 0.1) - (uvias_allowed no) - (uvia_min_size 0.2) - (uvia_min_drill 0.1) - (pcb_text_width 0.3) - (pcb_text_size 1.5 1.5) - (mod_edge_width 0.15) - (mod_text_size 1 1) - (mod_text_width 0.15) - (pad_size 1.8 2.2) - (pad_drill 0) - (pad_to_mask_clearance 0.051) - (solder_mask_min_width 0.25) - (aux_axis_origin 0 0) - (grid_origin 130.0861 124.9636) - (visible_elements 7FFFFFFF) - (pcbplotparams - (layerselection 0x010f0_ffffffff) - (usegerberextensions false) - (usegerberattributes false) - (usegerberadvancedattributes false) - (creategerberjobfile false) - (excludeedgelayer true) - (linewidth 0.100000) - (plotframeref false) - (viasonmask false) - (mode 1) - (useauxorigin false) - (hpglpennumber 1) - (hpglpenspeed 20) - (hpglpendiameter 15.000000) - (psnegative false) - (psa4output false) - (plotreference true) - (plotvalue true) - (plotinvisibletext false) - (padsonsilk true) - (subtractmaskfromsilk false) - (outputformat 1) - (mirror false) - (drillshape 0) - (scaleselection 1) - (outputdirectory "M644_breakout_v1.2d-a_factory_gerbers/")) - ) - - (net 0 "") - (net 1 GND) - (net 2 VCC) - (net 3 /PB4) - (net 4 /PB3) - (net 5 /PB2) - (net 6 /PB1) - (net 7 /PB0) - (net 8 /PA0) - (net 9 /PA1) - (net 10 /PA2) - (net 11 /PA3) - (net 12 /PA4) - (net 13 /PA5) - (net 14 /PA6) - (net 15 /PA7) - (net 16 /AREF) - (net 17 "Net-(C11-PadP$1)") - (net 18 /PC7) - (net 19 /PC6) - (net 20 /PC5) - (net 21 /PC4) - (net 22 /PC3) - (net 23 /PC2) - (net 24 /PC1) - (net 25 /PC0) - (net 26 /PD7) - (net 27 /PD6) - (net 28 /PD5) - (net 29 /PD4) - (net 30 /PD3) - (net 31 /PD2) - (net 32 /PD1) - (net 33 /PD0) - (net 34 "Net-(C2-PadP$1)") - (net 35 "Net-(C1-PadP$1)") - (net 36 /RESET) - (net 37 /SCK) - (net 38 /MISO) - (net 39 /MOSI) - (net 40 "Net-(C4-PadP$1)") - (net 41 "Net-(LED1-PadA)") - (net 42 /PD3') - (net 43 /PD1') - (net 44 "Net-(D1-PadA)") - (net 45 "Net-(R3-PadP$1)") - - (net_class Default "This is the default net class." - (clearance 0.1524) - (trace_width 0.25) - (via_dia 0.8) - (via_drill 0.4) - (uvia_dia 0.3) - (uvia_drill 0.1) - (add_net /AREF) - (add_net /MISO) - (add_net /MOSI) - (add_net /PA0) - (add_net /PA1) - (add_net /PA2) - (add_net /PA3) - (add_net /PA4) - (add_net /PA5) - (add_net /PA6) - (add_net /PA7) - (add_net /PB0) - (add_net /PB1) - (add_net /PB2) - (add_net /PB3) - (add_net /PB4) - (add_net /PC0) - (add_net /PC1) - (add_net /PC2) - (add_net /PC3) - (add_net /PC4) - (add_net /PC5) - (add_net /PC6) - (add_net /PC7) - (add_net /PD0) - (add_net /PD1) - (add_net /PD1') - (add_net /PD2) - (add_net /PD3) - (add_net /PD3') - (add_net /PD4) - (add_net /PD5) - (add_net /PD6) - (add_net /PD7) - (add_net /RESET) - (add_net /SCK) - (add_net GND) - (add_net "Net-(C1-PadP$1)") - (add_net "Net-(C11-PadP$1)") - (add_net "Net-(C2-PadP$1)") - (add_net "Net-(C4-PadP$1)") - (add_net "Net-(D1-PadA)") - (add_net "Net-(LED1-PadA)") - (add_net "Net-(R3-PadP$1)") - (add_net VCC) - ) - - (module M644_breakout_v1.2d:SMBJ (layer Bottom) (tedit 5C814E5A) (tstamp 5C811BDF) - (at 165.6461 124.9636) - (descr "DO-214AA Modified J_BEND

\nSource: www.rsonline.de .. SMBJ12/C/15/C/24/C/30/C/5.0/C/7.5/C Voltage Suppressor. Data Sheet") - (path /76CA823F) - (fp_text reference D3 (at 2.794 -0.5036) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value SM6T15CA (at -1.905 -3.81) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 2.25 -1.1) (xy 2.8 -1.1) (xy 2.8 1.1) (xy 2.25 1.1)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.8 -1.1) (xy -2.25 -1.1) (xy -2.25 1.1) (xy -2.8 1.1)) (layer B.Fab) (width 0)) - (fp_line (start -2.24 1.92) (end 2.24 1.92) (layer B.SilkS) (width 0.1016)) - (fp_line (start -2.24 -1.92) (end -2.24 1.92) (layer B.Fab) (width 0.1016)) - (fp_line (start 2.24 -1.92) (end -2.24 -1.92) (layer B.SilkS) (width 0.1016)) - (fp_line (start 2.24 1.92) (end 2.24 -1.92) (layer B.Fab) (width 0.1016)) - (pad A smd rect (at 2.04 0 180) (size 1.78 2.16) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad C smd rect (at -2.03 0) (size 1.78 2.16) (layers Bottom B.Paste B.Mask) - (net 44 "Net-(D1-PadA)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_SMB.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:DO214AA (layer Bottom) (tedit 5CAC8FE6) (tstamp 5C811C44) - (at 161.0741 121.1536 270) - (descr DIODE) - (path /C7EBFCBF) - (fp_text reference D1 (at 5.8464 0.4191 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value SM4007 (at -2.64 -2.706 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top mirror)) - ) - (fp_poly (pts (xy -1.4 -1.05) (xy -1.1 -1.05) (xy -1.1 1.05) (xy -1.4 1.05)) (layer B.SilkS) (width 0)) - (fp_poly (pts (xy 2.5 -0.7) (xy 2.75 -0.7) (xy 2.75 0.65) (xy 2.5 0.65)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.75 -0.7) (xy -2.5 -0.7) (xy -2.5 0.65) (xy -2.75 0.65)) (layer B.Fab) (width 0)) - (fp_line (start 0.05 -0.7) (end -1.2 0) (layer B.SilkS) (width 0.254)) - (fp_line (start 0.05 0.7) (end 0.05 -0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -1.2 0) (end 0.05 0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -2.4 -1.1) (end -2.4 1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 -1.1) (end -2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 1.1) (end 2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start -2.4 1.1) (end 2.4 1.1) (layer B.Fab) (width 0.254)) - (pad A smd rect (at 2.55 0 270) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 44 "Net-(D1-PadA)") (solder_mask_margin 0.0508)) - (pad C smd rect (at -2.55 0 270) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 40 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_MELF.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:D_7343-31R (layer Bottom) (tedit 5C814E3B) (tstamp 5C811BEA) - (at 164.8587 104.5928 90) - (descr "Chip Capacitor Type KEMET D / EIA 7343-21

\nKEMET V / EIA 7343-20, KEMET X / EIA 7343-43 Reflow solder") - (path /FFB33241) - (fp_text reference C12 (at -6.5322 1.5113 180) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 100uF (at -3.65 -3.575 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 2.675 -2.125) (xy 3.15 -2.125) (xy 3.15 2.125) (xy 2.675 2.125)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3.5 -1.2) (xy 3.65 -1.2) (xy 3.65 1.2) (xy 3.5 1.2)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -3.65 -1.2) (xy -3.5 -1.2) (xy -3.5 1.2) (xy -3.65 1.2)) (layer B.Fab) (width 0)) - (fp_line (start -3.45 -2.1) (end -3.45 2.1) (layer B.Fab) (width 0.1016)) - (fp_line (start 3.45 -2.1) (end -3.45 -2.1) (layer B.Fab) (width 0.1016)) - (fp_line (start 3.45 2.1) (end 3.45 -2.1) (layer B.Fab) (width 0.1016)) - (fp_line (start -3.45 2.1) (end 3.45 2.1) (layer B.Fab) (width 0.1016)) - (pad - smd rect (at -3.175 0 90) (size 2.55 2.7) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad + smd rect (at 3.175 0 90) (size 2.55 2.7) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_Tantalum_SMD.3dshapes/CP_EIA-7343-31_Kemet-D.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:CHIPLED_1206 (layer Top) (tedit 5C8136C2) (tstamp 5C811DE2) - (at 130.4925 111.4508) - (descr "CHIPLED

\nSource: http://www.osram.convergy.de/ ... LG_LY N971.pdf") - (path /DD7CFDEC) - (fp_text reference LED1_SMD1 (at -1.27 1.27 90) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_text value LED_RED/PC4/20 (at 2.54 1.27 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.175 0) (xy 0.175 0) (xy 0.175 -0.35) (xy -0.175 -0.35)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy 0.525 -0.35) (xy 0.85 -0.35) (xy 0.85 -0.775) (xy 0.525 -0.775)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -0.85 -0.35) (xy -0.525 -0.35) (xy -0.525 -0.775) (xy -0.85 -0.775)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -0.85 1.65) (xy 0.85 1.65) (xy 0.85 0.95) (xy -0.85 0.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -0.95) (xy 0.85 -0.95) (xy 0.85 -1.25) (xy -0.85 -1.25)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.25 -1.225) (xy 0.85 -1.225) (xy 0.85 -1.35) (xy 0.25 -1.35)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.35 -1.3) (xy 0.85 -1.3) (xy 0.85 -1.65) (xy 0.35 -1.65)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.65 -1.225) (xy -0.225 -1.225) (xy -0.225 -1.35) (xy -0.65 -1.35)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.45 -1.225) (xy -0.325 -1.225) (xy -0.325 -1.45) (xy -0.45 -1.45)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -1.225) (xy -0.625 -1.225) (xy -0.625 -1.55) (xy -0.85 -1.55)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -1.525) (xy -0.35 -1.525) (xy -0.35 -1.65) (xy -0.85 -1.65)) (layer F.Fab) (width 0)) - (fp_circle (center -0.55 -1.425) (end -0.45 -1.425) (layer F.Fab) (width 0.1016)) - (fp_line (start 0.8 -0.95) (end 0.8 0.95) (layer F.Fab) (width 0.1016)) - (fp_line (start -0.8 0.95) (end -0.8 -0.95) (layer F.Fab) (width 0.1016)) - (fp_arc (start 0 -1.625799) (end -0.4 -1.6) (angle -172.619069) (layer F.Fab) (width 0.1016)) - (pad A smd rect (at 0 1.75) (size 1.5 1.5) (layers Top F.Paste F.Mask) - (net 41 "Net-(LED1-PadA)") (solder_mask_margin 0.0508)) - (pad C smd rect (at 0 -1.75) (size 1.5 1.5) (layers Top F.Paste F.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/LED_SMD.3dshapes/LED_1206_3216Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:L3216C (layer Bottom) (tedit 5C814DB8) (tstamp 5C811AEE) - (at 131.1021 106.2946 270) - (descr "INDUCTOR

\nchip") - (path /EA05AC24) - (fp_text reference L2 (at -1.5196 2.1971 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 10uH (at -1.524 -2.413 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy -0.4001 -0.5999) (xy 0.4001 -0.5999) (xy 0.4001 0.5999) (xy -0.4001 0.5999)) (layer B.Adhes) (width 0)) - (fp_poly (pts (xy 1.2446 -0.9525) (xy 1.7447 -0.9525) (xy 1.7447 0.9474) (xy 1.2446 0.9474)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.7526 -0.9525) (xy -1.2525 -0.9525) (xy -1.2525 0.9474) (xy -1.7526 0.9474)) (layer B.Fab) (width 0)) - (fp_line (start -0.762 -0.883) (end 0.762 -0.883) (layer B.SilkS) (width 0.1016)) - (fp_line (start -0.762 0.896) (end 0.762 0.896) (layer B.SilkS) (width 0.1016)) - (fp_line (start 2.473 1.483) (end 2.473 -1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.27 -0.883) (end 1.27 -0.883) (layer B.Fab) (width 0.1016)) - (fp_line (start -1.27 0.896) (end 1.27 0.896) (layer B.Fab) (width 0.1016)) - (fp_line (start -2.473 -1.483) (end -2.473 1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 2.473 -1.483) (end -2.473 -1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -2.473 1.483) (end 2.473 1.483) (layer Dwgs.User) (width 0.0508)) - (pad 2 smd rect (at 1.5 0 270) (size 1.2 1.6) (layers Bottom B.Paste B.Mask) - (net 17 "Net-(C11-PadP$1)") (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -1.5 0 270) (size 1.2 1.6) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Inductor_SMD.3dshapes/L_1206_3216Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:SW_TACT_SMALL (layer Top) (tedit 5C81489F) (tstamp 5C811C71) - (at 132.6261 91.9436 180) - (path /21BF7E4D) - (fp_text reference SW1/PC5 (at -3.04 -2.9825) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value SMD_TACT_4x4 (at 0 0 180) (layer F.SilkS) hide - (effects (font (size 1.27 1.27) (thickness 0.15)) (justify right top)) - ) - (fp_poly (pts (xy 1.3003 2.1) (xy 3.3 2.1) (xy 3.3 1.6) (xy 1.8003 1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.3003 -2.1) (xy -3.3 -2.1) (xy -3.3 -1.6) (xy -1.8003 -1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.3003 2.1) (xy -3.3 2.1) (xy -3.3 1.6) (xy -1.8003 1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.3003 -2.1) (xy 3.3 -2.1) (xy 3.3 -1.6) (xy 1.8003 -1.6)) (layer F.Fab) (width 0)) - (fp_circle (center 0 0) (end 0.865 0) (layer F.SilkS) (width 0.0762)) - (fp_circle (center 0 0) (end 1 0) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.645 0.9958) (end 0.9958 1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.645 -0.9958) (end 1.645 0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start -0.9958 1.645) (end -1.645 0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start 0.9958 1.645) (end -0.9958 1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.645 -0.9958) (end -0.9958 -1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.645 0.9958) (end -1.645 -0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start 0.9958 -1.645) (end 1.645 -0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start -0.9958 -1.645) (end 0.9958 -1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.812 1.065) (end 1.065 1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.812 -1.065) (end 1.812 1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.065 1.812) (end -1.812 1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.065 1.812) (end -1.065 1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.812 -1.065) (end -1.065 -1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.812 1.065) (end -1.812 -1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.065 -1.812) (end 1.812 -1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.065 -1.812) (end 1.065 -1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start 2.5 1.1335) (end 2.181 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.5 -1.1335) (end 2.5 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.1335) (end 2.5 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.1335) (end 2.182 1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.2183) (end 2.182 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.5 -1.1335) (end -2.181 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.5 1.1335) (end -2.5 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.1335) (end -2.5 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.1335) (end -2.182 -1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.2183) (end -2.182 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 2.5) (end -1.1335 2.181) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.5) (end -1.1335 2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.182) (end 1.1335 2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.182) (end -1.2183 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.2183 2.182) (end 1.1335 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 -2.5) (end 1.1335 -2.181) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.5) (end 1.1335 -2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.182) (end -1.1335 -2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 -1.2183) (end -1.2183 -2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.2183 2.182) (end -2.182 1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 1.2183) (end 1.2183 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.2183 -2.182) (end 2.182 -1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.182) (end 1.2183 -2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.2183 -2.182) (end -1.1335 -2.182) (layer F.SilkS) (width 0.1524)) - (pad 4 smd rect (at 3.15 1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 3 smd rect (at -3.15 1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 2 smd rect (at 3.15 -1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 45 "Net-(R3-PadP$1)") (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -3.15 -1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 45 "Net-(R3-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Button_Switch_SMD.3dshapes/SW_SPST_TL3342.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:TO220V (layer Top) (tedit 5C81480A) (tstamp 5C811A9B) - (at 169.0751 108.4536 90) - (descr "TO 200 vertical") - (path /BC34DC86) - (fp_text reference IC2 (at -2.286 5.969 90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 78TV (at -5.08 7.62 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_poly (pts (xy 1.651 1.27) (xy 3.429 1.27) (xy 3.429 0.762) (xy 1.651 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.889 1.27) (xy 0.889 1.27) (xy 0.889 0.762) (xy -0.889 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.429 1.27) (xy 5.334 1.27) (xy 5.334 0.762) (xy 3.429 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy 0.889 1.27) (xy 1.651 1.27) (xy 1.651 0.762) (xy 0.889 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -3.429 1.27) (xy -1.651 1.27) (xy -1.651 0.762) (xy -3.429 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.651 1.27) (xy -0.889 1.27) (xy -0.889 0.762) (xy -1.651 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -5.334 1.27) (xy -3.429 1.27) (xy -3.429 0.762) (xy -5.334 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -5.334 0.762) (xy 5.334 0.762) (xy 5.334 0) (xy -5.334 0)) (layer F.SilkS) (width 0)) - (fp_text user 3 (at 1.905 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 2 (at -0.635 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 1 (at -3.175 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_circle (center -4.4958 3.7084) (end -4.2418 3.7084) (layer F.SilkS) (width 0.127)) - (fp_line (start -4.953 4.064) (end -5.08 1.143) (layer F.SilkS) (width 0.127)) - (fp_line (start -4.953 4.064) (end -4.699 4.318) (layer F.SilkS) (width 0.127)) - (fp_line (start 4.699 4.318) (end -4.699 4.318) (layer F.SilkS) (width 0.127)) - (fp_line (start 4.699 4.318) (end 4.953 4.064) (layer F.SilkS) (width 0.127)) - (fp_line (start 5.08 1.143) (end 4.953 4.064) (layer F.SilkS) (width 0.127)) - (pad 3 thru_hole oval (at 2.54 2.54 180) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 2 thru_hole oval (at 0 2.54 180) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 1 thru_hole oval (at -2.54 2.54 180) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (net 40 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Package_TO_SOT_THT.3dshapes/TO-220-3_Horizontal_TabDown.wrl - (offset (xyz -2.5 -2.5 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:ML6 (layer Top) (tedit 5CA3AA4B) (tstamp 5C811A62) - (at 163.1061 91.9436 270) - (descr HARTING) - (path /03BB57A4) - (fp_text reference SV1 (at -5.5836 9.4361) (layer F.SilkS) - (effects (font (size 1.6891 1.6891) (thickness 0.3)) (justify left bottom)) - ) - (fp_text value ISP_6PIN (at 0.635 -5.08) (layer F.Fab) - (effects (font (size 1.6891 1.6891) (thickness 0.16891)) (justify left bottom)) - ) - (fp_poly (pts (xy 2.286 1.524) (xy 2.794 1.524) (xy 2.794 1.016) (xy 2.286 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 1.524) (xy -2.286 1.524) (xy -2.286 1.016) (xy -2.794 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 1.524) (xy 0.254 1.524) (xy 0.254 1.016) (xy -0.254 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 -1.016) (xy 2.794 -1.016) (xy 2.794 -1.524) (xy 2.286 -1.524)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 -1.016) (xy -2.286 -1.016) (xy -2.286 -1.524) (xy -2.794 -1.524)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 -1.016) (xy 0.254 -1.016) (xy 0.254 -1.524) (xy -0.254 -1.524)) (layer F.Fab) (width 0)) - (fp_text user 6 (at -0.381 4.064 270) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 2 (at -5.08 -0.635 270) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 1 (at -5.08 1.905 270) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_line (start -3.81 4.445) (end -7.62 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.81 4.445) (end -3.81 4.318) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 4.318) (end -3.81 4.318) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 4.318) (end -2.54 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 4.445) (end -2.54 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.429) (end -2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.604 3.429) (end -2.032 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start -6.604 -3.429) (end -6.604 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 6.604 -3.429) (end -6.604 -3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 6.604 3.429) (end 6.604 -3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 2.032 3.429) (end 6.604 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 2.032 3.429) (end 2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 3.175) (end 2.032 3.429) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 3.175) (end 2.032 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 4.445) (end -2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 4.445) (end 2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.445) (end -0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.699) (end -5.08 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -4.699) (end -6.35 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.699) (end -6.35 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -4.699) (end -0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.445) (end 5.08 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.699) (end 0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.699) (end -0.635 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.445) (end 7.62 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -4.445) (end 5.08 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.699) (end 5.08 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.445) (end 6.35 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -2.032 3.429) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -6.35 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -2.032 2.413) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 2.413) (end -2.032 2.413) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 2.413) (end 2.032 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -4.445) (end -7.62 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 4.445) (end 7.62 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -4.445) (end -6.35 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -3.175) (end -6.35 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 3.175) (end 6.35 -3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -3.175) (end 6.35 -3.175) (layer F.SilkS) (width 0.1524)) - (pad 6 thru_hole circle (at 2.54 -1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 2.54 1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 36 /RESET) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at 0 -1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 39 /MOSI) (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at 0 1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 37 /SCK) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -2.54 -1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -2.54 1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 38 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_IDC.3dshapes/IDC-Header_2x03_P2.54mm_Vertical.wrl - (offset (xyz -2.5 -1.5 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 -90)) - ) - ) - - (module M644_breakout_v1.2d:1X12 (layer Top) (tedit 5C8136DB) (tstamp 5C811B39) - (at 144.0561 124.9636 180) - (descr "PIN HEADER") - (path /B09918B6) - (fp_text reference JP3 (at -15.3162 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x12 (at -15.24 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy 13.716 0.254) (xy 14.224 0.254) (xy 14.224 -0.254) (xy 13.716 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -14.224 0.254) (xy -13.716 0.254) (xy -13.716 -0.254) (xy -14.224 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -11.684 0.254) (xy -11.176 0.254) (xy -11.176 -0.254) (xy -11.684 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -9.144 0.254) (xy -8.636 0.254) (xy -8.636 -0.254) (xy -9.144 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.604 0.254) (xy -6.096 0.254) (xy -6.096 -0.254) (xy -6.604 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -4.064 0.254) (xy -3.556 0.254) (xy -3.556 -0.254) (xy -4.064 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.524 0.254) (xy -1.016 0.254) (xy -1.016 -0.254) (xy -1.524 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.016 0.254) (xy 1.524 0.254) (xy 1.524 -0.254) (xy 1.016 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.556 0.254) (xy 4.064 0.254) (xy 4.064 -0.254) (xy 3.556 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 6.096 0.254) (xy 6.604 0.254) (xy 6.604 -0.254) (xy 6.096 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 8.636 0.254) (xy 9.144 0.254) (xy 9.144 -0.254) (xy 8.636 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 11.176 0.254) (xy 11.684 0.254) (xy 11.684 -0.254) (xy 11.176 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 13.335 1.27) (end 12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 14.605 1.27) (end 13.335 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 15.24 0.635) (end 14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 15.24 -0.635) (end 15.24 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 14.605 -1.27) (end 15.24 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 13.335 -1.27) (end 14.605 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 -0.635) (end 13.335 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -13.335 1.27) (end -14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -15.24 0.635) (end -14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -14.605 -1.27) (end -15.24 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -15.24 -0.635) (end -15.24 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.065 1.27) (end -12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.795 1.27) (end -12.065 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 0.635) (end -10.795 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 -0.635) (end -10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.795 -1.27) (end -10.16 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.065 -1.27) (end -10.795 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 -0.635) (end -12.065 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 0.635) (end -13.335 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 -0.635) (end -12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -13.335 -1.27) (end -12.7 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -14.605 -1.27) (end -13.335 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.715 1.27) (end -6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 0.635) (end -6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.985 -1.27) (end -7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -9.525 1.27) (end -10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -8.255 1.27) (end -9.525 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 0.635) (end -8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -0.635) (end -7.62 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -8.255 -1.27) (end -7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -9.525 -1.27) (end -8.255 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 -0.635) (end -9.525 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.445 1.27) (end -5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.175 1.27) (end -4.445 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 0.635) (end -3.175 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 -0.635) (end -2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.175 -1.27) (end -2.54 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.445 -1.27) (end -3.175 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -0.635) (end -4.445 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 0.635) (end -5.715 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -0.635) (end -5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.715 -1.27) (end -5.08 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.985 -1.27) (end -5.715 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.905 1.27) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 0 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.905 1.27) (end -2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 1.27) (end -1.905 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 -0.635) (end 0 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.905 -1.27) (end -0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 -0.635) (end -1.905 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.175 1.27) (end 2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.445 1.27) (end 3.175 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 0.635) (end 4.445 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -0.635) (end 5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.445 -1.27) (end 5.08 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.175 -1.27) (end 4.445 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 -0.635) (end 3.175 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 0.635) (end 1.905 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 -0.635) (end 2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.905 -1.27) (end 2.54 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.905 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 9.525 1.27) (end 8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 0.635) (end 8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 8.255 -1.27) (end 7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.715 1.27) (end 5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.985 1.27) (end 5.715 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 0.635) (end 6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 -0.635) (end 7.62 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.985 -1.27) (end 7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.715 -1.27) (end 6.985 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -0.635) (end 5.715 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.795 1.27) (end 10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.065 1.27) (end 10.795 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 0.635) (end 12.065 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 -0.635) (end 12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.065 -1.27) (end 12.7 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.795 -1.27) (end 12.065 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 -0.635) (end 10.795 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 0.635) (end 9.525 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 -0.635) (end 10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 9.525 -1.27) (end 10.16 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 8.255 -1.27) (end 9.525 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 12 thru_hole circle (at 13.97 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 22 /PC3) (solder_mask_margin 0.0508)) - (pad 11 thru_hole circle (at 11.43 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 23 /PC2) (solder_mask_margin 0.0508)) - (pad 10 thru_hole circle (at 8.89 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 24 /PC1) (solder_mask_margin 0.0508)) - (pad 9 thru_hole circle (at 6.35 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 25 /PC0) (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 3.81 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 26 /PD7) (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 1.27 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 27 /PD6) (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at -1.27 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 28 /PD5) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at -3.81 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 29 /PD4) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -6.35 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 42 /PD3') (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -8.89 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 31 /PD2) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -11.43 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 43 /PD1') (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -13.97 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 33 /PD0) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x12_P2.54mm_Vertical.wrl - (offset (xyz 14 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:TQFP44 (layer Bottom) (tedit 5C814DE3) (tstamp 5C8119C4) - (at 142.7861 105.9136 180) - (descr "Thin Plasic Quad Flat Package") - (path /0232E636) - (fp_text reference IC1 (at -5.1689 6.985) (layer B.SilkS) - (effects (font (size 1.6891 1.6891) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value ATMEGA16/32/644/1284 (at -4.445 -8.7551) (layer B.Fab) - (effects (font (size 1.35128 1.35128) (thickness 0.108102)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -4.1999 4.95) (xy -3.8001 4.95) (xy -3.8001 6.1001) (xy -4.1999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -3.4 4.95) (xy -3 4.95) (xy -3 6.1001) (xy -3.4 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.5999 4.95) (xy -2.1999 4.95) (xy -2.1999 6.1001) (xy -2.5999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.8001 4.95) (xy -1.4 4.95) (xy -1.4 6.1001) (xy -1.8001 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1 4.95) (xy -0.5999 4.95) (xy -0.5999 6.1001) (xy -1 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -0.1999 4.95) (xy 0.1999 4.95) (xy 0.1999 6.1001) (xy -0.1999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.5999 4.95) (xy 1 4.95) (xy 1 6.1001) (xy 0.5999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 1.4 4.95) (xy 1.8001 4.95) (xy 1.8001 6.1001) (xy 1.4 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 2.1999 4.95) (xy 2.5999 4.95) (xy 2.5999 6.1001) (xy 2.1999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3 4.95) (xy 3.4 4.95) (xy 3.4 6.1001) (xy 3 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3.8001 4.95) (xy 4.1999 4.95) (xy 4.1999 6.1001) (xy 3.8001 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 3.8001) (xy 6.1001 3.8001) (xy 6.1001 4.1999) (xy 4.95 4.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 3) (xy 6.1001 3) (xy 6.1001 3.4) (xy 4.95 3.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 2.1999) (xy 6.1001 2.1999) (xy 6.1001 2.5999) (xy 4.95 2.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 1.4) (xy 6.1001 1.4) (xy 6.1001 1.8001) (xy 4.95 1.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 0.5999) (xy 6.1001 0.5999) (xy 6.1001 1) (xy 4.95 1)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -0.1999) (xy 6.1001 -0.1999) (xy 6.1001 0.1999) (xy 4.95 0.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -1) (xy 6.1001 -1) (xy 6.1001 -0.5999) (xy 4.95 -0.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -1.8001) (xy 6.1001 -1.8001) (xy 6.1001 -1.4) (xy 4.95 -1.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -2.5999) (xy 6.1001 -2.5999) (xy 6.1001 -2.1999) (xy 4.95 -2.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -3.4) (xy 6.1001 -3.4) (xy 6.1001 -3) (xy 4.95 -3)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -4.1999) (xy 6.1001 -4.1999) (xy 6.1001 -3.8001) (xy 4.95 -3.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3.8001 -6.1001) (xy 4.1999 -6.1001) (xy 4.1999 -4.95) (xy 3.8001 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3 -6.1001) (xy 3.4 -6.1001) (xy 3.4 -4.95) (xy 3 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 2.1999 -6.1001) (xy 2.5999 -6.1001) (xy 2.5999 -4.95) (xy 2.1999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 1.4 -6.1001) (xy 1.8001 -6.1001) (xy 1.8001 -4.95) (xy 1.4 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.5999 -6.1001) (xy 1 -6.1001) (xy 1 -4.95) (xy 0.5999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -0.1999 -6.1001) (xy 0.1999 -6.1001) (xy 0.1999 -4.95) (xy -0.1999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1 -6.1001) (xy -0.5999 -6.1001) (xy -0.5999 -4.95) (xy -1 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.8001 -6.1001) (xy -1.4 -6.1001) (xy -1.4 -4.95) (xy -1.8001 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.5999 -6.1001) (xy -2.1999 -6.1001) (xy -2.1999 -4.95) (xy -2.5999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -3.4 -6.1001) (xy -3 -6.1001) (xy -3 -4.95) (xy -3.4 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -4.1999 -6.1001) (xy -3.8001 -6.1001) (xy -3.8001 -4.95) (xy -4.1999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -4.1999) (xy -4.95 -4.1999) (xy -4.95 -3.8001) (xy -6.1001 -3.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -3.4) (xy -4.95 -3.4) (xy -4.95 -3) (xy -6.1001 -3)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -2.5999) (xy -4.95 -2.5999) (xy -4.95 -2.1999) (xy -6.1001 -2.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -1.8001) (xy -4.95 -1.8001) (xy -4.95 -1.4) (xy -6.1001 -1.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -1) (xy -4.95 -1) (xy -4.95 -0.5999) (xy -6.1001 -0.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -0.1999) (xy -4.95 -0.1999) (xy -4.95 0.1999) (xy -6.1001 0.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 0.5999) (xy -4.95 0.5999) (xy -4.95 1) (xy -6.1001 1)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 1.4) (xy -4.95 1.4) (xy -4.95 1.8001) (xy -6.1001 1.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 2.1999) (xy -4.95 2.1999) (xy -4.95 2.5999) (xy -6.1001 2.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 3) (xy -4.95 3) (xy -4.95 3.4) (xy -6.1001 3.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 3.8001) (xy -4.95 3.8001) (xy -4.95 4.1999) (xy -6.1001 4.1999)) (layer B.Fab) (width 0)) - (fp_circle (center -4 4) (end -3.7173 4) (layer B.SilkS) (width 0.254)) - (fp_line (start -4.8 -4.4) (end -4.8 4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start -4.4 -4.8) (end -4.8 -4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.4 -4.8) (end -4.4 -4.8) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.8 -4.4) (end 4.4 -4.8) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.8 4.4) (end 4.8 -4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.4 4.8) (end 4.8 4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start -4.4 4.8) (end 4.4 4.8) (layer B.SilkS) (width 0.2032)) - (fp_line (start -4.8 4.4) (end -4.4 4.8) (layer B.SilkS) (width 0.2032)) - (pad 44 smd rect (at -4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 3 /PB4) (solder_mask_margin 0.0508)) - (pad 43 smd rect (at -3.2 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 4 /PB3) (solder_mask_margin 0.0508)) - (pad 42 smd rect (at -2.4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 5 /PB2) (solder_mask_margin 0.0508)) - (pad 41 smd rect (at -1.6 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 6 /PB1) (solder_mask_margin 0.0508)) - (pad 40 smd rect (at -0.8 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 7 /PB0) (solder_mask_margin 0.0508)) - (pad 39 smd rect (at 0 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 38 smd rect (at 0.8 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 37 smd rect (at 1.6 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 8 /PA0) (solder_mask_margin 0.0508)) - (pad 36 smd rect (at 2.4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 9 /PA1) (solder_mask_margin 0.0508)) - (pad 35 smd rect (at 3.2 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 10 /PA2) (solder_mask_margin 0.0508)) - (pad 34 smd rect (at 4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 11 /PA3) (solder_mask_margin 0.0508)) - (pad 33 smd rect (at 5.8 4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 12 /PA4) (solder_mask_margin 0.0508)) - (pad 32 smd rect (at 5.8 3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 13 /PA5) (solder_mask_margin 0.0508)) - (pad 31 smd rect (at 5.8 2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 14 /PA6) (solder_mask_margin 0.0508)) - (pad 30 smd rect (at 5.8 1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 15 /PA7) (solder_mask_margin 0.0508)) - (pad 29 smd rect (at 5.8 0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 16 /AREF) (solder_mask_margin 0.0508)) - (pad 28 smd rect (at 5.8 0 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 27 smd rect (at 5.8 -0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 17 "Net-(C11-PadP$1)") (solder_mask_margin 0.0508)) - (pad 26 smd rect (at 5.8 -1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 18 /PC7) (solder_mask_margin 0.0508)) - (pad 25 smd rect (at 5.8 -2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 19 /PC6) (solder_mask_margin 0.0508)) - (pad 24 smd rect (at 5.8 -3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 20 /PC5) (solder_mask_margin 0.0508)) - (pad 23 smd rect (at 5.8 -4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 21 /PC4) (solder_mask_margin 0.0508)) - (pad 22 smd rect (at 4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 22 /PC3) (solder_mask_margin 0.0508)) - (pad 21 smd rect (at 3.2 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 23 /PC2) (solder_mask_margin 0.0508)) - (pad 20 smd rect (at 2.4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 24 /PC1) (solder_mask_margin 0.0508)) - (pad 19 smd rect (at 1.6 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 25 /PC0) (solder_mask_margin 0.0508)) - (pad 18 smd rect (at 0.8 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 17 smd rect (at 0 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 16 smd rect (at -0.8 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 26 /PD7) (solder_mask_margin 0.0508)) - (pad 15 smd rect (at -1.6 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 27 /PD6) (solder_mask_margin 0.0508)) - (pad 14 smd rect (at -2.4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 28 /PD5) (solder_mask_margin 0.0508)) - (pad 13 smd rect (at -3.2 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 29 /PD4) (solder_mask_margin 0.0508)) - (pad 12 smd rect (at -4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 30 /PD3) (solder_mask_margin 0.0508)) - (pad 11 smd rect (at -5.8 -4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 31 /PD2) (solder_mask_margin 0.0508)) - (pad 10 smd rect (at -5.8 -3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 32 /PD1) (solder_mask_margin 0.0508)) - (pad 9 smd rect (at -5.8 -2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 33 /PD0) (solder_mask_margin 0.0508)) - (pad 8 smd rect (at -5.8 -1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 34 "Net-(C2-PadP$1)") (solder_mask_margin 0.0508)) - (pad 7 smd rect (at -5.8 -0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 35 "Net-(C1-PadP$1)") (solder_mask_margin 0.0508)) - (pad 6 smd rect (at -5.8 0 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 5 smd rect (at -5.8 0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 4 smd rect (at -5.8 1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 36 /RESET) (solder_mask_margin 0.0508)) - (pad 3 smd rect (at -5.8 2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 37 /SCK) (solder_mask_margin 0.0508)) - (pad 2 smd rect (at -5.8 3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 38 /MISO) (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -5.8 4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 39 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Package_QFP.3dshapes/TQFP-44_10x10mm_P0.8mm.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814E22) (tstamp 5C811A50) - (at 159.2961 100.8336 270) - (descr LYT) - (path /120B1331) - (fp_text reference R2 (at -1.7736 0.5461 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 4.7KOm (at -0.762 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 36 /RESET) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814DC4) (tstamp 5C811BA9) - (at 129.5019 114.8036 180) - (descr LYT) - (path /DE40310A) - (fp_text reference R1 (at -3.2131 -2.6714) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 1Kom (at -0.762 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 41 "Net-(LED1-PadA)") (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 21 /PC4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C814899) (tstamp 5C811CA6) - (at 128.1811 98.9286 270) - (descr LYT) - (path /EA9A6EB6) - (fp_text reference R3 (at 3.3064 0.5461) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 510Om (at -0.762 2.286) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 20 /PC5) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 45 "Net-(R3-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C81486B) (tstamp 5C811CD6) - (at 157.3911 118.6136 90) - (descr LYT) - (path /292B8E46) - (fp_text reference R4 (at 1.7736 0.7239 90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 10KOm (at -0.762 2.286 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 33 /PD0) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C814862) (tstamp 5C811CDF) - (at 151.6761 118.6136 90) - (descr LYT) - (path /59505C8B) - (fp_text reference R5 (at 1.7736 0.7239 90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 10KOm (at -0.762 2.286 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 31 /PD2) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C8148A8) (tstamp 5C811D50) - (at 131.3561 98.2936 180) - (descr LYT) - (path /9C9DB109) - (fp_text reference R6 (at -3.8989 -1.016) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value 10kOm (at -0.762 2.286) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 270) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 20 /PC5) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 270) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814DF7) (tstamp 5C811DD0) - (at 150.4061 116.0736 90) - (descr LYT) - (path /F96F0265) - (fp_text reference R9 (at 4.3136 0.7239 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 2Kom (at -0.762 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 42 /PD3') (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814E10) (tstamp 5C811DD9) - (at 157.1625 121.179) - (descr LYT) - (path /1B221D8E) - (fp_text reference R10 (at 1.5875 2.646) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 2Kom (at -0.762 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 43 /PD1') (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:QS (layer Bottom) (tedit 5C814DF0) (tstamp 5C811A28) - (at 156.7561 108.4536 90) - (descr CRYSTAL) - (path /098A5C63) - (fp_text reference Q1 (at -1.4014 -3.0861 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 16Mhz (at -5.08 -3.937 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom mirror)) - ) - (fp_arc (start -3.429 0) (end -3.429 1.778) (angle 180) (layer B.SilkS) (width 0.0508)) - (fp_arc (start -3.429 0) (end -3.429 2.286) (angle 180) (layer B.SilkS) (width 0.1524)) - (fp_arc (start 3.429 0) (end 3.429 2.286) (angle -180) (layer B.SilkS) (width 0.1524)) - (fp_arc (start 3.429 0) (end 3.429 1.778) (angle -180) (layer B.SilkS) (width 0.0508)) - (fp_line (start 3.429 1.778) (end -3.429 1.778) (layer B.SilkS) (width 0.0508)) - (fp_line (start -3.429 -1.778) (end 3.429 -1.778) (layer B.SilkS) (width 0.0508)) - (fp_line (start 3.429 2.286) (end -3.429 2.286) (layer B.SilkS) (width 0.1524)) - (fp_line (start -3.429 -2.286) (end 3.429 -2.286) (layer B.SilkS) (width 0.1524)) - (pad 2 thru_hole oval (at 2.54 0) (size 2.8448 1.4224) (drill 0.7) (layers *.Cu *.Mask) - (net 35 "Net-(C1-PadP$1)") (solder_mask_margin 0.0508)) - (pad 1 thru_hole oval (at -2.54 0) (size 2.8448 1.4224) (drill 0.7) (layers *.Cu *.Mask) - (net 34 "Net-(C2-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Crystal.3dshapes/Crystal_HC49-4H_Vertical.step - (offset (xyz -2.5 0 0)) - (scale (xyz 1 1 0.8)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E35) (tstamp 5C811A35) - (at 160.1343 110.0411 90) - (descr LYT) - (path /B2C130AB) - (fp_text reference C2 (at -1.7189 0.5207 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 18pf (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 34 "Net-(C2-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DE9) (tstamp 5C811A3E) - (at 153.3906 107.0947 270) - (descr LYT) - (path /D645821B) - (fp_text reference C1 (at -1.6847 0.9906 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 18pf (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 35 "Net-(C1-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E2F) (tstamp 5C811A47) - (at 160.2359 104.6436 270) - (descr LYT) - (path /A401EF9C) - (fp_text reference C7 (at 1.4014 -0.4191 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DBD) (tstamp 5C811A59) - (at 133.8961 103.9451) - (descr LYT) - (path /ED3BBF87) - (fp_text reference C3 (at -1.1811 -1.0751 -90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 16 /AREF) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E4C) (tstamp 5C811AB2) - (at 173.0883 109.5966 90) - (descr LYT) - (path /4EACBEDA) - (fp_text reference C5 (at -3.4334 2.1717 180) (layer B.SilkS) - (effects (font (size 1.2 1.2) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 40 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:LED3MM (layer Top) (tedit 5C8148C1) (tstamp 5C811ABB) - (at 128.8161 110.9936 90) - (descr "LED

\n3 mm, round") - (path /F50B0571) - (fp_text reference LED1 (at -1.4014 7.0739) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value LED_RED/PC4/20 (at 1.905 1.651) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_arc (start 0 0.000083) (end -2.032 0) (angle -31.60822) (layer F.Fab) (width 0.254)) - (fp_arc (start 0 0.000002) (end -2.032 0) (angle 28.301701) (layer F.Fab) (width 0.254)) - (fp_arc (start -0.000056 0) (end -1.7643 1.0082) (angle -60.255215) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.000037 0) (end 0 2.032) (angle -49.763022) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.00006 0) (end -1.7929 -0.9562) (angle 61.926949) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.000012 0) (end 0 -2.032) (angle 50.193108) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0 0) (end 0 1.016) (angle -90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end 0 0.635) (angle -90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end -1.016 0) (angle 90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end -0.635 0) (angle 90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0.000008 0) (end -1.203 0.9356) (angle -52.126876) (layer F.SilkS) (width 0.1524)) - (fp_arc (start -0.000008 0) (end 0 1.524) (angle -52.126876) (layer F.SilkS) (width 0.1524)) - (fp_arc (start 0 0) (end -1.2192 -0.9144) (angle 53.130102) (layer F.SilkS) (width 0.1524)) - (fp_arc (start -0.000034 0) (end 0 -1.524) (angle 54.461337) (layer F.SilkS) (width 0.1524)) - (fp_arc (start 0 -0.000004) (end 1.1708 0.9756) (angle -39.80361) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000014) (end 1.1571 -0.9918) (angle 40.601165) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000063) (end -1.524 0) (angle -41.633208) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000004) (end -1.524 0) (angle 39.80361) (layer F.Fab) (width 0.1524)) - (fp_line (start 1.5748 1.27) (end 1.5748 -1.27) (layer F.Fab) (width 0.254)) - (pad K thru_hole circle (at 1.27 0 90) (size 1.6764 1.6764) (drill 0.8128) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad A thru_hole circle (at -1.27 0 90) (size 1.6764 1.6764) (drill 0.8128) (layers *.Cu *.Mask) - (net 41 "Net-(LED1-PadA)") (solder_mask_margin 0.0508)) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DB1) (tstamp 5C811AD3) - (at 133.8961 105.9136 180) - (descr LYT) - (path /C2BBB70B) - (fp_text reference C8 (at 1.8161 -3.3064 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DCC) (tstamp 5C811ADC) - (at 142.0241 116.1371 270) - (descr LYT) - (path /90B5D1B4) - (fp_text reference C9 (at -1.2021 -2.7559 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 270) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DDC) (tstamp 5C811AE5) - (at 142.7861 95.8806 90) - (descr LYT) - (path /0BB7FF73) - (fp_text reference C10 (at 1.9006 -1.1811 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DAB) (tstamp 5C811AFE) - (at 134.1501 109.2664 270) - (descr LYT) - (path /31DB2A51) - (fp_text reference C11 (at 1.8586 1.4351 180) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 17 "Net-(C11-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X09-BIG (layer Top) (tedit 5C81367B) (tstamp 5C811B07) - (at 140.2461 86.8636 180) - (path /A13C1BE3) - (fp_text reference JP1 (at -10.2362 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x9 (at -10.16 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy 9.906 0.254) (xy 10.414 0.254) (xy 10.414 -0.254) (xy 9.906 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 7.366 0.254) (xy 7.874 0.254) (xy 7.874 -0.254) (xy 7.366 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -10.414 0.254) (xy -9.906 0.254) (xy -9.906 -0.254) (xy -10.414 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -7.874 0.254) (xy -7.366 0.254) (xy -7.366 -0.254) (xy -7.874 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -5.334 0.254) (xy -4.826 0.254) (xy -4.826 -0.254) (xy -5.334 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 0.254) (xy -2.286 0.254) (xy -2.286 -0.254) (xy -2.794 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 0.254) (xy 2.794 0.254) (xy 2.794 -0.254) (xy 2.286 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.826 0.254) (xy 5.334 0.254) (xy 5.334 -0.254) (xy 4.826 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start -11.43 1.27) (end -11.43 -1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 1.27) (end -11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 -1.27) (end 11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start -11.43 -1.27) (end 11.43 -1.27) (layer F.SilkS) (width 0.127)) - (pad 9 thru_hole circle (at 10.16 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 11 /PA3) (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 7.62 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 10 /PA2) (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 5.08 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 9 /PA1) (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at 2.54 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 8 /PA0) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 0 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 7 /PB0) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -2.54 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 6 /PB1) (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -5.08 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 5 /PB2) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -7.62 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 4 /PB3) (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -10.16 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 3 /PB4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x09_P2.54mm_Vertical.wrl - (offset (xyz 10 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:1X09-BIG (layer Top) (tedit 5C813684) (tstamp 5C811B20) - (at 125.0061 107.1836 270) - (path /10A664E2) - (fp_text reference JP2 (at -15.1086 0.5461 90) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x9 (at -10.16 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy 9.906 0.254) (xy 10.414 0.254) (xy 10.414 -0.254) (xy 9.906 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 7.366 0.254) (xy 7.874 0.254) (xy 7.874 -0.254) (xy 7.366 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -10.414 0.254) (xy -9.906 0.254) (xy -9.906 -0.254) (xy -10.414 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -7.874 0.254) (xy -7.366 0.254) (xy -7.366 -0.254) (xy -7.874 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -5.334 0.254) (xy -4.826 0.254) (xy -4.826 -0.254) (xy -5.334 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 0.254) (xy -2.286 0.254) (xy -2.286 -0.254) (xy -2.794 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 0.254) (xy 2.794 0.254) (xy 2.794 -0.254) (xy 2.286 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.826 0.254) (xy 5.334 0.254) (xy 5.334 -0.254) (xy 4.826 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start -11.43 1.27) (end -11.43 -1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 1.27) (end -11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 -1.27) (end 11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start -11.43 -1.27) (end 11.43 -1.27) (layer F.SilkS) (width 0.127)) - (pad 9 thru_hole circle (at 10.16 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 19 /PC6) (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 7.62 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 18 /PC7) (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 5.08 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 15 /PA7) (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at 2.54 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 0 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 16 /AREF) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -2.54 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -5.08 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 13 /PA5) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -7.62 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 12 /PA4) (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -10.16 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 14 /PA6) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x09_P2.54mm_Vertical.wrl - (offset (xyz 10 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E47) (tstamp 5C811BB2) - (at 174.5361 109.5966 90) - (descr LYT) - (path /487BCAB4) - (fp_text reference C4 (at 1.6466 0.7239 180) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 10uF (at -0.889 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 40 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E29) (tstamp 5C811BBB) - (at 161.9377 104.6436 270) - (descr LYT) - (path /04BD8970) - (fp_text reference C6 (at -2.4086 0.6477 270) (layer B.SilkS) - (effects (font (size 0.9652 0.9652) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 22uF (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 0.9652 0.9652) (thickness 0.077216)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:W237-102 (layer Top) (tedit 5C814829) (tstamp 5C8E7C86) - (at 165.6461 123.6936 180) - (descr "WAGO SCREW CLAMP") - (path /484D9DCB) - (fp_text reference X2 (at 1.778 7.62) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value DG300-5.0-02P-12 (at -5.04 7.62) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text user 2 (at 0.421 -0.635 180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 1 (at -4.532 -0.635 180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_circle (center 2.5038 -2.2098) (end 3.0118 -2.2098) (layer F.SilkS) (width 0.1524)) - (fp_circle (center 2.5038 1.27) (end 4.0024 1.27) (layer F.Fab) (width 0.1524)) - (fp_circle (center -2.5 -2.2098) (end -1.992 -2.2098) (layer F.SilkS) (width 0.1524)) - (fp_circle (center -2.5 1.27) (end -1.0014 1.27) (layer F.Fab) (width 0.1524)) - (fp_line (start 1.615 3.073) (end 3.393 3.073) (layer F.Fab) (width 0.1524)) - (fp_line (start 4.993 -3.531) (end 4.993 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 -3.531) (end -4.989 -3.734) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 -3.531) (end 4.993 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 3.073) (end 4.993 5.461) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 3.073) (end -4.989 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.393 3.073) (end 4.993 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.611 3.073) (end 1.615 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.389 3.073) (end -1.611 3.073) (layer F.Fab) (width 0.1524)) - (fp_line (start -4.989 3.073) (end -3.389 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 5.461) (end -4.989 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 -3.734) (end -4.989 -3.734) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 -3.734) (end 4.993 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 5.461) (end 4.993 5.461) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.488 2.261) (end 3.469 0.254) (layer F.Fab) (width 0.254)) - (fp_line (start -3.491 2.286) (end -1.484 0.279) (layer F.Fab) (width 0.254)) - (pad 2 thru_hole oval (at 2.5 1.27 270) (size 3.5814 1.7907) (drill 1.1938) (layers *.Cu *.Mask) - (net 44 "Net-(D1-PadA)") (solder_mask_margin 0.0508)) - (pad 1 thru_hole oval (at -2.5 1.27 270) (size 3.5814 1.7907) (drill 1.1938) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KIPRJMOD}/3d_terminal_blocks/300_2_5.wrl - (offset (xyz 7.8 -1.8 7.5)) - (scale (xyz 0.4 0.4 0.4)) - (rotate (xyz -90 0 180)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135FC) (tstamp 5C811BF6) - (at 150.4061 97.0236) - (descr "PIN HEADER") - (path /81FCD7AF) - (fp_text reference JP4 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 37 /SCK) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813605) (tstamp 5C811C03) - (at 152.9461 97.0236) - (descr "PIN HEADER") - (path /9DADB6DD) - (fp_text reference JP5 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 37 /SCK) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135F0) (tstamp 5C811C10) - (at 152.9461 94.4836) - (descr "PIN HEADER") - (path /3ADBB494) - (fp_text reference JP6 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 38 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135E8) (tstamp 5C811C1D) - (at 150.4061 94.4836) - (descr "PIN HEADER") - (path /350157B3) - (fp_text reference JP7 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 38 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135B1) (tstamp 5C811C2A) - (at 150.4061 91.9436) - (descr "PIN HEADER") - (path /ADB8D889) - (fp_text reference JP8 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 39 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135B9) (tstamp 5C8E5AA9) - (at 152.9461 91.9436) - (descr "PIN HEADER") - (path /50718617) - (fp_text reference JP9 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 39 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813610) (tstamp 5C811CAF) - (at 155.4861 97.0236) - (descr "PIN HEADER") - (path /71218B71) - (fp_text reference JP11 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 37 /SCK) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135F7) (tstamp 5C811CBC) - (at 155.4861 94.4836) - (descr "PIN HEADER") - (path /81AF9221) - (fp_text reference JP12 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 38 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C81361A) (tstamp 5C8E5AF0) - (at 155.4861 91.9436) - (descr "PIN HEADER") - (path /03497A6C) - (fp_text reference JP13 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 39 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813753) (tstamp 5C811CE8) - (at 171.9961 91.9436) - (descr "PIN HEADER") - (path /679AEFF0) - (fp_text reference JP14 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8137D2) (tstamp 5C811CF5) - (at 171.9961 94.4836) - (descr "PIN HEADER") - (path /D0A47C9F) - (fp_text reference JP15 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8137DC) (tstamp 5C811D02) - (at 171.9961 97.0236) - (descr "PIN HEADER") - (path /C3CE8354) - (fp_text reference JP16 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8137E3) (tstamp 5C811D0F) - (at 171.9961 99.5636) - (descr "PIN HEADER") - (path /BAC3901A) - (fp_text reference JP17 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C81374F) (tstamp 5C811D1C) - (at 169.4561 91.9436) - (descr "PIN HEADER") - (path /14CC0547) - (fp_text reference JP19 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8CF7C1) (tstamp 5C811D29) - (at 169.4561 94.4836) - (descr "PIN HEADER") - (path /5467ECB4) - (fp_text reference JP20 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8CF7C3) (tstamp 5C811D36) - (at 169.4561 97.0236) - (descr "PIN HEADER") - (path /3FA45B4D) - (fp_text reference JP21 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8CF7C7) (tstamp 5C811D43) - (at 169.4561 99.5636) - (descr "PIN HEADER") - (path /1375B3FD) - (fp_text reference JP22 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136F9) (tstamp 5C811D59) - (at 152.9461 122.4236) - (descr "PIN HEADER") - (path /211071EA) - (fp_text reference JP24 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 31 /PD2) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136E7) (tstamp 5C811D66) - (at 150.4061 122.4236) - (descr "PIN HEADER") - (path /CD247A09) - (fp_text reference JP25 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 42 /PD3') (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136D4) (tstamp 5C811D73) - (at 147.8661 122.4236) - (descr "PIN HEADER") - (path /02F38983) - (fp_text reference JP26 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 29 /PD4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136A1) (tstamp 5C811D80) - (at 127.5461 107.1836) - (descr "PIN HEADER") - (path /AB274EC9) - (fp_text reference JP27 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 20 /PC5) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813696) (tstamp 5C811D8D) - (at 127.5461 117.3436) - (descr "PIN HEADER") - (path /7D22D023) - (fp_text reference JP28 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 21 /PC4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813716) (tstamp 5C811D9A) - (at 171.9961 114.1686) - (descr "PIN HEADER") - (path /391CE814) - (fp_text reference JP10 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 40 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813724) (tstamp 5C811DA7) - (at 174.5361 114.1686) - (descr "PIN HEADER") - (path /1A752D3A) - (fp_text reference JP29 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 40 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805 (layer Bottom) (tedit 5C814E04) (tstamp 5C811DB4) - (at 150.4061 119.8836 270) - (descr "RESISTOR

\nchip") - (path /6C5D1C71) - (fp_text reference R7 (at -1.1386 1.016 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 1Kom (at -0.762 -2.286 270) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -0.1999 -0.5001) (xy 0.1999 -0.5001) (xy 0.1999 0.5001) (xy -0.1999 0.5001)) (layer B.Adhes) (width 0)) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -1.973 -0.983) (end -1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 -0.983) (end -1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 0.983) (end 1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.973 0.983) (end 1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad 2 smd rect (at 0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 42 /PD3') (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 30 /PD3) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805 (layer Bottom) (tedit 5C814E0A) (tstamp 5C811DC2) - (at 154.8003 120.3662 270) - (descr "RESISTOR

\nchip") - (path /B110DF28) - (fp_text reference R8 (at -1.6212 1.016 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 1Kom (at -0.762 -2.286 270) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -0.1999 -0.5001) (xy 0.1999 -0.5001) (xy 0.1999 0.5001) (xy -0.1999 0.5001)) (layer B.Adhes) (width 0)) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -1.973 -0.983) (end -1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 -0.983) (end -1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 0.983) (end 1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.973 0.983) (end 1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad 2 smd rect (at 0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 43 /PD1') (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 32 /PD1) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module Pin_Headers:Pin_Header_Straight_2x04_Pitch2.54mm (layer Top) (tedit 5C8E6EA2) (tstamp 5C8E7144) - (at 171.9961 117.3436) - (descr "Through hole straight pin header, 2x04, 2.54mm pitch, double rows") - (tags "Through hole pin header THT 2x04 2.54mm double row") - (fp_text reference REF** (at 1.27 -2.33) (layer F.SilkS) hide - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_text value Pin_Header_Straight_2x04_Pitch2.54mm (at 1.27 9.95) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_line (start 0 -1.27) (end 3.81 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start 3.81 -1.27) (end 3.81 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start 3.81 8.89) (end -1.27 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 8.89) (end -1.27 0) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 0) (end 0 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start -1.33 8.95) (end 3.87 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end -1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start 3.87 -1.33) (end 3.87 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end 1.27 1.27) (layer F.SilkS) (width 0.12)) - (fp_line (start 1.27 1.27) (end 1.27 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start 1.27 -1.33) (end 3.87 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 0) (end -1.33 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 -1.33) (end 0 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.8 -1.8) (end -1.8 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start -1.8 9.4) (end 4.35 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start 4.35 9.4) (end 4.35 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_line (start 4.35 -1.8) (end -1.8 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_text user %R (at 1.27 3.81 90) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (pad 1 thru_hole rect (at 0 0) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 2 thru_hole oval (at 2.54 0) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 3 thru_hole oval (at 0 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 4 thru_hole oval (at 2.54 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 5 thru_hole oval (at 0 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 6 thru_hole oval (at 2.54 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 7 thru_hole oval (at 0 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 8 thru_hole oval (at 2.54 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (model ${KISYS3DMOD}/Pin_Headers.3dshapes/Pin_Header_Straight_2x04_Pitch2.54mm.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_2x04_P2.54mm_Vertical.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm (layer Top) (tedit 5C8E715B) (tstamp 5C8E7C22) - (at 174.5361 91.9436) - (descr "Through hole straight pin header, 1x04, 2.54mm pitch, single row") - (tags "Through hole pin header THT 1x04 2.54mm single row") - (fp_text reference REF** (at 0 -2.33) (layer F.SilkS) hide - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_text value Pin_Header_Straight_1x04_Pitch2.54mm (at 0 9.95) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_line (start -0.635 -1.27) (end 1.27 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start 1.27 -1.27) (end 1.27 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start 1.27 8.89) (end -1.27 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 8.89) (end -1.27 -0.635) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 -0.635) (end -0.635 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start -1.33 8.95) (end 1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end -1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start 1.33 1.27) (end 1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end 1.33 1.27) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 0) (end -1.33 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 -1.33) (end 0 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.8 -1.8) (end -1.8 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start -1.8 9.4) (end 1.8 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start 1.8 9.4) (end 1.8 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_line (start 1.8 -1.8) (end -1.8 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_text user %R (at 0 3.81 90) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (pad 1 thru_hole rect (at 0 0) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (pad 2 thru_hole oval (at 0 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (pad 3 thru_hole oval (at 0 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (pad 4 thru_hole oval (at 0 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (model ${KISYS3DMOD}/Pin_Headers.3dshapes/Pin_Header_Straight_1x04_Pitch2.54mm.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x04_P2.54mm_Vertical.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (gr_text GND (at 168.9481 104.1356 90) (layer F.SilkS) (tstamp 5CAC8E0A) - (effects (font (size 1 1) (thickness 0.25)) (justify left bottom)) - ) - (gr_line (start 121.1961 127.5036) (end 176.0601 127.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109CD970)) - (gr_line (start 176.0601 127.5036) (end 176.0601 82.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109CD8D0)) - (gr_line (start 176.0601 82.5036) (end 121.1961 82.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109CD830)) - (gr_line (start 121.1961 82.5036) (end 121.1961 127.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109DEDB0)) - (gr_line (start 149.1361 91.9436) (end 145.9611 89.4036) (layer Cmts.User) (width 0.15) (tstamp 5C8E8346)) - (gr_line (start 145.9611 89.4036) (end 121.8311 89.4036) (layer Cmts.User) (width 0.15) (tstamp 109DEC70)) - (gr_line (start 149.1361 94.4836) (end 145.9611 91.9436) (layer Cmts.User) (width 0.15) (tstamp 109DEBD0)) - (gr_line (start 145.9611 91.9436) (end 121.8311 91.9436) (layer Cmts.User) (width 0.15) (tstamp 109DEB30)) - (gr_line (start 149.1361 97.0236) (end 145.9611 94.4836) (layer Cmts.User) (width 0.15) (tstamp 109E0070)) - (gr_line (start 145.9611 94.4836) (end 121.8311 94.4836) (layer Cmts.User) (width 0.15) (tstamp 109DFFD0)) - (gr_line (start 176.4411 91.9436) (end 176.4411 94.4836) (layer Cmts.User) (width 0.15) (tstamp 109DFF30)) - (gr_line (start 176.4411 94.4836) (end 176.4411 97.0236) (layer Cmts.User) (width 0.15) (tstamp 109DFE90)) - (gr_line (start 176.4411 97.0236) (end 176.4411 99.5636) (layer Cmts.User) (width 0.15) (tstamp 109DFDF0)) - (gr_line (start 176.4411 91.9436) (end 175.8061 91.9436) (layer Cmts.User) (width 0.15) (tstamp 109DFA30)) - (gr_line (start 175.8061 94.4836) (end 176.4411 94.4836) (layer Cmts.User) (width 0.15) (tstamp 109DF990)) - (gr_line (start 175.8061 97.0236) (end 176.4411 97.0236) (layer Cmts.User) (width 0.15) (tstamp 109DF8F0)) - (gr_line (start 175.8061 99.5636) (end 176.4411 99.5636) (layer Cmts.User) (width 0.15) (tstamp 109DF850)) - (gr_line (start 176.4411 117.3436) (end 176.4411 119.8836) (layer Cmts.User) (width 0.15) (tstamp 109DF7B0)) - (gr_line (start 176.4411 119.8836) (end 176.4411 122.4236) (layer Cmts.User) (width 0.15) (tstamp 109DF3F0)) - (gr_line (start 176.4411 122.4236) (end 176.4411 124.9636) (layer Cmts.User) (width 0.15) (tstamp 109DF350)) - (gr_line (start 176.4411 117.3436) (end 175.8061 117.3436) (layer Cmts.User) (width 0.15) (tstamp 109DF2B0)) - (gr_line (start 175.8061 119.8836) (end 176.4411 119.8836) (layer Cmts.User) (width 0.15) (tstamp 109DF210)) - (gr_line (start 175.8061 122.4236) (end 176.4411 122.4236) (layer Cmts.User) (width 0.15) (tstamp 109DF170)) - (gr_line (start 175.8061 124.9636) (end 176.4411 124.9636) (layer Cmts.User) (width 0.15) (tstamp 109DE770)) - (gr_line (start 127.5461 118.6136) (end 126.2761 119.8836) (layer Cmts.User) (width 0.15) (tstamp 109DE6D0)) - (gr_line (start 126.2761 119.8836) (end 121.1961 119.8836) (layer Cmts.User) (width 0.15) (tstamp 109DE630)) - (gr_line (start 121.1961 122.4236) (end 131.3561 122.4236) (layer Cmts.User) (width 0.15) (tstamp 109DE590)) - (gr_line (start 131.3561 122.4236) (end 136.4361 117.3436) (layer Cmts.User) (width 0.15) (tstamp 109DE4F0)) - (gr_line (start 136.4361 117.3436) (end 136.4361 112.8986) (layer Cmts.User) (width 0.15) (tstamp 109D6430)) - (gr_line (start 136.4361 112.8986) (end 128.8161 107.1836) (layer Cmts.User) (width 0.15) (tstamp 109D6390)) - (gr_line (start 159.2961 98.9286) (end 159.2961 93.8486) (layer Dwgs.User) (width 0.15) (tstamp 109D62F0)) - (gr_line (start 159.2961 93.8486) (end 159.2961 90.0386) (layer Dwgs.User) (width 0.15) (tstamp 109D6250)) - (gr_line (start 159.2961 90.0386) (end 159.2961 84.9586) (layer Dwgs.User) (width 0.15) (tstamp 109D61B0)) - (gr_line (start 159.2961 84.9586) (end 165.6461 84.9586) (layer Dwgs.User) (width 0.15) (tstamp 109D4B30)) - (gr_line (start 165.6461 84.9586) (end 165.6461 98.9286) (layer Dwgs.User) (width 0.15) (tstamp 109D4A90)) - (gr_line (start 165.6461 98.9286) (end 159.2961 98.9286) (layer Dwgs.User) (width 0.15) (tstamp 109D49F0)) - (gr_line (start 159.2961 90.0386) (end 160.5661 90.0386) (layer Dwgs.User) (width 0.15) (tstamp 109D4950)) - (gr_line (start 160.5661 90.0386) (end 160.5661 93.8486) (layer Dwgs.User) (width 0.15) (tstamp 109D48B0)) - (gr_line (start 160.5661 93.8486) (end 159.2961 93.8486) (layer Dwgs.User) (width 0.15) (tstamp 109CAEF0)) - (gr_line (start 160.5661 125.2176) (end 160.5661 127.1226) (layer Dwgs.User) (width 0.15) (tstamp 109CAE50)) - (gr_line (start 160.5661 127.1226) (end 170.5991 127.1226) (layer Dwgs.User) (width 0.15) (tstamp 109CADB0)) - (gr_line (start 170.5991 127.1226) (end 170.5991 125.3446) (layer Dwgs.User) (width 0.15) (tstamp 109CAD10)) - (gr_circle (center 148.0693 100.1097) (end 148.4952 100.1097) (layer B.SilkS) (width 0.4064) (tstamp 109CAC70)) - (gr_circle (center 159.2961 97.0236) (end 159.8961 97.0236) (layer Dwgs.User) (width 0.5) (tstamp 109CB530)) - (gr_circle (center 159.2961 94.4836) (end 159.8961 94.4836) (layer Dwgs.User) (width 0.5) (tstamp 109CB490)) - (gr_circle (center 161.8361 91.9436) (end 162.4361 91.9436) (layer Dwgs.User) (width 0.5) (tstamp 109CB3F0)) - (gr_circle (center 161.8361 94.4836) (end 162.4361 94.4836) (layer Dwgs.User) (width 0.5) (tstamp 109CB350)) - (gr_circle (center 161.8361 97.0236) (end 162.4361 97.0236) (layer Dwgs.User) (width 0.5) (tstamp 109CB2B0)) - (gr_circle (center 157.4419 87.8288) (end 157.9251 87.8288) (layer F.SilkS) (width 0.6096) (tstamp 109CE730)) - (gr_circle (center 161.8615 112.9494) (end 162.6554 112.9494) (layer Dwgs.User) (width 0.6096) (tstamp 109CE690)) - (gr_circle (center 161.8615 114.8544) (end 162.6554 114.8544) (layer Dwgs.User) (width 0.6096) (tstamp 109CE5F0)) - (gr_circle (center 171.0309 117.1912) (end 171.8248 117.1912) (layer Dwgs.User) (width 0.6096) (tstamp 109CE550)) - (gr_circle (center 161.8615 125.0144) (end 162.6554 125.0144) (layer Dwgs.User) (width 0.6096) (tstamp 109CE4B0)) - (gr_circle (center 159.2961 91.9436) (end 159.8961 91.9436) (layer Dwgs.User) (width 0.5) (tstamp 109D3870)) - (gr_circle (center 174.4091 111.8826) (end 174.835 111.8826) (layer F.SilkS) (width 0.4064) (tstamp 109D37D0)) - (gr_circle (center 157.5181 86.1016) (end 158.1531 86.1016) (layer Dwgs.User) (width 0.4064) (tstamp 109D3730)) - (gr_circle (center 174.1551 112.1366) (end 174.7901 112.1366) (layer Dwgs.User) (width 0.4064) (tstamp 109D3690)) - (gr_text "M644/M1284 v1.2d" (at 126.365 104.775) (layer F.SilkS) (tstamp 5C81D4C7) - (effects (font (size 1.6891 1.6891) (thickness 0.32004)) (justify left bottom)) - ) - (gr_text 26/01/19 (at 138.43 107.95) (layer F.SilkS) (tstamp 109D50D0) - (effects (font (size 1.6891 1.6891) (thickness 0.32004)) (justify left bottom)) - ) - (gr_text RX0 (at 158.9151 117.0134 90) (layer F.SilkS) (tstamp 109D4F90) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text TX0 (at 154.8511 117.3944 90) (layer F.SilkS) (tstamp 109E1FB0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text TX1 (at 149.0091 117.2166 90) (layer F.SilkS) (tstamp 109E1E70) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text RX1 (at 154.3431 121.1536 90) (layer F.SilkS) (tstamp 109E1D30) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text XCK1 (at 146.9771 115.7688 90) (layer F.SilkS) (tstamp 109E18D0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text XCK0 (at 139.6111 88.6416 90) (layer F.SilkS) (tstamp 109E1790) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text PB4/4/SS (at 151.0411 82.4186 90) (layer Cmts.User) (tstamp 109E1330) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB3/3 (at 148.5011 82.4186 90) (layer Cmts.User) (tstamp 109E11F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB2/2 (at 145.9611 82.4186 90) (layer Cmts.User) (tstamp 109E10B0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB1/1 (at 143.4211 82.4186 90) (layer Cmts.User) (tstamp 109CBAD0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA0/31/A0 (at 138.3411 82.4186 90) (layer Cmts.User) (tstamp 109CB990) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA1/30/A1 (at 135.8011 82.4186 90) (layer Cmts.User) (tstamp 109CCE30) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA2/29/A2 (at 133.2611 82.4186 90) (layer Cmts.User) (tstamp 109CCCF0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA3/28/A3 (at 130.7211 82.4186 90) (layer Cmts.User) (tstamp 109CCBB0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB0/0/XCK0 (at 140.8811 82.4186 90) (layer Cmts.User) (tstamp 109CC110) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text GND (at 177.0761 119.8836 90) (layer Cmts.User) (tstamp 109CBFD0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify right top)) - ) - (gr_text +5V (at 177.0761 93.2136 90) (layer Cmts.User) (tstamp 109CD470) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify right top)) - ) - (gr_text PA6/25/A6 (at 109.1311 97.6586) (layer Cmts.User) (tstamp 109CD330) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA4/27/A4 (at 109.1311 100.1986) (layer Cmts.User) (tstamp 109CD1F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA5/26/A5 (at 109.1311 102.7386) (layer Cmts.User) (tstamp 109E2550) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text +5V (at 116.7511 105.2786) (layer Cmts.User) (tstamp 109E2410) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text AREF (at 116.7511 107.8186) (layer Cmts.User) (tstamp 109DA8F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text GND (at 116.7511 110.3586) (layer Cmts.User) (tstamp 109DA7B0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC5/21 (at 112.9411 123.0586) (layer Cmts.User) (tstamp 109DA670) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC4/20 (at 112.9411 120.5186) (layer Cmts.User) (tstamp 109DA210) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC3/19 (at 130.7211 135.7586 90) (layer Cmts.User) (tstamp 109DA0D0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC2/18 (at 133.2611 135.7586 90) (layer Cmts.User) (tstamp 109D9C70) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC1/17/SDA (at 135.8011 140.8386 90) (layer Cmts.User) (tstamp 109D9B30) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC0/16/SCL (at 138.3411 140.8386 90) (layer Cmts.User) (tstamp 109D99F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD7/15 (at 140.8811 135.7586 90) (layer Cmts.User) (tstamp 109D9590) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD6/14 (at 143.4211 135.7586 90) (layer Cmts.User) (tstamp 109D9450) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD5/13 (at 145.9611 135.7586 90) (layer Cmts.User) (tstamp 109D8FF0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD4/12/XCK1 (at 148.5011 140.8386 90) (layer Cmts.User) (tstamp 109D8EB0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD3/11/TX1 (at 151.0411 140.8386 90) (layer Cmts.User) (tstamp 109D8D70) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD2/10/RX1 (at 153.5811 140.8386 90) (layer Cmts.User) (tstamp 109D7C90) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD1/9/TX0 (at 156.1211 140.8386 90) (layer Cmts.User) (tstamp 109D7B50) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD0/8/RX0 (at 158.6611 140.8386 90) (layer Cmts.User) (tstamp 109D8370) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB5/5/MOSI (at 109.1311 90.0386) (layer Cmts.User) (tstamp 109D8230) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB6/6/MISO (at 109.1311 92.5786) (layer Cmts.User) (tstamp 109D80F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB7/7/SCK (at 109.1311 95.1186) (layer Cmts.User) (tstamp 109D05D0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text +12V (at 160.5661 129.4086) (layer Cmts.User) (tstamp 109D0490) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text GND (at 167.5511 129.4086) (layer Cmts.User) (tstamp 109D0030) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA7/24/A7 (at 109.1311 112.8986) (layer Cmts.User) (tstamp 109CFEF0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC7/23 (at 112.9411 115.4386) (layer Cmts.User) (tstamp 109CFDB0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC6/22 (at 112.9411 117.9786) (layer Cmts.User) (tstamp 109E4850) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text SW1/PC5 (at 130.7211 99.0556 90) (layer Dwgs.User) (tstamp 109E4710) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text LED/PC4 (at 133.1087 117.877 90) (layer Dwgs.User) (tstamp 109E45D0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text SCL (at 138.3411 123.1856 90) (layer F.SilkS) (tstamp 109E4490) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text SDA (at 134.4041 119.3248 90) (layer F.SilkS) (tstamp 109E4350) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text +5V (at 174.5361 101.3416) (layer F.SilkS) (tstamp 109BE0B0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text GND (at 166.4081 117.3436) (layer F.SilkS) (tstamp 5C8E764B) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text +5V (at 121.8311 102.7386 90) (layer F.SilkS) (tstamp 109BDE30) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify right top)) - ) - (gr_text GND (at 123.2281 111.3492 90) (layer F.SilkS) (tstamp 109BDCF0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text MOSI (at 148.6281 91.1816) (layer F.SilkS) (tstamp 109BDBB0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text MISO (at 148.6281 93.7216) (layer F.SilkS) (tstamp 5C8E8010) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text SCK (at 148.6281 96.5156) (layer F.SilkS) (tstamp 109B48D0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text +5V (at 175.7553 101.2908) (layer Dwgs.User) (tstamp 109B4790) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text GND (at 171.7167 101.3416) (layer Dwgs.User) (tstamp 109B4650) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text +9V (at 166.1541 115.5656) (layer F.SilkS) (tstamp 109B4510) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - - (via (at 125.0061 86.3302) (size 7.62) (drill 3.2) (layers Top Bottom) (net 0) (tstamp 142C2950) (status 40000)) - (via (at 125.0061 123.6936) (size 7.62) (drill 3.2) (layers Top Bottom) (net 0) (tstamp 142C2A90) (status 40000)) - (via (at 171.9707 86.3302) (size 7.62) (drill 3.2) (layers Top Bottom) (net 0) (tstamp 142C2BD0) (status 40000)) - (segment (start 141.9785 109.5968) (end 141.986 110.7904) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D9770)) - (segment (start 141.9479 105.9136) (end 141.9785 109.5968) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D98B0)) - (segment (start 137.8712 105.9136) (end 141.9479 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D96D0)) - (segment (start 142.6591 106.0406) (end 142.6591 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D91D0)) - (segment (start 142.6591 105.9136) (end 142.6591 103.3736) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D9310)) - (segment (start 142.6591 101.9131) (end 142.7861 101.0241) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D9130)) - (segment (start 141.9479 105.9136) (end 142.6591 106.0406) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D9270)) - (segment (start 137.5156 110.9936) (end 134.3406 110.9936) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D9090)) - (segment (start 139.4206 109.5966) (end 137.5156 110.9936) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D7F10)) - (segment (start 141.9785 109.5968) (end 141.9606 109.5966) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D8050)) - (segment (start 141.9606 109.5966) (end 139.4206 109.5966) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D7E70)) - (segment (start 155.1686 108.8981) (end 153.9748 108.2631) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D7FB0)) - (segment (start 157.5181 108.8981) (end 156.7561 108.8981) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D7DD0)) - (segment (start 151.1681 105.8882) (end 154.0891 103.6911) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D8550)) - (segment (start 154.0891 103.6911) (end 156.6291 103.688237) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D8690)) - (segment (start 157.7255 103.687) (end 159.2072 104.9061) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D84B0)) - (segment (start 148.5861 105.9136) (end 151.1681 105.8882) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D85F0)) - (segment (start 141.9861 111.7136) (end 142.0241 113.7241) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D8410)) - (segment (start 141.9606 111.6881) (end 141.9861 111.7136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0850)) - (segment (start 141.986 110.7904) (end 141.9606 111.6881) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0990)) - (segment (start 142.0241 113.7241) (end 142.0241 114.9941) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D07B0)) - (segment (start 142.7861 100.1136) (end 142.7861 97.0236) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D08F0)) - (segment (start 142.7861 101.0241) (end 142.7861 100.1136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0710)) - (segment (start 142.6591 105.9136) (end 143.4211 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D0210)) - (segment (start 143.4211 105.9136) (end 145.3261 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D0350)) - (segment (start 153.9748 108.2631) (end 153.6954 108.1615) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0170)) - (segment (start 153.9748 108.2631) (end 153.3906 108.2377) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D02B0)) - (segment (start 136.9861 105.9136) (end 137.8712 105.9136) (width 0.381) (layer Bottom) (net 1) (tstamp 109D00D0)) - (segment (start 162.1536 100.8336) (end 163.7538 96.2616) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C80B0)) - (segment (start 135.0391 105.9136) (end 136.9861 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8010)) - (segment (start 132.7531 103.9451) (end 132.9436 103.9451) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8150)) - (segment (start 132.9436 103.9451) (end 133.7691 104.7706) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C7F70)) - (segment (start 133.7691 104.7706) (end 133.7691 105.2786) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C99B0)) - (segment (start 133.7691 105.2786) (end 134.4041 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9910)) - (segment (start 134.4041 105.9136) (end 135.0391 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9A50)) - (segment (start 134.3406 110.9936) (end 134.3406 110.5491) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9870)) - (segment (start 134.3406 110.5491) (end 134.1501 110.4094) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C85B0)) - (segment (start 168.1861 108.4536) (end 168.1861 108.4536) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8510)) - (segment (start 174.5361 124.9636) (end 174.5361 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8650)) - (segment (start 174.5361 119.8836) (end 174.5361 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8470)) - (segment (start 174.5361 117.3436) (end 174.5361 119.8836) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8FB0)) - (segment (start 162.1536 108.4536) (end 162.1536 100.8336) (width 0.4064) (layer Top) (net 1) (tstamp 109C8F10)) - (segment (start 125.0061 109.7236) (end 122.4661 108.4536) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C9050)) - (segment (start 122.4661 108.4536) (end 122.4661 107.1836) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C8E70)) - (segment (start 122.4661 104.6436) (end 123.7361 103.3736) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C8AB0)) - (segment (start 123.7361 103.3736) (end 127.5461 103.3736) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8A10)) - (segment (start 127.5461 103.3736) (end 128.1557 103.018) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8B50)) - (segment (start 128.1557 103.018) (end 129.5527 103.018) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8970)) - (segment (start 129.5527 103.018) (end 130.1369 103.4244) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C94B0)) - (segment (start 130.1369 103.4244) (end 131.9149 103.4498) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9410)) - (segment (start 131.9149 103.4498) (end 132.7531 103.9451) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9550)) - (segment (start 125.0061 109.7236) (end 128.8161 109.7236) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C9370)) - (segment (start 158.6611 107.8186) (end 157.5181 108.8981) (width 0.6096) (layer Bottom) (net 1) (tstamp 106017A0)) - (segment (start 159.2498 107.1848) (end 158.6611 107.8186) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601700)) - (segment (start 158.6611 107.8186) (end 160.1343 108.8981) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601660)) - (segment (start 159.2072 104.9061) (end 159.2498 104.9061) (width 0.6096) (layer Bottom) (net 1) (tstamp 106015C0)) - (segment (start 159.2498 104.9061) (end 159.2498 105.7866) (width 0.6096) (layer Bottom) (net 1) (tstamp 106012A0)) - (segment (start 159.2498 105.7866) (end 159.2498 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601200)) - (segment (start 159.2498 105.9136) (end 159.2498 107.1848) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601160)) - (segment (start 159.2498 105.7866) (end 160.2359 105.7866) (width 0.8128) (layer Bottom) (net 1) (tstamp 106010C0)) - (segment (start 159.2498 105.7866) (end 159.2498 105.9136) (width 0.8128) (layer Bottom) (net 1) (tstamp 10601CA0)) - (segment (start 122.4661 108.4536) (end 122.4661 103.3736) (width 0.4064) (layer Top) (net 1) (tstamp 10601B60)) - (segment (start 122.4661 92.0736) (end 123.104 91.4386) (width 0.4064) (layer Top) (net 1) (tstamp 10601AC0)) - (segment (start 122.4661 108.4536) (end 125.0061 109.7236) (width 0.4064) (layer Top) (net 1) (tstamp 10602100)) - (segment (start 171.6151 108.4536) (end 170.7261 108.4536) (width 0.8128) (layer Top) (net 1) (tstamp 10601FC0)) - (segment (start 171.9961 124.9636) (end 174.5361 124.9636) (width 1.27) (layer Bottom) (net 1) (tstamp 10609FE0)) - (segment (start 171.9961 119.8836) (end 171.9961 117.3436) (width 1.27) (layer Bottom) (net 1) (tstamp 10609F40)) - (segment (start 171.9961 121.1536) (end 171.9961 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 10609EA0)) - (segment (start 171.9961 121.1536) (end 171.9961 119.8836) (width 1.27) (layer Bottom) (net 1) (tstamp 10609E00)) - (segment (start 171.9961 122.4236) (end 171.9961 124.9636) (width 1.27) (layer Bottom) (net 1) (tstamp 10609AE0)) - (segment (start 171.9961 117.3436) (end 174.5361 117.3436) (width 1.27) (layer Bottom) (net 1) (tstamp 10609A40)) - (segment (start 168.1461 122.4236) (end 167.6861 124.9636) (width 1.27) (layer Bottom) (net 1) (tstamp 106099A0)) - (segment (start 168.1461 122.4236) (end 171.9961 121.1536) (width 1.4224) (layer Bottom) (net 1) (tstamp 10609900)) - (segment (start 168.1861 108.4536) (end 165.6461 109.4696) (width 1.27) (layer Bottom) (net 1) (tstamp 106095E0)) - (segment (start 165.6461 109.4696) (end 165.6461 116.0736) (width 1.27) (layer Bottom) (net 1) (tstamp 10609540)) - (segment (start 165.6461 119.8836) (end 166.9161 119.8836) (width 1.27) (layer Bottom) (net 1) (tstamp 106094A0)) - (segment (start 165.6461 108.4536) (end 168.1861 108.4536) (width 1.27) (layer Bottom) (net 1) (tstamp 10609400)) - (segment (start 164.8587 107.7678) (end 165.3316 108.1797) (width 1.27) (layer Bottom) (net 1) (tstamp 106090E0)) - (segment (start 165.3316 108.1797) (end 165.6461 108.4536) (width 1.27) (layer Bottom) (net 1) (tstamp 10609040)) - (segment (start 164.3761 107.1836) (end 165.1381 107.3868) (width 1.27) (layer Bottom) (net 1) (tstamp 10608FA0)) - (segment (start 165.1381 107.3868) (end 164.8587 107.7678) (width 1.27) (layer Bottom) (net 1) (tstamp 10608F00)) - (segment (start 161.9377 105.7866) (end 164.3761 107.1836) (width 1.016) (layer Bottom) (net 1) (tstamp 10608BE0)) - (segment (start 150.4061 114.1686) (end 150.4061 114.9306) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608B40)) - (segment (start 148.5011 112.2636) (end 148.5011 112.2636) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608AA0)) - (segment (start 148.5011 111.6286) (end 148.5011 112.2636) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608A00)) - (segment (start 143.4211 106.5486) (end 145.3261 108.4536) (width 0.4064) (layer Bottom) (net 1) (tstamp 106086E0)) - (segment (start 143.4211 105.9136) (end 143.4211 106.5486) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608640)) - (segment (start 158.3055 115.1592) (end 158.3055 116.0736) (width 0.4064) (layer Bottom) (net 1) (tstamp 106085A0)) - (segment (start 165.0111 108.4536) (end 164.8523 108.6124) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608500)) - (segment (start 164.8523 108.6124) (end 158.3055 115.1592) (width 0.4064) (layer Bottom) (net 1) (tstamp 106081E0)) - (segment (start 165.0577 108.4536) (end 165.0111 108.4536) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608140)) - (segment (start 165.3316 108.1797) (end 165.0577 108.4536) (width 0.4064) (layer Bottom) (net 1) (tstamp 106080A0)) - (segment (start 170.7261 108.4536) (end 168.8211 107.1836) (width 1.016) (layer Top) (net 1) (tstamp 10608000)) - (segment (start 168.8211 107.1836) (end 168.8211 104.0086) (width 1.016) (layer Top) (net 1) (tstamp 10607CE0)) - (segment (start 168.8211 104.0086) (end 169.4561 103.3736) (width 1.016) (layer Top) (net 1) (tstamp 10607C40)) - (segment (start 169.4561 103.3736) (end 169.4561 99.5636) (width 1.016) (layer Top) (net 1) (tstamp 10607BA0)) - (segment (start 169.4561 99.5636) (end 169.4561 97.0236) (width 1.016) (layer Top) (net 1) (tstamp 10607B00)) - (segment (start 169.4561 97.0236) (end 169.4561 94.4836) (width 1.016) (layer Top) (net 1) (tstamp 106077E0)) - (segment (start 169.4561 94.4836) (end 169.4561 91.9436) (width 1.016) (layer Top) (net 1) (tstamp 10607740)) - (segment (start 160.2359 105.7866) (end 161.9377 105.7866) (width 0.8128) (layer Bottom) (net 1) (tstamp 106076A0)) - (segment (start 164.0967 108.479) (end 162.1536 108.4536) (width 0.8128) (layer Bottom) (net 1) (tstamp 10607600)) - (segment (start 164.8523 108.6124) (end 164.0967 108.479) (width 0.8128) (layer Bottom) (net 1) (tstamp 106072E0)) - (segment (start 171.6151 108.4536) (end 173.0883 108.4536) (width 0.8128) (layer Bottom) (net 1) (tstamp 10607240)) - (segment (start 173.0883 108.4536) (end 174.5361 108.4536) (width 0.8128) (layer Bottom) (net 1) (tstamp 106071A0)) - (segment (start 128.8161 109.7262) (end 130.4925 109.7008) (width 0.6096) (layer Top) (net 1) (tstamp 10607100)) - (segment (start 128.8161 109.7236) (end 128.8161 109.7262) (width 0.6096) (layer Top) (net 1) (tstamp 10606DE0)) - (via (at 174.5361 119.8836) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606D40)) - (via (at 174.5361 122.4236) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606CA0)) - (via (at 174.5361 124.9636) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606C00)) - (via (at 174.5361 117.3436) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 106068E0)) - (via (at 162.1536 108.4536) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 1) (tstamp 10606840)) - (via (at 162.1536 100.8336) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 1) (tstamp 106067A0)) - (via (at 171.9961 124.9636) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606700)) - (via (at 171.9961 122.4236) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 106063E0)) - (via (at 171.9961 119.8836) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606340)) - (via (at 171.9961 117.3436) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 106062A0)) - (segment (start 135.7761 90.0436) (end 129.4761 90.0436) (width 0.4064) (layer Top) (net 1)) - (segment (start 127.710506 91.459194) (end 127.5461 91.459194) (width 0.4064) (layer Top) (net 1)) - (segment (start 129.1261 90.0436) (end 127.710506 91.459194) (width 0.4064) (layer Top) (net 1)) - (segment (start 129.4761 90.0436) (end 129.1261 90.0436) (width 0.4064) (layer Top) (net 1)) - (segment (start 123.104 91.4386) (end 127.5461 91.459194) (width 0.4064) (layer Top) (net 1)) - (via (at 170.0911 124.9636) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 170.0911 123.0586) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 165.6461 122.4236) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 165.6461 119.8836) (end 165.6461 119.8836) (width 1.27) (layer Bottom) (net 1) (tstamp 5CA346B1)) - (via (at 165.6461 119.8836) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 165.6461 116.0736) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 162.4711 116.0736) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 158.3055 116.0736) (end 158.3055 121.179) (width 0.4064) (layer Bottom) (net 1) (tstamp 5CA346B6)) - (via (at 159.2961 116.0736) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 164.3761 113.5336) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 161.8361 113.5336) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 168.1861 108.4536) (end 171.6151 108.4536) (width 1.27) (layer Bottom) (net 1) (tstamp 5CA34731)) - (via (at 168.1861 108.4536) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 170.7261 102.1036) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 174.5361 107.1836) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 156.7561 108.8981) (end 155.1686 108.8981) (width 0.6096) (layer Bottom) (net 1) (tstamp 5CA3477B)) - (via (at 157.8991 108.4536) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 164.8841 104.7706) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 156.6291 103.688237) (end 157.7255 103.687) (width 0.6096) (layer Bottom) (net 1) (tstamp 5CA3489C)) - (via (at 156.7561 104.0086) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 163.7538 96.2616) (end 164.3761 94.4836) (width 0.4064) (layer Bottom) (net 1) (tstamp 5CA348F0)) - (via (at 163.7538 96.2616) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 162.0901 99.1826) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 165.6461 85.5936) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 161.8361 84.3236) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 154.2161 84.3236) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 146.5961 84.3236) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 138.9761 84.3236) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 132.6261 84.3236) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 145.3261 108.4536) (end 148.5011 111.6286) (width 0.4064) (layer Bottom) (net 1) (tstamp 5CA34AB2)) - (via (at 145.3261 108.4536) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 142.6591 108.4536) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 142.6591 105.9136) (end 142.6591 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 5CA34AB5)) - (via (at 142.6591 105.9136) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 142.6591 103.3736) (end 142.6591 101.9131) (width 0.4064) (layer Bottom) (net 1) (tstamp 5CA34AB7)) - (via (at 142.6591 103.3736) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 145.3261 103.3736) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 145.3261 105.9136) (end 148.5861 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 5CA34AB9)) - (via (at 145.3261 105.9136) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 127.5461 91.459194) (end 127.5461 91.459194) (width 0.4064) (layer Top) (net 1) (tstamp 5CA34ACD)) - (via (at 127.5461 91.459194) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 125.0061 93.2136) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 122.4661 95.7536) (end 122.4661 92.0736) (width 0.4064) (layer Top) (net 1) (tstamp 5CA34AD8)) - (via (at 122.4661 95.7536) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 122.4661 98.2936) (end 122.4661 95.7536) (width 0.4064) (layer Top) (net 1) (tstamp 5CA34ADB)) - (via (at 122.4661 99.5636) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 122.4661 103.3736) (end 122.4661 98.2936) (width 0.4064) (layer Top) (net 1) (tstamp 5CA34AEF)) - (via (at 122.4661 103.3736) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 122.4661 107.1836) (end 122.4661 104.6436) (width 0.6096) (layer Bottom) (net 1) (tstamp 5CA34AF1)) - (via (at 122.4661 107.1836) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 122.4661 112.2636) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 122.4661 117.3436) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 129.5781 121.4076) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 148.5011 112.2636) (end 150.4061 114.1686) (width 0.4064) (layer Bottom) (net 1) (tstamp 5CA34B76)) - (via (at 148.5011 112.2636) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 149.0091 115.3116) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 131.9911 95.3726) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 154.0891 104.2626) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 154.9781 107.8186) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 137.1981 99.0556) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 156.8831 88.7686) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 165.6461 119.8836) (end 164.3761 119.8836) (width 1.27) (layer Bottom) (net 1)) - (segment (start 165.080415 119.8836) (end 164.3761 119.8836) (width 1.016) (layer Bottom) (net 1)) - (segment (start 165.6461 119.8836) (end 166.9161 119.8836) (width 1.016) (layer Bottom) (net 1)) - (segment (start 165.6461 116.0736) (end 163.8681 116.0736) (width 1.016) (layer Bottom) (net 1)) - (segment (start 164.3761 119.8836) (end 165.080415 119.8836) (width 1.016) (layer Bottom) (net 1) (tstamp 5CAC90CE)) - (via (at 164.3761 119.8836) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 166.9161 119.8836) (end 168.1461 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 5CAC90D0)) - (via (at 166.9161 119.8836) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 168.9481 119.8836) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (via (at 169.9641 118.3596) (size 0.8) (drill 0.4) (layers Top Bottom) (net 1)) - (segment (start 142.7861 113.5971) (end 142.7861 111.7136) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060FA80)) - (segment (start 141.3891 96.2108) (end 141.3891 97.0998) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060FC60)) - (segment (start 141.3891 97.0998) (end 141.9861 98.3316) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F620)) - (segment (start 141.9861 98.3316) (end 141.9861 100.1136) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F6C0)) - (segment (start 142.0241 117.2801) (end 142.9131 117.1531) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F580)) - (segment (start 142.9131 117.1531) (end 143.2624 116.8038) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F760)) - (segment (start 143.2624 116.8038) (end 143.3195 116.6451) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F120)) - (segment (start 143.3195 116.6451) (end 143.3195 114.1686) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F1C0)) - (segment (start 143.3195 114.1686) (end 143.3322 114.1432) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F080)) - (segment (start 143.3322 114.1432) (end 142.7861 113.5971) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F260)) - (segment (start 141.8971 94.7376) (end 141.3891 96.2108) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060EC20)) - (segment (start 142.7861 94.7376) (end 141.8971 94.7376) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060ECC0)) - (segment (start 142.7861 93.2136) (end 142.7861 94.7376) (width 0.8128) (layer Bottom) (net 2) (tstamp 1060EB80)) - (segment (start 141.5161 119.2486) (end 142.0241 117.2801) (width 0.8128) (layer Bottom) (net 2) (tstamp 1060ED60)) - (segment (start 142.7861 93.2136) (end 142.9766 93.1501) (width 0.381) (layer Bottom) (net 2) (tstamp 1060E720)) - (segment (start 143.2624 116.8038) (end 143.2941 116.8356) (width 0.381) (layer Bottom) (net 2) (tstamp 1060E7C0)) - (segment (start 131.1021 104.7946) (end 131.8881 105.0486) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060E680)) - (segment (start 131.8881 105.0486) (end 132.7531 105.9136) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060E860)) - (segment (start 166.9161 102.9926) (end 166.8653 102.9164) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E220)) - (segment (start 166.8653 102.9164) (end 171.6151 105.9136) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E2C0)) - (segment (start 166.9161 98.2936) (end 166.9161 95.7536) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E180)) - (segment (start 166.9161 98.2936) (end 166.9161 100.8336) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E360)) - (segment (start 166.9161 100.8336) (end 166.9161 102.1036) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DD20)) - (segment (start 166.9161 102.1036) (end 166.9161 102.9926) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DDC0)) - (segment (start 174.5361 94.4836) (end 174.5361 91.9436) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DC80)) - (segment (start 174.5361 97.0236) (end 174.5361 94.4836) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DE60)) - (segment (start 174.5361 102.3576) (end 174.5361 99.5636) (width 1.27) (layer Bottom) (net 2) (tstamp 1060D320)) - (segment (start 171.6151 105.9136) (end 174.5361 102.3576) (width 1.27) (layer Bottom) (net 2) (tstamp 1060D3C0)) - (segment (start 174.5361 99.5636) (end 174.5361 97.0236) (width 1.27) (layer Bottom) (net 2) (tstamp 1060D280)) - (segment (start 128.8161 104.6436) (end 131.1021 104.7946) (width 0.6096) (layer Bottom) (net 2) (tstamp 1060D460)) - (segment (start 125.0061 104.6436) (end 128.8161 104.6436) (width 0.6096) (layer Bottom) (net 2) (tstamp 1060CE20)) - (segment (start 166.9161 95.7536) (end 166.9161 91.9436) (width 0.6096) (layer Top) (net 2) (tstamp 1060CEC0)) - (segment (start 165.6461 87.4986) (end 165.7304 87.4986) (width 0.6096) (layer Top) (net 2) (tstamp 1060D820)) - (segment (start 128.8161 104.6436) (end 134.5311 97.6586) (width 0.6096) (layer Top) (net 2) (tstamp 10601840)) - (segment (start 166.9161 100.8336) (end 166.9161 102.1036) (width 0.6096) (layer Top) (net 2) (tstamp 10601A20)) - (segment (start 166.9161 102.1036) (end 166.9161 102.7386) (width 0.6096) (layer Top) (net 2) (tstamp 106013E0)) - (segment (start 166.9161 102.7386) (end 166.9161 107.1836) (width 0.6096) (layer Top) (net 2) (tstamp 10601480)) - (segment (start 166.9161 107.1836) (end 164.3761 110.3586) (width 0.6096) (layer Top) (net 2) (tstamp 10601340)) - (segment (start 164.3761 110.3586) (end 162.4711 110.3586) (width 0.6096) (layer Top) (net 2) (tstamp 10601520)) - (segment (start 162.4711 110.3586) (end 157.3911 113.5336) (width 0.6096) (layer Top) (net 2) (tstamp 10601DE0)) - (segment (start 157.3911 113.5336) (end 151.6761 113.5336) (width 0.6096) (layer Top) (net 2) (tstamp 10601E80)) - (segment (start 151.6761 113.5336) (end 145.9611 113.5336) (width 0.6096) (layer Top) (net 2) (tstamp 10601D40)) - (segment (start 145.9611 113.5336) (end 141.5161 119.2486) (width 0.6096) (layer Top) (net 2) (tstamp 10601F20)) - (segment (start 159.2915 101.9766) (end 159.2961 101.9766) (width 0.4064) (layer Bottom) (net 2) (tstamp 106022E0)) - (segment (start 159.2153 102.4945) (end 159.2915 101.9766) (width 0.4064) (layer Bottom) (net 2) (tstamp 10602380)) - (segment (start 166.9161 93.2136) (end 164.3761 89.4036) (width 0.4064) (layer Bottom) (net 2) (tstamp 10602240)) - (segment (start 166.9161 95.7536) (end 166.9161 93.2136) (width 0.4064) (layer Bottom) (net 2) (tstamp 10602420)) - (segment (start 151.6761 113.5336) (end 151.6761 117.4706) (width 0.4064) (layer Top) (net 2) (tstamp F950850)) - (segment (start 157.3911 113.5336) (end 157.3911 117.4706) (width 0.4064) (layer Top) (net 2) (tstamp F9508F0)) - (segment (start 134.5311 97.6586) (end 133.8961 98.2936) (width 0.4064) (layer Top) (net 2) (tstamp F950990)) - (segment (start 133.8961 98.2936) (end 132.4991 98.2936) (width 0.4064) (layer Top) (net 2) (tstamp F950A30)) - (segment (start 166.9161 102.1036) (end 164.8587 101.4178) (width 1.016) (layer Bottom) (net 2) (tstamp F950AD0)) - (segment (start 174.5361 91.9436) (end 171.9961 91.9436) (width 1.016) (layer Bottom) (net 2) (tstamp F950B70)) - (segment (start 171.9961 94.4836) (end 171.9961 91.9436) (width 1.016) (layer Bottom) (net 2) (tstamp F950C10)) - (segment (start 171.9961 97.0236) (end 171.9961 94.4836) (width 1.016) (layer Bottom) (net 2) (tstamp F950CB0)) - (segment (start 174.5361 94.4836) (end 171.9961 94.4836) (width 1.016) (layer Bottom) (net 2) (tstamp F950D50)) - (segment (start 174.5361 97.0236) (end 171.9961 97.0236) (width 1.016) (layer Bottom) (net 2) (tstamp F950DF0)) - (segment (start 166.9161 91.9436) (end 166.9161 88.7686) (width 0.6096) (layer Top) (net 2) (tstamp F950E90)) - (segment (start 166.9161 88.7686) (end 165.6461 87.4986) (width 0.6096) (layer Top) (net 2) (tstamp F950F30)) - (segment (start 171.9961 99.5636) (end 171.9961 97.0236) (width 1.016) (layer Bottom) (net 2) (tstamp F950FD0)) - (segment (start 174.5361 99.5636) (end 171.9961 99.5636) (width 1.016) (layer Bottom) (net 2) (tstamp F951070)) - (segment (start 160.2359 103.5006) (end 159.2153 102.4945) (width 0.8128) (layer Bottom) (net 2) (tstamp F951110)) - (segment (start 164.8587 101.4178) (end 161.9377 103.5006) (width 1.016) (layer Bottom) (net 2) (tstamp F9511B0)) - (segment (start 161.9377 103.5006) (end 160.2359 103.5006) (width 0.8128) (layer Bottom) (net 2) (tstamp F951250)) - (via (at 142.7861 93.2136) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F9512F0)) - (via (at 141.5161 119.2486) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951390)) - (via (at 128.8161 104.6436) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951430)) - (via (at 166.9161 100.8336) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F9514D0)) - (via (at 166.9161 98.2936) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951570)) - (via (at 166.9161 95.7536) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951610)) - (via (at 174.5361 94.4836) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F9516B0)) - (via (at 174.5361 97.0236) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F951750)) - (via (at 174.5361 99.5636) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F9517F0)) - (via (at 174.5361 91.9436) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F951890)) - (segment (start 142.7861 90.0386) (end 142.7861 93.2136) (width 0.6096) (layer Top) (net 2)) - (segment (start 143.5481 89.1496) (end 142.7861 90.0386) (width 0.6096) (layer Top) (net 2)) - (segment (start 150.9141 89.1496) (end 143.5481 89.1496) (width 0.6096) (layer Top) (net 2)) - (segment (start 165.6461 87.4986) (end 153.5811 87.4986) (width 0.6096) (layer Top) (net 2)) - (segment (start 153.5811 87.4986) (end 150.9141 89.1496) (width 0.6096) (layer Top) (net 2)) - (segment (start 165.6461 98.2936) (end 166.9161 98.2936) (width 0.6096) (layer Top) (net 2)) - (segment (start 165.0111 97.6586) (end 165.6461 98.2936) (width 0.6096) (layer Top) (net 2)) - (segment (start 159.2961 97.6586) (end 165.0111 97.6586) (width 0.6096) (layer Top) (net 2)) - (segment (start 158.5341 96.8966) (end 159.2961 97.6586) (width 0.6096) (layer Top) (net 2)) - (segment (start 158.5341 92.9596) (end 158.5341 96.8966) (width 0.6096) (layer Top) (net 2)) - (segment (start 156.5021 90.1656) (end 158.5341 92.9596) (width 0.6096) (layer Top) (net 2)) - (segment (start 134.5311 97.6586) (end 141.5161 97.6586) (width 0.6096) (layer Top) (net 2)) - (segment (start 141.5161 97.5316) (end 148.8821 90.1656) (width 0.6096) (layer Top) (net 2)) - (segment (start 141.5161 97.6586) (end 141.5161 97.5316) (width 0.6096) (layer Top) (net 2)) - (segment (start 148.8821 90.1656) (end 156.5021 90.1656) (width 0.6096) (layer Top) (net 2)) - (segment (start 149.1361 105.1516) (end 148.5861 105.1136) (width 0.4064) (layer Bottom) (net 2)) - (segment (start 150.876 105.1262) (end 149.1361 105.1516) (width 0.4064) (layer Bottom) (net 2)) - (segment (start 159.2153 102.4945) (end 153.7081 102.4846) (width 0.4064) (layer Bottom) (net 2)) - (segment (start 153.7081 102.4846) (end 150.876 105.1262) (width 0.4064) (layer Bottom) (net 2)) - (segment (start 164.3761 110.3586) (end 164.3761 110.3586) (width 0.6096) (layer Top) (net 2) (tstamp 5CA34779)) - (segment (start 148.5011 90.6736) (end 150.4061 86.8636) (width 0.4064) (layer Bottom) (net 3)) - (segment (start 147.8661 97.6586) (end 148.5011 90.6736) (width 0.4064) (layer Bottom) (net 3)) - (segment (start 146.7861 100.1136) (end 146.8115 98.9672) (width 0.4064) (layer Bottom) (net 3)) - (segment (start 146.8115 98.9672) (end 147.8661 97.6586) (width 0.4064) (layer Bottom) (net 3)) - (segment (start 147.2311 90.6736) (end 147.8661 86.8636) (width 0.4064) (layer Bottom) (net 4)) - (segment (start 146.9009 97.6078) (end 147.2311 90.6736) (width 0.4064) (layer Bottom) (net 4)) - (segment (start 145.9861 100.1136) (end 145.9865 98.8016) (width 0.4064) (layer Bottom) (net 4)) - (segment (start 145.9865 98.8016) (end 146.9009 97.6078) (width 0.4064) (layer Bottom) (net 4)) - (segment (start 145.3261 89.4036) (end 145.3261 86.8636) (width 0.4064) (layer Bottom) (net 5)) - (segment (start 146.0373 91.3848) (end 145.3261 89.4036) (width 0.4064) (layer Bottom) (net 5)) - (segment (start 146.0373 91.3594) (end 146.0373 91.3848) (width 0.4064) (layer Bottom) (net 5)) - (segment (start 146.0119 97.6332) (end 146.0373 91.3594) (width 0.4064) (layer Bottom) (net 5)) - (segment (start 145.1861 100.1136) (end 145.1483 98.7) (width 0.4064) (layer Bottom) (net 5)) - (segment (start 145.1483 98.7) (end 146.0119 97.6332) (width 0.4064) (layer Bottom) (net 5)) - (segment (start 142.7607 87.9558) (end 142.7861 86.8636) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 145.2245 92.2992) (end 142.7607 87.9558) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 145.2245 97.43) (end 145.2245 92.2992) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 144.3861 100.1136) (end 144.3609 98.5476) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 144.3609 98.5476) (end 145.2245 97.43) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 140.2461 88.1336) (end 140.2461 86.8636) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 144.4117 92.477) (end 140.2461 88.1336) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 144.4117 97.2522) (end 144.4117 92.477) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 143.5861 100.1136) (end 143.5735 98.446) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 143.5735 98.446) (end 144.4117 97.2522) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 137.7061 90.6736) (end 137.7061 86.8636) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 140.2461 97.0236) (end 137.7061 90.6736) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 141.1861 100.1136) (end 141.1605 98.6238) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 141.1605 98.6238) (end 140.2461 97.0236) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 135.1661 89.4036) (end 135.1661 86.8636) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 140.3861 100.1136) (end 140.3985 98.7762) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 140.3985 98.7762) (end 135.1661 89.4036) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 132.6261 89.4036) (end 132.6261 86.8636) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 139.5861 100.1136) (end 139.5857 98.9286) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 139.5857 98.9286) (end 132.6261 89.4036) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 130.0861 89.4036) (end 130.0861 86.8636) (width 0.4064) (layer Bottom) (net 11)) - (segment (start 138.7861 100.1136) (end 138.7729 99.3096) (width 0.4064) (layer Bottom) (net 11)) - (segment (start 138.7729 99.3096) (end 130.0861 89.4036) (width 0.4064) (layer Bottom) (net 11)) - (segment (start 127.5461 99.5636) (end 134.0231 99.5636) (width 0.4064) (layer Bottom) (net 12) (tstamp 10605760)) - (segment (start 134.0231 99.5636) (end 136.0551 101.8496) (width 0.4064) (layer Bottom) (net 12) (tstamp 10605120)) - (segment (start 136.0551 101.8496) (end 136.9861 101.9136) (width 0.4064) (layer Bottom) (net 12) (tstamp 106051C0)) - (segment (start 125.0061 99.5636) (end 127.5461 99.5636) (width 0.4064) (layer Bottom) (net 12) (tstamp 10605080)) - (segment (start 132.2705 102.0782) (end 133.2611 101.2146) (width 0.4064) (layer Bottom) (net 13) (tstamp 142C2E50)) - (segment (start 133.2611 101.2146) (end 134.4041 101.2146) (width 0.4064) (layer Bottom) (net 13) (tstamp 142C2EF0)) - (segment (start 134.4041 101.2146) (end 135.8011 102.7386) (width 0.4064) (layer Bottom) (net 13) (tstamp 142C2F90)) - (segment (start 135.8011 102.7386) (end 136.9861 102.7136) (width 0.4064) (layer Bottom) (net 13) (tstamp 142C3030)) - (segment (start 125.0061 102.1036) (end 132.2705 102.0782) (width 0.4064) (layer Bottom) (net 13) (tstamp 142C30D0)) - (segment (start 138.2586 103.545) (end 136.9861 103.5136) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 138.5189 103.2911) (end 138.2586 103.545) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 138.5189 101.7988) (end 138.5189 103.2911) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 125.0061 97.0236) (end 133.5151 97.0236) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 133.5151 97.0236) (end 138.5189 101.7988) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 139.4333 104.3388) (end 136.9861 104.3136) (width 0.4064) (layer Bottom) (net 15) (tstamp 142C44D0)) - (segment (start 125.0061 112.2636) (end 127.5715 114.575) (width 0.4064) (layer Top) (net 15) (tstamp 142C4570)) - (segment (start 127.5715 114.575) (end 131.3815 114.575) (width 0.4064) (layer Top) (net 15) (tstamp 142C4610)) - (segment (start 131.3815 114.575) (end 139.4333 104.3388) (width 0.4064) (layer Top) (net 15) (tstamp 142C46B0)) - (via (at 139.4333 104.3388) (size 1.27) (drill 0.6) (layers Top Bottom) (net 15) (tstamp 142C4750)) - (segment (start 136.1441 105.1136) (end 136.9861 105.1136) (width 0.4064) (layer Bottom) (net 16) (tstamp 1060DAA0)) - (segment (start 135.2931 104.5166) (end 136.1441 105.1136) (width 0.4064) (layer Bottom) (net 16) (tstamp 1060DA00)) - (segment (start 135.1661 104.0721) (end 135.2931 104.5166) (width 0.4064) (layer Bottom) (net 16) (tstamp 1060D1E0)) - (segment (start 135.0391 103.9451) (end 135.1661 104.0721) (width 0.4064) (layer Bottom) (net 16) (tstamp 1060D140)) - (segment (start 133.8961 102.4846) (end 135.0391 103.9451) (width 0.4064) (layer Bottom) (net 16) (tstamp 1060D0A0)) - (segment (start 125.0061 107.1836) (end 127.0381 108.4536) (width 0.4064) (layer Top) (net 16) (tstamp 1060D000)) - (segment (start 127.0381 108.4536) (end 130.7211 108.4536) (width 0.4064) (layer Top) (net 16) (tstamp 1060CCE0)) - (segment (start 130.7211 108.4536) (end 133.8961 102.4846) (width 0.4064) (layer Top) (net 16) (tstamp 1060CC40)) - (via (at 133.8961 102.4846) (size 1.27) (drill 0.6) (layers Top Bottom) (net 16) (tstamp 1060CBA0)) - (segment (start 131.1021 107.7946) (end 134.1261 108.0486) (width 0.4064) (layer Bottom) (net 17) (tstamp 1060D500)) - (segment (start 134.1261 108.0486) (end 134.1501 108.1234) (width 0.4064) (layer Bottom) (net 17) (tstamp 10602BA0)) - (segment (start 134.1501 108.1234) (end 134.6581 108.0726) (width 0.4064) (layer Bottom) (net 17) (tstamp 10602B00)) - (segment (start 134.6581 108.0726) (end 136.0551 106.6756) (width 0.4064) (layer Bottom) (net 17) (tstamp 10602A60)) - (segment (start 136.0551 106.6756) (end 136.9481 106.6756) (width 0.4064) (layer Bottom) (net 17) (tstamp 106029C0)) - (segment (start 136.9481 106.6756) (end 136.9861 106.7136) (width 0.4064) (layer Bottom) (net 17) (tstamp 10602920)) - (segment (start 139.4841 107.0566) (end 138.3157 107.5138) (width 0.4064) (layer Bottom) (net 18) (tstamp 142C49D0)) - (segment (start 138.3157 107.5138) (end 136.9861 107.5136) (width 0.4064) (layer Bottom) (net 18) (tstamp 142C4A70)) - (segment (start 132.5753 114.6258) (end 139.4841 107.0566) (width 0.4064) (layer Top) (net 18) (tstamp 142C4B10)) - (segment (start 126.2507 115.8958) (end 125.0061 114.8036) (width 0.4064) (layer Top) (net 18) (tstamp 142C4BB0)) - (segment (start 126.2507 115.8958) (end 131.3307 115.8958) (width 0.4064) (layer Top) (net 18) (tstamp 142C4C50)) - (segment (start 131.3307 115.8958) (end 132.5753 114.6258) (width 0.4064) (layer Top) (net 18) (tstamp 142C4CF0)) - (via (at 139.4841 107.0566) (size 1.27) (drill 0.6) (layers Top Bottom) (net 18) (tstamp 142C4D90)) - (segment (start 140.6271 108.2758) (end 138.4427 108.2758) (width 0.4064) (layer Bottom) (net 19) (tstamp 142C5010)) - (segment (start 138.4427 108.2758) (end 136.9861 108.3136) (width 0.4064) (layer Bottom) (net 19) (tstamp 142C50B0)) - (via (at 140.6271 108.2758) (size 1.27) (drill 0.6) (layers Top Bottom) (net 19) (tstamp 142C53D0)) - (segment (start 131.071875 119.1216) (end 140.6271 108.2758) (width 0.4064) (layer Top) (net 19)) - (segment (start 125.0061 117.3436) (end 128.0541 119.1216) (width 0.4064) (layer Top) (net 19)) - (segment (start 128.0541 119.1216) (end 131.071875 119.1216) (width 0.4064) (layer Top) (net 19)) - (segment (start 128.1811 100.8336) (end 128.1811 100.0716) (width 0.4064) (layer Top) (net 20) (tstamp 10604680)) - (segment (start 128.1811 100.8336) (end 129.8956 100.8336) (width 0.4064) (layer Top) (net 20) (tstamp 10604860)) - (segment (start 129.8956 100.8336) (end 130.2131 100.5161) (width 0.4064) (layer Top) (net 20) (tstamp 10604220)) - (segment (start 130.2131 100.5161) (end 130.2131 98.2936) (width 0.4064) (layer Top) (net 20) (tstamp 106042C0)) - (segment (start 135.2169 108.9108) (end 136.9861 109.1136) (width 0.4064) (layer Bottom) (net 20)) - (segment (start 132.4229 108.9108) (end 135.2169 108.9108) (width 0.4064) (layer Bottom) (net 20)) - (segment (start 132.1181 109.2156) (end 132.4229 108.9108) (width 0.4064) (layer Bottom) (net 20)) - (segment (start 130.3401 109.2156) (end 132.1181 109.2156) (width 0.4064) (layer Bottom) (net 20)) - (segment (start 127.5461 107.1836) (end 128.8161 107.6916) (width 0.4064) (layer Bottom) (net 20)) - (segment (start 128.8161 107.6916) (end 130.3401 109.2156) (width 0.4064) (layer Bottom) (net 20)) - (segment (start 127.2921 105.6596) (end 127.5461 107.1836) (width 0.4064) (layer Top) (net 20)) - (segment (start 128.1811 100.8336) (end 127.2921 101.7226) (width 0.4064) (layer Top) (net 20)) - (segment (start 127.2921 101.7226) (end 127.2921 105.6596) (width 0.4064) (layer Top) (net 20)) - (segment (start 131.4829 114.8419) (end 133.0579 109.622) (width 0.4064) (layer Bottom) (net 21) (tstamp 10603460)) - (segment (start 133.0579 109.622) (end 135.2931 109.622) (width 0.4064) (layer Bottom) (net 21) (tstamp 1060C920)) - (segment (start 135.2931 109.622) (end 136.9861 109.9136) (width 0.4064) (layer Bottom) (net 21) (tstamp 1060C9C0)) - (segment (start 131.4446 114.8036) (end 130.6449 114.8036) (width 0.4064) (layer Bottom) (net 21) (tstamp 1060C380)) - (segment (start 131.4829 114.8419) (end 131.4446 114.8036) (width 0.4064) (layer Bottom) (net 21) (tstamp 1060C560)) - (segment (start 128.8161 117.3436) (end 127.5461 117.3436) (width 0.4064) (layer Bottom) (net 21)) - (segment (start 130.0861 117.3436) (end 128.8161 117.3436) (width 0.4064) (layer Bottom) (net 21)) - (segment (start 131.2799 116.1498) (end 130.0861 117.3436) (width 0.4064) (layer Bottom) (net 21)) - (segment (start 131.4829 114.8419) (end 131.2799 115.5148) (width 0.4064) (layer Bottom) (net 21)) - (segment (start 131.2799 115.5148) (end 131.2799 116.1498) (width 0.4064) (layer Bottom) (net 21)) - (segment (start 138.7475 112.67) (end 138.7861 111.7136) (width 0.4064) (layer Bottom) (net 22)) - (segment (start 131.8641 120.5186) (end 138.7475 112.67) (width 0.4064) (layer Bottom) (net 22)) - (segment (start 131.3561 121.1536) (end 131.8641 120.5186) (width 0.4064) (layer Bottom) (net 22)) - (segment (start 130.0861 124.9636) (end 130.0861 123.6936) (width 0.4064) (layer Bottom) (net 22)) - (segment (start 130.0861 123.6936) (end 131.3561 121.1536) (width 0.4064) (layer Bottom) (net 22)) - (segment (start 139.5603 113.2034) (end 139.5861 111.7136) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 134.0231 120.8996) (end 139.5603 113.2034) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 132.6261 124.9636) (end 133.8961 121.1536) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 133.8961 121.1536) (end 134.0231 120.8996) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 135.1661 124.9636) (end 135.1661 122.4236) (width 0.4064) (layer Bottom) (net 24) (tstamp F952470)) - (segment (start 135.1661 122.4236) (end 140.2461 113.5336) (width 0.4064) (layer Bottom) (net 24) (tstamp F952510)) - (segment (start 140.2461 113.5336) (end 140.3861 111.7136) (width 0.4064) (layer Bottom) (net 24) (tstamp F9525B0)) - (segment (start 141.1097 113.5336) (end 141.1861 111.7136) (width 0.4064) (layer Bottom) (net 25) (tstamp F952830)) - (segment (start 137.7061 123.6936) (end 141.1097 113.5336) (width 0.4064) (layer Bottom) (net 25) (tstamp F9528D0)) - (segment (start 137.7061 124.9636) (end 137.7061 123.6936) (width 0.4064) (layer Bottom) (net 25) (tstamp F952970)) - (segment (start 144.0561 117.3436) (end 144.0561 114.0162) (width 0.4064) (layer Bottom) (net 26) (tstamp F952FB0)) - (segment (start 144.0561 114.0162) (end 143.5989 113.0256) (width 0.4064) (layer Bottom) (net 26) (tstamp F953050)) - (segment (start 143.5989 113.0256) (end 143.5861 111.7136) (width 0.4064) (layer Bottom) (net 26) (tstamp F9530F0)) - (segment (start 140.2461 123.178487) (end 143.286987 120.1376) (width 0.4064) (layer Bottom) (net 26)) - (segment (start 140.2461 124.9636) (end 140.2461 123.178487) (width 0.4064) (layer Bottom) (net 26)) - (segment (start 143.286987 120.1376) (end 144.0561 117.3436) (width 0.4064) (layer Bottom) (net 26)) - (segment (start 144.4117 112.9748) (end 144.3861 111.7136) (width 0.4064) (layer Bottom) (net 27) (tstamp 142C1FF0)) - (segment (start 144.7419 113.5336) (end 144.4117 112.9748) (width 0.4064) (layer Bottom) (net 27) (tstamp 142C2090)) - (segment (start 144.7419 117.9278) (end 144.7419 113.5336) (width 0.4064) (layer Bottom) (net 27) (tstamp 142C2130)) - (segment (start 143.7259 122.2204) (end 144.7419 117.9278) (width 0.4064) (layer Bottom) (net 27) (tstamp 142C21D0)) - (segment (start 142.8115 123.1602) (end 143.7259 122.2204) (width 0.4064) (layer Bottom) (net 27) (tstamp 142C2270)) - (segment (start 142.7861 124.9636) (end 142.8115 123.1602) (width 0.4064) (layer Bottom) (net 27) (tstamp 142C2310)) - (segment (start 145.1991 112.7716) (end 145.1861 111.7136) (width 0.4064) (layer Bottom) (net 28) (tstamp 142C1B90)) - (segment (start 145.4277 113.3304) (end 145.1991 112.7716) (width 0.4064) (layer Bottom) (net 28) (tstamp 142C1C30)) - (segment (start 145.4277 118.385) (end 145.4277 113.3304) (width 0.4064) (layer Bottom) (net 28) (tstamp 142C1CD0)) - (segment (start 145.3261 124.9636) (end 145.4277 118.385) (width 0.4064) (layer Bottom) (net 28) (tstamp 142C1D70)) - (segment (start 145.9865 112.7462) (end 145.9861 111.7136) (width 0.4064) (layer Bottom) (net 29) (tstamp 142C1730)) - (segment (start 146.3929 114.194) (end 145.9865 112.7462) (width 0.4064) (layer Bottom) (net 29) (tstamp 142C17D0)) - (segment (start 147.8661 124.9636) (end 147.8661 122.4236) (width 0.4064) (layer Bottom) (net 29) (tstamp 142C1870)) - (segment (start 147.8661 122.4236) (end 146.3929 114.194) (width 0.4064) (layer Bottom) (net 29) (tstamp 142C1910)) - (segment (start 146.7739 112.6954) (end 146.7861 111.7136) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C10F0)) - (segment (start 148.5011 117.3436) (end 146.7739 112.6954) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C1190)) - (segment (start 149.1361 118.6136) (end 148.5011 117.3436) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C1230)) - (segment (start 149.7711 119.2486) (end 149.1361 118.6136) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C12D0)) - (segment (start 150.1911 119.2486) (end 149.7711 119.2486) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C1370)) - (segment (start 150.4061 119.0336) (end 150.1911 119.2486) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C1410)) - (segment (start 149.6441 110.2316) (end 148.5861 109.9136) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C0970)) - (segment (start 152.9461 117.3436) (end 149.6441 110.2316) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C0A10)) - (segment (start 152.9461 124.9636) (end 152.9461 122.4236) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C0AB0)) - (segment (start 152.9461 122.4236) (end 152.9461 117.3436) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C0B50)) - (segment (start 152.9461 124.9636) (end 152.9461 123.0586) (width 0.4064) (layer Top) (net 31) (tstamp 142C0BF0)) - (segment (start 152.9461 122.4236) (end 152.9461 123.0586) (width 0.4064) (layer Top) (net 31) (tstamp 142C0C90)) - (segment (start 152.9461 122.4236) (end 151.6761 121.1536) (width 0.4064) (layer Top) (net 31) (tstamp 142C0D30)) - (segment (start 151.6761 121.1536) (end 151.6761 119.7566) (width 0.4064) (layer Top) (net 31) (tstamp 142C0DD0)) - (segment (start 152.9461 124.9636) (end 152.9461 122.4236) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C0E70)) - (segment (start 150.1267 109.2156) (end 148.5861 109.1136) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C03D0)) - (segment (start 154.8511 117.4706) (end 150.1267 109.2156) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C0470)) - (segment (start 154.8511 119.4654) (end 154.8511 117.4706) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C0510)) - (segment (start 154.8003 119.5162) (end 154.8511 119.4654) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C05B0)) - (segment (start 150.4061 108.4536) (end 148.5861 108.3136) (width 0.4064) (layer Bottom) (net 33) (tstamp 142BFD90)) - (segment (start 152.9461 110.9936) (end 150.4061 108.4536) (width 0.4064) (layer Bottom) (net 33) (tstamp 142BFE30)) - (segment (start 157.0101 118.7406) (end 152.9461 110.9936) (width 0.4064) (layer Bottom) (net 33) (tstamp 142BFED0)) - (segment (start 158.0261 124.9636) (end 157.0101 122.5506) (width 0.4064) (layer Bottom) (net 33) (tstamp 142BFF70)) - (segment (start 157.0101 122.5506) (end 157.0101 118.7406) (width 0.4064) (layer Bottom) (net 33) (tstamp 142C0010)) - (segment (start 158.0261 124.9636) (end 157.3911 122.4236) (width 0.4064) (layer Top) (net 33) (tstamp 142C00B0)) - (segment (start 157.3911 122.4236) (end 157.3911 119.7566) (width 0.4064) (layer Top) (net 33) (tstamp 142C0150)) - (segment (start 149.3266 107.5011) (end 150.7109 107.5392) (width 0.4064) (layer Bottom) (net 34) (tstamp 106049A0)) - (segment (start 150.7109 107.5392) (end 154.6479 110.9682) (width 0.4064) (layer Bottom) (net 34) (tstamp 10604900)) - (segment (start 148.5861 107.5136) (end 149.3266 107.5011) (width 0.4064) (layer Bottom) (net 34) (tstamp 106045E0)) - (segment (start 154.6479 110.9682) (end 156.7561 110.9936) (width 0.4064) (layer Bottom) (net 34) (tstamp 10604540)) - (segment (start 157.3911 111.1841) (end 160.1343 111.1841) (width 0.4064) (layer Bottom) (net 34) (tstamp 106044A0)) - (segment (start 156.7561 110.9936) (end 157.3911 111.1841) (width 0.4064) (layer Bottom) (net 34) (tstamp 10604400)) - (segment (start 149.3266 106.7391) (end 151.7396 106.7264) (width 0.4064) (layer Bottom) (net 35) (tstamp 10603BE0)) - (segment (start 148.5861 106.7136) (end 149.3266 106.7391) (width 0.4064) (layer Bottom) (net 35) (tstamp 10603B40)) - (segment (start 151.7396 106.7264) (end 153.3906 105.9517) (width 0.4064) (layer Bottom) (net 35) (tstamp 10603AA0)) - (segment (start 153.3906 105.9517) (end 156.7561 105.9136) (width 0.4064) (layer Bottom) (net 35) (tstamp 10603A00)) - (segment (start 148.6281 104.3261) (end 150.5966 104.3261) (width 0.381) (layer Bottom) (net 36) (tstamp 1060A8A0)) - (segment (start 148.5861 104.3136) (end 148.6281 104.3261) (width 0.381) (layer Bottom) (net 36) (tstamp 1060A800)) - (segment (start 159.2961 99.6906) (end 161.8361 94.4836) (width 0.4064) (layer Bottom) (net 36) (tstamp 1060FDA0)) - (segment (start 158.6611 99.5636) (end 159.2961 99.6906) (width 0.4064) (layer Bottom) (net 36)) - (segment (start 157.0101 101.7226) (end 158.6611 99.5636) (width 0.4064) (layer Bottom) (net 36)) - (segment (start 150.5966 104.3261) (end 153.3271 101.7226) (width 0.4064) (layer Bottom) (net 36)) - (segment (start 153.3271 101.7226) (end 157.0101 101.7226) (width 0.4064) (layer Bottom) (net 36)) - (segment (start 148.5861 103.5136) (end 148.6916 103.5641) (width 0.4064) (layer Bottom) (net 37) (tstamp 1060F440)) - (segment (start 148.8821 103.5006) (end 149.1996 103.5006) (width 0.381) (layer Bottom) (net 37) (tstamp 1060F3A0)) - (segment (start 148.5861 103.5136) (end 148.8821 103.5006) (width 0.381) (layer Bottom) (net 37) (tstamp 1060F300)) - (segment (start 156.7561 97.0236) (end 161.8361 91.9436) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 150.4061 97.0236) (end 152.9461 97.0236) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 152.9461 97.0236) (end 155.4861 97.0236) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 155.4861 97.0236) (end 156.7561 97.0236) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 152.9461 100.3256) (end 152.9461 97.0236) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 152.9461 101.0876) (end 152.9461 100.3256) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 150.3045 103.472324) (end 152.9461 101.0876) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 149.1996 103.5006) (end 150.3045 103.5006) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 150.3045 103.5006) (end 150.3045 103.472324) (width 0.4064) (layer Bottom) (net 37)) - (segment (start 156.7561 94.4836) (end 161.8361 89.4036) (width 0.4064) (layer Bottom) (net 38)) - (segment (start 153.846099 95.383599) (end 152.9461 94.4836) (width 0.4064) (layer Top) (net 38)) - (segment (start 154.230499 95.767999) (end 153.846099 95.383599) (width 0.4064) (layer Top) (net 38)) - (segment (start 154.230499 95.739201) (end 154.230499 95.767999) (width 0.4064) (layer Top) (net 38)) - (segment (start 155.4861 94.4836) (end 154.230499 95.739201) (width 0.4064) (layer Top) (net 38)) - (segment (start 156.7561 94.4836) (end 155.4861 94.4836) (width 0.4064) (layer Bottom) (net 38)) - (segment (start 155.4861 94.4836) (end 152.9461 94.4836) (width 0.4064) (layer Bottom) (net 38)) - (segment (start 152.9461 94.4836) (end 150.4061 94.4836) (width 0.4064) (layer Bottom) (net 38)) - (segment (start 149.5883 102.7331) (end 148.5861 102.7136) (width 0.4064) (layer Bottom) (net 38)) - (via (at 151.9301 100.5796) (size 1.27) (drill 0.6) (layers Top Bottom) (net 38)) - (segment (start 154.230499 98.279201) (end 151.9301 100.5796) (width 0.4064) (layer Top) (net 38)) - (segment (start 154.230499 95.767999) (end 154.230499 98.279201) (width 0.4064) (layer Top) (net 38)) - (segment (start 149.7766 102.7331) (end 151.9301 100.5796) (width 0.4064) (layer Bottom) (net 38)) - (segment (start 149.5883 102.7331) (end 149.7766 102.7331) (width 0.4064) (layer Bottom) (net 38)) - (segment (start 148.5861 101.9136) (end 148.6027 101.9385) (width 0.381) (layer Bottom) (net 39) (tstamp 10603000)) - (segment (start 154.2161 91.9436) (end 156.7561 91.9436) (width 0.4064) (layer Bottom) (net 39) (tstamp 1060C600)) - (segment (start 156.7561 91.9436) (end 160.2486 87.4986) (width 0.4064) (layer Bottom) (net 39) (tstamp 1060C2E0)) - (segment (start 160.2486 87.4986) (end 162.4711 87.4986) (width 0.4064) (layer Bottom) (net 39) (tstamp 5C8E5F91)) - (segment (start 162.4711 87.4986) (end 163.1061 88.1336) (width 0.4064) (layer Bottom) (net 39) (tstamp 1060C1A0)) - (segment (start 163.1061 88.1336) (end 163.1061 90.6736) (width 0.4064) (layer Bottom) (net 39) (tstamp 1060C100)) - (segment (start 163.1061 90.6736) (end 164.3761 91.9436) (width 0.4064) (layer Bottom) (net 39) (tstamp 1060BDE0)) - (segment (start 150.4061 91.9436) (end 154.2161 91.9436) (width 0.4064) (layer Bottom) (net 39)) - (segment (start 149.7425 101.9136) (end 150.5331 101.123) (width 0.4064) (layer Bottom) (net 39)) - (segment (start 148.5861 101.9136) (end 149.7425 101.9136) (width 0.4064) (layer Bottom) (net 39)) - (via (at 150.5331 99.6906) (size 1.27) (drill 0.6) (layers Top Bottom) (net 39)) - (segment (start 150.5331 101.123) (end 150.5331 99.6906) (width 0.4064) (layer Bottom) (net 39)) - (segment (start 152.046101 92.843599) (end 152.9461 91.9436) (width 0.4064) (layer Top) (net 39)) - (segment (start 151.661701 93.227999) (end 152.046101 92.843599) (width 0.4064) (layer Top) (net 39)) - (segment (start 151.661701 98.561999) (end 151.661701 93.227999) (width 0.4064) (layer Top) (net 39)) - (segment (start 150.5331 99.6906) (end 151.661701 98.561999) (width 0.4064) (layer Top) (net 39)) - (segment (start 151.306099 92.872397) (end 151.661701 93.227999) (width 0.4064) (layer Top) (net 39)) - (segment (start 151.306099 92.843599) (end 151.306099 92.872397) (width 0.4064) (layer Top) (net 39)) - (segment (start 150.4061 91.9436) (end 151.306099 92.843599) (width 0.4064) (layer Top) (net 39)) - (segment (start 171.6151 110.9936) (end 171.0121 111.0256) (width 0.8128) (layer Bottom) (net 40) (tstamp 142C35D0)) - (segment (start 171.6151 110.9936) (end 171.2849 110.9682) (width 0.8128) (layer Bottom) (net 40) (tstamp 142C3670)) - (segment (start 171.6151 110.9936) (end 170.7261 111.2476) (width 1.27) (layer Bottom) (net 40) (tstamp 142C3710)) - (segment (start 171.9961 114.1686) (end 174.5361 114.1686) (width 1.27) (layer Bottom) (net 40) (tstamp 142C3A30)) - (segment (start 171.6151 110.9936) (end 173.0883 110.7396) (width 0.8128) (layer Bottom) (net 40) (tstamp 142C3AD0)) - (segment (start 173.0883 110.7396) (end 174.5361 110.7396) (width 0.8128) (layer Bottom) (net 40) (tstamp 142C3B70)) - (segment (start 171.9961 113.7808) (end 171.9961 114.1686) (width 1.27) (layer Bottom) (net 40)) - (segment (start 171.6151 110.9936) (end 171.9961 113.7808) (width 1.27) (layer Bottom) (net 40)) - (segment (start 161.3181 118.3596) (end 161.0741 118.6036) (width 1.016) (layer Bottom) (net 40)) - (segment (start 167.4241 118.3596) (end 161.3181 118.3596) (width 1.016) (layer Bottom) (net 40)) - (segment (start 168.4401 117.0896) (end 167.4241 118.3596) (width 1.016) (layer Bottom) (net 40)) - (segment (start 168.4401 113.5336) (end 168.4401 117.0896) (width 1.016) (layer Bottom) (net 40)) - (segment (start 171.6151 110.9936) (end 169.9641 110.9936) (width 1.016) (layer Bottom) (net 40)) - (segment (start 169.9641 110.9936) (end 168.4401 113.5336) (width 1.016) (layer Bottom) (net 40)) - (segment (start 128.3589 114.8036) (end 128.8161 112.2636) (width 0.4064) (layer Bottom) (net 41) (tstamp 142C2630)) - (segment (start 130.2867 113.0992) (end 130.4925 113.2008) (width 0.6096) (layer Top) (net 41) (tstamp 142C26D0)) - (segment (start 129.4511 112.2636) (end 130.2867 113.0992) (width 0.6096) (layer Top) (net 41) (tstamp 142C2770)) - (segment (start 128.8161 112.2636) (end 129.4511 112.2636) (width 0.6096) (layer Top) (net 41) (tstamp 142C2810)) - (segment (start 150.4061 124.9636) (end 150.4061 122.4236) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C5790)) - (segment (start 150.4061 122.4236) (end 150.4061 120.7336) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C5830)) - (segment (start 151.5491 117.8516) (end 150.4061 117.2166) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C58D0)) - (segment (start 151.6761 117.9786) (end 151.5491 117.8516) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C5970)) - (segment (start 151.6761 120.2011) (end 151.6761 117.9786) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C5A10)) - (segment (start 151.3586 120.5186) (end 151.6761 120.2011) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C5AB0)) - (segment (start 150.6211 120.5186) (end 151.3586 120.5186) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C5B50)) - (segment (start 150.4061 120.7336) (end 150.6211 120.5186) (width 0.4064) (layer Bottom) (net 42) (tstamp 142C5BF0)) - (segment (start 154.8003 122.3728) (end 154.8003 121.2162) (width 0.4064) (layer Bottom) (net 43) (tstamp 142C6190)) - (segment (start 155.4861 123.0586) (end 154.8003 122.3728) (width 0.4064) (layer Bottom) (net 43) (tstamp 142C6230)) - (segment (start 155.4861 124.9636) (end 155.4861 123.0586) (width 0.4064) (layer Bottom) (net 43) (tstamp 142C62D0)) - (segment (start 154.8375 121.179) (end 156.0195 121.179) (width 0.4064) (layer Bottom) (net 43) (tstamp 142C6370)) - (segment (start 154.8003 121.2162) (end 154.8375 121.179) (width 0.4064) (layer Bottom) (net 43) (tstamp 142C6410)) - (segment (start 163.1461 122.4236) (end 163.6161 124.9636) (width 1.27) (layer Bottom) (net 44) (tstamp 1060E0E0)) - (segment (start 161.0741 123.7036) (end 163.1461 122.4236) (width 1.27) (layer Bottom) (net 44) (tstamp 1060E040)) - (segment (start 128.1811 97.7856) (end 128.1811 97.0436) (width 0.4064) (layer Top) (net 45) (tstamp 142C4110)) - (segment (start 128.1811 97.0436) (end 129.4761 95.1136) (width 0.4064) (layer Top) (net 45) (tstamp 142C41B0)) - (segment (start 129.4761 95.1136) (end 129.4761 93.8436) (width 0.4064) (layer Top) (net 45)) - (segment (start 129.4761 93.8436) (end 135.7761 93.8436) (width 0.4064) (layer Top) (net 45)) - - (zone (net 1) (net_name GND) (layer Bottom) (tstamp 5CA38C45) (hatch edge 0.508) - (priority 6) - (connect_pads (clearance 0.3048)) - (min_thickness 0.3048) - (fill yes (arc_segments 32) (thermal_gap 0.3548) (thermal_bridge_width 0.3548)) - (polygon - (pts - (xy 145.9611 109.7236) (xy 146.5961 109.0886) (xy 146.5961 102.7386) (xy 145.9611 101.9766) (xy 139.6111 101.9766) - (xy 139.6111 103.3736) (xy 138.9761 104.8976) (xy 138.9761 109.0886) (xy 139.6111 109.7236) - ) - ) - (filled_polygon - (pts - (xy 146.4437 102.793776) (xy 146.4437 109.025474) (xy 145.897974 109.5712) (xy 139.674226 109.5712) (xy 139.1285 109.025474) - (xy 139.1285 108.9362) (xy 139.754787 108.9362) (xy 139.778733 108.972037) (xy 139.930863 109.124167) (xy 140.109749 109.243695) - (xy 140.308517 109.326028) (xy 140.519528 109.368) (xy 140.734672 109.368) (xy 140.945683 109.326028) (xy 141.144451 109.243695) - (xy 141.323337 109.124167) (xy 141.475467 108.972037) (xy 141.594995 108.793151) (xy 141.677328 108.594383) (xy 141.7193 108.383372) - (xy 141.7193 108.168228) (xy 141.677328 107.957217) (xy 141.594995 107.758449) (xy 141.475467 107.579563) (xy 141.323337 107.427433) - (xy 141.144451 107.307905) (xy 140.945683 107.225572) (xy 140.734672 107.1836) (xy 140.572436 107.1836) (xy 140.5763 107.164172) - (xy 140.5763 106.949028) (xy 140.534328 106.738017) (xy 140.451995 106.539249) (xy 140.332467 106.360363) (xy 140.180337 106.208233) - (xy 140.001451 106.088705) (xy 139.802683 106.006372) (xy 139.591672 105.9644) (xy 139.376528 105.9644) (xy 139.165517 106.006372) - (xy 139.1285 106.021705) (xy 139.1285 105.39177) (xy 139.325728 105.431) (xy 139.540872 105.431) (xy 139.751883 105.389028) - (xy 139.950651 105.306695) (xy 140.129537 105.187167) (xy 140.281667 105.035037) (xy 140.401195 104.856151) (xy 140.483528 104.657383) - (xy 140.5255 104.446372) (xy 140.5255 104.231228) (xy 140.483528 104.020217) (xy 140.401195 103.821449) (xy 140.281667 103.642563) - (xy 140.129537 103.490433) (xy 139.950651 103.370905) (xy 139.7635 103.293384) (xy 139.7635 102.129) (xy 145.88972 102.129) - ) - ) - ) - (zone (net 1) (net_name GND) (layer Bottom) (tstamp 5CA38C42) (hatch edge 0.508) - (priority 6) - (connect_pads (clearance 0.6096)) - (min_thickness 0.254) - (fill yes (arc_segments 32) (thermal_gap 0.304) (thermal_bridge_width 0.304)) - (polygon - (pts - (xy 121.8311 83.0536) (xy 175.1711 83.0536) (xy 175.1711 126.8686) (xy 121.8311 126.8686) - ) - ) - (filled_polygon - (pts - (xy 170.556575 113.3772) (xy 170.545764 113.393379) (xy 170.422393 113.691221) (xy 170.3595 114.007409) (xy 170.3595 114.329791) - (xy 170.422393 114.645979) (xy 170.545764 114.943821) (xy 170.72487 115.211872) (xy 170.952828 115.43983) (xy 171.220879 115.618936) - (xy 171.518721 115.742307) (xy 171.834909 115.8052) (xy 172.157291 115.8052) (xy 172.473479 115.742307) (xy 172.771321 115.618936) - (xy 172.889158 115.5402) (xy 173.643042 115.5402) (xy 173.760879 115.618936) (xy 174.058721 115.742307) (xy 174.374909 115.8052) - (xy 174.697291 115.8052) (xy 175.013479 115.742307) (xy 175.0441 115.729623) (xy 175.0441 116.171671) (xy 175.002847 116.150658) - (xy 174.761147 116.082522) (xy 174.5611 116.170593) (xy 174.5611 117.3186) (xy 174.5811 117.3186) (xy 174.5811 117.3686) - (xy 174.5611 117.3686) (xy 174.5611 118.516607) (xy 174.761147 118.604678) (xy 175.002847 118.536542) (xy 175.0441 118.515529) - (xy 175.0441 118.711671) (xy 175.002847 118.690658) (xy 174.761147 118.622522) (xy 174.5611 118.710593) (xy 174.5611 119.8586) - (xy 174.5811 119.8586) (xy 174.5811 119.9086) (xy 174.5611 119.9086) (xy 174.5611 121.056607) (xy 174.761147 121.144678) - (xy 175.002847 121.076542) (xy 175.0441 121.055529) (xy 175.0441 121.251671) (xy 175.002847 121.230658) (xy 174.761147 121.162522) - (xy 174.5611 121.250593) (xy 174.5611 122.3986) (xy 174.5811 122.3986) (xy 174.5811 122.4486) (xy 174.5611 122.4486) - (xy 174.5611 123.596607) (xy 174.761147 123.684678) (xy 175.002847 123.616542) (xy 175.0441 123.595529) (xy 175.0441 123.791671) - (xy 175.002847 123.770658) (xy 174.761147 123.702522) (xy 174.5611 123.790593) (xy 174.5611 124.9386) (xy 174.5811 124.9386) - (xy 174.5811 124.9886) (xy 174.5611 124.9886) (xy 174.5611 126.136607) (xy 174.761147 126.224678) (xy 175.002847 126.156542) - (xy 175.0441 126.135529) (xy 175.0441 126.692) (xy 164.855619 126.692) (xy 164.917313 126.659024) (xy 165.029475 126.566975) - (xy 165.121524 126.454813) (xy 165.189922 126.326849) (xy 165.232042 126.187999) (xy 165.246264 126.0436) (xy 165.246264 125.09635) - (xy 166.3651 125.09635) (xy 166.3651 126.08605) (xy 166.381663 126.169318) (xy 166.414153 126.247755) (xy 166.46132 126.318346) - (xy 166.521353 126.378379) (xy 166.591945 126.425547) (xy 166.670382 126.458037) (xy 166.75365 126.4746) (xy 167.55335 126.4746) - (xy 167.6611 126.36685) (xy 167.6611 124.9886) (xy 167.7111 124.9886) (xy 167.7111 126.36685) (xy 167.81885 126.4746) - (xy 168.61855 126.4746) (xy 168.701818 126.458037) (xy 168.780255 126.425547) (xy 168.850847 126.378379) (xy 168.91088 126.318346) - (xy 168.958047 126.247755) (xy 168.990537 126.169318) (xy 169.0071 126.08605) (xy 169.0071 125.188647) (xy 170.735023 125.188647) - (xy 170.744895 125.238277) (xy 170.822523 125.477097) (xy 170.945251 125.696184) (xy 171.108363 125.887118) (xy 171.30559 126.042562) - (xy 171.529353 126.156542) (xy 171.771053 126.224678) (xy 171.9711 126.136607) (xy 171.9711 124.9886) (xy 172.0211 124.9886) - (xy 172.0211 126.136607) (xy 172.221147 126.224678) (xy 172.462847 126.156542) (xy 172.68661 126.042562) (xy 172.883837 125.887118) - (xy 173.046949 125.696184) (xy 173.169677 125.477097) (xy 173.247305 125.238277) (xy 173.257177 125.188647) (xy 173.275023 125.188647) - (xy 173.284895 125.238277) (xy 173.362523 125.477097) (xy 173.485251 125.696184) (xy 173.648363 125.887118) (xy 173.84559 126.042562) - (xy 174.069353 126.156542) (xy 174.311053 126.224678) (xy 174.5111 126.136607) (xy 174.5111 124.9886) (xy 173.363116 124.9886) - (xy 173.275023 125.188647) (xy 173.257177 125.188647) (xy 173.169084 124.9886) (xy 172.0211 124.9886) (xy 171.9711 124.9886) - (xy 170.823116 124.9886) (xy 170.735023 125.188647) (xy 169.0071 125.188647) (xy 169.0071 125.09635) (xy 168.89935 124.9886) - (xy 167.7111 124.9886) (xy 167.6611 124.9886) (xy 166.47285 124.9886) (xy 166.3651 125.09635) (xy 165.246264 125.09635) - (xy 165.246264 123.8836) (xy 165.242084 123.84115) (xy 166.3651 123.84115) (xy 166.3651 124.83085) (xy 166.47285 124.9386) - (xy 167.6611 124.9386) (xy 167.6611 124.9186) (xy 167.7111 124.9186) (xy 167.7111 124.9386) (xy 168.89935 124.9386) - (xy 169.0071 124.83085) (xy 169.0071 124.738553) (xy 170.735023 124.738553) (xy 170.823116 124.9386) (xy 171.9711 124.9386) - (xy 171.9711 123.790593) (xy 172.0211 123.790593) (xy 172.0211 124.9386) (xy 173.169084 124.9386) (xy 173.257177 124.738553) - (xy 173.275023 124.738553) (xy 173.363116 124.9386) (xy 174.5111 124.9386) (xy 174.5111 123.790593) (xy 174.311053 123.702522) - (xy 174.069353 123.770658) (xy 173.84559 123.884638) (xy 173.648363 124.040082) (xy 173.485251 124.231016) (xy 173.362523 124.450103) - (xy 173.284895 124.688923) (xy 173.275023 124.738553) (xy 173.257177 124.738553) (xy 173.247305 124.688923) (xy 173.169677 124.450103) - (xy 173.046949 124.231016) (xy 172.883837 124.040082) (xy 172.68661 123.884638) (xy 172.462847 123.770658) (xy 172.221147 123.702522) - (xy 172.0211 123.790593) (xy 171.9711 123.790593) (xy 171.771053 123.702522) (xy 171.529353 123.770658) (xy 171.30559 123.884638) - (xy 171.108363 124.040082) (xy 170.945251 124.231016) (xy 170.822523 124.450103) (xy 170.744895 124.688923) (xy 170.735023 124.738553) - (xy 169.0071 124.738553) (xy 169.0071 124.321238) (xy 169.066293 124.274498) (xy 169.23503 124.076617) (xy 169.36192 123.849619) - (xy 169.442087 123.602228) (xy 169.47245 123.34395) (xy 169.47245 122.648647) (xy 170.735023 122.648647) (xy 170.744895 122.698277) - (xy 170.822523 122.937097) (xy 170.945251 123.156184) (xy 171.108363 123.347118) (xy 171.30559 123.502562) (xy 171.529353 123.616542) - (xy 171.771053 123.684678) (xy 171.9711 123.596607) (xy 171.9711 122.4486) (xy 172.0211 122.4486) (xy 172.0211 123.596607) - (xy 172.221147 123.684678) (xy 172.462847 123.616542) (xy 172.68661 123.502562) (xy 172.883837 123.347118) (xy 173.046949 123.156184) - (xy 173.169677 122.937097) (xy 173.247305 122.698277) (xy 173.257177 122.648647) (xy 173.275023 122.648647) (xy 173.284895 122.698277) - (xy 173.362523 122.937097) (xy 173.485251 123.156184) (xy 173.648363 123.347118) (xy 173.84559 123.502562) (xy 174.069353 123.616542) - (xy 174.311053 123.684678) (xy 174.5111 123.596607) (xy 174.5111 122.4486) (xy 173.363116 122.4486) (xy 173.275023 122.648647) - (xy 173.257177 122.648647) (xy 173.169084 122.4486) (xy 172.0211 122.4486) (xy 171.9711 122.4486) (xy 170.823116 122.4486) - (xy 170.735023 122.648647) (xy 169.47245 122.648647) (xy 169.47245 122.4486) (xy 168.1711 122.4486) (xy 168.1711 122.4686) - (xy 168.1211 122.4686) (xy 168.1211 122.4486) (xy 166.81975 122.4486) (xy 166.81975 123.34395) (xy 166.832523 123.4526) - (xy 166.75365 123.4526) (xy 166.670382 123.469163) (xy 166.591945 123.501653) (xy 166.521353 123.548821) (xy 166.46132 123.608854) - (xy 166.414153 123.679445) (xy 166.381663 123.757882) (xy 166.3651 123.84115) (xy 165.242084 123.84115) (xy 165.232042 123.739201) - (xy 165.189922 123.600351) (xy 165.121524 123.472387) (xy 165.029475 123.360225) (xy 164.917313 123.268176) (xy 164.789349 123.199778) - (xy 164.77805 123.19635) (xy 164.77805 121.50325) (xy 166.81975 121.50325) (xy 166.81975 122.3986) (xy 168.1211 122.3986) - (xy 168.1211 120.309906) (xy 168.1711 120.309906) (xy 168.1711 122.3986) (xy 169.47245 122.3986) (xy 169.47245 122.198553) - (xy 170.735023 122.198553) (xy 170.823116 122.3986) (xy 171.9711 122.3986) (xy 171.9711 121.250593) (xy 172.0211 121.250593) - (xy 172.0211 122.3986) (xy 173.169084 122.3986) (xy 173.257177 122.198553) (xy 173.275023 122.198553) (xy 173.363116 122.3986) - (xy 174.5111 122.3986) (xy 174.5111 121.250593) (xy 174.311053 121.162522) (xy 174.069353 121.230658) (xy 173.84559 121.344638) - (xy 173.648363 121.500082) (xy 173.485251 121.691016) (xy 173.362523 121.910103) (xy 173.284895 122.148923) (xy 173.275023 122.198553) - (xy 173.257177 122.198553) (xy 173.247305 122.148923) (xy 173.169677 121.910103) (xy 173.046949 121.691016) (xy 172.883837 121.500082) - (xy 172.68661 121.344638) (xy 172.462847 121.230658) (xy 172.221147 121.162522) (xy 172.0211 121.250593) (xy 171.9711 121.250593) - (xy 171.771053 121.162522) (xy 171.529353 121.230658) (xy 171.30559 121.344638) (xy 171.108363 121.500082) (xy 170.945251 121.691016) - (xy 170.822523 121.910103) (xy 170.744895 122.148923) (xy 170.735023 122.198553) (xy 169.47245 122.198553) (xy 169.47245 121.50325) - (xy 169.442087 121.244972) (xy 169.36192 120.997581) (xy 169.23503 120.770583) (xy 169.066293 120.572702) (xy 168.862194 120.411542) - (xy 168.630576 120.293296) (xy 168.380339 120.222509) (xy 168.378242 120.222374) (xy 168.1711 120.309906) (xy 168.1211 120.309906) - (xy 167.913958 120.222374) (xy 167.911861 120.222509) (xy 167.661624 120.293296) (xy 167.430006 120.411542) (xy 167.225907 120.572702) - (xy 167.05717 120.770583) (xy 166.93028 120.997581) (xy 166.850113 121.244972) (xy 166.81975 121.50325) (xy 164.77805 121.50325) - (xy 164.77805 121.44808) (xy 164.754437 121.208332) (xy 164.66112 120.900708) (xy 164.509582 120.6172) (xy 164.305646 120.368704) - (xy 164.05715 120.164768) (xy 163.952155 120.108647) (xy 170.735023 120.108647) (xy 170.744895 120.158277) (xy 170.822523 120.397097) - (xy 170.945251 120.616184) (xy 171.108363 120.807118) (xy 171.30559 120.962562) (xy 171.529353 121.076542) (xy 171.771053 121.144678) - (xy 171.9711 121.056607) (xy 171.9711 119.9086) (xy 172.0211 119.9086) (xy 172.0211 121.056607) (xy 172.221147 121.144678) - (xy 172.462847 121.076542) (xy 172.68661 120.962562) (xy 172.883837 120.807118) (xy 173.046949 120.616184) (xy 173.169677 120.397097) - (xy 173.247305 120.158277) (xy 173.257177 120.108647) (xy 173.275023 120.108647) (xy 173.284895 120.158277) (xy 173.362523 120.397097) - (xy 173.485251 120.616184) (xy 173.648363 120.807118) (xy 173.84559 120.962562) (xy 174.069353 121.076542) (xy 174.311053 121.144678) - (xy 174.5111 121.056607) (xy 174.5111 119.9086) (xy 173.363116 119.9086) (xy 173.275023 120.108647) (xy 173.257177 120.108647) - (xy 173.169084 119.9086) (xy 172.0211 119.9086) (xy 171.9711 119.9086) (xy 170.823116 119.9086) (xy 170.735023 120.108647) - (xy 163.952155 120.108647) (xy 163.773642 120.01323) (xy 163.466018 119.919913) (xy 163.1461 119.888404) (xy 162.826183 119.919913) - (xy 162.7718 119.93641) (xy 162.789524 119.914813) (xy 162.857922 119.786849) (xy 162.900042 119.647999) (xy 162.904356 119.6042) - (xy 167.309363 119.6042) (xy 167.317063 119.605632) (xy 167.431784 119.6042) (xy 167.485243 119.6042) (xy 167.493002 119.603436) - (xy 167.562208 119.602572) (xy 167.614682 119.591452) (xy 167.668084 119.586192) (xy 167.734339 119.566094) (xy 167.802046 119.551745) - (xy 167.851345 119.5306) (xy 167.902692 119.515024) (xy 167.963747 119.48239) (xy 168.02736 119.455105) (xy 168.071591 119.424746) - (xy 168.118908 119.399454) (xy 168.17242 119.355537) (xy 168.229491 119.316365) (xy 168.26695 119.277959) (xy 168.308423 119.243923) - (xy 168.352338 119.190412) (xy 168.357773 119.18484) (xy 168.391115 119.143163) (xy 168.463954 119.054408) (xy 168.467649 119.047495) - (xy 169.407144 117.873127) (xy 169.479954 117.784408) (xy 169.512582 117.723366) (xy 169.550323 117.665327) (xy 169.570235 117.615504) - (xy 169.595524 117.568192) (xy 169.61562 117.501945) (xy 169.625849 117.47635) (xy 170.7151 117.47635) (xy 170.7151 118.23605) - (xy 170.731663 118.319318) (xy 170.764153 118.397755) (xy 170.81132 118.468346) (xy 170.871353 118.528379) (xy 170.941945 118.575547) - (xy 171.020382 118.608037) (xy 171.10365 118.6246) (xy 171.763682 118.6246) (xy 171.529353 118.690658) (xy 171.30559 118.804638) - (xy 171.108363 118.960082) (xy 170.945251 119.151016) (xy 170.822523 119.370103) (xy 170.744895 119.608923) (xy 170.735023 119.658553) - (xy 170.823116 119.8586) (xy 171.9711 119.8586) (xy 171.9711 118.710593) (xy 171.775773 118.6246) (xy 171.86335 118.6246) - (xy 171.9711 118.51685) (xy 171.9711 117.3686) (xy 172.0211 117.3686) (xy 172.0211 118.51685) (xy 172.12885 118.6246) - (xy 172.216427 118.6246) (xy 172.0211 118.710593) (xy 172.0211 119.8586) (xy 173.169084 119.8586) (xy 173.257177 119.658553) - (xy 173.275023 119.658553) (xy 173.363116 119.8586) (xy 174.5111 119.8586) (xy 174.5111 118.710593) (xy 174.311053 118.622522) - (xy 174.069353 118.690658) (xy 173.84559 118.804638) (xy 173.648363 118.960082) (xy 173.485251 119.151016) (xy 173.362523 119.370103) - (xy 173.284895 119.608923) (xy 173.275023 119.658553) (xy 173.257177 119.658553) (xy 173.247305 119.608923) (xy 173.169677 119.370103) - (xy 173.046949 119.151016) (xy 172.883837 118.960082) (xy 172.68661 118.804638) (xy 172.462847 118.690658) (xy 172.228518 118.6246) - (xy 172.88855 118.6246) (xy 172.971818 118.608037) (xy 173.050255 118.575547) (xy 173.120847 118.528379) (xy 173.18088 118.468346) - (xy 173.228047 118.397755) (xy 173.260537 118.319318) (xy 173.2771 118.23605) (xy 173.2771 117.579089) (xy 173.284895 117.618277) - (xy 173.362523 117.857097) (xy 173.485251 118.076184) (xy 173.648363 118.267118) (xy 173.84559 118.422562) (xy 174.069353 118.536542) - (xy 174.311053 118.604678) (xy 174.5111 118.516607) (xy 174.5111 117.3686) (xy 173.363116 117.3686) (xy 173.2771 117.56393) - (xy 173.2771 117.47635) (xy 173.16935 117.3686) (xy 172.0211 117.3686) (xy 171.9711 117.3686) (xy 170.82285 117.3686) - (xy 170.7151 117.47635) (xy 169.625849 117.47635) (xy 169.641308 117.43767) (xy 169.651115 117.384933) (xy 169.666692 117.333584) - (xy 169.673478 117.264681) (xy 169.686132 117.196638) (xy 169.6847 117.081916) (xy 169.6847 116.45115) (xy 170.7151 116.45115) - (xy 170.7151 117.21085) (xy 170.82285 117.3186) (xy 171.9711 117.3186) (xy 171.9711 116.17035) (xy 172.0211 116.17035) - (xy 172.0211 117.3186) (xy 173.16935 117.3186) (xy 173.2771 117.21085) (xy 173.2771 117.12327) (xy 173.363116 117.3186) - (xy 174.5111 117.3186) (xy 174.5111 116.170593) (xy 174.311053 116.082522) (xy 174.069353 116.150658) (xy 173.84559 116.264638) - (xy 173.648363 116.420082) (xy 173.485251 116.611016) (xy 173.362523 116.830103) (xy 173.284895 117.068923) (xy 173.2771 117.108111) - (xy 173.2771 116.45115) (xy 173.260537 116.367882) (xy 173.228047 116.289445) (xy 173.18088 116.218854) (xy 173.120847 116.158821) - (xy 173.050255 116.111653) (xy 172.971818 116.079163) (xy 172.88855 116.0626) (xy 172.12885 116.0626) (xy 172.0211 116.17035) - (xy 171.9711 116.17035) (xy 171.86335 116.0626) (xy 171.10365 116.0626) (xy 171.020382 116.079163) (xy 170.941945 116.111653) - (xy 170.871353 116.158821) (xy 170.81132 116.218854) (xy 170.764153 116.289445) (xy 170.731663 116.367882) (xy 170.7151 116.45115) - (xy 169.6847 116.45115) (xy 169.6847 113.878333) (xy 170.450588 112.601854) - ) - ) - (filled_polygon - (pts - (xy 158.539278 103.433086) (xy 158.784536 103.67486) (xy 158.784536 103.8562) (xy 158.798758 104.000599) (xy 158.840878 104.139449) - (xy 158.909276 104.267413) (xy 159.001325 104.379575) (xy 159.113487 104.471624) (xy 159.241451 104.540022) (xy 159.380301 104.582142) - (xy 159.5247 104.596364) (xy 159.910639 104.596364) (xy 160.011833 104.627061) (xy 160.01594 104.627466) (xy 160.019897 104.628635) - (xy 160.127891 104.638492) (xy 160.179754 104.6436) (xy 160.183857 104.6436) (xy 160.244116 104.6491) (xy 160.296141 104.6436) - (xy 161.441152 104.6436) (xy 161.494423 104.670026) (xy 161.731084 104.734035) (xy 161.975685 104.750644) (xy 162.218827 104.719214) - (xy 162.451165 104.640954) (xy 162.528817 104.596364) (xy 162.6489 104.596364) (xy 162.793299 104.582142) (xy 162.932149 104.540022) - (xy 163.060113 104.471624) (xy 163.172275 104.379575) (xy 163.264324 104.267413) (xy 163.332722 104.139449) (xy 163.373352 104.005512) - (xy 164.176316 103.432964) (xy 165.588545 103.432964) (xy 165.591425 103.442495) (xy 165.60027 103.459085) (xy 165.606194 103.476921) - (xy 165.66375 103.578146) (xy 165.686686 103.621164) (xy 165.697045 103.636703) (xy 165.73974 103.711791) (xy 165.754218 103.728522) - (xy 165.770139 103.758307) (xy 165.855226 103.861985) (xy 165.940522 103.96614) (xy 165.941082 103.9666) (xy 165.941541 103.96716) - (xy 166.045354 104.052357) (xy 166.149195 104.137759) (xy 166.149834 104.138101) (xy 166.150394 104.138561) (xy 166.269068 104.201994) - (xy 166.387341 104.265371) (xy 166.388032 104.265581) (xy 166.388673 104.265924) (xy 166.475469 104.292253) (xy 169.367286 106.117037) - (xy 169.376184 106.207377) (xy 169.461875 106.489864) (xy 169.601031 106.750206) (xy 169.788303 106.978397) (xy 170.016494 107.165669) - (xy 170.276836 107.304825) (xy 170.416087 107.347066) (xy 170.373462 107.360978) (xy 170.169518 107.475545) (xy 169.991844 107.627698) - (xy 169.847267 107.81159) (xy 169.741344 108.020154) (xy 169.678957 108.242322) (xy 169.768138 108.4286) (xy 171.5901 108.4286) - (xy 171.5901 108.4086) (xy 171.6401 108.4086) (xy 171.6401 108.4286) (xy 174.5111 108.4286) (xy 174.5111 107.77475) - (xy 174.40335 107.667) (xy 173.269255 107.667) (xy 173.238356 107.627698) (xy 173.060682 107.475545) (xy 172.856738 107.360978) - (xy 172.814113 107.347066) (xy 172.953364 107.304825) (xy 173.213706 107.165669) (xy 173.441897 106.978397) (xy 173.629169 106.750206) - (xy 173.768325 106.489864) (xy 173.854016 106.207377) (xy 173.882951 105.9136) (xy 173.854016 105.619823) (xy 173.793986 105.421929) - (xy 175.0441 103.900052) (xy 175.0441 107.667) (xy 174.66885 107.667) (xy 174.5611 107.77475) (xy 174.5611 108.4286) - (xy 174.5811 108.4286) (xy 174.5811 108.4786) (xy 174.5611 108.4786) (xy 174.5611 109.13245) (xy 174.66885 109.2402) - (xy 175.0441 109.2402) (xy 175.0441 109.643836) (xy 174.861361 109.643836) (xy 174.760167 109.613139) (xy 174.592246 109.5966) - (xy 173.159122 109.5966) (xy 173.117715 109.591448) (xy 173.046833 109.5966) (xy 173.032154 109.5966) (xy 172.990814 109.600672) - (xy 172.955042 109.603272) (xy 172.953364 109.602375) (xy 172.814113 109.560134) (xy 172.856738 109.546222) (xy 173.060682 109.431655) - (xy 173.238356 109.279502) (xy 173.269255 109.2402) (xy 174.40335 109.2402) (xy 174.5111 109.13245) (xy 174.5111 108.4786) - (xy 171.6401 108.4786) (xy 171.6401 108.4986) (xy 171.5901 108.4986) (xy 171.5901 108.4786) (xy 169.768138 108.4786) - (xy 169.678957 108.664878) (xy 169.741344 108.887046) (xy 169.847267 109.09561) (xy 169.991844 109.279502) (xy 170.169518 109.431655) - (xy 170.373462 109.546222) (xy 170.416087 109.560134) (xy 170.276836 109.602375) (xy 170.016494 109.741531) (xy 170.007393 109.749) - (xy 169.994924 109.749) (xy 169.903307 109.744457) (xy 169.812 109.757958) (xy 169.720116 109.767008) (xy 169.690936 109.77586) - (xy 169.660779 109.780319) (xy 169.573856 109.811376) (xy 169.485508 109.838176) (xy 169.458617 109.85255) (xy 169.429908 109.862807) - (xy 169.350706 109.910229) (xy 169.269292 109.953746) (xy 169.245726 109.973086) (xy 169.219565 109.98875) (xy 169.151123 110.050725) - (xy 169.079777 110.109277) (xy 169.06044 110.132839) (xy 169.037834 110.153309) (xy 168.982798 110.227446) (xy 168.924246 110.298792) - (xy 168.881002 110.379696) (xy 167.419951 112.814782) (xy 167.400246 112.838793) (xy 167.356999 112.919702) (xy 167.341407 112.945689) - (xy 167.328193 112.973594) (xy 167.284676 113.055009) (xy 167.275825 113.084185) (xy 167.262778 113.111739) (xy 167.240309 113.201267) - (xy 167.213508 113.289617) (xy 167.210519 113.319963) (xy 167.203099 113.349529) (xy 167.198528 113.441717) (xy 167.1955 113.472458) - (xy 167.1955 113.502775) (xy 167.190957 113.594392) (xy 167.1955 113.625116) (xy 167.195501 116.653017) (xy 166.825915 117.115) - (xy 162.617998 117.115) (xy 162.585313 117.088176) (xy 162.457349 117.019778) (xy 162.318499 116.977658) (xy 162.1741 116.963436) - (xy 159.9741 116.963436) (xy 159.829701 116.977658) (xy 159.690851 117.019778) (xy 159.562887 117.088176) (xy 159.450725 117.180225) - (xy 159.358676 117.292387) (xy 159.290278 117.420351) (xy 159.248158 117.559201) (xy 159.233936 117.7036) (xy 159.233936 119.5036) - (xy 159.248158 119.647999) (xy 159.290278 119.786849) (xy 159.358676 119.914813) (xy 159.450725 120.026975) (xy 159.562887 120.119024) - (xy 159.690851 120.187422) (xy 159.829701 120.229542) (xy 159.9741 120.243764) (xy 162.138794 120.243764) (xy 161.986555 120.368704) - (xy 161.782619 120.6172) (xy 161.631081 120.900708) (xy 161.537764 121.208332) (xy 161.51415 121.44808) (xy 161.51415 121.819539) - (xy 161.119343 122.063436) (xy 159.9741 122.063436) (xy 159.829701 122.077658) (xy 159.690851 122.119778) (xy 159.562887 122.188176) - (xy 159.450725 122.280225) (xy 159.358676 122.392387) (xy 159.290278 122.520351) (xy 159.248158 122.659201) (xy 159.233936 122.8036) - (xy 159.233936 123.87249) (xy 159.06236 123.700914) (xy 158.796111 123.523012) (xy 158.50027 123.40047) (xy 158.377354 123.376021) - (xy 157.9499 122.360817) (xy 157.9499 122.3212) (xy 158.17275 122.3212) (xy 158.2805 122.21345) (xy 158.2805 121.204) - (xy 158.3305 121.204) (xy 158.3305 122.21345) (xy 158.43825 122.3212) (xy 158.70355 122.3212) (xy 158.786818 122.304637) - (xy 158.865255 122.272147) (xy 158.935846 122.22498) (xy 158.995879 122.164947) (xy 159.043047 122.094355) (xy 159.075537 122.015918) - (xy 159.0921 121.93265) (xy 159.0921 121.31175) (xy 158.98435 121.204) (xy 158.3305 121.204) (xy 158.2805 121.204) - (xy 158.2605 121.204) (xy 158.2605 121.154) (xy 158.2805 121.154) (xy 158.2805 120.14455) (xy 158.3305 120.14455) - (xy 158.3305 121.154) (xy 158.98435 121.154) (xy 159.0921 121.04625) (xy 159.0921 120.42535) (xy 159.075537 120.342082) - (xy 159.043047 120.263645) (xy 158.995879 120.193053) (xy 158.935846 120.13302) (xy 158.865255 120.085853) (xy 158.786818 120.053363) - (xy 158.70355 120.0368) (xy 158.43825 120.0368) (xy 158.3305 120.14455) (xy 158.2805 120.14455) (xy 158.17275 120.0368) - (xy 157.9499 120.0368) (xy 157.9499 118.744137) (xy 157.950588 118.655322) (xy 157.941208 118.606177) (xy 157.936302 118.556367) - (xy 157.923892 118.515458) (xy 157.91588 118.47348) (xy 157.897091 118.427105) (xy 157.882563 118.379214) (xy 157.840664 118.300827) - (xy 154.480331 111.895192) (xy 154.490544 111.896323) (xy 154.527827 111.904882) (xy 154.582329 111.90648) (xy 154.590415 111.907375) - (xy 154.628492 111.907834) (xy 154.712872 111.910308) (xy 154.720941 111.908948) (xy 154.92519 111.911408) (xy 155.016198 112.022302) - (xy 155.236654 112.203226) (xy 155.48817 112.337665) (xy 155.761082 112.420451) (xy 155.973778 112.4414) (xy 157.538422 112.4414) - (xy 157.751118 112.420451) (xy 158.02403 112.337665) (xy 158.275546 112.203226) (xy 158.372205 112.1239) (xy 158.97384 112.1239) - (xy 159.011887 112.155124) (xy 159.139851 112.223522) (xy 159.278701 112.265642) (xy 159.4231 112.279864) (xy 160.8455 112.279864) - (xy 160.989899 112.265642) (xy 161.128749 112.223522) (xy 161.256713 112.155124) (xy 161.368875 112.063075) (xy 161.460924 111.950913) - (xy 161.529322 111.822949) (xy 161.571442 111.684099) (xy 161.585664 111.5397) (xy 161.585664 110.8285) (xy 161.571442 110.684101) - (xy 161.529322 110.545251) (xy 161.460924 110.417287) (xy 161.368875 110.305125) (xy 161.256713 110.213076) (xy 161.128749 110.144678) - (xy 160.989899 110.102558) (xy 160.8455 110.088336) (xy 159.4231 110.088336) (xy 159.278701 110.102558) (xy 159.139851 110.144678) - (xy 159.011887 110.213076) (xy 158.97384 110.2443) (xy 158.708434 110.2443) (xy 158.676926 110.185354) (xy 158.496002 109.964898) - (xy 158.275546 109.783974) (xy 158.02403 109.649535) (xy 157.751118 109.566749) (xy 157.538422 109.5458) (xy 155.973778 109.5458) - (xy 155.761082 109.566749) (xy 155.48817 109.649535) (xy 155.236654 109.783974) (xy 155.016198 109.964898) (xy 154.978967 110.010265) - (xy 153.854454 109.03085) (xy 158.9921 109.03085) (xy 158.9921 109.29615) (xy 159.008663 109.379418) (xy 159.041153 109.457855) - (xy 159.08832 109.528446) (xy 159.148353 109.588479) (xy 159.218945 109.635647) (xy 159.297382 109.668137) (xy 159.38065 109.6847) - (xy 160.00155 109.6847) (xy 160.1093 109.57695) (xy 160.1093 108.9231) (xy 160.1593 108.9231) (xy 160.1593 109.57695) - (xy 160.26705 109.6847) (xy 160.88795 109.6847) (xy 160.971218 109.668137) (xy 161.049655 109.635647) (xy 161.120247 109.588479) - (xy 161.18028 109.528446) (xy 161.227447 109.457855) (xy 161.259937 109.379418) (xy 161.2765 109.29615) (xy 161.2765 109.03085) - (xy 161.16875 108.9231) (xy 160.1593 108.9231) (xy 160.1093 108.9231) (xy 159.09985 108.9231) (xy 158.9921 109.03085) - (xy 153.854454 109.03085) (xy 153.846933 109.0243) (xy 154.14425 109.0243) (xy 154.227518 109.007737) (xy 154.305955 108.975247) - (xy 154.376547 108.928079) (xy 154.43658 108.868046) (xy 154.483747 108.797455) (xy 154.516237 108.719018) (xy 154.5328 108.63575) - (xy 154.5328 108.50005) (xy 158.9921 108.50005) (xy 158.9921 108.76535) (xy 159.09985 108.8731) (xy 160.1093 108.8731) - (xy 160.1093 108.21925) (xy 160.1593 108.21925) (xy 160.1593 108.8731) (xy 161.16875 108.8731) (xy 161.2765 108.76535) - (xy 161.2765 108.50005) (xy 161.259937 108.416782) (xy 161.227447 108.338345) (xy 161.18028 108.267754) (xy 161.120247 108.207721) - (xy 161.049655 108.160553) (xy 160.971218 108.128063) (xy 160.88795 108.1115) (xy 160.26705 108.1115) (xy 160.1593 108.21925) - (xy 160.1093 108.21925) (xy 160.00155 108.1115) (xy 159.38065 108.1115) (xy 159.297382 108.128063) (xy 159.218945 108.160553) - (xy 159.148353 108.207721) (xy 159.08832 108.267754) (xy 159.041153 108.338345) (xy 159.008663 108.416782) (xy 158.9921 108.50005) - (xy 154.5328 108.50005) (xy 154.5328 108.37045) (xy 154.42505 108.2627) (xy 153.4156 108.2627) (xy 153.4156 108.2827) - (xy 153.3656 108.2827) (xy 153.3656 108.2627) (xy 153.3456 108.2627) (xy 153.3456 108.2127) (xy 153.3656 108.2127) - (xy 153.3656 107.55885) (xy 153.4156 107.55885) (xy 153.4156 108.2127) (xy 154.42505 108.2127) (xy 154.5328 108.10495) - (xy 154.5328 107.90055) (xy 163.0777 107.90055) (xy 163.0777 109.08525) (xy 163.094263 109.168518) (xy 163.126753 109.246955) - (xy 163.173921 109.317547) (xy 163.233954 109.37758) (xy 163.304545 109.424747) (xy 163.382982 109.457237) (xy 163.46625 109.4738) - (xy 164.72595 109.4738) (xy 164.8337 109.36605) (xy 164.8337 107.7928) (xy 164.8837 107.7928) (xy 164.8837 109.36605) - (xy 164.99145 109.4738) (xy 166.25115 109.4738) (xy 166.334418 109.457237) (xy 166.412855 109.424747) (xy 166.483446 109.37758) - (xy 166.543479 109.317547) (xy 166.590647 109.246955) (xy 166.623137 109.168518) (xy 166.6397 109.08525) (xy 166.6397 107.90055) - (xy 166.53195 107.7928) (xy 164.8837 107.7928) (xy 164.8337 107.7928) (xy 163.18545 107.7928) (xy 163.0777 107.90055) - (xy 154.5328 107.90055) (xy 154.5328 107.83965) (xy 154.516237 107.756382) (xy 154.483747 107.677945) (xy 154.43658 107.607354) - (xy 154.376547 107.547321) (xy 154.305955 107.500153) (xy 154.227518 107.467663) (xy 154.14425 107.4511) (xy 153.52335 107.4511) - (xy 153.4156 107.55885) (xy 153.3656 107.55885) (xy 153.25785 107.4511) (xy 152.63695 107.4511) (xy 152.553682 107.467663) - (xy 152.475245 107.500153) (xy 152.404653 107.547321) (xy 152.34462 107.607354) (xy 152.298801 107.675927) (xy 152.169116 107.562976) - (xy 153.267748 107.047464) (xy 154.1018 107.047464) (xy 154.246199 107.033242) (xy 154.385049 106.991122) (xy 154.513013 106.922724) - (xy 154.567217 106.87824) (xy 154.959974 106.873793) (xy 155.016198 106.942302) (xy 155.236654 107.123226) (xy 155.48817 107.257665) - (xy 155.761082 107.340451) (xy 155.973778 107.3614) (xy 157.538422 107.3614) (xy 157.751118 107.340451) (xy 158.02403 107.257665) - (xy 158.275546 107.123226) (xy 158.496002 106.942302) (xy 158.676926 106.721846) (xy 158.811365 106.47033) (xy 158.894151 106.197418) - (xy 158.921538 105.91935) (xy 159.0937 105.91935) (xy 159.0937 106.18465) (xy 159.110263 106.267918) (xy 159.142753 106.346355) - (xy 159.18992 106.416946) (xy 159.249953 106.476979) (xy 159.320545 106.524147) (xy 159.398982 106.556637) (xy 159.48225 106.5732) - (xy 160.10315 106.5732) (xy 160.2109 106.46545) (xy 160.2109 105.8116) (xy 160.2609 105.8116) (xy 160.2609 106.46545) - (xy 160.36865 106.5732) (xy 160.98955 106.5732) (xy 161.072818 106.556637) (xy 161.0868 106.550845) (xy 161.100782 106.556637) - (xy 161.18405 106.5732) (xy 161.80495 106.5732) (xy 161.9127 106.46545) (xy 161.9127 105.8116) (xy 161.9627 105.8116) - (xy 161.9627 106.46545) (xy 162.07045 106.5732) (xy 162.69135 106.5732) (xy 162.774618 106.556637) (xy 162.853055 106.524147) - (xy 162.923647 106.476979) (xy 162.950276 106.45035) (xy 163.0777 106.45035) (xy 163.0777 107.63505) (xy 163.18545 107.7428) - (xy 164.8337 107.7428) (xy 164.8337 106.16955) (xy 164.8837 106.16955) (xy 164.8837 107.7428) (xy 166.53195 107.7428) - (xy 166.6397 107.63505) (xy 166.6397 106.45035) (xy 166.623137 106.367082) (xy 166.590647 106.288645) (xy 166.543479 106.218053) - (xy 166.483446 106.15802) (xy 166.412855 106.110853) (xy 166.334418 106.078363) (xy 166.25115 106.0618) (xy 164.99145 106.0618) - (xy 164.8837 106.16955) (xy 164.8337 106.16955) (xy 164.72595 106.0618) (xy 163.46625 106.0618) (xy 163.382982 106.078363) - (xy 163.304545 106.110853) (xy 163.233954 106.15802) (xy 163.173921 106.218053) (xy 163.126753 106.288645) (xy 163.094263 106.367082) - (xy 163.0777 106.45035) (xy 162.950276 106.45035) (xy 162.98368 106.416946) (xy 163.030847 106.346355) (xy 163.063337 106.267918) - (xy 163.0799 106.18465) (xy 163.0799 105.91935) (xy 162.97215 105.8116) (xy 161.9627 105.8116) (xy 161.9127 105.8116) - (xy 160.2609 105.8116) (xy 160.2109 105.8116) (xy 159.20145 105.8116) (xy 159.0937 105.91935) (xy 158.921538 105.91935) - (xy 158.922105 105.9136) (xy 158.894151 105.629782) (xy 158.820975 105.38855) (xy 159.0937 105.38855) (xy 159.0937 105.65385) - (xy 159.20145 105.7616) (xy 160.2109 105.7616) (xy 160.2109 105.10775) (xy 160.2609 105.10775) (xy 160.2609 105.7616) - (xy 161.9127 105.7616) (xy 161.9127 105.10775) (xy 161.9627 105.10775) (xy 161.9627 105.7616) (xy 162.97215 105.7616) - (xy 163.0799 105.65385) (xy 163.0799 105.38855) (xy 163.063337 105.305282) (xy 163.030847 105.226845) (xy 162.98368 105.156254) - (xy 162.923647 105.096221) (xy 162.853055 105.049053) (xy 162.774618 105.016563) (xy 162.69135 105) (xy 162.07045 105) - (xy 161.9627 105.10775) (xy 161.9127 105.10775) (xy 161.80495 105) (xy 161.18405 105) (xy 161.100782 105.016563) - (xy 161.0868 105.022355) (xy 161.072818 105.016563) (xy 160.98955 105) (xy 160.36865 105) (xy 160.2609 105.10775) - (xy 160.2109 105.10775) (xy 160.10315 105) (xy 159.48225 105) (xy 159.398982 105.016563) (xy 159.320545 105.049053) - (xy 159.249953 105.096221) (xy 159.18992 105.156254) (xy 159.142753 105.226845) (xy 159.110263 105.305282) (xy 159.0937 105.38855) - (xy 158.820975 105.38855) (xy 158.811365 105.35687) (xy 158.676926 105.105354) (xy 158.496002 104.884898) (xy 158.275546 104.703974) - (xy 158.02403 104.569535) (xy 157.751118 104.486749) (xy 157.538422 104.4658) (xy 155.973778 104.4658) (xy 155.761082 104.486749) - (xy 155.48817 104.569535) (xy 155.236654 104.703974) (xy 155.016198 104.884898) (xy 154.926287 104.994455) (xy 154.535197 104.998882) - (xy 154.513013 104.980676) (xy 154.385049 104.912278) (xy 154.246199 104.870158) (xy 154.1018 104.855936) (xy 152.6794 104.855936) - (xy 152.535001 104.870158) (xy 152.525131 104.873152) (xy 154.077647 103.425065) - ) - ) - (filled_polygon - (pts - (xy 129.1463 89.326536) (xy 129.143778 89.341809) (xy 129.1463 89.418926) (xy 129.1463 89.449766) (xy 129.14781 89.465098) - (xy 129.149829 89.526833) (xy 129.156861 89.556995) (xy 129.159898 89.587832) (xy 129.177837 89.646967) (xy 129.191861 89.707123) - (xy 129.204643 89.735337) (xy 129.213637 89.764985) (xy 129.242761 89.819472) (xy 129.268257 89.875749) (xy 129.286301 89.90093) - (xy 129.300904 89.928251) (xy 129.340106 89.976019) (xy 129.349064 89.98852) (xy 129.36936 90.011664) (xy 129.418346 90.071354) - (xy 129.430321 90.081182) (xy 137.795936 99.62092) (xy 137.795936 99.809792) (xy 134.205295 96.38319) (xy 134.182854 96.355846) - (xy 134.13849 96.319437) (xy 134.130528 96.311839) (xy 134.102817 96.290161) (xy 134.039751 96.238404) (xy 134.029978 96.23318) - (xy 134.021257 96.226358) (xy 133.948462 96.189609) (xy 133.876486 96.151137) (xy 133.865882 96.14792) (xy 133.855997 96.14293) - (xy 133.777424 96.121087) (xy 133.699333 96.097398) (xy 133.688306 96.096312) (xy 133.677637 96.093346) (xy 133.596317 96.087252) - (xy 133.561267 96.0838) (xy 133.550252 96.0838) (xy 133.493031 96.079512) (xy 133.457925 96.0838) (xy 126.333239 96.0838) - (xy 126.268786 95.98734) (xy 126.04236 95.760914) (xy 125.776111 95.583012) (xy 125.48027 95.46047) (xy 125.166208 95.398) - (xy 124.845992 95.398) (xy 124.53193 95.46047) (xy 124.236089 95.583012) (xy 123.96984 95.760914) (xy 123.743414 95.98734) - (xy 123.565512 96.253589) (xy 123.44297 96.54943) (xy 123.3805 96.863492) (xy 123.3805 97.183708) (xy 123.44297 97.49777) - (xy 123.565512 97.793611) (xy 123.743414 98.05986) (xy 123.96984 98.286286) (xy 123.980786 98.2936) (xy 123.96984 98.300914) - (xy 123.743414 98.52734) (xy 123.565512 98.793589) (xy 123.44297 99.08943) (xy 123.3805 99.403492) (xy 123.3805 99.723708) - (xy 123.44297 100.03777) (xy 123.565512 100.333611) (xy 123.743414 100.59986) (xy 123.96984 100.826286) (xy 123.980786 100.8336) - (xy 123.96984 100.840914) (xy 123.743414 101.06734) (xy 123.565512 101.333589) (xy 123.44297 101.62943) (xy 123.3805 101.943492) - (xy 123.3805 102.263708) (xy 123.44297 102.57777) (xy 123.565512 102.873611) (xy 123.743414 103.13986) (xy 123.96984 103.366286) - (xy 123.980786 103.3736) (xy 123.96984 103.380914) (xy 123.743414 103.60734) (xy 123.565512 103.873589) (xy 123.44297 104.16943) - (xy 123.3805 104.483492) (xy 123.3805 104.803708) (xy 123.44297 105.11777) (xy 123.565512 105.413611) (xy 123.743414 105.67986) - (xy 123.96984 105.906286) (xy 123.980786 105.9136) (xy 123.96984 105.920914) (xy 123.743414 106.14734) (xy 123.565512 106.413589) - (xy 123.44297 106.70943) (xy 123.3805 107.023492) (xy 123.3805 107.343708) (xy 123.44297 107.65777) (xy 123.565512 107.953611) - (xy 123.743414 108.21986) (xy 123.96984 108.446286) (xy 124.236089 108.624188) (xy 124.253659 108.631466) (xy 124.246833 108.636027) - (xy 124.162252 108.844397) (xy 125.0061 109.688245) (xy 125.849948 108.844397) (xy 125.765367 108.636027) (xy 125.757791 108.631776) - (xy 125.776111 108.624188) (xy 126.04236 108.446286) (xy 126.268786 108.21986) (xy 126.269485 108.218813) (xy 126.27487 108.226872) - (xy 126.502828 108.45483) (xy 126.770879 108.633936) (xy 127.068721 108.757307) (xy 127.384909 108.8202) (xy 127.707291 108.8202) - (xy 128.023479 108.757307) (xy 128.062132 108.741296) (xy 128.008356 108.8805) (xy 128.8161 109.688245) (xy 128.830243 109.674103) - (xy 128.865598 109.709458) (xy 128.851455 109.7236) (xy 129.6592 110.531344) (xy 129.862369 110.452858) (xy 129.984537 110.234729) - (xy 130.027398 110.102831) (xy 130.155867 110.141802) (xy 130.293933 110.1554) (xy 130.293942 110.1554) (xy 130.340099 110.159946) - (xy 130.386256 110.1554) (xy 131.915309 110.1554) (xy 130.950728 113.352236) (xy 130.2893 113.352236) (xy 130.144901 113.366458) - (xy 130.006051 113.408578) (xy 129.878087 113.476976) (xy 129.765925 113.569025) (xy 129.673876 113.681187) (xy 129.605478 113.809151) - (xy 129.563358 113.948001) (xy 129.549136 114.0924) (xy 129.549136 115.5148) (xy 129.563358 115.659199) (xy 129.605478 115.798049) - (xy 129.673876 115.926013) (xy 129.765925 116.038175) (xy 129.878087 116.130224) (xy 129.938244 116.162379) (xy 129.696824 116.4038) - (xy 128.886468 116.4038) (xy 128.81733 116.300328) (xy 128.766814 116.249812) (xy 128.858899 116.240742) (xy 128.997749 116.198622) - (xy 129.125713 116.130224) (xy 129.237875 116.038175) (xy 129.329924 115.926013) (xy 129.398322 115.798049) (xy 129.440442 115.659199) - (xy 129.454664 115.5148) (xy 129.454664 114.0924) (xy 129.450121 114.046276) (xy 129.516397 113.678079) (xy 129.562048 113.65917) - (xy 129.819977 113.486827) (xy 130.039327 113.267477) (xy 130.21167 113.009548) (xy 130.330382 112.722952) (xy 130.3909 112.418704) - (xy 130.3909 112.108496) (xy 130.330382 111.804248) (xy 130.21167 111.517652) (xy 130.039327 111.259723) (xy 129.819977 111.040373) - (xy 129.562048 110.86803) (xy 129.453738 110.823167) (xy 129.503652 110.797736) (xy 129.545358 110.769869) (xy 129.623844 110.5667) - (xy 128.8161 109.758955) (xy 128.008356 110.5667) (xy 128.086842 110.769869) (xy 128.180498 110.822323) (xy 128.070152 110.86803) - (xy 127.812223 111.040373) (xy 127.592873 111.259723) (xy 127.42053 111.517652) (xy 127.301818 111.804248) (xy 127.2413 112.108496) - (xy 127.2413 112.418704) (xy 127.301818 112.722952) (xy 127.42053 113.009548) (xy 127.592873 113.267477) (xy 127.667133 113.341737) - (xy 127.648187 113.44699) (xy 127.592087 113.476976) (xy 127.479925 113.569025) (xy 127.387876 113.681187) (xy 127.319478 113.809151) - (xy 127.277358 113.948001) (xy 127.263136 114.0924) (xy 127.263136 115.5148) (xy 127.277358 115.659199) (xy 127.297153 115.724455) - (xy 127.068721 115.769893) (xy 126.770879 115.893264) (xy 126.502828 116.07237) (xy 126.27487 116.300328) (xy 126.269485 116.308387) - (xy 126.268786 116.30734) (xy 126.04236 116.080914) (xy 126.031414 116.0736) (xy 126.04236 116.066286) (xy 126.268786 115.83986) - (xy 126.446688 115.573611) (xy 126.56923 115.27777) (xy 126.6317 114.963708) (xy 126.6317 114.643492) (xy 126.56923 114.32943) - (xy 126.446688 114.033589) (xy 126.268786 113.76734) (xy 126.04236 113.540914) (xy 126.031414 113.5336) (xy 126.04236 113.526286) - (xy 126.268786 113.29986) (xy 126.446688 113.033611) (xy 126.56923 112.73777) (xy 126.6317 112.423708) (xy 126.6317 112.103492) - (xy 126.56923 111.78943) (xy 126.446688 111.493589) (xy 126.268786 111.22734) (xy 126.04236 111.000914) (xy 125.776111 110.823012) - (xy 125.758541 110.815734) (xy 125.765367 110.811173) (xy 125.849948 110.602803) (xy 125.0061 109.758955) (xy 124.162252 110.602803) - (xy 124.246833 110.811173) (xy 124.254409 110.815424) (xy 124.236089 110.823012) (xy 123.96984 111.000914) (xy 123.743414 111.22734) - (xy 123.565512 111.493589) (xy 123.44297 111.78943) (xy 123.3805 112.103492) (xy 123.3805 112.423708) (xy 123.44297 112.73777) - (xy 123.565512 113.033611) (xy 123.743414 113.29986) (xy 123.96984 113.526286) (xy 123.980786 113.5336) (xy 123.96984 113.540914) - (xy 123.743414 113.76734) (xy 123.565512 114.033589) (xy 123.44297 114.32943) (xy 123.3805 114.643492) (xy 123.3805 114.963708) - (xy 123.44297 115.27777) (xy 123.565512 115.573611) (xy 123.743414 115.83986) (xy 123.96984 116.066286) (xy 123.980786 116.0736) - (xy 123.96984 116.080914) (xy 123.743414 116.30734) (xy 123.565512 116.573589) (xy 123.44297 116.86943) (xy 123.3805 117.183492) - (xy 123.3805 117.503708) (xy 123.44297 117.81777) (xy 123.565512 118.113611) (xy 123.743414 118.37986) (xy 123.96984 118.606286) - (xy 124.236089 118.784188) (xy 124.53193 118.90673) (xy 124.845992 118.9692) (xy 125.166208 118.9692) (xy 125.48027 118.90673) - (xy 125.776111 118.784188) (xy 126.04236 118.606286) (xy 126.268786 118.37986) (xy 126.269485 118.378813) (xy 126.27487 118.386872) - (xy 126.502828 118.61483) (xy 126.770879 118.793936) (xy 127.068721 118.917307) (xy 127.384909 118.9802) (xy 127.707291 118.9802) - (xy 128.023479 118.917307) (xy 128.321321 118.793936) (xy 128.589372 118.61483) (xy 128.81733 118.386872) (xy 128.886468 118.2834) - (xy 130.039943 118.2834) (xy 130.0861 118.287946) (xy 130.132257 118.2834) (xy 130.132267 118.2834) (xy 130.270333 118.269802) - (xy 130.447486 118.216063) (xy 130.610751 118.128796) (xy 130.753854 118.011354) (xy 130.783291 117.975485) (xy 131.911795 116.846982) - (xy 131.947654 116.817554) (xy 131.991915 116.763622) (xy 132.065096 116.674452) (xy 132.142803 116.529071) (xy 132.152363 116.511186) - (xy 132.206102 116.334033) (xy 132.2197 116.195967) (xy 132.2197 116.195958) (xy 132.224246 116.149801) (xy 132.2197 116.103644) - (xy 132.2197 115.653471) (xy 132.382633 115.113383) (xy 132.409101 115.026132) (xy 132.40917 115.025436) (xy 133.564625 111.196) - (xy 134.01735 111.196) (xy 134.1251 111.08825) (xy 134.1251 110.5618) (xy 134.1751 110.5618) (xy 134.1751 111.08825) - (xy 134.28285 111.196) (xy 134.90375 111.196) (xy 134.987018 111.179437) (xy 135.065455 111.146947) (xy 135.136047 111.099779) - (xy 135.19608 111.039746) (xy 135.243247 110.969155) (xy 135.275737 110.890718) (xy 135.2923 110.80745) (xy 135.2923 110.5755) - (xy 135.675391 110.641483) (xy 135.712725 110.686975) (xy 135.824887 110.779024) (xy 135.952851 110.847422) (xy 136.091701 110.889542) - (xy 136.2361 110.903764) (xy 137.7361 110.903764) (xy 137.802473 110.897227) (xy 137.795936 110.9636) (xy 137.795936 112.329684) - (xy 131.173943 119.880224) (xy 131.15908 119.895462) (xy 131.143519 119.914914) (xy 131.127097 119.933638) (xy 131.114699 119.950938) - (xy 130.646747 120.535878) (xy 130.610071 120.574608) (xy 130.564414 120.647137) (xy 130.517769 120.718869) (xy 130.497981 120.76838) - (xy 129.46919 122.825964) (xy 129.377977 122.367406) (xy 129.035245 121.539977) (xy 128.537675 120.795311) (xy 127.904389 120.162025) - (xy 127.159723 119.664455) (xy 126.332294 119.321723) (xy 125.453901 119.147) (xy 124.558299 119.147) (xy 123.679906 119.321723) - (xy 122.852477 119.664455) (xy 122.107811 120.162025) (xy 122.0077 120.262136) (xy 122.0077 109.696516) (xy 123.679991 109.696516) - (xy 123.700188 109.955748) (xy 123.77057 110.206058) (xy 123.888434 110.437828) (xy 123.918527 110.482867) (xy 124.126897 110.567448) - (xy 124.970745 109.7236) (xy 125.041455 109.7236) (xy 125.885303 110.567448) (xy 126.093673 110.482867) (xy 126.220901 110.256102) - (xy 126.301445 110.008874) (xy 126.332209 109.750684) (xy 126.328145 109.69852) (xy 127.541004 109.69852) (xy 127.560612 109.947761) - (xy 127.628468 110.188388) (xy 127.741964 110.411152) (xy 127.769831 110.452858) (xy 127.973 110.531344) (xy 128.780745 109.7236) - (xy 127.973 108.915856) (xy 127.769831 108.994342) (xy 127.647663 109.212471) (xy 127.570398 109.450243) (xy 127.541004 109.69852) - (xy 126.328145 109.69852) (xy 126.312012 109.491452) (xy 126.24163 109.241142) (xy 126.123766 109.009372) (xy 126.093673 108.964333) - (xy 125.885303 108.879752) (xy 125.041455 109.7236) (xy 124.970745 109.7236) (xy 124.126897 108.879752) (xy 123.918527 108.964333) - (xy 123.791299 109.191098) (xy 123.710755 109.438326) (xy 123.679991 109.696516) (xy 122.0077 109.696516) (xy 122.0077 89.761664) - (xy 122.107811 89.861775) (xy 122.852477 90.359345) (xy 123.679906 90.702077) (xy 124.558299 90.8768) (xy 125.453901 90.8768) - (xy 126.332294 90.702077) (xy 127.159723 90.359345) (xy 127.904389 89.861775) (xy 128.537675 89.228489) (xy 129.035245 88.483823) - (xy 129.1463 88.215711) - ) - ) - (filled_polygon - (pts - (xy 147.8361 110.903764) (xy 148.615482 110.903764) (xy 148.969415 111.010145) (xy 150.460702 114.222148) (xy 150.4311 114.25175) - (xy 150.4311 114.9056) (xy 150.4511 114.9056) (xy 150.4511 114.9556) (xy 150.4311 114.9556) (xy 150.4311 115.60945) - (xy 150.53885 115.7172) (xy 151.154833 115.7172) (xy 151.363123 116.165825) (xy 151.261699 116.135058) (xy 151.1173 116.120836) - (xy 149.6949 116.120836) (xy 149.550501 116.135058) (xy 149.411651 116.177178) (xy 149.283687 116.245576) (xy 149.171525 116.337625) - (xy 149.142859 116.372555) (xy 148.656379 115.06335) (xy 149.2639 115.06335) (xy 149.2639 115.32865) (xy 149.280463 115.411918) - (xy 149.312953 115.490355) (xy 149.36012 115.560946) (xy 149.420153 115.620979) (xy 149.490745 115.668147) (xy 149.569182 115.700637) - (xy 149.65245 115.7172) (xy 150.27335 115.7172) (xy 150.3811 115.60945) (xy 150.3811 114.9556) (xy 149.37165 114.9556) - (xy 149.2639 115.06335) (xy 148.656379 115.06335) (xy 148.459142 114.53255) (xy 149.2639 114.53255) (xy 149.2639 114.79785) - (xy 149.37165 114.9056) (xy 150.3811 114.9056) (xy 150.3811 114.25175) (xy 150.27335 114.144) (xy 149.65245 114.144) - (xy 149.569182 114.160563) (xy 149.490745 114.193053) (xy 149.420153 114.240221) (xy 149.36012 114.300254) (xy 149.312953 114.370845) - (xy 149.280463 114.449282) (xy 149.2639 114.53255) (xy 148.459142 114.53255) (xy 147.753936 112.634721) (xy 147.762042 112.607999) - (xy 147.776264 112.4636) (xy 147.776264 110.9636) (xy 147.769727 110.897227) - ) - ) - (filled_polygon - (pts - (xy 142.000904 114.121751) (xy 142.109849 114.254501) (xy 142.0491 114.31525) (xy 142.0491 114.9691) (xy 142.0691 114.9691) - (xy 142.0691 115.0191) (xy 142.0491 115.0191) (xy 142.0491 115.67295) (xy 142.15685 115.7807) (xy 142.3797 115.7807) - (xy 142.3797 116.184336) (xy 142.35573 116.184336) (xy 142.311092 116.168005) (xy 142.088618 116.133384) (xy 141.863666 116.142831) - (xy 141.692817 116.184336) (xy 141.3129 116.184336) (xy 141.209421 116.194528) (xy 141.348054 115.7807) (xy 141.89135 115.7807) - (xy 141.9991 115.67295) (xy 141.9991 115.0191) (xy 141.9791 115.0191) (xy 141.9791 114.9691) (xy 141.9991 114.9691) - (xy 141.9991 114.31525) (xy 141.89135 114.2075) (xy 141.875075 114.2075) (xy 141.941213 114.010076) - ) - ) - (filled_polygon - (pts - (xy 142.812725 101.386975) (xy 142.924887 101.479024) (xy 143.052851 101.547422) (xy 143.191701 101.589542) (xy 143.3361 101.603764) - (xy 143.8361 101.603764) (xy 143.980499 101.589542) (xy 143.9861 101.587843) (xy 143.991701 101.589542) (xy 144.1361 101.603764) - (xy 144.6361 101.603764) (xy 144.780499 101.589542) (xy 144.7861 101.587843) (xy 144.791701 101.589542) (xy 144.9361 101.603764) - (xy 145.4361 101.603764) (xy 145.580499 101.589542) (xy 145.5861 101.587843) (xy 145.591701 101.589542) (xy 145.7361 101.603764) - (xy 146.2361 101.603764) (xy 146.380499 101.589542) (xy 146.3861 101.587843) (xy 146.391701 101.589542) (xy 146.5361 101.603764) - (xy 147.0361 101.603764) (xy 147.102473 101.597227) (xy 147.095936 101.6636) (xy 147.095936 102.1636) (xy 147.110158 102.307999) - (xy 147.111857 102.3136) (xy 147.110158 102.319201) (xy 147.095936 102.4636) (xy 147.095936 102.9636) (xy 147.110158 103.107999) - (xy 147.111857 103.1136) (xy 147.110158 103.119201) (xy 147.095936 103.2636) (xy 147.095936 103.7636) (xy 147.110158 103.907999) - (xy 147.111857 103.9136) (xy 147.110158 103.919201) (xy 147.095936 104.0636) (xy 147.095936 104.5636) (xy 147.110158 104.707999) - (xy 147.111857 104.7136) (xy 147.110158 104.719201) (xy 147.095936 104.8636) (xy 147.095936 105.3636) (xy 147.110158 105.507999) - (xy 147.152278 105.646849) (xy 147.220676 105.774813) (xy 147.312725 105.886975) (xy 147.345168 105.9136) (xy 147.312725 105.940225) - (xy 147.220676 106.052387) (xy 147.152278 106.180351) (xy 147.110158 106.319201) (xy 147.095936 106.4636) (xy 147.095936 106.9636) - (xy 147.110158 107.107999) (xy 147.111857 107.1136) (xy 147.110158 107.119201) (xy 147.095936 107.2636) (xy 147.095936 107.7636) - (xy 147.110158 107.907999) (xy 147.111857 107.9136) (xy 147.110158 107.919201) (xy 147.095936 108.0636) (xy 147.095936 108.5636) - (xy 147.110158 108.707999) (xy 147.111857 108.7136) (xy 147.110158 108.719201) (xy 147.095936 108.8636) (xy 147.095936 109.3636) - (xy 147.110158 109.507999) (xy 147.111857 109.5136) (xy 147.110158 109.519201) (xy 147.095936 109.6636) (xy 147.095936 110.1636) - (xy 147.102473 110.229973) (xy 147.0361 110.223436) (xy 146.5361 110.223436) (xy 146.391701 110.237658) (xy 146.3861 110.239357) - (xy 146.380499 110.237658) (xy 146.2361 110.223436) (xy 145.7361 110.223436) (xy 145.591701 110.237658) (xy 145.5861 110.239357) - (xy 145.580499 110.237658) (xy 145.4361 110.223436) (xy 144.9361 110.223436) (xy 144.791701 110.237658) (xy 144.7861 110.239357) - (xy 144.780499 110.237658) (xy 144.6361 110.223436) (xy 144.1361 110.223436) (xy 143.991701 110.237658) (xy 143.9861 110.239357) - (xy 143.980499 110.237658) (xy 143.8361 110.223436) (xy 143.3361 110.223436) (xy 143.191701 110.237658) (xy 143.1861 110.239357) - (xy 143.180499 110.237658) (xy 143.0361 110.223436) (xy 142.5361 110.223436) (xy 142.391701 110.237658) (xy 142.252851 110.279778) - (xy 142.124887 110.348176) (xy 142.012725 110.440225) (xy 141.9861 110.472668) (xy 141.959475 110.440225) (xy 141.847313 110.348176) - (xy 141.719349 110.279778) (xy 141.580499 110.237658) (xy 141.4361 110.223436) (xy 140.9361 110.223436) (xy 140.791701 110.237658) - (xy 140.7861 110.239357) (xy 140.780499 110.237658) (xy 140.6361 110.223436) (xy 140.1361 110.223436) (xy 139.991701 110.237658) - (xy 139.9861 110.239357) (xy 139.980499 110.237658) (xy 139.8361 110.223436) (xy 139.3361 110.223436) (xy 139.191701 110.237658) - (xy 139.1861 110.239357) (xy 139.180499 110.237658) (xy 139.0361 110.223436) (xy 138.5361 110.223436) (xy 138.469727 110.229973) - (xy 138.476264 110.1636) (xy 138.476264 109.6636) (xy 138.462042 109.519201) (xy 138.460343 109.5136) (xy 138.462042 109.507999) - (xy 138.476264 109.3636) (xy 138.476264 109.2156) (xy 139.627164 109.2156) (xy 139.752756 109.341192) (xy 139.977404 109.491297) - (xy 140.227019 109.594691) (xy 140.492009 109.6474) (xy 140.762191 109.6474) (xy 141.027181 109.594691) (xy 141.276796 109.491297) - (xy 141.501444 109.341192) (xy 141.692492 109.150144) (xy 141.842597 108.925496) (xy 141.945991 108.675881) (xy 141.9987 108.410891) - (xy 141.9987 108.140709) (xy 141.945991 107.875719) (xy 141.842597 107.626104) (xy 141.692492 107.401456) (xy 141.501444 107.210408) - (xy 141.276796 107.060303) (xy 141.027181 106.956909) (xy 140.8557 106.9228) (xy 140.8557 106.921509) (xy 140.802991 106.656519) - (xy 140.699597 106.406904) (xy 140.549492 106.182256) (xy 140.358444 105.991208) (xy 140.133796 105.841103) (xy 139.884181 105.737709) - (xy 139.657639 105.692648) (xy 139.833381 105.657691) (xy 140.082996 105.554297) (xy 140.307644 105.404192) (xy 140.498692 105.213144) - (xy 140.648797 104.988496) (xy 140.752191 104.738881) (xy 140.8049 104.473891) (xy 140.8049 104.203709) (xy 140.752191 103.938719) - (xy 140.648797 103.689104) (xy 140.498692 103.464456) (xy 140.307644 103.273408) (xy 140.082996 103.123303) (xy 139.833381 103.019909) - (xy 139.568391 102.9672) (xy 139.4587 102.9672) (xy 139.4587 101.833951) (xy 139.462988 101.77673) (xy 139.453103 101.695804) - (xy 139.445102 101.614567) (xy 139.441884 101.603959) (xy 139.44186 101.603764) (xy 139.8361 101.603764) (xy 139.980499 101.589542) - (xy 139.9861 101.587843) (xy 139.991701 101.589542) (xy 140.1361 101.603764) (xy 140.6361 101.603764) (xy 140.780499 101.589542) - (xy 140.7861 101.587843) (xy 140.791701 101.589542) (xy 140.9361 101.603764) (xy 141.4361 101.603764) (xy 141.580499 101.589542) - (xy 141.5861 101.587843) (xy 141.591701 101.589542) (xy 141.7361 101.603764) (xy 142.2361 101.603764) (xy 142.380499 101.589542) - (xy 142.519349 101.547422) (xy 142.647313 101.479024) (xy 142.759475 101.386975) (xy 142.7861 101.354532) - ) - ) - (filled_polygon - (pts - (xy 133.761009 103.8562) (xy 133.776137 103.8562) (xy 133.943336 104.069843) (xy 133.943336 104.6563) (xy 133.957558 104.800699) - (xy 133.999678 104.939549) (xy 134.068076 105.067513) (xy 134.160125 105.179675) (xy 134.2525 105.255485) (xy 134.2525 105.78085) - (xy 134.36025 105.8886) (xy 135.0141 105.8886) (xy 135.0141 105.8686) (xy 135.0641 105.8686) (xy 135.0641 105.8886) - (xy 135.0841 105.8886) (xy 135.0841 105.9386) (xy 135.0641 105.9386) (xy 135.0641 105.9586) (xy 135.0141 105.9586) - (xy 135.0141 105.9386) (xy 134.36025 105.9386) (xy 134.2525 106.04635) (xy 134.2525 106.66725) (xy 134.269063 106.750518) - (xy 134.301553 106.828955) (xy 134.348721 106.899547) (xy 134.408754 106.95958) (xy 134.42871 106.972914) (xy 134.373987 107.027636) - (xy 133.728602 107.027636) (xy 133.792522 106.908049) (xy 133.834642 106.769199) (xy 133.848864 106.6248) (xy 133.848864 105.2024) - (xy 133.834642 105.058001) (xy 133.792522 104.919151) (xy 133.724124 104.791187) (xy 133.632075 104.679025) (xy 133.5397 104.603215) - (xy 133.5397 104.07785) (xy 133.43195 103.9701) (xy 132.7781 103.9701) (xy 132.7781 103.9901) (xy 132.7281 103.9901) - (xy 132.7281 103.9701) (xy 132.7081 103.9701) (xy 132.7081 103.9201) (xy 132.7281 103.9201) (xy 132.7281 103.9001) - (xy 132.7781 103.9001) (xy 132.7781 103.9201) (xy 133.43195 103.9201) (xy 133.5397 103.81235) (xy 133.5397 103.81218) - ) - ) - (filled_polygon - (pts - (xy 138.558956 105.404192) (xy 138.783604 105.554297) (xy 139.033219 105.657691) (xy 139.259761 105.702752) (xy 139.084019 105.737709) - (xy 138.834404 105.841103) (xy 138.609756 105.991208) (xy 138.420083 106.180881) (xy 138.419922 106.180351) (xy 138.351524 106.052387) - (xy 138.259475 105.940225) (xy 138.227032 105.9136) (xy 138.259475 105.886975) (xy 138.351524 105.774813) (xy 138.419922 105.646849) - (xy 138.462042 105.507999) (xy 138.476264 105.3636) (xy 138.476264 105.3215) - ) - ) - (filled_polygon - (pts - (xy 168.439125 83.431911) (xy 167.941555 84.176577) (xy 167.598823 85.004006) (xy 167.4241 85.882399) (xy 167.4241 86.778001) - (xy 167.598823 87.656394) (xy 167.941555 88.483823) (xy 168.439125 89.228489) (xy 169.072411 89.861775) (xy 169.817077 90.359345) - (xy 170.644506 90.702077) (xy 170.876896 90.748302) (xy 170.72487 90.900328) (xy 170.545764 91.168379) (xy 170.543411 91.17406) - (xy 170.34312 91.091935) (xy 169.491455 91.9436) (xy 170.34312 92.795265) (xy 170.543411 92.71314) (xy 170.545764 92.718821) - (xy 170.72487 92.986872) (xy 170.751501 93.013503) (xy 170.7515 93.413698) (xy 170.72487 93.440328) (xy 170.545764 93.708379) - (xy 170.543411 93.71406) (xy 170.34312 93.631935) (xy 169.491455 94.4836) (xy 170.34312 95.335265) (xy 170.543411 95.25314) - (xy 170.545764 95.258821) (xy 170.72487 95.526872) (xy 170.751501 95.553503) (xy 170.7515 95.953698) (xy 170.72487 95.980328) - (xy 170.545764 96.248379) (xy 170.543411 96.25406) (xy 170.34312 96.171935) (xy 169.491455 97.0236) (xy 170.34312 97.875265) - (xy 170.543411 97.79314) (xy 170.545764 97.798821) (xy 170.72487 98.066872) (xy 170.751501 98.093503) (xy 170.7515 98.493698) - (xy 170.72487 98.520328) (xy 170.545764 98.788379) (xy 170.543411 98.79406) (xy 170.34312 98.711935) (xy 169.491455 99.5636) - (xy 170.34312 100.415265) (xy 170.543411 100.33314) (xy 170.545764 100.338821) (xy 170.72487 100.606872) (xy 170.952828 100.83483) - (xy 171.220879 101.013936) (xy 171.518721 101.137307) (xy 171.834909 101.2002) (xy 172.157291 101.2002) (xy 172.473479 101.137307) - (xy 172.771321 101.013936) (xy 173.039372 100.83483) (xy 173.066002 100.8082) (xy 173.164501 100.8082) (xy 173.1645 101.866486) - (xy 171.323476 104.107735) (xy 168.2877 102.192113) (xy 168.2877 101.844014) (xy 168.424215 101.639704) (xy 168.552501 101.329997) - (xy 168.6179 101.001213) (xy 168.6179 100.665987) (xy 168.579935 100.475123) (xy 168.604436 100.450622) (xy 168.690335 100.660117) - (xy 168.918969 100.78844) (xy 169.168245 100.869695) (xy 169.428582 100.900756) (xy 169.689977 100.880431) (xy 169.942384 100.809501) - (xy 170.176104 100.690692) (xy 170.221865 100.660117) (xy 170.307765 100.45062) (xy 169.4561 99.598955) (xy 169.441958 99.613098) - (xy 169.406603 99.577743) (xy 169.420745 99.5636) (xy 169.406603 99.549458) (xy 169.441958 99.514103) (xy 169.4561 99.528245) - (xy 170.307765 98.67658) (xy 170.221865 98.467083) (xy 169.993231 98.33876) (xy 169.855586 98.293893) (xy 169.942384 98.269501) - (xy 170.176104 98.150692) (xy 170.221865 98.120117) (xy 170.307765 97.91062) (xy 169.4561 97.058955) (xy 169.441958 97.073098) - (xy 169.406603 97.037743) (xy 169.420745 97.0236) (xy 169.406603 97.009458) (xy 169.441958 96.974103) (xy 169.4561 96.988245) - (xy 170.307765 96.13658) (xy 170.221865 95.927083) (xy 169.993231 95.79876) (xy 169.855586 95.753893) (xy 169.942384 95.729501) - (xy 170.176104 95.610692) (xy 170.221865 95.580117) (xy 170.307765 95.37062) (xy 169.4561 94.518955) (xy 169.441958 94.533098) - (xy 169.406603 94.497743) (xy 169.420745 94.4836) (xy 168.56908 93.631935) (xy 168.359583 93.717835) (xy 168.23126 93.946469) - (xy 168.150005 94.195745) (xy 168.118944 94.456082) (xy 168.12684 94.557632) (xy 168.000934 94.431726) (xy 167.8559 94.334818) - (xy 167.8559 93.260254) (xy 167.860446 93.214587) (xy 167.8559 93.167931) (xy 167.8559 93.167433) (xy 167.851354 93.121276) - (xy 167.842493 93.030335) (xy 167.842351 93.029865) (xy 167.842302 93.029367) (xy 167.815414 92.940729) (xy 167.78894 92.853126) - (xy 167.788707 92.852689) (xy 167.788563 92.852214) (xy 167.777021 92.83062) (xy 168.604435 92.83062) (xy 168.690335 93.040117) - (xy 168.918969 93.16844) (xy 169.056614 93.213307) (xy 168.969816 93.237699) (xy 168.736096 93.356508) (xy 168.690335 93.387083) - (xy 168.604435 93.59658) (xy 169.4561 94.448245) (xy 170.307765 93.59658) (xy 170.221865 93.387083) (xy 169.993231 93.25876) - (xy 169.855586 93.213893) (xy 169.942384 93.189501) (xy 170.176104 93.070692) (xy 170.221865 93.040117) (xy 170.307765 92.83062) - (xy 169.4561 91.978955) (xy 168.604435 92.83062) (xy 167.777021 92.83062) (xy 167.745083 92.77087) (xy 167.723669 92.730705) - (xy 167.723397 92.730297) (xy 167.701296 92.688949) (xy 167.672179 92.65347) (xy 167.180587 91.916082) (xy 168.118944 91.916082) - (xy 168.139269 92.177477) (xy 168.210199 92.429884) (xy 168.329008 92.663604) (xy 168.359583 92.709365) (xy 168.56908 92.795265) - (xy 169.420745 91.9436) (xy 168.56908 91.091935) (xy 168.359583 91.177835) (xy 168.23126 91.406469) (xy 168.150005 91.655745) - (xy 168.118944 91.916082) (xy 167.180587 91.916082) (xy 166.607586 91.05658) (xy 168.604435 91.05658) (xy 169.4561 91.908245) - (xy 170.307765 91.05658) (xy 170.221865 90.847083) (xy 169.993231 90.71876) (xy 169.743955 90.637505) (xy 169.483618 90.606444) - (xy 169.222223 90.626769) (xy 168.969816 90.697699) (xy 168.736096 90.816508) (xy 168.690335 90.847083) (xy 168.604435 91.05658) - (xy 166.607586 91.05658) (xy 165.860281 89.935623) (xy 165.890382 89.862952) (xy 165.9509 89.558704) (xy 165.9509 89.248496) - (xy 165.890382 88.944248) (xy 165.77167 88.657652) (xy 165.599327 88.399723) (xy 165.379977 88.180373) (xy 165.122048 88.00803) - (xy 164.835452 87.889318) (xy 164.531204 87.8288) (xy 164.220996 87.8288) (xy 164.008547 87.871058) (xy 163.978563 87.772214) - (xy 163.916656 87.656394) (xy 163.891296 87.608948) (xy 163.803284 87.501706) (xy 163.803282 87.501704) (xy 163.773854 87.465846) - (xy 163.737995 87.436417) (xy 163.16829 86.866714) (xy 163.138854 86.830846) (xy 162.995751 86.713404) (xy 162.832486 86.626137) - (xy 162.655333 86.572398) (xy 162.517267 86.5588) (xy 162.517257 86.5588) (xy 162.4711 86.554254) (xy 162.424943 86.5588) - (xy 160.331083 86.5588) (xy 160.321168 86.557046) (xy 160.238648 86.5588) (xy 160.202433 86.5588) (xy 160.192466 86.559782) - (xy 160.136085 86.56098) (xy 160.100572 86.568832) (xy 160.064367 86.572398) (xy 160.010388 86.588772) (xy 159.955326 86.600947) - (xy 159.922026 86.615577) (xy 159.887214 86.626137) (xy 159.837475 86.652723) (xy 159.785838 86.675409) (xy 159.756027 86.696258) - (xy 159.723949 86.713404) (xy 159.680356 86.74918) (xy 159.634133 86.781507) (xy 159.608962 86.807772) (xy 159.580846 86.830846) - (xy 159.545065 86.874445) (xy 159.538141 86.88167) (xy 159.515791 86.910116) (xy 159.463404 86.973949) (xy 159.458655 86.982835) - (xy 156.546375 90.689373) (xy 156.529372 90.67237) (xy 156.261321 90.493264) (xy 155.963479 90.369893) (xy 155.647291 90.307) - (xy 155.324909 90.307) (xy 155.008721 90.369893) (xy 154.710879 90.493264) (xy 154.442828 90.67237) (xy 154.2161 90.899098) - (xy 153.989372 90.67237) (xy 153.721321 90.493264) (xy 153.423479 90.369893) (xy 153.107291 90.307) (xy 152.784909 90.307) - (xy 152.468721 90.369893) (xy 152.170879 90.493264) (xy 151.902828 90.67237) (xy 151.6761 90.899098) (xy 151.449372 90.67237) - (xy 151.181321 90.493264) (xy 150.883479 90.369893) (xy 150.567291 90.307) (xy 150.244909 90.307) (xy 149.928721 90.369893) - (xy 149.6449 90.487456) (xy 150.652622 88.472011) (xy 150.88027 88.42673) (xy 151.176111 88.304188) (xy 151.44236 88.126286) - (xy 151.668786 87.89986) (xy 151.846688 87.633611) (xy 151.96923 87.33777) (xy 152.0317 87.023708) (xy 152.0317 86.703492) - (xy 151.96923 86.38943) (xy 151.846688 86.093589) (xy 151.668786 85.82734) (xy 151.44236 85.600914) (xy 151.176111 85.423012) - (xy 150.88027 85.30047) (xy 150.566208 85.238) (xy 150.245992 85.238) (xy 149.93193 85.30047) (xy 149.636089 85.423012) - (xy 149.36984 85.600914) (xy 149.143414 85.82734) (xy 149.1361 85.838286) (xy 149.128786 85.82734) (xy 148.90236 85.600914) - (xy 148.636111 85.423012) (xy 148.34027 85.30047) (xy 148.026208 85.238) (xy 147.705992 85.238) (xy 147.39193 85.30047) - (xy 147.096089 85.423012) (xy 146.82984 85.600914) (xy 146.603414 85.82734) (xy 146.5961 85.838286) (xy 146.588786 85.82734) - (xy 146.36236 85.600914) (xy 146.096111 85.423012) (xy 145.80027 85.30047) (xy 145.486208 85.238) (xy 145.165992 85.238) - (xy 144.85193 85.30047) (xy 144.556089 85.423012) (xy 144.28984 85.600914) (xy 144.063414 85.82734) (xy 144.0561 85.838286) - (xy 144.048786 85.82734) (xy 143.82236 85.600914) (xy 143.556111 85.423012) (xy 143.26027 85.30047) (xy 142.946208 85.238) - (xy 142.625992 85.238) (xy 142.31193 85.30047) (xy 142.016089 85.423012) (xy 141.74984 85.600914) (xy 141.523414 85.82734) - (xy 141.5161 85.838286) (xy 141.508786 85.82734) (xy 141.28236 85.600914) (xy 141.016111 85.423012) (xy 140.72027 85.30047) - (xy 140.406208 85.238) (xy 140.085992 85.238) (xy 139.77193 85.30047) (xy 139.476089 85.423012) (xy 139.20984 85.600914) - (xy 138.983414 85.82734) (xy 138.9761 85.838286) (xy 138.968786 85.82734) (xy 138.74236 85.600914) (xy 138.476111 85.423012) - (xy 138.18027 85.30047) (xy 137.866208 85.238) (xy 137.545992 85.238) (xy 137.23193 85.30047) (xy 136.936089 85.423012) - (xy 136.66984 85.600914) (xy 136.443414 85.82734) (xy 136.4361 85.838286) (xy 136.428786 85.82734) (xy 136.20236 85.600914) - (xy 135.936111 85.423012) (xy 135.64027 85.30047) (xy 135.326208 85.238) (xy 135.005992 85.238) (xy 134.69193 85.30047) - (xy 134.396089 85.423012) (xy 134.12984 85.600914) (xy 133.903414 85.82734) (xy 133.8961 85.838286) (xy 133.888786 85.82734) - (xy 133.66236 85.600914) (xy 133.396111 85.423012) (xy 133.10027 85.30047) (xy 132.786208 85.238) (xy 132.465992 85.238) - (xy 132.15193 85.30047) (xy 131.856089 85.423012) (xy 131.58984 85.600914) (xy 131.363414 85.82734) (xy 131.3561 85.838286) - (xy 131.348786 85.82734) (xy 131.12236 85.600914) (xy 130.856111 85.423012) (xy 130.56027 85.30047) (xy 130.246208 85.238) - (xy 129.925992 85.238) (xy 129.61193 85.30047) (xy 129.450267 85.367433) (xy 129.377977 85.004006) (xy 129.035245 84.176577) - (xy 128.537675 83.431911) (xy 128.420964 83.3152) (xy 168.555836 83.3152) - ) - ) - (filled_polygon - (pts - (xy 128.009996 103.135485) (xy 127.731266 103.321726) (xy 127.494226 103.558766) (xy 127.465204 103.6022) (xy 126.263646 103.6022) - (xy 126.04236 103.380914) (xy 126.031414 103.3736) (xy 126.04236 103.366286) (xy 126.268786 103.13986) (xy 126.336343 103.038754) - (xy 128.25976 103.032029) - ) - ) - (filled_polygon - (pts - (xy 132.015553 103.029745) (xy 131.983063 103.108182) (xy 131.9665 103.19145) (xy 131.9665 103.460779) (xy 131.9021 103.454436) - (xy 130.3021 103.454436) (xy 130.157701 103.468658) (xy 130.07343 103.494222) (xy 129.900934 103.321726) (xy 129.622204 103.135485) - (xy 129.363127 103.028171) (xy 132.022819 103.018871) - ) - ) - (filled_polygon - (pts - (xy 163.152873 92.947477) (xy 163.372223 93.166827) (xy 163.630152 93.33917) (xy 163.738462 93.384033) (xy 163.688548 93.409464) - (xy 163.646842 93.437331) (xy 163.568356 93.6405) (xy 164.3761 94.448245) (xy 165.183844 93.6405) (xy 165.105358 93.437331) - (xy 165.011702 93.384877) (xy 165.122048 93.33917) (xy 165.379977 93.166827) (xy 165.599327 92.947477) (xy 165.604262 92.940092) - (xy 165.976301 93.498151) (xy 165.976301 94.334817) (xy 165.831266 94.431726) (xy 165.637348 94.625644) (xy 165.651196 94.50868) - (xy 165.631588 94.259439) (xy 165.563732 94.018812) (xy 165.450236 93.796048) (xy 165.422369 93.754342) (xy 165.2192 93.675856) - (xy 164.411455 94.4836) (xy 164.425598 94.497742) (xy 164.390242 94.533098) (xy 164.3761 94.518955) (xy 163.568356 95.3267) - (xy 163.646842 95.529869) (xy 163.864971 95.652037) (xy 164.102743 95.729302) (xy 164.35102 95.758696) (xy 164.600261 95.739088) - (xy 164.840888 95.671232) (xy 165.063652 95.557736) (xy 165.105358 95.529869) (xy 165.183843 95.326701) (xy 165.252265 95.395123) - (xy 165.2143 95.585987) (xy 165.2143 95.921213) (xy 165.279699 96.249997) (xy 165.407985 96.559704) (xy 165.544501 96.764015) - (xy 165.5445 97.283186) (xy 165.407985 97.487496) (xy 165.279699 97.797203) (xy 165.2143 98.125987) (xy 165.2143 98.461213) - (xy 165.279699 98.789997) (xy 165.407985 99.099704) (xy 165.5445 99.304014) (xy 165.5445 99.402636) (xy 163.5087 99.402636) - (xy 163.364301 99.416858) (xy 163.225451 99.458978) (xy 163.097487 99.527376) (xy 162.985325 99.619425) (xy 162.893276 99.731587) - (xy 162.824878 99.859551) (xy 162.782758 99.998401) (xy 162.768536 100.1428) (xy 162.768536 101.379583) (xy 161.396927 102.3576) - (xy 160.744962 102.3576) (xy 160.747464 102.3322) (xy 160.747464 101.621) (xy 160.733242 101.476601) (xy 160.691122 101.337751) - (xy 160.622724 101.209787) (xy 160.530675 101.097625) (xy 160.418513 101.005576) (xy 160.290549 100.937178) (xy 160.151699 100.895058) - (xy 160.0073 100.880836) (xy 158.836895 100.880836) (xy 158.909139 100.786364) (xy 160.0073 100.786364) (xy 160.151699 100.772142) - (xy 160.290549 100.730022) (xy 160.418513 100.661624) (xy 160.530675 100.569575) (xy 160.622724 100.457413) (xy 160.691122 100.329449) - (xy 160.733242 100.190599) (xy 160.747464 100.0462) (xy 160.747464 99.335) (xy 160.733242 99.190601) (xy 160.691122 99.051751) - (xy 160.671392 99.014838) (xy 162.126705 96.031447) (xy 162.295452 95.997882) (xy 162.582048 95.87917) (xy 162.839977 95.706827) - (xy 163.059327 95.487477) (xy 163.23167 95.229548) (xy 163.276533 95.121238) (xy 163.301964 95.171152) (xy 163.329831 95.212858) - (xy 163.533 95.291344) (xy 164.340745 94.4836) (xy 163.533 93.675856) (xy 163.329831 93.754342) (xy 163.277377 93.847998) - (xy 163.23167 93.737652) (xy 163.059327 93.479723) (xy 162.839977 93.260373) (xy 162.769976 93.2136) (xy 162.839977 93.166827) - (xy 163.059327 92.947477) (xy 163.1061 92.877476) - ) - ) - (filled_polygon - (pts - (xy 143.4719 96.237) (xy 142.91885 96.237) (xy 142.8111 96.34475) (xy 142.8111 96.9986) (xy 142.8311 96.9986) - (xy 142.8311 97.0486) (xy 142.8111 97.0486) (xy 142.8111 97.70245) (xy 142.891087 97.782437) (xy 142.822593 97.879989) - (xy 142.81571 97.888506) (xy 142.737146 97.726404) (xy 142.7611 97.70245) (xy 142.7611 97.0486) (xy 142.7411 97.0486) - (xy 142.7411 96.9986) (xy 142.7611 96.9986) (xy 142.7611 96.34475) (xy 142.65335 96.237) (xy 142.37417 96.237) - (xy 142.508382 95.847786) (xy 142.562034 95.864061) (xy 142.7861 95.88613) (xy 143.010167 95.864061) (xy 143.111361 95.833364) - (xy 143.4719 95.833364) - ) - ) - ) - (zone (net 1) (net_name GND) (layer Top) (tstamp 5CA38C3F) (hatch edge 0.508) - (connect_pads (clearance 0.508)) - (min_thickness 0.254) - (fill yes (arc_segments 16) (thermal_gap 0.508) (thermal_bridge_width 0.508)) - (polygon - (pts - (xy 121.8311 83.0536) (xy 175.1711 83.0536) (xy 175.1711 126.8686) (xy 121.8311 126.8686) - ) - ) - (filled_polygon - (pts - (xy 168.202411 83.81231) (xy 167.5257 85.446034) (xy 167.5257 87.214366) (xy 168.202411 88.84809) (xy 169.45281 90.098489) - (xy 171.020878 90.748005) (xy 170.69479 91.074093) (xy 170.686662 91.093715) (xy 170.536259 91.043046) (xy 169.635705 91.9436) - (xy 170.536259 92.844154) (xy 170.686662 92.793485) (xy 170.69479 92.813107) (xy 171.095283 93.2136) (xy 170.69479 93.614093) - (xy 170.686662 93.633715) (xy 170.536259 93.583046) (xy 169.635705 94.4836) (xy 170.536259 95.384154) (xy 170.686662 95.333485) - (xy 170.69479 95.353107) (xy 171.095283 95.7536) (xy 170.69479 96.154093) (xy 170.686662 96.173715) (xy 170.536259 96.123046) - (xy 169.635705 97.0236) (xy 170.536259 97.924154) (xy 170.686662 97.873485) (xy 170.69479 97.893107) (xy 171.095283 98.2936) - (xy 170.69479 98.694093) (xy 170.686662 98.713715) (xy 170.536259 98.663046) (xy 169.635705 99.5636) (xy 170.536259 100.464154) - (xy 170.686662 100.413485) (xy 170.69479 100.433107) (xy 171.126593 100.86491) (xy 171.69077 101.0986) (xy 172.30143 101.0986) - (xy 172.865607 100.86491) (xy 173.219996 100.510521) (xy 173.629659 100.920184) (xy 174.2178 101.1638) (xy 174.8544 101.1638) - (xy 175.0441 101.085224) (xy 175.0441 112.717549) (xy 174.84143 112.6336) (xy 174.23077 112.6336) (xy 173.666593 112.86729) - (xy 173.2661 113.267783) (xy 172.865607 112.86729) (xy 172.30143 112.6336) (xy 171.69077 112.6336) (xy 171.126593 112.86729) - (xy 170.69479 113.299093) (xy 170.4611 113.86327) (xy 170.4611 114.47393) (xy 170.69479 115.038107) (xy 171.126593 115.46991) - (xy 171.69077 115.7036) (xy 172.30143 115.7036) (xy 172.865607 115.46991) (xy 173.2661 115.069417) (xy 173.666593 115.46991) - (xy 174.23077 115.7036) (xy 174.84143 115.7036) (xy 175.0441 115.619651) (xy 175.0441 115.973078) (xy 174.892992 115.902114) - (xy 174.6631 116.022781) (xy 174.6631 117.2166) (xy 174.6831 117.2166) (xy 174.6831 117.4706) (xy 174.6631 117.4706) - (xy 174.6631 119.7566) (xy 174.6831 119.7566) (xy 174.6831 120.0106) (xy 174.6631 120.0106) (xy 174.6631 122.2966) - (xy 174.6831 122.2966) (xy 174.6831 122.5506) (xy 174.6631 122.5506) (xy 174.6631 124.8366) (xy 174.6831 124.8366) - (xy 174.6831 125.0906) (xy 174.6631 125.0906) (xy 174.6631 126.284419) (xy 174.892992 126.405086) (xy 175.0441 126.334122) - (xy 175.0441 126.7416) (xy 128.244279 126.7416) (xy 128.774389 126.21149) (xy 128.892817 125.925579) (xy 129.222823 126.255585) - (xy 129.782958 126.4876) (xy 130.389242 126.4876) (xy 130.949377 126.255585) (xy 131.3561 125.848862) (xy 131.762823 126.255585) - (xy 132.322958 126.4876) (xy 132.929242 126.4876) (xy 133.489377 126.255585) (xy 133.8961 125.848862) (xy 134.302823 126.255585) - (xy 134.862958 126.4876) (xy 135.469242 126.4876) (xy 136.029377 126.255585) (xy 136.4361 125.848862) (xy 136.842823 126.255585) - (xy 137.402958 126.4876) (xy 138.009242 126.4876) (xy 138.569377 126.255585) (xy 138.9761 125.848862) (xy 139.382823 126.255585) - (xy 139.942958 126.4876) (xy 140.549242 126.4876) (xy 141.109377 126.255585) (xy 141.5161 125.848862) (xy 141.922823 126.255585) - (xy 142.482958 126.4876) (xy 143.089242 126.4876) (xy 143.649377 126.255585) (xy 144.0561 125.848862) (xy 144.462823 126.255585) - (xy 145.022958 126.4876) (xy 145.629242 126.4876) (xy 146.189377 126.255585) (xy 146.5961 125.848862) (xy 147.002823 126.255585) - (xy 147.562958 126.4876) (xy 148.169242 126.4876) (xy 148.729377 126.255585) (xy 149.1361 125.848862) (xy 149.542823 126.255585) - (xy 150.102958 126.4876) (xy 150.709242 126.4876) (xy 151.269377 126.255585) (xy 151.6761 125.848862) (xy 152.082823 126.255585) - (xy 152.642958 126.4876) (xy 153.249242 126.4876) (xy 153.809377 126.255585) (xy 154.2161 125.848862) (xy 154.622823 126.255585) - (xy 155.182958 126.4876) (xy 155.789242 126.4876) (xy 156.349377 126.255585) (xy 156.7561 125.848862) (xy 157.162823 126.255585) - (xy 157.722958 126.4876) (xy 158.329242 126.4876) (xy 158.889377 126.255585) (xy 159.318085 125.826877) (xy 159.527836 125.32049) - (xy 170.554624 125.32049) (xy 170.724455 125.730524) (xy 171.114742 126.158783) (xy 171.639208 126.405086) (xy 171.8691 126.284419) - (xy 171.8691 125.0906) (xy 172.1231 125.0906) (xy 172.1231 126.284419) (xy 172.352992 126.405086) (xy 172.877458 126.158783) - (xy 173.2661 125.732329) (xy 173.654742 126.158783) (xy 174.179208 126.405086) (xy 174.4091 126.284419) (xy 174.4091 125.0906) - (xy 172.1231 125.0906) (xy 171.8691 125.0906) (xy 170.675945 125.0906) (xy 170.554624 125.32049) (xy 159.527836 125.32049) - (xy 159.5501 125.266742) (xy 159.5501 124.660458) (xy 159.318085 124.100323) (xy 158.889377 123.671615) (xy 158.529872 123.522704) - (xy 158.516615 123.469674) (xy 161.61575 123.469674) (xy 161.704542 123.916062) (xy 162.042779 124.422271) (xy 162.548987 124.760508) - (xy 163.1461 124.879281) (xy 163.743212 124.760508) (xy 164.249421 124.422271) (xy 164.587658 123.916063) (xy 164.67645 123.469675) - (xy 164.67645 122.5506) (xy 166.61575 122.5506) (xy 166.61575 123.44595) (xy 166.780842 124.021922) (xy 167.153782 124.490873) - (xy 167.677793 124.781409) (xy 167.78209 124.805378) (xy 168.0191 124.684658) (xy 168.0191 122.5506) (xy 168.2731 122.5506) - (xy 168.2731 124.684658) (xy 168.51011 124.805378) (xy 168.614407 124.781409) (xy 169.138418 124.490873) (xy 169.511358 124.021922) - (xy 169.67645 123.44595) (xy 169.67645 122.78049) (xy 170.554624 122.78049) (xy 170.724455 123.190524) (xy 171.114742 123.618783) - (xy 171.274054 123.6936) (xy 171.114742 123.768417) (xy 170.724455 124.196676) (xy 170.554624 124.60671) (xy 170.675945 124.8366) - (xy 171.8691 124.8366) (xy 171.8691 122.5506) (xy 172.1231 122.5506) (xy 172.1231 124.8366) (xy 174.4091 124.8366) - (xy 174.4091 122.5506) (xy 172.1231 122.5506) (xy 171.8691 122.5506) (xy 170.675945 122.5506) (xy 170.554624 122.78049) - (xy 169.67645 122.78049) (xy 169.67645 122.5506) (xy 168.2731 122.5506) (xy 168.0191 122.5506) (xy 166.61575 122.5506) - (xy 164.67645 122.5506) (xy 164.67645 121.40125) (xy 166.61575 121.40125) (xy 166.61575 122.2966) (xy 168.0191 122.2966) - (xy 168.0191 120.162542) (xy 168.2731 120.162542) (xy 168.2731 122.2966) (xy 169.67645 122.2966) (xy 169.67645 121.40125) - (xy 169.511358 120.825278) (xy 169.138418 120.356327) (xy 168.929495 120.24049) (xy 170.554624 120.24049) (xy 170.724455 120.650524) - (xy 171.114742 121.078783) (xy 171.274054 121.1536) (xy 171.114742 121.228417) (xy 170.724455 121.656676) (xy 170.554624 122.06671) - (xy 170.675945 122.2966) (xy 171.8691 122.2966) (xy 171.8691 120.0106) (xy 172.1231 120.0106) (xy 172.1231 122.2966) - (xy 174.4091 122.2966) (xy 174.4091 120.0106) (xy 172.1231 120.0106) (xy 171.8691 120.0106) (xy 170.675945 120.0106) - (xy 170.554624 120.24049) (xy 168.929495 120.24049) (xy 168.614407 120.065791) (xy 168.51011 120.041822) (xy 168.2731 120.162542) - (xy 168.0191 120.162542) (xy 167.78209 120.041822) (xy 167.677793 120.065791) (xy 167.153782 120.356327) (xy 166.780842 120.825278) - (xy 166.61575 121.40125) (xy 164.67645 121.40125) (xy 164.67645 121.377525) (xy 164.587658 120.931137) (xy 164.249421 120.424929) - (xy 163.743213 120.086692) (xy 163.1461 119.967919) (xy 162.548988 120.086692) (xy 162.04278 120.424929) (xy 161.704543 120.931137) - (xy 161.615751 121.377525) (xy 161.61575 123.469674) (xy 158.516615 123.469674) (xy 158.2293 122.320414) (xy 158.2293 120.734378) - (xy 158.350065 120.710357) (xy 158.560109 120.570009) (xy 158.700457 120.359965) (xy 158.74974 120.1122) (xy 158.74974 119.401) - (xy 158.700457 119.153235) (xy 158.560109 118.943191) (xy 158.350065 118.802843) (xy 158.1023 118.75356) (xy 156.6799 118.75356) - (xy 156.432135 118.802843) (xy 156.222091 118.943191) (xy 156.081743 119.153235) (xy 156.03246 119.401) (xy 156.03246 120.1122) - (xy 156.081743 120.359965) (xy 156.222091 120.570009) (xy 156.432135 120.710357) (xy 156.552901 120.734379) (xy 156.5529 122.277963) - (xy 156.545787 122.297814) (xy 156.5529 122.443966) (xy 156.5529 122.506153) (xy 156.556907 122.526297) (xy 156.557905 122.546804) - (xy 156.572982 122.607111) (xy 156.601533 122.750648) (xy 156.61325 122.768184) (xy 156.903851 123.930587) (xy 156.7561 124.078338) - (xy 156.349377 123.671615) (xy 155.789242 123.4396) (xy 155.182958 123.4396) (xy 154.622823 123.671615) (xy 154.2161 124.078338) - (xy 153.83914 123.701378) (xy 154.24741 123.293107) (xy 154.4811 122.72893) (xy 154.4811 122.11827) (xy 154.24741 121.554093) - (xy 153.815607 121.12229) (xy 153.25143 120.8886) (xy 152.64077 120.8886) (xy 152.609462 120.901568) (xy 152.5143 120.806407) - (xy 152.5143 120.734378) (xy 152.635065 120.710357) (xy 152.845109 120.570009) (xy 152.985457 120.359965) (xy 153.03474 120.1122) - (xy 153.03474 119.401) (xy 152.985457 119.153235) (xy 152.845109 118.943191) (xy 152.635065 118.802843) (xy 152.3873 118.75356) - (xy 150.9649 118.75356) (xy 150.717135 118.802843) (xy 150.507091 118.943191) (xy 150.366743 119.153235) (xy 150.31746 119.401) - (xy 150.31746 120.1122) (xy 150.366743 120.359965) (xy 150.507091 120.570009) (xy 150.717135 120.710357) (xy 150.8379 120.734378) - (xy 150.8379 120.940986) (xy 150.71143 120.8886) (xy 150.10077 120.8886) (xy 149.536593 121.12229) (xy 149.1361 121.522783) - (xy 148.735607 121.12229) (xy 148.17143 120.8886) (xy 147.56077 120.8886) (xy 146.996593 121.12229) (xy 146.56479 121.554093) - (xy 146.3311 122.11827) (xy 146.3311 122.72893) (xy 146.56479 123.293107) (xy 146.973061 123.701378) (xy 146.5961 124.078338) - (xy 146.189377 123.671615) (xy 145.629242 123.4396) (xy 145.022958 123.4396) (xy 144.462823 123.671615) (xy 144.0561 124.078338) - (xy 143.649377 123.671615) (xy 143.089242 123.4396) (xy 142.482958 123.4396) (xy 141.922823 123.671615) (xy 141.5161 124.078338) - (xy 141.109377 123.671615) (xy 140.549242 123.4396) (xy 139.942958 123.4396) (xy 139.382823 123.671615) (xy 138.9761 124.078338) - (xy 138.569377 123.671615) (xy 138.009242 123.4396) (xy 137.402958 123.4396) (xy 136.842823 123.671615) (xy 136.4361 124.078338) - (xy 136.029377 123.671615) (xy 135.469242 123.4396) (xy 134.862958 123.4396) (xy 134.302823 123.671615) (xy 133.8961 124.078338) - (xy 133.489377 123.671615) (xy 132.929242 123.4396) (xy 132.322958 123.4396) (xy 131.762823 123.671615) (xy 131.3561 124.078338) - (xy 130.949377 123.671615) (xy 130.389242 123.4396) (xy 129.782958 123.4396) (xy 129.4511 123.57706) (xy 129.4511 122.809434) - (xy 128.774389 121.17571) (xy 127.52399 119.925311) (xy 125.890266 119.2486) (xy 124.121934 119.2486) (xy 122.48821 119.925311) - (xy 121.9581 120.455421) (xy 121.9581 109.485565) (xy 123.470584 109.485565) (xy 123.496377 110.0913) (xy 123.678561 110.531133) - (xy 123.933904 110.616191) (xy 124.826495 109.7236) (xy 123.933904 108.831009) (xy 123.678561 108.916067) (xy 123.470584 109.485565) - (xy 121.9581 109.485565) (xy 121.9581 89.568379) (xy 122.48821 90.098489) (xy 124.121934 90.7752) (xy 125.890266 90.7752) - (xy 126.966642 90.32935) (xy 127.9911 90.32935) (xy 127.9911 90.669909) (xy 128.087773 90.903298) (xy 128.266401 91.081927) - (xy 128.49979 91.1786) (xy 129.19035 91.1786) (xy 129.3491 91.01985) (xy 129.3491 90.1706) (xy 129.6031 90.1706) - (xy 129.6031 91.01985) (xy 129.76185 91.1786) (xy 130.45241 91.1786) (xy 130.685799 91.081927) (xy 130.864427 90.903298) - (xy 130.9611 90.669909) (xy 130.9611 90.32935) (xy 134.2911 90.32935) (xy 134.2911 90.669909) (xy 134.387773 90.903298) - (xy 134.566401 91.081927) (xy 134.79979 91.1786) (xy 135.49035 91.1786) (xy 135.6491 91.01985) (xy 135.6491 90.1706) - (xy 135.9031 90.1706) (xy 135.9031 91.01985) (xy 136.06185 91.1786) (xy 136.75241 91.1786) (xy 136.985799 91.081927) - (xy 137.164427 90.903298) (xy 137.2611 90.669909) (xy 137.2611 90.32935) (xy 137.10235 90.1706) (xy 135.9031 90.1706) - (xy 135.6491 90.1706) (xy 134.44985 90.1706) (xy 134.2911 90.32935) (xy 130.9611 90.32935) (xy 130.80235 90.1706) - (xy 129.6031 90.1706) (xy 129.3491 90.1706) (xy 128.14985 90.1706) (xy 127.9911 90.32935) (xy 126.966642 90.32935) - (xy 127.52399 90.098489) (xy 127.9911 89.631379) (xy 127.9911 89.75785) (xy 128.14985 89.9166) (xy 129.3491 89.9166) - (xy 129.3491 89.06735) (xy 129.6031 89.06735) (xy 129.6031 89.9166) (xy 130.80235 89.9166) (xy 130.9611 89.75785) - (xy 130.9611 89.417291) (xy 134.2911 89.417291) (xy 134.2911 89.75785) (xy 134.44985 89.9166) (xy 135.6491 89.9166) - (xy 135.6491 89.06735) (xy 135.9031 89.06735) (xy 135.9031 89.9166) (xy 137.10235 89.9166) (xy 137.2611 89.75785) - (xy 137.2611 89.417291) (xy 137.164427 89.183902) (xy 136.985799 89.005273) (xy 136.75241 88.9086) (xy 136.06185 88.9086) - (xy 135.9031 89.06735) (xy 135.6491 89.06735) (xy 135.49035 88.9086) (xy 134.79979 88.9086) (xy 134.566401 89.005273) - (xy 134.387773 89.183902) (xy 134.2911 89.417291) (xy 130.9611 89.417291) (xy 130.864427 89.183902) (xy 130.685799 89.005273) - (xy 130.45241 88.9086) (xy 129.76185 88.9086) (xy 129.6031 89.06735) (xy 129.3491 89.06735) (xy 129.19035 88.9086) - (xy 128.713879 88.9086) (xy 128.774389 88.84809) (xy 129.108562 88.041324) (xy 129.222823 88.155585) (xy 129.782958 88.3876) - (xy 130.389242 88.3876) (xy 130.949377 88.155585) (xy 131.3561 87.748862) (xy 131.762823 88.155585) (xy 132.322958 88.3876) - (xy 132.929242 88.3876) (xy 133.489377 88.155585) (xy 133.8961 87.748862) (xy 134.302823 88.155585) (xy 134.862958 88.3876) - (xy 135.469242 88.3876) (xy 136.029377 88.155585) (xy 136.4361 87.748862) (xy 136.842823 88.155585) (xy 137.402958 88.3876) - (xy 138.009242 88.3876) (xy 138.569377 88.155585) (xy 138.9761 87.748862) (xy 139.382823 88.155585) (xy 139.942958 88.3876) - (xy 140.549242 88.3876) (xy 141.109377 88.155585) (xy 141.5161 87.748862) (xy 141.922823 88.155585) (xy 142.482958 88.3876) - (xy 142.996777 88.3876) (xy 142.995963 88.388239) (xy 142.870543 88.472043) (xy 142.797944 88.580695) (xy 142.156596 89.328935) - (xy 142.108543 89.361043) (xy 142.035941 89.469699) (xy 142.012315 89.497263) (xy 141.984637 89.546481) (xy 141.900828 89.67191) - (xy 141.893563 89.708433) (xy 141.875313 89.740886) (xy 141.85732 89.890639) (xy 141.8463 89.946042) (xy 141.8463 89.982361) - (xy 141.830713 90.112091) (xy 141.8463 90.167735) (xy 141.846301 91.890374) (xy 141.429516 92.307159) (xy 141.1859 92.8953) - (xy 141.1859 93.5319) (xy 141.429516 94.120041) (xy 141.879659 94.570184) (xy 142.4678 94.8138) (xy 142.904823 94.8138) - (xy 140.999823 96.7188) (xy 134.576553 96.7188) (xy 134.435754 96.705145) (xy 134.301786 96.746002) (xy 134.164409 96.773328) - (xy 134.124291 96.800134) (xy 134.07814 96.814209) (xy 133.969997 96.903231) (xy 133.853543 96.981043) (xy 133.774953 97.098661) - (xy 133.483075 97.4554) (xy 133.476878 97.4554) (xy 133.452857 97.334635) (xy 133.312509 97.124591) (xy 133.102465 96.984243) - (xy 132.8547 96.93496) (xy 132.1435 96.93496) (xy 131.895735 96.984243) (xy 131.685691 97.124591) (xy 131.545343 97.334635) - (xy 131.49606 97.5824) (xy 131.49606 99.0048) (xy 131.545343 99.252565) (xy 131.685691 99.462609) (xy 131.785984 99.529623) - (xy 131.0513 100.427571) (xy 131.0513 99.425507) (xy 131.166857 99.252565) (xy 131.21614 99.0048) (xy 131.21614 97.5824) - (xy 131.166857 97.334635) (xy 131.026509 97.124591) (xy 130.816465 96.984243) (xy 130.5687 96.93496) (xy 129.8575 96.93496) - (xy 129.609735 96.984243) (xy 129.435813 97.100455) (xy 129.350109 96.972191) (xy 129.272991 96.920662) (xy 130.079707 95.718376) - (xy 130.080408 95.717908) (xy 130.172488 95.5801) (xy 130.218131 95.512077) (xy 130.218447 95.511319) (xy 130.265667 95.440649) - (xy 130.281929 95.358895) (xy 130.313974 95.281953) (xy 130.314139 95.196965) (xy 130.3143 95.196154) (xy 130.3143 95.113676) - (xy 130.314538 94.99104) (xy 130.3261 94.99104) (xy 130.573865 94.941757) (xy 130.783909 94.801409) (xy 130.86383 94.6818) - (xy 134.38837 94.6818) (xy 134.468291 94.801409) (xy 134.678335 94.941757) (xy 134.9261 94.99104) (xy 136.6261 94.99104) - (xy 136.873865 94.941757) (xy 137.083909 94.801409) (xy 137.224257 94.591365) (xy 137.27354 94.3436) (xy 137.27354 93.3436) - (xy 137.224257 93.095835) (xy 137.083909 92.885791) (xy 136.873865 92.745443) (xy 136.6261 92.69616) (xy 134.9261 92.69616) - (xy 134.678335 92.745443) (xy 134.468291 92.885791) (xy 134.38837 93.0054) (xy 130.86383 93.0054) (xy 130.783909 92.885791) - (xy 130.573865 92.745443) (xy 130.3261 92.69616) (xy 128.6261 92.69616) (xy 128.378335 92.745443) (xy 128.168291 92.885791) - (xy 128.027943 93.095835) (xy 127.97866 93.3436) (xy 127.97866 94.3436) (xy 128.027943 94.591365) (xy 128.168291 94.801409) - (xy 128.378335 94.941757) (xy 128.558019 94.977498) (xy 127.577493 96.438825) (xy 127.576793 96.439292) (xy 127.484812 96.576951) - (xy 127.439069 96.645124) (xy 127.438753 96.645883) (xy 127.391534 96.716551) (xy 127.375273 96.798301) (xy 127.373873 96.801661) - (xy 127.222135 96.831843) (xy 127.012091 96.972191) (xy 126.871743 97.182235) (xy 126.82246 97.43) (xy 126.82246 98.1412) - (xy 126.871743 98.388965) (xy 127.012091 98.599009) (xy 127.222135 98.739357) (xy 127.4699 98.78864) (xy 128.8923 98.78864) - (xy 129.140065 98.739357) (xy 129.21006 98.692587) (xy 129.21006 99.0048) (xy 129.246721 99.189109) (xy 129.140065 99.117843) - (xy 128.8923 99.06856) (xy 127.4699 99.06856) (xy 127.222135 99.117843) (xy 127.012091 99.258191) (xy 126.871743 99.468235) - (xy 126.82246 99.716) (xy 126.82246 100.4272) (xy 126.871743 100.674965) (xy 126.984937 100.84437) (xy 126.757778 101.071528) - (xy 126.687792 101.118292) (xy 126.502533 101.395552) (xy 126.457065 101.624135) (xy 126.298085 101.240323) (xy 125.891362 100.8336) - (xy 126.298085 100.426877) (xy 126.5301 99.866742) (xy 126.5301 99.260458) (xy 126.298085 98.700323) (xy 125.891362 98.2936) - (xy 126.298085 97.886877) (xy 126.5301 97.326742) (xy 126.5301 96.720458) (xy 126.298085 96.160323) (xy 125.869377 95.731615) - (xy 125.309242 95.4996) (xy 124.702958 95.4996) (xy 124.142823 95.731615) (xy 123.714115 96.160323) (xy 123.4821 96.720458) - (xy 123.4821 97.326742) (xy 123.714115 97.886877) (xy 124.120838 98.2936) (xy 123.714115 98.700323) (xy 123.4821 99.260458) - (xy 123.4821 99.866742) (xy 123.714115 100.426877) (xy 124.120838 100.8336) (xy 123.714115 101.240323) (xy 123.4821 101.800458) - (xy 123.4821 102.406742) (xy 123.714115 102.966877) (xy 124.120838 103.3736) (xy 123.714115 103.780323) (xy 123.4821 104.340458) - (xy 123.4821 104.946742) (xy 123.714115 105.506877) (xy 124.120838 105.9136) (xy 123.714115 106.320323) (xy 123.4821 106.880458) - (xy 123.4821 107.486742) (xy 123.714115 108.046877) (xy 124.142823 108.475585) (xy 124.16853 108.486233) (xy 124.113509 108.651404) - (xy 125.0061 109.543995) (xy 125.020243 109.529853) (xy 125.199848 109.709458) (xy 125.185705 109.7236) (xy 126.078296 110.616191) - (xy 126.333639 110.531133) (xy 126.541616 109.961635) (xy 126.515823 109.3559) (xy 126.381531 109.031689) (xy 126.583038 109.157631) - (xy 126.711051 109.243167) (xy 126.80623 109.262099) (xy 126.896967 109.296486) (xy 127.050814 109.2918) (xy 127.405656 109.2918) - (xy 127.331123 109.497697) (xy 127.357711 110.083169) (xy 127.53061 110.500583) (xy 127.780687 110.579408) (xy 128.636495 109.7236) - (xy 128.622353 109.709458) (xy 128.801958 109.529853) (xy 128.8161 109.543995) (xy 128.830243 109.529853) (xy 129.009848 109.709458) - (xy 128.995705 109.7236) (xy 129.009848 109.737743) (xy 128.830243 109.917348) (xy 128.8161 109.903205) (xy 127.960292 110.759013) - (xy 128.034033 110.992962) (xy 127.981599 111.014681) (xy 127.567181 111.429099) (xy 127.3429 111.970562) (xy 127.3429 112.556638) - (xy 127.567181 113.098101) (xy 127.981599 113.512519) (xy 128.523062 113.7368) (xy 127.893411 113.7368) (xy 126.5301 112.508471) - (xy 126.5301 111.960458) (xy 126.298085 111.400323) (xy 125.869377 110.971615) (xy 125.84367 110.960967) (xy 125.898691 110.795796) - (xy 125.0061 109.903205) (xy 124.113509 110.795796) (xy 124.16853 110.960967) (xy 124.142823 110.971615) (xy 123.714115 111.400323) - (xy 123.4821 111.960458) (xy 123.4821 112.566742) (xy 123.714115 113.126877) (xy 124.120838 113.5336) (xy 123.714115 113.940323) - (xy 123.4821 114.500458) (xy 123.4821 115.106742) (xy 123.714115 115.666877) (xy 124.120838 116.0736) (xy 123.714115 116.480323) - (xy 123.4821 117.040458) (xy 123.4821 117.646742) (xy 123.714115 118.206877) (xy 124.142823 118.635585) (xy 124.702958 118.8676) - (xy 125.309242 118.8676) (xy 125.686949 118.711149) (xy 127.609686 119.832746) (xy 127.727051 119.911167) (xy 127.834847 119.932609) - (xy 127.938758 119.968401) (xy 128.07964 119.9598) (xy 131.015988 119.9598) (xy 131.12583 119.974515) (xy 131.261359 119.93853) - (xy 131.398924 119.911167) (xy 131.421677 119.895964) (xy 131.44812 119.888943) (xy 131.55957 119.803827) (xy 131.676183 119.725908) - (xy 131.737758 119.633754) (xy 140.625316 109.5458) (xy 140.879719 109.5458) (xy 141.346497 109.352454) (xy 141.703754 108.995197) - (xy 141.8971 108.528419) (xy 141.8971 108.023181) (xy 141.703754 107.556403) (xy 141.346497 107.199146) (xy 140.879719 107.0058) - (xy 140.7541 107.0058) (xy 140.7541 106.803981) (xy 140.560754 106.337203) (xy 140.203497 105.979946) (xy 140.043324 105.9136) - (xy 154.672327 105.9136) (xy 154.776808 106.438861) (xy 155.074344 106.884156) (xy 155.519639 107.181692) (xy 155.912314 107.2598) - (xy 157.599886 107.2598) (xy 157.992561 107.181692) (xy 158.437856 106.884156) (xy 158.735392 106.438861) (xy 158.839873 105.9136) - (xy 158.735392 105.388339) (xy 158.437856 104.943044) (xy 157.992561 104.645508) (xy 157.599886 104.5674) (xy 155.912314 104.5674) - (xy 155.519639 104.645508) (xy 155.074344 104.943044) (xy 154.776808 105.388339) (xy 154.672327 105.9136) (xy 140.043324 105.9136) - (xy 139.736719 105.7866) (xy 139.360899 105.7866) (xy 139.500757 105.6088) (xy 139.685919 105.6088) (xy 140.152697 105.415454) - (xy 140.509954 105.058197) (xy 140.7033 104.591419) (xy 140.7033 104.086181) (xy 140.509954 103.619403) (xy 140.152697 103.262146) - (xy 139.685919 103.0688) (xy 139.180681 103.0688) (xy 138.713903 103.262146) (xy 138.356646 103.619403) (xy 138.1633 104.086181) - (xy 138.1633 104.591419) (xy 138.164973 104.595458) (xy 131.88994 112.572867) (xy 131.88994 112.4508) (xy 131.840657 112.203035) - (xy 131.700309 111.992991) (xy 131.490265 111.852643) (xy 131.2425 111.80336) (xy 130.319937 111.80336) (xy 130.181087 111.66451) - (xy 130.132262 111.591438) (xy 130.065019 111.429099) (xy 129.72172 111.0858) (xy 130.20675 111.0858) (xy 130.3655 110.92705) - (xy 130.3655 109.8278) (xy 130.6195 109.8278) (xy 130.6195 110.92705) (xy 130.77825 111.0858) (xy 131.368809 111.0858) - (xy 131.602198 110.989127) (xy 131.780827 110.810499) (xy 131.8775 110.57711) (xy 131.8775 109.98655) (xy 131.71875 109.8278) - (xy 130.6195 109.8278) (xy 130.3655 109.8278) (xy 130.3455 109.8278) (xy 130.3455 109.5738) (xy 130.3655 109.5738) - (xy 130.3655 109.5538) (xy 130.6195 109.5538) (xy 130.6195 109.5738) (xy 131.71875 109.5738) (xy 131.8775 109.41505) - (xy 131.8775 108.82449) (xy 131.780827 108.591101) (xy 131.661065 108.471339) (xy 134.175974 103.743311) (xy 134.615497 103.561254) - (xy 134.972754 103.203997) (xy 135.1661 102.737219) (xy 135.1661 102.231981) (xy 134.972754 101.765203) (xy 134.615497 101.407946) - (xy 134.148719 101.2146) (xy 133.643481 101.2146) (xy 133.176703 101.407946) (xy 132.819446 101.765203) (xy 132.6261 102.231981) - (xy 132.6261 102.737219) (xy 132.70763 102.93405) (xy 130.21755 107.6154) (xy 129.028714 107.6154) (xy 129.0811 107.48893) - (xy 129.0811 106.87827) (xy 128.84741 106.314093) (xy 128.777117 106.2438) (xy 129.1344 106.2438) (xy 129.722541 106.000184) - (xy 130.172684 105.550041) (xy 130.4163 104.9619) (xy 130.4163 104.3253) (xy 130.374121 104.22347) (xy 134.976452 98.5984) - (xy 141.423541 98.5984) (xy 141.5161 98.616811) (xy 141.608659 98.5984) (xy 141.882791 98.543872) (xy 142.193657 98.336157) - (xy 142.401372 98.025291) (xy 142.413759 97.963018) (xy 148.964858 91.411919) (xy 148.8711 91.63827) (xy 148.8711 92.24893) - (xy 149.10479 92.813107) (xy 149.505283 93.2136) (xy 149.10479 93.614093) (xy 148.8711 94.17827) (xy 148.8711 94.78893) - (xy 149.10479 95.353107) (xy 149.505283 95.7536) (xy 149.10479 96.154093) (xy 148.8711 96.71827) (xy 148.8711 97.32893) - (xy 149.10479 97.893107) (xy 149.536593 98.32491) (xy 150.024045 98.526819) (xy 149.813703 98.613946) (xy 149.456446 98.971203) - (xy 149.2631 99.437981) (xy 149.2631 99.943219) (xy 149.456446 100.409997) (xy 149.813703 100.767254) (xy 150.280481 100.9606) - (xy 150.713277 100.9606) (xy 150.853446 101.298997) (xy 151.210703 101.656254) (xy 151.677481 101.8496) (xy 152.182719 101.8496) - (xy 152.649497 101.656254) (xy 153.006754 101.298997) (xy 153.2001 100.832219) (xy 153.2001 100.494993) (xy 154.764823 98.930271) - (xy 154.834807 98.883509) (xy 155.020066 98.60625) (xy 155.041056 98.500728) (xy 155.18077 98.5586) (xy 155.79143 98.5586) - (xy 156.355607 98.32491) (xy 156.78741 97.893107) (xy 157.0211 97.32893) (xy 157.0211 96.71827) (xy 156.78741 96.154093) - (xy 156.386917 95.7536) (xy 156.78741 95.353107) (xy 157.0211 94.78893) (xy 157.0211 94.17827) (xy 156.78741 93.614093) - (xy 156.386917 93.2136) (xy 156.78741 92.813107) (xy 156.960896 92.394276) (xy 157.5943 93.265208) (xy 157.594301 96.804041) - (xy 157.57589 96.8966) (xy 157.648829 97.263292) (xy 157.804112 97.495689) (xy 157.804115 97.495692) (xy 157.856544 97.574157) - (xy 157.935008 97.626585) (xy 158.566114 98.257692) (xy 158.618543 98.336157) (xy 158.697008 98.388586) (xy 158.69701 98.388588) - (xy 158.838968 98.483441) (xy 158.929409 98.543872) (xy 159.203541 98.5984) (xy 159.203546 98.5984) (xy 159.2961 98.61681) - (xy 159.388654 98.5984) (xy 164.621823 98.5984) (xy 164.916114 98.892692) (xy 164.968543 98.971157) (xy 165.047008 99.023586) - (xy 165.04701 99.023588) (xy 165.188073 99.117843) (xy 165.279409 99.178872) (xy 165.553541 99.2334) (xy 165.553546 99.2334) - (xy 165.60264 99.243165) (xy 165.923075 99.5636) (xy 165.559516 99.927159) (xy 165.3159 100.5153) (xy 165.3159 101.1519) - (xy 165.559516 101.740041) (xy 165.9763 102.156825) (xy 165.9763 102.646042) (xy 165.976301 106.853935) (xy 163.92441 109.4188) - (xy 162.485348 109.4188) (xy 162.31286 109.413546) (xy 162.211124 109.452101) (xy 162.104409 109.473328) (xy 161.96089 109.569224) - (xy 158.659325 111.632703) (xy 158.735392 111.518861) (xy 158.839873 110.9936) (xy 158.735392 110.468339) (xy 158.437856 110.023044) - (xy 157.992561 109.725508) (xy 157.599886 109.6474) (xy 155.912314 109.6474) (xy 155.519639 109.725508) (xy 155.074344 110.023044) - (xy 154.776808 110.468339) (xy 154.672327 110.9936) (xy 154.776808 111.518861) (xy 155.074344 111.964156) (xy 155.519639 112.261692) - (xy 155.912314 112.3398) (xy 157.527971 112.3398) (xy 157.121571 112.5938) (xy 145.994917 112.5938) (xy 145.842248 112.58279) - (xy 145.720379 112.623271) (xy 145.594409 112.648328) (xy 145.544451 112.681709) (xy 145.487435 112.700648) (xy 145.390323 112.784694) - (xy 145.283543 112.856043) (xy 145.1985 112.983318) (xy 141.570105 117.6484) (xy 141.1978 117.6484) (xy 140.609659 117.892016) - (xy 140.159516 118.342159) (xy 139.9159 118.9303) (xy 139.9159 119.5669) (xy 140.159516 120.155041) (xy 140.609659 120.605184) - (xy 141.1978 120.8488) (xy 141.8344 120.8488) (xy 142.422541 120.605184) (xy 142.872684 120.155041) (xy 143.1163 119.5669) - (xy 143.1163 118.9303) (xy 143.059992 118.794362) (xy 146.42074 114.4734) (xy 150.8379 114.4734) (xy 150.837901 116.492821) - (xy 150.717135 116.516843) (xy 150.507091 116.657191) (xy 150.366743 116.867235) (xy 150.31746 117.115) (xy 150.31746 117.8262) - (xy 150.366743 118.073965) (xy 150.507091 118.284009) (xy 150.717135 118.424357) (xy 150.9649 118.47364) (xy 152.3873 118.47364) - (xy 152.635065 118.424357) (xy 152.845109 118.284009) (xy 152.985457 118.073965) (xy 153.03474 117.8262) (xy 153.03474 117.115) - (xy 152.985457 116.867235) (xy 152.845109 116.657191) (xy 152.635065 116.516843) (xy 152.5143 116.492822) (xy 152.5143 114.4734) - (xy 156.5529 114.4734) (xy 156.552901 116.492821) (xy 156.432135 116.516843) (xy 156.222091 116.657191) (xy 156.081743 116.867235) - (xy 156.03246 117.115) (xy 156.03246 117.8262) (xy 156.081743 118.073965) (xy 156.222091 118.284009) (xy 156.432135 118.424357) - (xy 156.6799 118.47364) (xy 158.1023 118.47364) (xy 158.350065 118.424357) (xy 158.560109 118.284009) (xy 158.700457 118.073965) - (xy 158.74974 117.8262) (xy 158.74974 117.62935) (xy 170.5111 117.62935) (xy 170.5111 118.31991) (xy 170.607773 118.553299) - (xy 170.786402 118.731927) (xy 170.995978 118.818736) (xy 170.724455 119.116676) (xy 170.554624 119.52671) (xy 170.675945 119.7566) - (xy 171.8691 119.7566) (xy 171.8691 117.4706) (xy 172.1231 117.4706) (xy 172.1231 119.7566) (xy 174.4091 119.7566) - (xy 174.4091 117.4706) (xy 172.1231 117.4706) (xy 171.8691 117.4706) (xy 170.66985 117.4706) (xy 170.5111 117.62935) - (xy 158.74974 117.62935) (xy 158.74974 117.115) (xy 158.700457 116.867235) (xy 158.560109 116.657191) (xy 158.350065 116.516843) - (xy 158.2293 116.492822) (xy 158.2293 116.36729) (xy 170.5111 116.36729) (xy 170.5111 117.05785) (xy 170.66985 117.2166) - (xy 171.8691 117.2166) (xy 171.8691 116.01735) (xy 172.1231 116.01735) (xy 172.1231 117.2166) (xy 174.4091 117.2166) - (xy 174.4091 116.022781) (xy 174.179208 115.902114) (xy 173.654742 116.148417) (xy 173.47303 116.347808) (xy 173.384427 116.133901) - (xy 173.205798 115.955273) (xy 172.972409 115.8586) (xy 172.28185 115.8586) (xy 172.1231 116.01735) (xy 171.8691 116.01735) - (xy 171.71035 115.8586) (xy 171.019791 115.8586) (xy 170.786402 115.955273) (xy 170.607773 116.133901) (xy 170.5111 116.36729) - (xy 158.2293 116.36729) (xy 158.2293 114.117981) (xy 162.740631 111.2984) (xy 164.335827 111.2984) (xy 164.481916 111.310949) - (xy 164.610484 111.270189) (xy 164.742791 111.243872) (xy 164.787294 111.214136) (xy 164.838311 111.197962) (xy 164.941502 111.111097) - (xy 165.053657 111.036157) (xy 165.082092 110.9936) (xy 169.428732 110.9936) (xy 169.537156 111.538682) (xy 169.84592 112.00078) - (xy 170.308018 112.309544) (xy 170.715512 112.3906) (xy 172.514688 112.3906) (xy 172.922182 112.309544) (xy 173.38428 112.00078) - (xy 173.693044 111.538682) (xy 173.801468 110.9936) (xy 173.693044 110.448518) (xy 173.38428 109.98642) (xy 172.973611 109.71202) - (xy 173.029041 109.695659) (xy 173.45473 109.351626) (xy 173.71636 108.870877) (xy 173.73132 108.79667) (xy 173.60882 108.5806) - (xy 171.7421 108.5806) (xy 171.7421 108.6006) (xy 171.4881 108.6006) (xy 171.4881 108.5806) (xy 169.62138 108.5806) - (xy 169.49888 108.79667) (xy 169.51384 108.870877) (xy 169.77547 109.351626) (xy 170.201159 109.695659) (xy 170.256589 109.71202) - (xy 169.84592 109.98642) (xy 169.537156 110.448518) (xy 169.428732 110.9936) (xy 165.082092 110.9936) (xy 165.135127 110.914229) - (xy 167.559127 107.884229) (xy 167.593657 107.861157) (xy 167.675125 107.739231) (xy 167.707781 107.698412) (xy 167.726431 107.662447) - (xy 167.801372 107.550291) (xy 167.811813 107.497799) (xy 167.836451 107.450288) (xy 167.847995 107.315901) (xy 167.8559 107.276159) - (xy 167.8559 107.223873) (xy 167.868449 107.077784) (xy 167.8559 107.038201) (xy 167.8559 105.9136) (xy 169.428732 105.9136) - (xy 169.537156 106.458682) (xy 169.84592 106.92078) (xy 170.256589 107.19518) (xy 170.201159 107.211541) (xy 169.77547 107.555574) - (xy 169.51384 108.036323) (xy 169.49888 108.11053) (xy 169.62138 108.3266) (xy 171.4881 108.3266) (xy 171.4881 108.3066) - (xy 171.7421 108.3066) (xy 171.7421 108.3266) (xy 173.60882 108.3266) (xy 173.73132 108.11053) (xy 173.71636 108.036323) - (xy 173.45473 107.555574) (xy 173.029041 107.211541) (xy 172.973611 107.19518) (xy 173.38428 106.92078) (xy 173.693044 106.458682) - (xy 173.801468 105.9136) (xy 173.693044 105.368518) (xy 173.38428 104.90642) (xy 172.922182 104.597656) (xy 172.514688 104.5166) - (xy 170.715512 104.5166) (xy 170.308018 104.597656) (xy 169.84592 104.90642) (xy 169.537156 105.368518) (xy 169.428732 105.9136) - (xy 167.8559 105.9136) (xy 167.8559 102.156825) (xy 168.272684 101.740041) (xy 168.5163 101.1519) (xy 168.5163 100.683008) - (xy 168.555547 100.643761) (xy 168.641952 100.900243) (xy 169.215436 101.110058) (xy 169.82556 101.084439) (xy 170.270248 100.900243) - (xy 170.356654 100.643759) (xy 169.4561 99.743205) (xy 169.441958 99.757348) (xy 169.262353 99.577743) (xy 169.276495 99.5636) - (xy 169.262353 99.549458) (xy 169.441958 99.369853) (xy 169.4561 99.383995) (xy 170.356654 98.483441) (xy 170.292699 98.2936) - (xy 170.356654 98.103759) (xy 169.4561 97.203205) (xy 169.441958 97.217348) (xy 169.262353 97.037743) (xy 169.276495 97.0236) - (xy 169.262353 97.009458) (xy 169.441958 96.829853) (xy 169.4561 96.843995) (xy 170.356654 95.943441) (xy 170.292699 95.7536) - (xy 170.356654 95.563759) (xy 169.4561 94.663205) (xy 169.441958 94.677348) (xy 169.262353 94.497743) (xy 169.276495 94.4836) - (xy 168.375941 93.583046) (xy 168.119457 93.669452) (xy 167.909642 94.242936) (xy 167.920213 94.494688) (xy 167.8559 94.430375) - (xy 167.8559 93.023759) (xy 168.555546 93.023759) (xy 168.619501 93.2136) (xy 168.555546 93.403441) (xy 169.4561 94.303995) - (xy 170.356654 93.403441) (xy 170.292699 93.2136) (xy 170.356654 93.023759) (xy 169.4561 92.123205) (xy 168.555546 93.023759) - (xy 167.8559 93.023759) (xy 167.8559 91.702936) (xy 167.909642 91.702936) (xy 167.935261 92.31306) (xy 168.119457 92.757748) - (xy 168.375941 92.844154) (xy 169.276495 91.9436) (xy 168.375941 91.043046) (xy 168.119457 91.129452) (xy 167.909642 91.702936) - (xy 167.8559 91.702936) (xy 167.8559 90.863441) (xy 168.555546 90.863441) (xy 169.4561 91.763995) (xy 170.356654 90.863441) - (xy 170.270248 90.606957) (xy 169.696764 90.397142) (xy 169.08664 90.422761) (xy 168.641952 90.606957) (xy 168.555546 90.863441) - (xy 167.8559 90.863441) (xy 167.8559 88.861153) (xy 167.87431 88.768599) (xy 167.8559 88.676045) (xy 167.8559 88.676041) - (xy 167.801372 88.401909) (xy 167.699175 88.248961) (xy 167.646087 88.169509) (xy 167.646086 88.169508) (xy 167.593657 88.091043) - (xy 167.515192 88.038614) (xy 166.617456 87.140879) (xy 166.615672 87.131909) (xy 166.407957 86.821043) (xy 166.097091 86.613328) - (xy 165.822959 86.5588) (xy 165.738654 86.5588) (xy 165.6461 86.54039) (xy 165.553546 86.5588) (xy 153.597386 86.5588) - (xy 153.426917 86.552875) (xy 153.323111 86.591706) (xy 153.214409 86.613328) (xy 153.072581 86.708095) (xy 151.791615 87.501074) - (xy 151.9301 87.166742) (xy 151.9301 86.560458) (xy 151.698085 86.000323) (xy 151.269377 85.571615) (xy 150.709242 85.3396) - (xy 150.102958 85.3396) (xy 149.542823 85.571615) (xy 149.1361 85.978338) (xy 148.729377 85.571615) (xy 148.169242 85.3396) - (xy 147.562958 85.3396) (xy 147.002823 85.571615) (xy 146.5961 85.978338) (xy 146.189377 85.571615) (xy 145.629242 85.3396) - (xy 145.022958 85.3396) (xy 144.462823 85.571615) (xy 144.0561 85.978338) (xy 143.649377 85.571615) (xy 143.089242 85.3396) - (xy 142.482958 85.3396) (xy 141.922823 85.571615) (xy 141.5161 85.978338) (xy 141.109377 85.571615) (xy 140.549242 85.3396) - (xy 139.942958 85.3396) (xy 139.382823 85.571615) (xy 138.9761 85.978338) (xy 138.569377 85.571615) (xy 138.009242 85.3396) - (xy 137.402958 85.3396) (xy 136.842823 85.571615) (xy 136.4361 85.978338) (xy 136.029377 85.571615) (xy 135.469242 85.3396) - (xy 134.862958 85.3396) (xy 134.302823 85.571615) (xy 133.8961 85.978338) (xy 133.489377 85.571615) (xy 132.929242 85.3396) - (xy 132.322958 85.3396) (xy 131.762823 85.571615) (xy 131.3561 85.978338) (xy 130.949377 85.571615) (xy 130.389242 85.3396) - (xy 129.782958 85.3396) (xy 129.4511 85.47706) (xy 129.4511 85.446034) (xy 128.774389 83.81231) (xy 128.175679 83.2136) - (xy 168.801121 83.2136) - ) - ) - (filled_polygon - (pts - (xy 160.587181 88.569099) (xy 160.3629 89.110562) (xy 160.3629 89.696638) (xy 160.587181 90.238101) (xy 161.001599 90.652519) - (xy 161.052493 90.6736) (xy 161.001599 90.694681) (xy 160.587181 91.109099) (xy 160.3629 91.650562) (xy 160.3629 92.236638) - (xy 160.587181 92.778101) (xy 161.001599 93.192519) (xy 161.052493 93.2136) (xy 161.001599 93.234681) (xy 160.587181 93.649099) - (xy 160.3629 94.190562) (xy 160.3629 94.776638) (xy 160.587181 95.318101) (xy 161.001599 95.732519) (xy 161.543062 95.9568) - (xy 162.129138 95.9568) (xy 162.670601 95.732519) (xy 163.085019 95.318101) (xy 163.106738 95.265667) (xy 163.340687 95.339408) - (xy 164.196495 94.4836) (xy 163.340687 93.627792) (xy 163.106738 93.701533) (xy 163.085019 93.649099) (xy 162.670601 93.234681) - (xy 162.619707 93.2136) (xy 162.670601 93.192519) (xy 163.085019 92.778101) (xy 163.1061 92.727207) (xy 163.127181 92.778101) - (xy 163.541599 93.192519) (xy 163.594033 93.214238) (xy 163.520292 93.448187) (xy 164.3761 94.303995) (xy 165.231908 93.448187) - (xy 165.158167 93.214238) (xy 165.210601 93.192519) (xy 165.625019 92.778101) (xy 165.8493 92.236638) (xy 165.8493 91.650562) - (xy 165.625019 91.109099) (xy 165.210601 90.694681) (xy 165.159707 90.6736) (xy 165.210601 90.652519) (xy 165.625019 90.238101) - (xy 165.8493 89.696638) (xy 165.8493 89.110562) (xy 165.792955 88.974532) (xy 165.976301 89.157879) (xy 165.9763 92.036158) - (xy 165.976301 92.036163) (xy 165.9763 94.430375) (xy 165.853957 94.552718) (xy 165.834489 94.124031) (xy 165.66159 93.706617) - (xy 165.411513 93.627792) (xy 164.555705 94.4836) (xy 164.569848 94.497743) (xy 164.390243 94.677348) (xy 164.3761 94.663205) - (xy 163.520292 95.519013) (xy 163.599117 95.76909) (xy 164.150197 95.968577) (xy 164.735669 95.941989) (xy 165.153083 95.76909) - (xy 165.231907 95.519015) (xy 165.3159 95.603008) (xy 165.3159 96.0719) (xy 165.559516 96.660041) (xy 165.923075 97.0236) - (xy 165.814126 97.132549) (xy 165.741087 97.05951) (xy 165.688657 96.981043) (xy 165.377791 96.773328) (xy 165.103659 96.7188) - (xy 165.103654 96.7188) (xy 165.0111 96.70039) (xy 164.918546 96.7188) (xy 159.685378 96.7188) (xy 159.4739 96.507323) - (xy 159.4739 93.12719) (xy 159.480584 93.109045) (xy 159.4739 92.940964) (xy 159.4739 92.867041) (xy 159.470226 92.84857) - (xy 159.465728 92.735464) (xy 159.434097 92.666937) (xy 159.419372 92.592909) (xy 159.356483 92.498789) (xy 159.348591 92.481692) - (xy 159.305118 92.421917) (xy 159.211657 92.282043) (xy 159.195578 92.271299) (xy 157.273132 89.627938) (xy 157.179657 89.488043) - (xy 157.085536 89.425153) (xy 157.002374 89.348352) (xy 156.93155 89.322262) (xy 156.868791 89.280328) (xy 156.757758 89.258242) - (xy 156.651544 89.219116) (xy 156.483464 89.2258) (xy 152.576496 89.2258) (xy 153.848451 88.4384) (xy 160.71788 88.4384) - ) - ) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X01.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X01.kicad_mod deleted file mode 100644 index 8bd97cd..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X01.kicad_mod +++ /dev/null @@ -1,25 +0,0 @@ -(module 1X01 (layer F.Cu) (tedit 5C812E67) - (descr "PIN HEADER") - (fp_text reference JP29 (at -1.3462 -1.8288) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X09-BIG.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X09-BIG.kicad_mod deleted file mode 100644 index 8b59188..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X09-BIG.kicad_mod +++ /dev/null @@ -1,44 +0,0 @@ -(module 1X09-BIG (layer F.Cu) (tedit 5C812EEB) - (fp_text reference JP2 (at -10.2362 -1.8288 -180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x9 (at -10.16 3.175 -180) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_line (start -11.43 -1.27) (end 11.43 -1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 -1.27) (end 11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 1.27) (end -11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start -11.43 1.27) (end -11.43 -1.27) (layer F.SilkS) (width 0.127)) - (fp_poly (pts (xy 4.826 0.254) (xy 5.334 0.254) (xy 5.334 -0.254) (xy 4.826 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 0.254) (xy 2.794 0.254) (xy 2.794 -0.254) (xy 2.286 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 0.254) (xy -2.286 0.254) (xy -2.286 -0.254) (xy -2.794 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -5.334 0.254) (xy -4.826 0.254) (xy -4.826 -0.254) (xy -5.334 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -7.874 0.254) (xy -7.366 0.254) (xy -7.366 -0.254) (xy -7.874 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -10.414 0.254) (xy -9.906 0.254) (xy -9.906 -0.254) (xy -10.414 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 7.366 0.254) (xy 7.874 0.254) (xy 7.874 -0.254) (xy 7.366 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 9.906 0.254) (xy 10.414 0.254) (xy 10.414 -0.254) (xy 9.906 -0.254)) (layer F.Fab) (width 0)) - (pad 1 thru_hole circle (at -10.16 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -7.62 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -5.08 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -2.54 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 0 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at 2.54 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 5.08 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 7.62 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 9 thru_hole circle (at 10.16 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x09_P2.54mm_Vertical.wrl - (offset (xyz 10 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X12.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X12.kicad_mod deleted file mode 100644 index 8d18b6e..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/1X12.kicad_mod +++ /dev/null @@ -1,135 +0,0 @@ -(module 1X12 (layer F.Cu) (tedit 5C812F6B) - (descr "PIN HEADER") - (fp_text reference JP3 (at -15.3162 -1.8288 -180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x12 (at -15.24 3.175 -180) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_line (start 8.255 -1.27) (end 9.525 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 9.525 -1.27) (end 10.16 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 -0.635) (end 10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 0.635) (end 9.525 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 -0.635) (end 10.795 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.795 -1.27) (end 12.065 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.065 -1.27) (end 12.7 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 -0.635) (end 12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 0.635) (end 12.065 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.065 1.27) (end 10.795 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.795 1.27) (end 10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -0.635) (end 5.715 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.715 -1.27) (end 6.985 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.985 -1.27) (end 7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 -0.635) (end 7.62 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 0.635) (end 6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.985 1.27) (end 5.715 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.715 1.27) (end 5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 8.255 -1.27) (end 7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 0.635) (end 8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 9.525 1.27) (end 8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.905 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.905 -1.27) (end 2.54 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 -0.635) (end 2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 0.635) (end 1.905 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 -0.635) (end 3.175 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.175 -1.27) (end 4.445 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.445 -1.27) (end 5.08 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -0.635) (end 5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 0.635) (end 4.445 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.445 1.27) (end 3.175 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.175 1.27) (end 2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 -0.635) (end -1.905 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.905 -1.27) (end -0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 -0.635) (end 0 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 1.27) (end -1.905 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.905 1.27) (end -2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 0 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.905 1.27) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.985 -1.27) (end -5.715 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.715 -1.27) (end -5.08 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -0.635) (end -5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 0.635) (end -5.715 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -0.635) (end -4.445 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.445 -1.27) (end -3.175 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.175 -1.27) (end -2.54 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 -0.635) (end -2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 0.635) (end -3.175 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.175 1.27) (end -4.445 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.445 1.27) (end -5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 -0.635) (end -9.525 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -9.525 -1.27) (end -8.255 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -8.255 -1.27) (end -7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -0.635) (end -7.62 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 0.635) (end -8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -8.255 1.27) (end -9.525 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -9.525 1.27) (end -10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.985 -1.27) (end -7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 0.635) (end -6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.715 1.27) (end -6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -14.605 -1.27) (end -13.335 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -13.335 -1.27) (end -12.7 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 -0.635) (end -12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 0.635) (end -13.335 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 -0.635) (end -12.065 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.065 -1.27) (end -10.795 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.795 -1.27) (end -10.16 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 -0.635) (end -10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 0.635) (end -10.795 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.795 1.27) (end -12.065 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.065 1.27) (end -12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -15.24 -0.635) (end -15.24 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -14.605 -1.27) (end -15.24 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -15.24 0.635) (end -14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -13.335 1.27) (end -14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 -0.635) (end 13.335 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 13.335 -1.27) (end 14.605 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 14.605 -1.27) (end 15.24 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 15.24 -0.635) (end 15.24 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 15.24 0.635) (end 14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 14.605 1.27) (end 13.335 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 13.335 1.27) (end 12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_poly (pts (xy 11.176 0.254) (xy 11.684 0.254) (xy 11.684 -0.254) (xy 11.176 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 8.636 0.254) (xy 9.144 0.254) (xy 9.144 -0.254) (xy 8.636 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 6.096 0.254) (xy 6.604 0.254) (xy 6.604 -0.254) (xy 6.096 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.556 0.254) (xy 4.064 0.254) (xy 4.064 -0.254) (xy 3.556 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.016 0.254) (xy 1.524 0.254) (xy 1.524 -0.254) (xy 1.016 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.524 0.254) (xy -1.016 0.254) (xy -1.016 -0.254) (xy -1.524 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -4.064 0.254) (xy -3.556 0.254) (xy -3.556 -0.254) (xy -4.064 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.604 0.254) (xy -6.096 0.254) (xy -6.096 -0.254) (xy -6.604 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -9.144 0.254) (xy -8.636 0.254) (xy -8.636 -0.254) (xy -9.144 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -11.684 0.254) (xy -11.176 0.254) (xy -11.176 -0.254) (xy -11.684 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -14.224 0.254) (xy -13.716 0.254) (xy -13.716 -0.254) (xy -14.224 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 13.716 0.254) (xy 14.224 0.254) (xy 14.224 -0.254) (xy 13.716 -0.254)) (layer F.Fab) (width 0)) - (pad 1 thru_hole circle (at -13.97 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -11.43 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -8.89 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -6.35 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at -3.81 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at -1.27 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 1.27 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 3.81 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 9 thru_hole circle (at 6.35 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 10 thru_hole circle (at 8.89 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 11 thru_hole circle (at 11.43 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 12 thru_hole circle (at 13.97 0 90) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x12_P2.54mm_Vertical.wrl - (offset (xyz 14 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/C0805H.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/C0805H.kicad_mod deleted file mode 100644 index 299039b..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/C0805H.kicad_mod +++ /dev/null @@ -1,22 +0,0 @@ -(module C0805H (layer F.Cu) (tedit 5C812CAA) - (descr LYT) - (fp_text reference C6 (at -0.889 -1.016 -270) (layer F.SilkS) - (effects (font (size 0.9652 0.9652) (thickness 0.077216)) (justify right top)) - ) - (fp_text value 22uF (at -0.889 2.286 -270) (layer F.Fab) - (effects (font (size 0.9652 0.9652) (thickness 0.077216)) (justify right top)) - ) - (fp_line (start -0.381 -0.66) (end 0.381 -0.66) (layer F.Fab) (width 0.1016)) - (fp_line (start -0.356 0.66) (end 0.381 0.66) (layer F.Fab) (width 0.1016)) - (fp_poly (pts (xy -1.0922 0.7239) (xy -0.3421 0.7239) (xy -0.3421 -0.7262) (xy -1.0922 -0.7262)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.3556 0.7239) (xy 1.1057 0.7239) (xy 1.1057 -0.7262) (xy 0.3556 -0.7262)) (layer F.Fab) (width 0)) - (pad P$1 smd rect (at -1.143 0 90) (size 1.4224 0.7112) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad P$2 smd rect (at 1.143 0 90) (size 1.4224 0.7112) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/CHIPLED_1206.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/CHIPLED_1206.kicad_mod deleted file mode 100644 index 77e8b4e..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/CHIPLED_1206.kicad_mod +++ /dev/null @@ -1,33 +0,0 @@ -(module CHIPLED_1206 (layer F.Cu) (tedit 5C81335F) - (descr "CHIPLED

\nSource: http://www.osram.convergy.de/ ... LG_LY N971.pdf") - (fp_text reference LED1_SMD (at -1.27 1.27 90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_text value LED_RED/PC4/20 (at 2.54 1.27 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_arc (start 0 -1.625799) (end -0.4 -1.6) (angle -172.619069) (layer F.Fab) (width 0.1016)) - (fp_line (start -0.8 0.95) (end -0.8 -0.95) (layer F.Fab) (width 0.1016)) - (fp_line (start 0.8 -0.95) (end 0.8 0.95) (layer F.Fab) (width 0.1016)) - (fp_circle (center -0.55 -1.425) (end -0.45 -1.425) (layer F.Fab) (width 0.1016)) - (fp_poly (pts (xy -0.85 -1.525) (xy -0.35 -1.525) (xy -0.35 -1.65) (xy -0.85 -1.65)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -1.225) (xy -0.625 -1.225) (xy -0.625 -1.55) (xy -0.85 -1.55)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.45 -1.225) (xy -0.325 -1.225) (xy -0.325 -1.45) (xy -0.45 -1.45)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.65 -1.225) (xy -0.225 -1.225) (xy -0.225 -1.35) (xy -0.65 -1.35)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.35 -1.3) (xy 0.85 -1.3) (xy 0.85 -1.65) (xy 0.35 -1.65)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.25 -1.225) (xy 0.85 -1.225) (xy 0.85 -1.35) (xy 0.25 -1.35)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -0.95) (xy 0.85 -0.95) (xy 0.85 -1.25) (xy -0.85 -1.25)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 1.65) (xy 0.85 1.65) (xy 0.85 0.95) (xy -0.85 0.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -0.35) (xy -0.525 -0.35) (xy -0.525 -0.775) (xy -0.85 -0.775)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy 0.525 -0.35) (xy 0.85 -0.35) (xy 0.85 -0.775) (xy 0.525 -0.775)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -0.175 0) (xy 0.175 0) (xy 0.175 -0.35) (xy -0.175 -0.35)) (layer F.SilkS) (width 0)) - (pad C smd rect (at 0 -1.75) (size 1.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad A smd rect (at 0 1.75) (size 1.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/LED_SMD.3dshapes/LED_1206_3216Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/DO214AA.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/DO214AA.kicad_mod deleted file mode 100644 index 973dcdc..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/DO214AA.kicad_mod +++ /dev/null @@ -1,28 +0,0 @@ -(module DO214AA (layer F.Cu) (tedit 5C8134A6) - (descr DIODE) - (fp_text reference D4 (at -2.64 -1.436 -270) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value SM4007 (at -2.64 2.706 -180) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_line (start -2.4 -1.1) (end 2.4 -1.1) (layer F.Fab) (width 0.254)) - (fp_line (start 2.4 -1.1) (end 2.4 1.1) (layer F.Fab) (width 0.254)) - (fp_line (start 2.4 1.1) (end -2.4 1.1) (layer F.Fab) (width 0.254)) - (fp_line (start -2.4 1.1) (end -2.4 -1.1) (layer F.Fab) (width 0.254)) - (fp_line (start -1.2 0) (end 0.05 -0.7) (layer F.SilkS) (width 0.254)) - (fp_line (start 0.05 -0.7) (end 0.05 0.7) (layer F.SilkS) (width 0.254)) - (fp_line (start 0.05 0.7) (end -1.2 0) (layer F.SilkS) (width 0.254)) - (fp_poly (pts (xy -2.75 0.7) (xy -2.5 0.7) (xy -2.5 -0.65) (xy -2.75 -0.65)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.5 0.7) (xy 2.75 0.7) (xy 2.75 -0.65) (xy 2.5 -0.65)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.4 1.05) (xy -1.1 1.05) (xy -1.1 -1.05) (xy -1.4 -1.05)) (layer F.SilkS) (width 0)) - (pad C smd rect (at -2.55 0) (size 1.8 2.2) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad A smd rect (at 2.55 0) (size 1.8 2.2) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_MELF.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/D_7343-31R.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/D_7343-31R.kicad_mod deleted file mode 100644 index 0b19c28..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/D_7343-31R.kicad_mod +++ /dev/null @@ -1,25 +0,0 @@ -(module D_7343-31R (layer F.Cu) (tedit 5C81340A) - (descr "Chip Capacitor Type KEMET D / EIA 7343-21

\nKEMET V / EIA 7343-20, KEMET X / EIA 7343-43 Reflow solder") - (fp_text reference C12 (at -3.65 -2.3 -90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_text value 100uF (at -3.65 3.575) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_line (start -3.45 -2.1) (end 3.45 -2.1) (layer F.Fab) (width 0.1016)) - (fp_line (start 3.45 -2.1) (end 3.45 2.1) (layer F.Fab) (width 0.1016)) - (fp_line (start 3.45 2.1) (end -3.45 2.1) (layer F.Fab) (width 0.1016)) - (fp_line (start -3.45 2.1) (end -3.45 -2.1) (layer F.Fab) (width 0.1016)) - (fp_poly (pts (xy -3.65 1.2) (xy -3.5 1.2) (xy -3.5 -1.2) (xy -3.65 -1.2)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.5 1.2) (xy 3.65 1.2) (xy 3.65 -1.2) (xy 3.5 -1.2)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.675 2.125) (xy 3.15 2.125) (xy 3.15 -2.125) (xy 2.675 -2.125)) (layer F.Fab) (width 0)) - (pad + smd rect (at 3.175 0) (size 2.55 2.7) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad - smd rect (at -3.175 0) (size 2.55 2.7) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_Tantalum_SMD.3dshapes/CP_EIA-7343-31_Kemet-D.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/L3216C.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/L3216C.kicad_mod deleted file mode 100644 index 35341f7..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/L3216C.kicad_mod +++ /dev/null @@ -1,29 +0,0 @@ -(module L3216C (layer F.Cu) (tedit 5C8132C2) - (descr "INDUCTOR

\nchip") - (fp_text reference L2 (at -1.524 -1.143 -180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_text value 10uH (at -1.524 2.413 -180) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_line (start -2.473 -1.483) (end 2.473 -1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 2.473 1.483) (end -2.473 1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -2.473 1.483) (end -2.473 -1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.27 -0.896) (end 1.27 -0.896) (layer F.Fab) (width 0.1016)) - (fp_line (start -1.27 0.883) (end 1.27 0.883) (layer F.Fab) (width 0.1016)) - (fp_line (start 2.473 -1.483) (end 2.473 1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -0.762 -0.896) (end 0.762 -0.896) (layer F.SilkS) (width 0.1016)) - (fp_line (start -0.762 0.883) (end 0.762 0.883) (layer F.SilkS) (width 0.1016)) - (fp_poly (pts (xy -1.7526 0.9525) (xy -1.2525 0.9525) (xy -1.2525 -0.9474) (xy -1.7526 -0.9474)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.2446 0.9525) (xy 1.7447 0.9525) (xy 1.7447 -0.9474) (xy 1.2446 -0.9474)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.4001 0.5999) (xy 0.4001 0.5999) (xy 0.4001 -0.5999) (xy -0.4001 -0.5999)) (layer F.Adhes) (width 0)) - (pad 1 smd rect (at -1.5 0) (size 1.2 1.6) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 2 smd rect (at 1.5 0) (size 1.2 1.6) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Inductor_SMD.3dshapes/L_1206_3216Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/LED3MM.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/LED3MM.kicad_mod deleted file mode 100644 index 0e9bed3..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/LED3MM.kicad_mod +++ /dev/null @@ -1,32 +0,0 @@ -(module LED3MM (layer F.Cu) (tedit 0) - (descr "LED

\n3 mm, round") - (fp_text reference LED1 (at 1.905 -0.381 -90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value LED_RED/PC4/20 (at 1.905 1.651 -90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_line (start 1.5748 1.27) (end 1.5748 -1.27) (layer F.Fab) (width 0.254)) - (fp_arc (start 0 0.000004) (end -1.524 0) (angle 39.80361) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000063) (end -1.524 0) (angle -41.633208) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000014) (end 1.1571 -0.9918) (angle 40.601165) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 -0.000004) (end 1.1708 0.9756) (angle -39.80361) (layer F.Fab) (width 0.1524)) - (fp_arc (start -0.000034 0) (end 0 -1.524) (angle 54.461337) (layer F.SilkS) (width 0.1524)) - (fp_arc (start 0 0) (end -1.2192 -0.9144) (angle 53.130102) (layer F.SilkS) (width 0.1524)) - (fp_arc (start -0.000008 0) (end 0 1.524) (angle -52.126876) (layer F.SilkS) (width 0.1524)) - (fp_arc (start 0.000008 0) (end -1.203 0.9356) (angle -52.126876) (layer F.SilkS) (width 0.1524)) - (fp_arc (start 0 0) (end -0.635 0) (angle 90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end -1.016 0) (angle 90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end 0 0.635) (angle -90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end 0 1.016) (angle -90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0.000012 0) (end 0 -2.032) (angle 50.193108) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.00006 0) (end -1.7929 -0.9562) (angle 61.926949) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.000037 0) (end 0 2.032) (angle -49.763022) (layer F.SilkS) (width 0.254)) - (fp_arc (start -0.000056 0) (end -1.7643 1.0082) (angle -60.255215) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0 0.000002) (end -2.032 0) (angle 28.301701) (layer F.Fab) (width 0.254)) - (fp_arc (start 0 0.000083) (end -2.032 0) (angle -31.60822) (layer F.Fab) (width 0.254)) - (pad A thru_hole circle (at -1.27 0) (size 1.6764 1.6764) (drill 0.8128) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad K thru_hole circle (at 1.27 0) (size 1.6764 1.6764) (drill 0.8128) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/ML6.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/ML6.kicad_mod deleted file mode 100644 index 7f542b2..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/ML6.kicad_mod +++ /dev/null @@ -1,80 +0,0 @@ -(module ML6 (layer F.Cu) (tedit 5C81304A) - (descr HARTING) - (fp_text reference SV1 (at -7.62 -5.08 -270) (layer F.SilkS) - (effects (font (size 1.6891 1.6891) (thickness 0.16891)) (justify left bottom)) - ) - (fp_text value ISP_6PIN (at 0.635 -5.08 -270) (layer F.Fab) - (effects (font (size 1.6891 1.6891) (thickness 0.16891)) (justify left bottom)) - ) - (fp_line (start -6.35 -3.175) (end 6.35 -3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 3.175) (end 6.35 -3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -3.175) (end -6.35 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -4.445) (end -6.35 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 4.445) (end 7.62 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -4.445) (end -7.62 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 2.413) (end 2.032 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 2.413) (end -2.032 2.413) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -2.032 2.413) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -6.35 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -2.032 3.429) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.445) (end 6.35 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.699) (end 5.08 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -4.445) (end 5.08 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.445) (end 7.62 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.699) (end -0.635 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.699) (end 0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.445) (end 5.08 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -4.699) (end -0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.699) (end -6.35 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -4.699) (end -6.35 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.699) (end -5.08 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.445) (end -0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 4.445) (end 2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 4.445) (end -2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 3.175) (end 2.032 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 3.175) (end 2.032 3.429) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 3.429) (end 2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 3.429) (end 6.604 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 6.604 3.429) (end 6.604 -3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 6.604 -3.429) (end -6.604 -3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start -6.604 -3.429) (end -6.604 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start -6.604 3.429) (end -2.032 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start -2.032 3.429) (end -2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 4.445) (end -2.54 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 4.318) (end -2.54 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 4.318) (end -3.81 4.318) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.81 4.445) (end -3.81 4.318) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.81 4.445) (end -7.62 4.445) (layer F.SilkS) (width 0.1524)) - (fp_text user 1 (at -5.08 1.905) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 2 (at -5.08 -0.635) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 6 (at -0.381 4.064) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 -1.016) (xy 0.254 -1.016) (xy 0.254 -1.524) (xy -0.254 -1.524)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 -1.016) (xy -2.286 -1.016) (xy -2.286 -1.524) (xy -2.794 -1.524)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 -1.016) (xy 2.794 -1.016) (xy 2.794 -1.524) (xy 2.286 -1.524)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 1.524) (xy 0.254 1.524) (xy 0.254 1.016) (xy -0.254 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 1.524) (xy -2.286 1.524) (xy -2.286 1.016) (xy -2.794 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 1.524) (xy 2.794 1.524) (xy 2.794 1.016) (xy 2.286 1.016)) (layer F.Fab) (width 0)) - (pad 1 thru_hole circle (at -2.54 1.27) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -2.54 -1.27) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at 0 1.27) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at 0 -1.27) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 2.54 1.27) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at 2.54 -1.27) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_IDC.3dshapes/IDC-Header_2x03_P2.54mm_Vertical.wrl - (offset (xyz -2.5 -1.5 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 -90)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/QS.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/QS.kicad_mod deleted file mode 100644 index 56a58a0..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/QS.kicad_mod +++ /dev/null @@ -1,26 +0,0 @@ -(module QS (layer F.Cu) (tedit 5C812DA8) - (descr CRYSTAL) - (fp_text reference Q1 (at -5.08 -2.667) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value 16Mhz (at -5.08 3.937) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_line (start -3.429 2.286) (end 3.429 2.286) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.429 -2.286) (end -3.429 -2.286) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.429 1.778) (end 3.429 1.778) (layer F.SilkS) (width 0.0508)) - (fp_line (start 3.429 -1.778) (end -3.429 -1.778) (layer F.SilkS) (width 0.0508)) - (fp_arc (start 3.429 0) (end 3.429 -1.778) (angle 180) (layer F.SilkS) (width 0.0508)) - (fp_arc (start 3.429 0) (end 3.429 -2.286) (angle 180) (layer F.SilkS) (width 0.1524)) - (fp_arc (start -3.429 0) (end -3.429 -2.286) (angle -180) (layer F.SilkS) (width 0.1524)) - (fp_arc (start -3.429 0) (end -3.429 -1.778) (angle -180) (layer F.SilkS) (width 0.0508)) - (pad 1 thru_hole oval (at -2.54 0 90) (size 2.8448 1.4224) (drill 0.7) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 2 thru_hole oval (at 2.54 0 90) (size 2.8448 1.4224) (drill 0.7) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Crystal.3dshapes/Crystal_HC49-4H_Vertical.step - (offset (xyz -2.5 0 0)) - (scale (xyz 1 1 0.8)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/R0805.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/R0805.kicad_mod deleted file mode 100644 index 7ea06ea..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/R0805.kicad_mod +++ /dev/null @@ -1,27 +0,0 @@ -(module R0805 (layer F.Cu) (tedit 5C812202) - (descr "RESISTOR

\nchip") - (fp_text reference R8 (at -0.762 -1.016) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_text value 1Kom (at -0.762 2.286) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -1.973 -0.983) (end 1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 -0.983) (end 1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 0.983) (end -1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.973 0.983) (end -1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.1999 0.5001) (xy 0.1999 0.5001) (xy 0.1999 -0.5001) (xy -0.1999 -0.5001)) (layer F.Adhes) (width 0)) - (pad 1 smd rect (at -0.85 0) (size 1.3 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 2 smd rect (at 0.85 0) (size 1.3 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/R0805H.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/R0805H.kicad_mod deleted file mode 100644 index 2899158..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/R0805H.kicad_mod +++ /dev/null @@ -1,22 +0,0 @@ -(module R0805H (layer F.Cu) (tedit 5C812498) - (descr LYT) - (fp_text reference R10 (at -0.762 -1.016) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_text value 2Kom (at -0.762 2.286) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (pad P$1 smd rect (at -1.143 0 90) (size 1.4224 0.7112) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad P$2 smd rect (at 1.143 0 90) (size 1.4224 0.7112) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/SMBJ.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/SMBJ.kicad_mod deleted file mode 100644 index 425612b..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/SMBJ.kicad_mod +++ /dev/null @@ -1,24 +0,0 @@ -(module SMBJ (layer F.Cu) (tedit 5C813504) - (descr "DO-214AA Modified J_BEND

\nSource: www.rsonline.de .. SMBJ12/C/15/C/24/C/30/C/5.0/C/7.5/C Voltage Suppressor. Data Sheet") - (fp_text reference D3 (at -1.905 -2.54) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_text value SM6T15CA (at -1.905 3.81) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_line (start 2.24 -1.92) (end 2.24 1.92) (layer F.Fab) (width 0.1016)) - (fp_line (start 2.24 1.92) (end -2.24 1.92) (layer F.SilkS) (width 0.1016)) - (fp_line (start -2.24 1.92) (end -2.24 -1.92) (layer F.Fab) (width 0.1016)) - (fp_line (start -2.24 -1.92) (end 2.24 -1.92) (layer F.SilkS) (width 0.1016)) - (fp_poly (pts (xy -2.8 1.1) (xy -2.25 1.1) (xy -2.25 -1.1) (xy -2.8 -1.1)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.25 1.1) (xy 2.8 1.1) (xy 2.8 -1.1) (xy 2.25 -1.1)) (layer F.Fab) (width 0)) - (pad C smd rect (at -2.03 0) (size 1.78 2.16) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad A smd rect (at 2.04 0 180) (size 1.78 2.16) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_SMB.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/SW_TACT_SMALL.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/SW_TACT_SMALL.kicad_mod deleted file mode 100644 index 98f5be0..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/SW_TACT_SMALL.kicad_mod +++ /dev/null @@ -1,67 +0,0 @@ -(module SW_TACT_SMALL (layer F.Cu) (tedit 5C813223) - (fp_text reference SW1/PC5 (at -3.04 -2.9825 -180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value SMD_TACT_4x4 (at 0 0) (layer F.SilkS) hide - (effects (font (size 1.27 1.27) (thickness 0.15)) (justify right top)) - ) - (fp_line (start -1.2183 -2.182) (end -1.1335 -2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.182) (end 1.2183 -2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.2183 -2.182) (end 2.182 -1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 1.2183) (end 1.2183 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.2183 2.182) (end -2.182 1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 -1.2183) (end -1.2183 -2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.182) (end -1.1335 -2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.5) (end 1.1335 -2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 -2.5) (end 1.1335 -2.181) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.2183 2.182) (end 1.1335 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.182) (end -1.2183 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.182) (end 1.1335 2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.5) (end -1.1335 2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 2.5) (end -1.1335 2.181) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.2183) (end -2.182 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.1335) (end -2.182 -1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.1335) (end -2.5 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.5 1.1335) (end -2.5 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.5 -1.1335) (end -2.181 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.2183) (end 2.182 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.1335) (end 2.182 1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.1335) (end 2.5 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.5 -1.1335) (end 2.5 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.5 1.1335) (end 2.181 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.065 -1.812) (end 1.065 -1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.065 -1.812) (end 1.812 -1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.812 1.065) (end -1.812 -1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.812 -1.065) (end -1.065 -1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.065 1.812) (end -1.065 1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.065 1.812) (end -1.812 1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.812 -1.065) (end 1.812 1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.812 1.065) (end 1.065 1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start -0.9958 -1.645) (end 0.9958 -1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start 0.9958 -1.645) (end 1.645 -0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.645 0.9958) (end -1.645 -0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.645 -0.9958) (end -0.9958 -1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start 0.9958 1.645) (end -0.9958 1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start -0.9958 1.645) (end -1.645 0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.645 -0.9958) (end 1.645 0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.645 0.9958) (end 0.9958 1.645) (layer F.SilkS) (width 0.0762)) - (fp_circle (center 0 0) (end 1 0) (layer F.SilkS) (width 0.0762)) - (fp_circle (center 0 0) (end 0.865 0) (layer F.SilkS) (width 0.0762)) - (fp_poly (pts (xy 1.3003 -2.1) (xy 3.3 -2.1) (xy 3.3 -1.6) (xy 1.8003 -1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.3003 2.1) (xy -3.3 2.1) (xy -3.3 1.6) (xy -1.8003 1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.3003 -2.1) (xy -3.3 -2.1) (xy -3.3 -1.6) (xy -1.8003 -1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.3003 2.1) (xy 3.3 2.1) (xy 3.3 1.6) (xy 1.8003 1.6)) (layer F.Fab) (width 0)) - (pad 1 smd rect (at -3.15 -1.9 90) (size 1 1.7) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 2 smd rect (at 3.15 -1.9 90) (size 1 1.7) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 3 smd rect (at -3.15 1.9 90) (size 1 1.7) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 4 smd rect (at 3.15 1.9 90) (size 1 1.7) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Button_Switch_SMD.3dshapes/SW_SPST_TL3342.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/TO220V.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/TO220V.kicad_mod deleted file mode 100644 index 2fb259c..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/TO220V.kicad_mod +++ /dev/null @@ -1,43 +0,0 @@ -(module TO220V (layer F.Cu) (tedit 5C81312D) - (descr "TO 200 vertical") - (fp_text reference IC2 (at -5.08 6.0452) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value 7805TV (at -5.08 7.62) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_line (start 5.08 1.143) (end 4.953 4.064) (layer F.SilkS) (width 0.127)) - (fp_line (start 4.699 4.318) (end 4.953 4.064) (layer F.SilkS) (width 0.127)) - (fp_line (start 4.699 4.318) (end -4.699 4.318) (layer F.SilkS) (width 0.127)) - (fp_line (start -4.953 4.064) (end -4.699 4.318) (layer F.SilkS) (width 0.127)) - (fp_line (start -4.953 4.064) (end -5.08 1.143) (layer F.SilkS) (width 0.127)) - (fp_circle (center -4.4958 3.7084) (end -4.2418 3.7084) (layer F.SilkS) (width 0.127)) - (fp_text user 1 (at -3.175 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 2 (at -0.635 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 3 (at 1.905 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_poly (pts (xy -5.334 0.762) (xy 5.334 0.762) (xy 5.334 0) (xy -5.334 0)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -5.334 1.27) (xy -3.429 1.27) (xy -3.429 0.762) (xy -5.334 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -1.651 1.27) (xy -0.889 1.27) (xy -0.889 0.762) (xy -1.651 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -3.429 1.27) (xy -1.651 1.27) (xy -1.651 0.762) (xy -3.429 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.889 1.27) (xy 1.651 1.27) (xy 1.651 0.762) (xy 0.889 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy 3.429 1.27) (xy 5.334 1.27) (xy 5.334 0.762) (xy 3.429 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -0.889 1.27) (xy 0.889 1.27) (xy 0.889 0.762) (xy -0.889 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.651 1.27) (xy 3.429 1.27) (xy 3.429 0.762) (xy 1.651 0.762)) (layer F.Fab) (width 0)) - (pad 1 thru_hole oval (at -2.54 2.54 90) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 2 thru_hole oval (at 0 2.54 90) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 3 thru_hole oval (at 2.54 2.54 90) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Package_TO_SOT_THT.3dshapes/TO-220-3_Horizontal_TabDown.wrl - (offset (xyz -2.5 -2.5 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/TQFP44.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/TQFP44.kicad_mod deleted file mode 100644 index 613189f..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/TQFP44.kicad_mod +++ /dev/null @@ -1,155 +0,0 @@ -(module TQFP44 (layer F.Cu) (tedit 5C812513) - (descr "Thin Plasic Quad Flat Package") - (fp_text reference IC1 (at -3.81 -6.985 -180) (layer F.SilkS) - (effects (font (size 1.6891 1.6891) (thickness 0.135128)) (justify left bottom)) - ) - (fp_text value ATMEGA16/32/644/1284 (at -4.445 8.7551 -180) (layer F.Fab) - (effects (font (size 1.35128 1.35128) (thickness 0.108102)) (justify left bottom)) - ) - (fp_line (start -4.8 -4.4) (end -4.4 -4.8) (layer F.SilkS) (width 0.2032)) - (fp_line (start -4.4 -4.8) (end 4.4 -4.8) (layer F.SilkS) (width 0.2032)) - (fp_line (start 4.4 -4.8) (end 4.8 -4.4) (layer F.SilkS) (width 0.2032)) - (fp_line (start 4.8 -4.4) (end 4.8 4.4) (layer F.SilkS) (width 0.2032)) - (fp_line (start 4.8 4.4) (end 4.4 4.8) (layer F.SilkS) (width 0.2032)) - (fp_line (start 4.4 4.8) (end -4.4 4.8) (layer F.SilkS) (width 0.2032)) - (fp_line (start -4.4 4.8) (end -4.8 4.4) (layer F.SilkS) (width 0.2032)) - (fp_line (start -4.8 4.4) (end -4.8 -4.4) (layer F.SilkS) (width 0.2032)) - (fp_circle (center -4 -4) (end -3.7173 -4) (layer F.SilkS) (width 0.254)) - (fp_poly (pts (xy -6.1001 -3.8001) (xy -4.95 -3.8001) (xy -4.95 -4.1999) (xy -6.1001 -4.1999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -3) (xy -4.95 -3) (xy -4.95 -3.4) (xy -6.1001 -3.4)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -2.1999) (xy -4.95 -2.1999) (xy -4.95 -2.5999) (xy -6.1001 -2.5999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -1.4) (xy -4.95 -1.4) (xy -4.95 -1.8001) (xy -6.1001 -1.8001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -0.5999) (xy -4.95 -0.5999) (xy -4.95 -1) (xy -6.1001 -1)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 0.1999) (xy -4.95 0.1999) (xy -4.95 -0.1999) (xy -6.1001 -0.1999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 1) (xy -4.95 1) (xy -4.95 0.5999) (xy -6.1001 0.5999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 1.8001) (xy -4.95 1.8001) (xy -4.95 1.4) (xy -6.1001 1.4)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 2.5999) (xy -4.95 2.5999) (xy -4.95 2.1999) (xy -6.1001 2.1999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 3.4) (xy -4.95 3.4) (xy -4.95 3) (xy -6.1001 3)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 4.1999) (xy -4.95 4.1999) (xy -4.95 3.8001) (xy -6.1001 3.8001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -4.1999 6.1001) (xy -3.8001 6.1001) (xy -3.8001 4.95) (xy -4.1999 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -3.4 6.1001) (xy -3 6.1001) (xy -3 4.95) (xy -3.4 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.5999 6.1001) (xy -2.1999 6.1001) (xy -2.1999 4.95) (xy -2.5999 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.8001 6.1001) (xy -1.4 6.1001) (xy -1.4 4.95) (xy -1.8001 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1 6.1001) (xy -0.5999 6.1001) (xy -0.5999 4.95) (xy -1 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.1999 6.1001) (xy 0.1999 6.1001) (xy 0.1999 4.95) (xy -0.1999 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.5999 6.1001) (xy 1 6.1001) (xy 1 4.95) (xy 0.5999 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.4 6.1001) (xy 1.8001 6.1001) (xy 1.8001 4.95) (xy 1.4 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.1999 6.1001) (xy 2.5999 6.1001) (xy 2.5999 4.95) (xy 2.1999 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3 6.1001) (xy 3.4 6.1001) (xy 3.4 4.95) (xy 3 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.8001 6.1001) (xy 4.1999 6.1001) (xy 4.1999 4.95) (xy 3.8001 4.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 4.1999) (xy 6.1001 4.1999) (xy 6.1001 3.8001) (xy 4.95 3.8001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 3.4) (xy 6.1001 3.4) (xy 6.1001 3) (xy 4.95 3)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 2.5999) (xy 6.1001 2.5999) (xy 6.1001 2.1999) (xy 4.95 2.1999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 1.8001) (xy 6.1001 1.8001) (xy 6.1001 1.4) (xy 4.95 1.4)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 1) (xy 6.1001 1) (xy 6.1001 0.5999) (xy 4.95 0.5999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 0.1999) (xy 6.1001 0.1999) (xy 6.1001 -0.1999) (xy 4.95 -0.1999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -0.5999) (xy 6.1001 -0.5999) (xy 6.1001 -1) (xy 4.95 -1)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -1.4) (xy 6.1001 -1.4) (xy 6.1001 -1.8001) (xy 4.95 -1.8001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -2.1999) (xy 6.1001 -2.1999) (xy 6.1001 -2.5999) (xy 4.95 -2.5999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -3) (xy 6.1001 -3) (xy 6.1001 -3.4) (xy 4.95 -3.4)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -3.8001) (xy 6.1001 -3.8001) (xy 6.1001 -4.1999) (xy 4.95 -4.1999)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.8001 -4.95) (xy 4.1999 -4.95) (xy 4.1999 -6.1001) (xy 3.8001 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3 -4.95) (xy 3.4 -4.95) (xy 3.4 -6.1001) (xy 3 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.1999 -4.95) (xy 2.5999 -4.95) (xy 2.5999 -6.1001) (xy 2.1999 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.4 -4.95) (xy 1.8001 -4.95) (xy 1.8001 -6.1001) (xy 1.4 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.5999 -4.95) (xy 1 -4.95) (xy 1 -6.1001) (xy 0.5999 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.1999 -4.95) (xy 0.1999 -4.95) (xy 0.1999 -6.1001) (xy -0.1999 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1 -4.95) (xy -0.5999 -4.95) (xy -0.5999 -6.1001) (xy -1 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.8001 -4.95) (xy -1.4 -4.95) (xy -1.4 -6.1001) (xy -1.8001 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.5999 -4.95) (xy -2.1999 -4.95) (xy -2.1999 -6.1001) (xy -2.5999 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -3.4 -4.95) (xy -3 -4.95) (xy -3 -6.1001) (xy -3.4 -6.1001)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -4.1999 -4.95) (xy -3.8001 -4.95) (xy -3.8001 -6.1001) (xy -4.1999 -6.1001)) (layer F.Fab) (width 0)) - (pad 1 smd rect (at -5.8 -4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 2 smd rect (at -5.8 -3.2) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 3 smd rect (at -5.8 -2.4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 4 smd rect (at -5.8 -1.6) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 5 smd rect (at -5.8 -0.8) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 6 smd rect (at -5.8 0) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 7 smd rect (at -5.8 0.8) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 8 smd rect (at -5.8 1.6) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 9 smd rect (at -5.8 2.4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 10 smd rect (at -5.8 3.2) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 11 smd rect (at -5.8 4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 12 smd rect (at -4 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 13 smd rect (at -3.2 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 14 smd rect (at -2.4 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 15 smd rect (at -1.6 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 16 smd rect (at -0.8 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 17 smd rect (at 0 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 18 smd rect (at 0.8 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 19 smd rect (at 1.6 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 20 smd rect (at 2.4 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 21 smd rect (at 3.2 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 22 smd rect (at 4 5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 23 smd rect (at 5.8 4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 24 smd rect (at 5.8 3.2) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 25 smd rect (at 5.8 2.4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 26 smd rect (at 5.8 1.6) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 27 smd rect (at 5.8 0.8) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 28 smd rect (at 5.8 0) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 29 smd rect (at 5.8 -0.8) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 30 smd rect (at 5.8 -1.6) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 31 smd rect (at 5.8 -2.4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 32 smd rect (at 5.8 -3.2) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 33 smd rect (at 5.8 -4) (size 1.5 0.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 34 smd rect (at 4 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 35 smd rect (at 3.2 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 36 smd rect (at 2.4 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 37 smd rect (at 1.6 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 38 smd rect (at 0.8 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 39 smd rect (at 0 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 40 smd rect (at -0.8 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 41 smd rect (at -1.6 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 42 smd rect (at -2.4 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 43 smd rect (at -3.2 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (pad 44 smd rect (at -4 -5.8) (size 0.5 1.5) (layers F.Cu F.Paste F.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Package_QFP.3dshapes/TQFP-44_10x10mm_P0.8mm.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/W237-102.kicad_mod b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/W237-102.kicad_mod deleted file mode 100644 index 5aaa795..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pretty/W237-102.kicad_mod +++ /dev/null @@ -1,44 +0,0 @@ -(module W237-102 (layer F.Cu) (tedit 5C812C06) - (descr "WAGO SCREW CLAMP") - (fp_text reference X2 (at -3.8462 5.0038 -180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value DG300-5.0-02P-12 (at -5.04 7.62 -180) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_line (start -3.491 2.286) (end -1.484 0.279) (layer F.Fab) (width 0.254)) - (fp_line (start 1.488 2.261) (end 3.469 0.254) (layer F.Fab) (width 0.254)) - (fp_line (start -4.989 5.461) (end 4.993 5.461) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 -3.734) (end 4.993 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 -3.734) (end -4.989 -3.734) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 5.461) (end -4.989 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 3.073) (end -3.389 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.389 3.073) (end -1.611 3.073) (layer F.Fab) (width 0.1524)) - (fp_line (start -1.611 3.073) (end 1.615 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.393 3.073) (end 4.993 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 3.073) (end -4.989 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 3.073) (end 4.993 5.461) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 -3.531) (end 4.993 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 -3.531) (end -4.989 -3.734) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 -3.531) (end 4.993 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.615 3.073) (end 3.393 3.073) (layer F.Fab) (width 0.1524)) - (fp_circle (center -2.5 1.27) (end -1.0014 1.27) (layer F.Fab) (width 0.1524)) - (fp_circle (center -2.5 -2.2098) (end -1.992 -2.2098) (layer F.SilkS) (width 0.1524)) - (fp_circle (center 2.5038 1.27) (end 4.0024 1.27) (layer F.Fab) (width 0.1524)) - (fp_circle (center 2.5038 -2.2098) (end 3.0118 -2.2098) (layer F.SilkS) (width 0.1524)) - (fp_text user 1 (at -4.532 -0.635) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 2 (at 0.421 -0.635) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (pad 1 thru_hole oval (at -2.5 1.27 90) (size 3.5814 1.7907) (drill 1.1938) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (pad 2 thru_hole oval (at 2.5 1.27 90) (size 3.5814 1.7907) (drill 1.1938) (layers *.Cu *.Mask) - (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_Phoenix_MC_HighVoltage.3dshapes/PhoenixContact_MCV_1,5_2-G-5.08_1x02_P5.08mm_Vertical.step - (offset (xyz -2.55 -1.25 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pro b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pro deleted file mode 100644 index 518ede2..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.pro +++ /dev/null @@ -1,43 +0,0 @@ -update=07/03/2019 17:16:44 -version=1 -last_client=kicad -[general] -version=1 -RootSch= -BoardNm= -[pcbnew] -version=1 -LastNetListRead= -UseCmpFile=1 -PadDrill=0.600000000000 -PadDrillOvalY=0.600000000000 -PadSizeH=1.500000000000 -PadSizeV=1.500000000000 -PcbTextSizeV=1.500000000000 -PcbTextSizeH=1.500000000000 -PcbTextThickness=0.300000000000 -ModuleTextSizeV=1.000000000000 -ModuleTextSizeH=1.000000000000 -ModuleTextSizeThickness=0.150000000000 -SolderMaskClearance=0.000000000000 -SolderMaskMinWidth=0.000000000000 -DrawSegmentWidth=0.200000000000 -BoardOutlineThickness=0.100000000000 -ModuleOutlineThickness=0.150000000000 -[cvpcb] -version=1 -NetIExt=net -[eeschema] -version=1 -LibDir= -[eeschema/libraries] -[schematic_editor] -version=1 -PageLayoutDescrFile=empty.kicad_wks -PlotDirectoryName= -SubpartIdSeparator=0 -SubpartFirstId=65 -NetFmtName= -SpiceAjustPassiveValues=0 -LabSize=50 -ERC_TestSimilarLabels=1 diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.sch b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.sch deleted file mode 100644 index 228cd98..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d.sch +++ /dev/null @@ -1,1775 +0,0 @@ -EESchema Schematic File Version 4 -LIBS:M644_breakout_v1.2d-cache -EELAYER 26 0 -EELAYER END -$Descr A4 11693 8268 -encoding utf-8 -Sheet 1 1 -Title "" -Date "" -Rev "" -Comp "" -Comment1 "" -Comment2 "" -Comment3 "" -Comment4 "" -$EndDescr -Wire Wire Line - 4400 3300 4300 3300 -Text Label 4400 3300 0 10 ~ 0 -GND -Wire Wire Line - 7150 1500 6850 1500 -Text Label 7150 1500 0 10 ~ 0 -GND -Wire Wire Line - 3250 2000 2850 2000 -Wire Wire Line - 5050 1900 5050 2000 -Wire Wire Line - 4500 2000 3750 2000 -Wire Wire Line - 3750 2000 3250 2000 -Wire Wire Line - 3750 2100 3750 2000 -Wire Wire Line - 3250 1900 3250 2000 -Wire Wire Line - 3750 1700 3750 2000 -Wire Wire Line - 2850 1900 2850 2000 -Wire Wire Line - 4500 1900 4500 2000 -Wire Wire Line - 2250 1850 2250 2000 -Wire Wire Line - 5050 2000 5550 2000 -Wire Wire Line - 5550 2000 5550 1900 -Connection ~ 3750 2000 -Connection ~ 3250 2000 -Connection ~ 2850 2000 -Connection ~ 4500 2000 -Connection ~ 5050 2000 -Text Label 3250 2000 0 10 ~ 0 -GND -Wire Wire Line - 3150 2600 2850 2600 -Wire Wire Line - 2850 2600 2850 2900 -Wire Wire Line - 3250 3100 2850 3100 -Wire Wire Line - 2850 2900 2850 3100 -Wire Wire Line - 2850 2900 2750 2900 -Connection ~ 2850 2900 -Text Label 3150 2600 0 10 ~ 0 -GND -Wire Wire Line - 4800 4300 4950 4300 -Wire Wire Line - 4800 3500 4950 3500 -Wire Wire Line - 4950 4100 4800 4100 -Wire Wire Line - 4800 4100 4800 4200 -Wire Wire Line - 4800 4200 4800 4300 -Wire Wire Line - 4950 4200 4800 4200 -Wire Wire Line - 4800 4400 4800 4300 -Wire Wire Line - 4800 4300 4350 4300 -Wire Wire Line - 4350 4300 3850 4300 -Wire Wire Line - 3850 4300 3850 4150 -Wire Wire Line - 3850 4300 3350 4300 -Wire Wire Line - 3350 4300 3350 4150 -Connection ~ 4800 4100 -Connection ~ 4800 4200 -Connection ~ 4800 4300 -Connection ~ 4350 4300 -Connection ~ 3850 4300 -Text Label 4800 4300 0 10 ~ 0 -GND -Wire Wire Line - 8550 4600 8500 4600 -Text Label 8550 4600 0 10 ~ 0 -GND -Wire Wire Line - 3500 3300 3600 3300 -Text Label 3500 3300 0 10 ~ 0 -GND -Text Label 7500 2550 0 10 ~ 0 -GND -Wire Wire Line - 9550 5400 9450 5400 -Wire Wire Line - 9450 5400 9350 5400 -Wire Wire Line - 9350 5500 9450 5500 -Wire Wire Line - 9450 5500 9450 5400 -Connection ~ 9450 5400 -Text Label 9550 5400 0 10 ~ 0 -GND -Wire Wire Line - 8700 5200 8650 5200 -Text Label 8700 5200 0 10 ~ 0 -GND -Text Label 8700 5700 0 10 ~ 0 -GND -Wire Wire Line - 4650 5050 4650 4850 -Wire Wire Line - 4400 5050 4650 5050 -Wire Wire Line - 4400 4850 4650 4850 -Wire Wire Line - 4400 5450 4650 5450 -Wire Wire Line - 4650 5450 4650 5250 -Connection ~ 4650 5050 -Wire Wire Line - 8550 4950 8500 4950 -Text Label 8550 4950 0 10 ~ 0 -GND -Wire Wire Line - 3850 2900 3650 2900 -Wire Wire Line - 3650 2900 3650 3100 -Wire Wire Line - 3650 3100 4950 3100 -Wire Wire Line - 3650 3100 3550 3100 -Connection ~ 3650 3100 -Wire Wire Line - 4950 2900 4350 2900 -Wire Wire Line - 4350 2900 4250 2900 -Wire Wire Line - 4350 2600 4350 2900 -Connection ~ 4350 2900 -Wire Wire Line - 7100 1600 7150 1600 -Wire Wire Line - 9150 3000 8800 3000 -Wire Wire Line - 8800 3000 8550 3000 -Wire Wire Line - 9150 3400 8800 3400 -Wire Wire Line - 8800 3400 8800 3200 -Wire Wire Line - 8800 3200 8800 3000 -Wire Wire Line - 9150 3200 8800 3200 -Connection ~ 8800 3000 -Wire Wire Line - 7750 1700 7850 1700 -Wire Wire Line - 9150 2250 8850 2250 -Wire Wire Line - 8850 2250 8550 2250 -Wire Wire Line - 9150 2650 8850 2650 -Wire Wire Line - 8850 2650 8850 2450 -Wire Wire Line - 8850 2450 8850 2250 -Wire Wire Line - 9150 2450 8850 2450 -Connection ~ 8850 2250 -Connection ~ 8850 2450 -Wire Wire Line - 7750 1500 7850 1500 -Wire Wire Line - 4950 2600 4850 2600 -Wire Wire Line - 4850 2600 4700 2600 -Wire Wire Line - 4850 2600 4850 2400 -Wire Wire Line - 4850 2400 4650 2400 -Connection ~ 4850 2600 -Wire Wire Line - 7750 1600 7850 1600 -Wire Wire Line - 9150 1500 8850 1500 -Wire Wire Line - 8850 1500 8550 1500 -Wire Wire Line - 9150 1900 8850 1900 -Wire Wire Line - 8850 1900 8850 1700 -Wire Wire Line - 8850 1700 8850 1500 -Wire Wire Line - 9150 1700 8850 1700 -Connection ~ 8850 1500 -Connection ~ 8850 1700 -Wire Wire Line - 2250 1400 2400 1400 -Wire Wire Line - 2250 1650 2250 1400 -Wire Wire Line - 7800 2650 7550 2650 -Wire Wire Line - 4950 3400 4450 3400 -Wire Wire Line - 4450 3400 4450 3500 -Wire Wire Line - 4450 3500 4050 3500 -Wire Wire Line - 4050 3500 3950 3500 -Wire Wire Line - 3900 3300 4050 3300 -Wire Wire Line - 4050 3300 4050 3500 -Connection ~ 4050 3500 -Wire Wire Line - 6950 4200 6550 4200 -Text Label 6750 4200 0 70 ~ 0 -PB0 -Wire Wire Line - 7800 3800 7150 3800 -Text Label 7150 3800 0 70 ~ 0 -PB0 -Wire Wire Line - 6950 4100 6550 4100 -Text Label 6750 4100 0 70 ~ 0 -PB1 -Text Label 7150 3900 0 70 ~ 0 -PB1 -Wire Wire Line - 6950 4000 6550 4000 -Text Label 6750 4000 0 70 ~ 0 -PB2 -Wire Wire Line - 7800 4000 7150 4000 -Text Label 7150 4000 0 70 ~ 0 -PB2 -Wire Wire Line - 6950 3900 6550 3900 -Text Label 6750 3900 0 70 ~ 0 -PB3 -Wire Wire Line - 7800 4100 7150 4100 -Text Label 7150 4100 0 70 ~ 0 -PB3 -Wire Wire Line - 6950 3800 6550 3800 -Text Label 6800 3800 0 47 ~ 0 -PB4 -Wire Wire Line - 7800 4200 7150 4200 -Text Label 7150 4200 0 70 ~ 0 -PB4 -Wire Wire Line - 6950 3300 6550 3300 -Text Label 6750 3300 0 70 ~ 0 -PA0 -Wire Wire Line - 7800 3700 7150 3700 -Text Label 7150 3700 0 70 ~ 0 -PA0 -Wire Wire Line - 6950 3200 6550 3200 -Text Label 6750 3200 0 70 ~ 0 -PA1 -Wire Wire Line - 7800 3600 7150 3600 -Text Label 7150 3600 0 70 ~ 0 -PA1 -Wire Wire Line - 6950 3100 6550 3100 -Text Label 6750 3100 0 70 ~ 0 -PA2 -Wire Wire Line - 7800 3500 7150 3500 -Text Label 7150 3500 0 70 ~ 0 -PA2 -Wire Wire Line - 6950 3000 6550 3000 -Text Label 6750 3000 0 70 ~ 0 -PA3 -Wire Wire Line - 7800 3400 7150 3400 -Text Label 7150 3400 0 70 ~ 0 -PA3 -Wire Wire Line - 6550 2700 6950 2700 -Text Label 6750 2700 0 70 ~ 0 -PA6 -Wire Wire Line - 7800 3050 7150 3050 -Text Label 7150 3150 0 70 ~ 0 -PA6 -Wire Wire Line - 6550 2900 6950 2900 -Text Label 6750 2900 0 70 ~ 0 -PA4 -Wire Wire Line - 7800 2950 7150 2950 -Text Label 7150 3050 0 70 ~ 0 -PA4 -Wire Wire Line - 6550 4600 6950 4600 -Text Label 6750 4600 0 70 ~ 0 -PC5 -Wire Wire Line - 7150 6100 8150 6100 -Wire Wire Line - 8150 6100 8150 5900 -Wire Wire Line - 8150 5900 8150 5400 -Wire Wire Line - 8150 5400 8350 5400 -Wire Wire Line - 8350 6100 8150 6100 -Wire Wire Line - 9550 5900 8150 5900 -Connection ~ 8150 6100 -Connection ~ 8150 5900 -Text Label 7150 6100 0 70 ~ 0 -PC5 -Text Label 9150 5900 0 70 ~ 0 -PC5 -Wire Wire Line - 6550 4700 6950 4700 -Text Label 6750 4700 0 70 ~ 0 -PC4 -Wire Wire Line - 7150 4600 7450 4600 -Wire Wire Line - 7450 4600 7600 4600 -Wire Wire Line - 8450 4000 8050 4000 -Wire Wire Line - 8050 4000 8050 4400 -Wire Wire Line - 8050 4400 7450 4400 -Wire Wire Line - 7450 4400 7450 4600 -Connection ~ 7450 4600 -Text Label 7150 4600 0 70 ~ 0 -PC4 -Text Label 7150 4600 0 70 ~ 0 -PC4 -Text Label 7500 2750 0 10 ~ 0 -VCC -Wire Wire Line - 4250 2400 4050 2400 -Text Label 4250 2400 0 10 ~ 0 -VCC -Wire Wire Line - 4950 3900 4550 3900 -Wire Wire Line - 4950 3800 4550 3800 -Wire Wire Line - 4950 3700 4550 3700 -Wire Wire Line - 4550 3800 4550 3700 -Wire Wire Line - 4550 3900 4550 3800 -Wire Wire Line - 4550 3700 4350 3700 -Wire Wire Line - 4350 3700 3850 3700 -Wire Wire Line - 3850 3700 3350 3700 -Wire Wire Line - 3350 3700 3350 3850 -Wire Wire Line - 3850 3850 3850 3700 -Wire Wire Line - 4350 3850 4350 3700 -Wire Wire Line - 3350 3700 2950 3700 -Wire Wire Line - 3550 3500 3350 3500 -Wire Wire Line - 3350 3500 3350 3700 -Connection ~ 4550 3700 -Connection ~ 4550 3800 -Connection ~ 3850 3700 -Connection ~ 4350 3700 -Connection ~ 3350 3700 -Text Label 4950 3900 0 10 ~ 0 -VCC -Wire Wire Line - 7150 1700 6850 1700 -Text Label 7150 1700 0 10 ~ 0 -VCC -Wire Wire Line - 5050 1600 5050 1400 -Wire Wire Line - 6050 1400 5550 1400 -Wire Wire Line - 5550 1400 5050 1400 -Wire Wire Line - 4500 1600 4500 1400 -Wire Wire Line - 5550 1600 5550 1400 -Connection ~ 5050 1400 -Connection ~ 4500 1400 -Connection ~ 5550 1400 -Text Label 5050 1600 0 10 ~ 0 -VCC -Wire Wire Line - 6650 6600 6650 6500 -Wire Wire Line - 6850 6500 6650 6500 -Connection ~ 6650 6500 -Text Label 6650 6600 0 10 ~ 0 -VCC -Wire Wire Line - 8950 6100 8750 6100 -Text Label 8950 6100 0 10 ~ 0 -VCC -Wire Wire Line - 3800 4850 3550 4850 -Wire Wire Line - 3550 5450 3800 5450 -Wire Wire Line - 3800 5250 3800 5050 -Wire Wire Line - 3800 5050 3800 4850 -Wire Wire Line - 3550 5050 3800 5050 -Connection ~ 3800 5250 -Connection ~ 3800 5050 -Text Label 3800 4850 2 10 ~ 0 -VCC -Wire Wire Line - 6550 4800 6950 4800 -Text Label 6750 4800 0 70 ~ 0 -PC3 -Wire Wire Line - 7900 4800 7150 4800 -Text Label 7150 4800 0 70 ~ 0 -PC3 -Wire Wire Line - 6550 4900 6950 4900 -Text Label 6750 4900 0 70 ~ 0 -PC2 -Wire Wire Line - 7900 4900 7150 4900 -Text Label 7150 4900 0 70 ~ 0 -PC2 -Wire Wire Line - 6550 5000 6950 5000 -Text Label 6750 5000 0 70 ~ 0 -PC1 -Wire Wire Line - 7150 5000 7900 5000 -Text Label 7150 5000 0 70 ~ 0 -PC1 -Wire Wire Line - 6550 5100 6950 5100 -Text Label 6750 5100 0 70 ~ 0 -PC0 -Wire Wire Line - 7150 5100 7900 5100 -Text Label 7150 5100 0 70 ~ 0 -PC0 -Wire Wire Line - 6550 5300 6950 5300 -Text Label 6750 5300 0 70 ~ 0 -PD7 -Wire Wire Line - 7150 5200 7900 5200 -Text Label 7150 5200 0 70 ~ 0 -PD7 -Wire Wire Line - 6550 6000 6650 6000 -Wire Wire Line - 6650 6000 6950 6000 -Wire Wire Line - 6650 6100 6650 6000 -Connection ~ 6650 6000 -Text Label 6750 6000 0 70 ~ 0 -PD0 -Wire Wire Line - 7150 5900 7900 5900 -Text Label 7150 5900 0 70 ~ 0 -PD0 -Wire Wire Line - 6550 5900 6950 5900 -Text Label 6750 5900 0 70 ~ 0 -PD1 -Wire Wire Line - 7150 5800 7250 5800 -Text Label 7150 5800 0 70 ~ 0 -PD1 -Wire Wire Line - 6550 5800 6850 5800 -Wire Wire Line - 6850 5800 6950 5800 -Wire Wire Line - 6850 6100 6850 5800 -Connection ~ 6850 5800 -Text Label 6750 5800 0 70 ~ 0 -PD2 -Wire Wire Line - 7150 5700 7900 5700 -Text Label 7150 5700 0 70 ~ 0 -PD2 -Wire Wire Line - 2650 4900 2950 4900 -Wire Wire Line - 6550 5700 6950 5700 -Text Label 6750 5700 0 70 ~ 0 -PD3 -Wire Wire Line - 7150 5600 7250 5600 -Text Label 7150 5600 0 70 ~ 0 -PD3 -Wire Wire Line - 6550 5600 6950 5600 -Text Label 6750 5600 0 70 ~ 0 -PD4 -Wire Wire Line - 7150 5500 7900 5500 -Text Label 7150 5500 0 70 ~ 0 -PD4 -Wire Wire Line - 2650 5400 2950 5400 -Wire Wire Line - 6550 5500 6950 5500 -Text Label 6750 5500 0 70 ~ 0 -PD5 -Wire Wire Line - 7150 5400 7900 5400 -Text Label 7150 5400 0 70 ~ 0 -PD5 -Wire Wire Line - 6550 5400 6950 5400 -Text Label 6750 5400 0 70 ~ 0 -PD6 -Wire Wire Line - 7150 5300 7900 5300 -Text Label 7150 5300 0 70 ~ 0 -PD6 -Wire Wire Line - 8200 4600 8050 4600 -Wire Wire Line - 8050 4600 8000 4600 -Wire Wire Line - 8200 4950 8150 4950 -Wire Wire Line - 8150 4950 8150 4700 -Wire Wire Line - 8150 4700 8050 4600 -Connection ~ 8050 4600 -Wire Wire Line - 6950 2800 6550 2800 -Text Label 6750 2800 0 70 ~ 0 -PA5 -Wire Wire Line - 7800 2850 7150 2850 -Text Label 7150 2950 0 70 ~ 0 -PA5 -Wire Wire Line - 2650 850 2650 1100 -Wire Wire Line - 2850 850 2850 1100 -Wire Wire Line - 2850 1100 2650 1100 -Wire Wire Line - 3350 1400 3250 1400 -Wire Wire Line - 3250 1400 2850 1400 -Wire Wire Line - 3250 1600 3250 1400 -Wire Wire Line - 2850 1600 2850 1400 -Connection ~ 2850 1100 -Connection ~ 3250 1400 -Connection ~ 2850 1400 -Wire Wire Line - 8950 5400 8850 5400 -Wire Wire Line - 8850 5400 8750 5400 -Wire Wire Line - 8950 5500 8850 5500 -Wire Wire Line - 8850 5500 8850 5400 -Connection ~ 8850 5400 -Wire Wire Line - 6550 2600 6950 2600 -Text Label 6750 2600 0 70 ~ 0 -PA7 -Wire Wire Line - 7150 2450 7800 2450 -Text Label 7150 2450 0 70 ~ 0 -PA7 -Wire Wire Line - 6550 4400 6950 4400 -Text Label 6750 4400 0 70 ~ 0 -PC7 -Wire Wire Line - 7150 2350 7800 2350 -Text Label 7150 2350 0 70 ~ 0 -PC7 -Wire Wire Line - 6550 4500 6950 4500 -Text Label 6750 4500 0 70 ~ 0 -PC6 -Wire Wire Line - 7800 2250 7150 2250 -Text Label 7150 2250 0 70 ~ 0 -PC6 -Wire Wire Line - 7650 5600 7800 5600 -Wire Wire Line - 7800 5600 7900 5600 -Wire Wire Line - 8250 5200 8100 5200 -Wire Wire Line - 8100 5200 8100 5550 -Wire Wire Line - 8100 5550 7800 5550 -Wire Wire Line - 7800 5550 7800 5600 -Connection ~ 7800 5600 -Text Label 8100 5200 0 47 ~ 0 -PD3' -Wire Wire Line - 2650 5150 2950 5150 -Wire Wire Line - 7650 5800 7800 5800 -Wire Wire Line - 7800 5800 7900 5800 -Wire Wire Line - 8300 5700 8100 5700 -Wire Wire Line - 8100 5700 8050 5750 -Wire Wire Line - 8050 5750 7800 5750 -Wire Wire Line - 7800 5750 7800 5800 -Connection ~ 7800 5800 -Text Label 8200 5700 0 47 ~ 0 -PD1' -Entry Wire Line - 6950 4200 7050 4100 -Entry Wire Line - 7050 3700 7150 3800 -Entry Wire Line - 6950 4100 7050 4000 -Entry Wire Line - 7050 3800 7150 3900 -Entry Wire Line - 6950 4000 7050 3900 -Entry Wire Line - 7050 3900 7150 4000 -Entry Wire Line - 6950 3900 7050 3800 -Entry Wire Line - 7050 4000 7150 4100 -Entry Wire Line - 6950 3800 7050 3700 -Entry Wire Line - 7050 4100 7150 4200 -Entry Wire Line - 6950 3300 7050 3200 -Entry Wire Line - 7050 3600 7150 3700 -Entry Wire Line - 6950 3200 7050 3100 -Entry Wire Line - 7050 3500 7150 3600 -Entry Wire Line - 6950 3100 7050 3000 -Entry Wire Line - 7050 3400 7150 3500 -Entry Wire Line - 6950 3000 7050 2900 -Entry Wire Line - 7050 3300 7150 3400 -Entry Wire Line - 6950 2700 7050 2800 -Entry Wire Line - 7050 2950 7150 3050 -Entry Wire Line - 6950 2900 7050 3000 -Entry Wire Line - 7050 2850 7150 2950 -Entry Wire Line - 6950 4600 7050 4700 -Entry Wire Line - 6950 4700 7050 4800 -Entry Wire Line - 7050 4500 7150 4600 -Entry Wire Line - 6950 4800 7050 4900 -Entry Wire Line - 7050 4700 7150 4800 -Entry Wire Line - 6950 4900 7050 5000 -Entry Wire Line - 7050 4800 7150 4900 -Entry Wire Line - 6950 5000 7050 5100 -Entry Wire Line - 7050 4900 7150 5000 -Entry Wire Line - 6950 5100 7050 5200 -Entry Wire Line - 7050 5000 7150 5100 -Entry Wire Line - 6950 5300 7050 5400 -Entry Wire Line - 7050 5100 7150 5200 -Entry Wire Line - 6950 6000 7050 5900 -Entry Wire Line - 7050 5800 7150 5900 -Entry Wire Line - 6950 5900 7050 6000 -Entry Wire Line - 7050 5700 7150 5800 -Entry Wire Line - 6950 5800 7050 5900 -Entry Wire Line - 7050 5600 7150 5700 -Entry Wire Line - 6950 5700 7050 5800 -Entry Wire Line - 7050 5500 7150 5600 -Entry Wire Line - 6950 5600 7050 5700 -Entry Wire Line - 7050 5400 7150 5500 -Entry Wire Line - 6950 5500 7050 5600 -Entry Wire Line - 7050 5300 7150 5400 -Entry Wire Line - 6950 5400 7050 5500 -Entry Wire Line - 7050 5200 7150 5300 -Entry Wire Line - 6950 2800 7050 2700 -Entry Wire Line - 7050 2750 7150 2850 -Entry Wire Line - 6950 2600 7050 2700 -Entry Wire Line - 7050 2350 7150 2450 -Entry Wire Line - 6950 4400 7050 4500 -Entry Wire Line - 7050 2250 7150 2350 -Entry Wire Line - 6950 4500 7050 4600 -Entry Wire Line - 7050 2150 7150 2250 -Entry Wire Line - 7050 6000 7150 6100 -$Comp -L M644_breakout_v1.2d-eagle-import:AT908535A IC1 -U 1 0 0232E636 -P 5750 4200 -F 0 "IC1" H 5150 5930 59 0000 L BNN -F 1 "ATMEGA16/32/644/1284" H 5150 2200 59 0000 L BNN -F 2 "M644_breakout_v1.2d:TQFP44" H 5750 4200 50 0001 C CNN -F 3 "" H 5750 4200 50 0001 C CNN - 1 5750 4200 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND04 -U 1 0 12C122FD -P 3750 2200 -F 0 "#GND04" H 3750 2200 50 0001 C CNN -F 1 "GND" H 3650 2100 59 0000 L BNN -F 2 "" H 3750 2200 50 0001 C CNN -F 3 "" H 3750 2200 50 0001 C CNN - 1 3750 2200 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+05 -U 1 0 57F4DC09 -P 6150 1400 -F 0 "#P+05" H 6150 1400 50 0001 C CNN -F 1 "VCC" V 6050 1300 59 0000 L BNN -F 2 "" H 6150 1400 50 0001 C CNN -F 3 "" H 6150 1400 50 0001 C CNN - 1 6150 1400 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+01 -U 1 0 6A081B6E -P 2850 3700 -F 0 "#P+01" H 2850 3700 50 0001 C CNN -F 1 "VCC" V 2750 3600 59 0000 L BNN -F 2 "" H 2850 3700 50 0001 C CNN -F 3 "" H 2850 3700 50 0001 C CNN - 1 2850 3700 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND01 -U 1 0 8DA2BB24 -P 4800 4500 -F 0 "#GND01" H 4800 4500 50 0001 C CNN -F 1 "GND" H 4700 4400 59 0000 L BNN -F 2 "" H 4800 4500 50 0001 C CNN -F 3 "" H 4800 4500 50 0001 C CNN - 1 4800 4500 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:XTAL_S Q1 -U 1 0 098A5C63 -P 4050 2900 -F 0 "Q1" H 3850 3050 59 0000 L BNN -F 1 "16Mhz" H 3850 2700 59 0000 L BNN -F 2 "M644_breakout_v1.2d:QS" H 4050 2900 50 0001 C CNN -F 3 "" H 4050 2900 50 0001 C CNN - 1 4050 2900 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C2 -U 1 0 B2C130AB -P 3450 3100 -F 0 "C2" H 3210 3115 59 0000 L BNN -F 1 "18pf" H 3210 2915 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 3450 3100 50 0001 C CNN -F 3 "" H 3450 3100 50 0001 C CNN - 1 3450 3100 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C1 -U 1 0 D645821B -P 3350 2600 -F 0 "C1" H 3410 2615 59 0000 L BNN -F 1 "18pf" H 3410 2415 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 3350 2600 50 0001 C CNN -F 3 "" H 3350 2600 50 0001 C CNN - 1 3350 2600 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND02 -U 1 0 4877C9E2 -P 2650 2900 -F 0 "#GND02" H 2650 2900 50 0001 C CNN -F 1 "GND" H 2550 2800 59 0000 L BNN -F 2 "" H 2650 2900 50 0001 C CNN -F 3 "" H 2650 2900 50 0001 C CNN - 1 2650 2900 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C7 -U 1 0 A401EF9C -P 5050 1700 -F 0 "C7" H 5110 1715 59 0000 L BNN -F 1 "0.1mF" H 5110 1515 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 5050 1700 50 0001 C CNN -F 3 "" H 5050 1700 50 0001 C CNN - 1 5050 1700 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R2 -U 1 0 120B1331 -P 4450 2400 -F 0 "R2" H 4300 2459 59 0000 L BNN -F 1 "4.7KOm" H 4300 2270 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 4450 2400 50 0001 C CNN -F 3 "" H 4450 2400 50 0001 C CNN - 1 4450 2400 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+03 -U 1 0 48C2C5DB -P 3950 2400 -F 0 "#P+03" H 3950 2400 50 0001 C CNN -F 1 "VCC" V 3850 2300 59 0000 L BNN -F 2 "" H 3950 2400 50 0001 C CNN -F 3 "" H 3950 2400 50 0001 C CNN - 1 3950 2400 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C3 -U 1 0 ED3BBF87 -P 4500 3300 -F 0 "C3" H 4560 3315 59 0000 L BNN -F 1 "0.1mF" H 4560 3115 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 4500 3300 50 0001 C CNN -F 3 "" H 4500 3300 50 0001 C CNN - 1 4500 3300 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND015 -U 1 0 7499CEA7 -P 4200 3300 -F 0 "#GND015" H 4200 3300 50 0001 C CNN -F 1 "GND" H 4100 3200 59 0000 L BNN -F 2 "" H 4200 3300 50 0001 C CNN -F 3 "" H 4200 3300 50 0001 C CNN - 1 4200 3300 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:ML6 SV1 -U 1 0 03BB57A4 -P 7450 1600 -F 0 "SV1" H 7300 1830 59 0000 L BNN -F 1 "ISP_6PIN" H 7300 1300 59 0000 L BNN -F 2 "M644_breakout_v1.2d:ML6" H 7450 1600 50 0001 C CNN -F 3 "" H 7450 1600 50 0001 C CNN - 1 7450 1600 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+02 -U 1 0 637B3A6A -P 6750 1700 -F 0 "#P+02" H 6750 1700 50 0001 C CNN -F 1 "VCC" V 6700 1700 59 0000 L BNN -F 2 "" H 6750 1700 50 0001 C CNN -F 3 "" H 6750 1700 50 0001 C CNN - 1 6750 1700 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND03 -U 1 0 21137572 -P 6750 1500 -F 0 "#GND03" H 6750 1500 50 0001 C CNN -F 1 "GND" H 6550 1400 59 0000 L BNN -F 2 "" H 6750 1500 50 0001 C CNN -F 3 "" H 6750 1500 50 0001 C CNN - 1 6750 1500 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:78TV IC2 -U 1 0 BC34DC86 -P 3750 1400 -F 0 "IC2" H 3450 1625 59 0000 L BNN -F 1 "KIA7805A" H 3450 1525 59 0000 L BNN -F 2 "M644_breakout_v1.2d:TO220V" H 3750 1400 50 0001 C CNN -F 3 "" H 3750 1400 50 0001 C CNN - 1 3750 1400 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C5 -U 1 0 4EACBEDA -P 3250 1700 -F 0 "C5" H 3310 1715 59 0000 L BNN -F 1 "0.1mF" H 3310 1515 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 3250 1700 50 0001 C CNN -F 3 "" H 3250 1700 50 0001 C CNN - 1 3250 1700 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND07 -U 1 0 C2693486 -P 8650 4600 -F 0 "#GND07" H 8650 4600 50 0001 C CNN -F 1 "GND" H 8550 4500 59 0000 L BNN -F 2 "" H 8650 4600 50 0001 C CNN -F 3 "" H 8650 4600 50 0001 C CNN - 1 8650 4600 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:LED3MM LED1 -U 1 0 F50B0571 -P 8300 4600 -F 0 "LED1" V 8390 4620 59 0001 L BNN -F 1 "LED_RED/PC4/20" V 8500 3900 59 0000 L BNN -F 2 "M644_breakout_v1.2d:LED3MM" H 8300 4600 50 0001 C CNN -F 3 "" H 8300 4600 50 0001 C CNN - 1 8300 4600 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C8 -U 1 0 C2BBB70B -P 4350 4050 -F 0 "C8" H 4410 4065 59 0000 L BNN -F 1 "0.1mF" H 4410 3865 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 4350 4050 50 0001 C CNN -F 3 "" H 4350 4050 50 0001 C CNN - 1 4350 4050 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C9 -U 1 0 90B5D1B4 -P 3850 4050 -F 0 "C9" H 3910 4065 59 0000 L BNN -F 1 "0.1mF" H 3910 3865 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 3850 4050 50 0001 C CNN -F 3 "" H 3850 4050 50 0001 C CNN - 1 3850 4050 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C10 -U 1 0 0BB7FF73 -P 3350 4050 -F 0 "C10" H 3410 4065 59 0000 L BNN -F 1 "0.1mF" H 3410 3865 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 3350 4050 50 0001 C CNN -F 3 "" H 3350 4050 50 0001 C CNN - 1 3350 4050 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:L-EUL3216C L2 -U 1 0 EA05AC24 -P 3750 3500 -F 0 "L2" V 3691 3350 59 0000 L BNN -F 1 "10uH" V 3880 3350 59 0000 L BNN -F 2 "M644_breakout_v1.2d:L3216C" H 3750 3500 50 0001 C CNN -F 3 "" H 3750 3500 50 0001 C CNN - 1 3750 3500 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C11 -U 1 0 31DB2A51 -P 3800 3300 -F 0 "C11" V 3735 3310 59 0000 L BNN -F 1 "0.1mF" V 3735 3010 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 3800 3300 50 0001 C CNN -F 3 "" H 3800 3300 50 0001 C CNN - 1 3800 3300 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND032 -U 1 0 FD501343 -P 3400 3300 -F 0 "#GND032" H 3400 3300 50 0001 C CNN -F 1 "GND" H 3300 3200 59 0000 L BNN -F 2 "" H 3400 3300 50 0001 C CNN -F 3 "" H 3400 3300 50 0001 C CNN - 1 3400 3300 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X9 JP1 -U 1 0 A13C1BE3 -P 7900 3800 -F 0 "JP1" H 7750 3200 59 0000 L BNN -F 1 "PIN1x9" H 8000 3300 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X09-BIG" H 7900 3800 50 0001 C CNN -F 3 "" H 7900 3800 50 0001 C CNN - 1 7900 3800 - 1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X9 JP2 -U 1 0 10A664E2 -P 7900 2650 -F 0 "JP2" H 7750 2050 59 0000 L BNN -F 1 "PIN1x9" H 8000 2150 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X09-BIG" H 7900 2650 50 0001 C CNN -F 3 "" H 7900 2650 50 0001 C CNN - 1 7900 2650 - 1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+04 -U 1 0 459FCD94 -P 7200 2750 -F 0 "#P+04" H 7200 2750 50 0001 C CNN -F 1 "VCC" V 7300 2700 59 0000 L BNN -F 2 "" H 7200 2750 50 0001 C CNN -F 3 "" H 7200 2750 50 0001 C CNN - 1 7200 2750 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND08 -U 1 0 E3161DBF -P 7200 2550 -F 0 "#GND08" H 7200 2550 50 0001 C CNN -F 1 "GND" H 7100 2450 59 0000 L BNN -F 2 "" H 7200 2550 50 0001 C CNN -F 3 "" H 7200 2550 50 0001 C CNN - 1 7200 2550 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X12 JP3 -U 1 0 B09918B6 -P 8000 5400 -F 0 "JP3" H 7550 4700 59 0000 L BNN -F 1 "PIN1x12" H 7350 4700 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X12" H 8000 5400 50 0001 C CNN -F 3 "" H 8000 5400 50 0001 C CNN - 1 8000 5400 - 1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R1 -U 1 0 DE40310A -P 7800 4600 -F 0 "R1" H 7540 4669 59 0000 L BNN -F 1 "1Kom" H 7680 4670 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 7800 4600 50 0001 C CNN -F 3 "" H 7800 4600 50 0001 C CNN - 1 7800 4600 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C4 -U 1 0 487BCAB4 -P 2850 1700 -F 0 "C4" H 2910 1715 59 0000 L BNN -F 1 "10uF" H 2910 1515 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 2850 1700 50 0001 C CNN -F 3 "" H 2850 1700 50 0001 C CNN - 1 2850 1700 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:C-EUC0805H C6 -U 1 0 04BD8970 -P 4500 1700 -F 0 "C6" H 4560 1715 59 0000 L BNN -F 1 "22uF" H 4560 1515 59 0000 L BNN -F 2 "M644_breakout_v1.2d:C0805H" H 4500 1700 50 0001 C CNN -F 3 "" H 4500 1700 50 0001 C CNN - 1 4500 1700 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:W237-102 X2 -U 1 0 484D9DCB -P 2050 2000 -F 0 "X2" H 2050 2035 59 0000 R TNN -F 1 "DG300-5.0-02P-12" H 1950 1855 59 0000 L BNN -F 2 "M644_breakout_v1.2d:W237-102" H 2050 2000 50 0001 C CNN -F 3 "" H 2050 2000 50 0001 C CNN - 1 2050 2000 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:W237-102 X2 -U 2 0 484D9DC7 -P 2050 1400 -F 0 "X2" H 2050 1435 59 0000 R TNN -F 1 "DG300-5.0-02P-12" H 2250 1645 59 0001 R TNN -F 2 "M644_breakout_v1.2d:W237-102" H 2050 1400 50 0001 C CNN -F 3 "" H 2050 1400 50 0001 C CNN - 2 2050 1400 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:SUPPRESSOR-SMBJ D3 -U 1 0 76CA823F -P 2250 1750 -F 0 "D3" H 2360 1825 59 0000 L BNN -F 1 "SM6T15CA" H 2360 1715 59 0000 L BNN -F 2 "M644_breakout_v1.2d:SMBJ" H 2250 1750 50 0001 C CNN -F 3 "" H 2250 1750 50 0001 C CNN - 1 2250 1750 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:CPOL-EUD_7343-31R C12 -U 1 0 FFB33241 -P 5550 1700 -F 0 "C12" H 5295 1719 59 0000 L BNN -F 1 "100uF" H 5200 1500 59 0000 L BNN -F 2 "M644_breakout_v1.2d:D_7343-31R" H 5550 1700 50 0001 C CNN -F 3 "" H 5550 1700 50 0001 C CNN - 1 5550 1700 - -1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP4 -U 1 0 81FCD7AF -P 9250 1500 -F 0 "JP4" H 9000 1625 59 0001 L BNN -F 1 "PINx1" H 9000 1300 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 1500 50 0001 C CNN -F 3 "" H 9250 1500 50 0001 C CNN - 1 9250 1500 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP5 -U 1 0 9DADB6DD -P 9250 1900 -F 0 "JP5" H 9000 2025 59 0001 L BNN -F 1 "PINx1" H 9000 1700 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 1900 50 0001 C CNN -F 3 "" H 9250 1900 50 0001 C CNN - 1 9250 1900 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP6 -U 1 0 3ADBB494 -P 9250 2250 -F 0 "JP6" H 9000 2375 59 0001 L BNN -F 1 "PINx1" H 9000 2050 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 2250 50 0001 C CNN -F 3 "" H 9250 2250 50 0001 C CNN - 1 9250 2250 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP7 -U 1 0 350157B3 -P 9250 2650 -F 0 "JP7" H 9000 2775 59 0001 L BNN -F 1 "PINx1" H 9000 2450 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 2650 50 0001 C CNN -F 3 "" H 9250 2650 50 0001 C CNN - 1 9250 2650 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP8 -U 1 0 ADB8D889 -P 9250 3000 -F 0 "JP8" H 9000 3125 59 0001 L BNN -F 1 "PINx1" H 9000 2800 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 3000 50 0001 C CNN -F 3 "" H 9250 3000 50 0001 C CNN - 1 9250 3000 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP9 -U 1 0 50718617 -P 9250 3400 -F 0 "JP9" H 9000 3525 59 0001 L BNN -F 1 "PINx1" H 9000 3200 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 3400 50 0001 C CNN -F 3 "" H 9250 3400 50 0001 C CNN - 1 9250 3400 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:DIODE-DO214AA D1 -U 1 0 C7EBFCBF -P 2500 1400 -F 0 "D1" H 2450 1500 59 0000 L BNN -F 1 "SM4007" H 2450 1250 59 0000 L BNN -F 2 "M644_breakout_v1.2d:DO214AA" H 2500 1400 50 0001 C CNN -F 3 "" H 2500 1400 50 0001 C CNN - 1 2500 1400 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:SW_TACT SW1/PC5/21 -U 1 0 21BF7E4D -P 9150 5400 -F 0 "SW1/PC5/21" H 9050 5600 70 0000 L BNN -F 1 "SMD_TACT_4x4" H 9050 5200 70 0001 L BNN -F 2 "M644_breakout_v1.2d:SW_TACT_SMALL" H 9150 5400 50 0001 C CNN -F 3 "" H 9150 5400 50 0001 C CNN - 1 9150 5400 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R3 -U 1 0 EA9A6EB6 -P 8550 5400 -F 0 "R3" H 8700 5300 59 0000 L BNN -F 1 "510Om" H 8350 5300 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 8550 5400 50 0001 C CNN -F 3 "" H 8550 5400 50 0001 C CNN - 1 8550 5400 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND05 -U 1 0 5B6A58CA -P 9650 5400 -F 0 "#GND05" H 9650 5400 50 0001 C CNN -F 1 "GND" H 9550 5300 59 0000 L BNN -F 2 "" H 9650 5400 50 0001 C CNN -F 3 "" H 9650 5400 50 0001 C CNN - 1 9650 5400 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP11 -U 1 0 71218B71 -P 9250 1700 -F 0 "JP11" H 9000 1825 59 0001 L BNN -F 1 "PINx1" H 9000 1500 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 1700 50 0001 C CNN -F 3 "" H 9250 1700 50 0001 C CNN - 1 9250 1700 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP12 -U 1 0 81AF9221 -P 9250 2450 -F 0 "JP12" H 9000 2575 59 0001 L BNN -F 1 "PINx1" H 9000 2250 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 2450 50 0001 C CNN -F 3 "" H 9250 2450 50 0001 C CNN - 1 9250 2450 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP13 -U 1 0 03497A6C -P 9250 3200 -F 0 "JP13" H 9000 3325 59 0001 L BNN -F 1 "PINx1" H 9000 3000 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9250 3200 50 0001 C CNN -F 3 "" H 9250 3200 50 0001 C CNN - 1 9250 3200 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R4 -U 1 0 292B8E46 -P 6650 6300 -F 0 "R4" H 6350 6189 59 0000 L BNN -F 1 "10KOm" H 6500 6170 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 6650 6300 50 0001 C CNN -F 3 "" H 6650 6300 50 0001 C CNN - 1 6650 6300 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R5 -U 1 0 59505C8B -P 6850 6300 -F 0 "R5" H 6550 6189 59 0000 L BNN -F 1 "10KOm" H 6700 6170 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 6850 6300 50 0001 C CNN -F 3 "" H 6850 6300 50 0001 C CNN - 1 6850 6300 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+06 -U 1 0 4B6CF0C8 -P 6650 6700 -F 0 "#P+06" H 6650 6700 50 0001 C CNN -F 1 "VCC" V 6550 6600 59 0000 L BNN -F 2 "" H 6650 6700 50 0001 C CNN -F 3 "" H 6650 6700 50 0001 C CNN - 1 6650 6700 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP14 -U 1 0 679AEFF0 -P 3450 5450 -F 0 "JP14" H 3200 5575 59 0001 L BNN -F 1 "PINx1" H 3200 5250 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 3450 5450 50 0001 C CNN -F 3 "" H 3450 5450 50 0001 C CNN - 1 3450 5450 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP15 -U 1 0 D0A47C9F -P 3450 5050 -F 0 "JP15" H 3200 5175 59 0001 L BNN -F 1 "PINx1" H 3200 4850 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 3450 5050 50 0001 C CNN -F 3 "" H 3450 5050 50 0001 C CNN - 1 3450 5050 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP16 -U 1 0 C3CE8354 -P 3450 4850 -F 0 "JP16" H 3200 4975 59 0001 L BNN -F 1 "PINx1" H 3200 4650 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 3450 4850 50 0001 C CNN -F 3 "" H 3450 4850 50 0001 C CNN - 1 3450 4850 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP17 -U 1 0 BAC3901A -P 3450 5250 -F 0 "JP17" H 3200 5375 59 0001 L BNN -F 1 "PINx1" H 3200 5050 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 3450 5250 50 0001 C CNN -F 3 "" H 3450 5250 50 0001 C CNN - 1 3450 5250 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP19 -U 1 0 14CC0547 -P 4300 4850 -F 0 "JP19" H 4050 4975 59 0001 L BNN -F 1 "PINx1" H 4050 4650 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 4300 4850 50 0001 C CNN -F 3 "" H 4300 4850 50 0001 C CNN - 1 4300 4850 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP20 -U 1 0 5467ECB4 -P 4300 5450 -F 0 "JP20" H 4050 5575 59 0001 L BNN -F 1 "PINx1" H 4050 5250 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 4300 5450 50 0001 C CNN -F 3 "" H 4300 5450 50 0001 C CNN - 1 4300 5450 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP21 -U 1 0 3FA45B4D -P 4300 5050 -F 0 "JP21" H 4050 5175 59 0001 L BNN -F 1 "PINx1" H 4050 4850 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 4300 5050 50 0001 C CNN -F 3 "" H 4300 5050 50 0001 C CNN - 1 4300 5050 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP22 -U 1 0 1375B3FD -P 4300 5250 -F 0 "JP22" H 4050 5375 59 0001 L BNN -F 1 "PINx1" H 4050 5050 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 4300 5250 50 0001 C CNN -F 3 "" H 4300 5250 50 0001 C CNN - 1 4300 5250 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND06 -U 1 0 F6847280 -P 4900 5050 -F 0 "#GND06" H 4900 5050 50 0001 C CNN -F 1 "GND" H 4800 4950 59 0000 L BNN -F 2 "" H 4900 5050 50 0001 C CNN -F 3 "" H 4900 5050 50 0001 C CNN - 1 4900 5050 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R6 -U 1 0 9C9DB109 -P 8550 6100 -F 0 "R6" H 8700 6000 59 0000 L BNN -F 1 "10kOm" H 8350 6000 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 8550 6100 50 0001 C CNN -F 3 "" H 8550 6100 50 0001 C CNN - 1 8550 6100 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+07 -U 1 0 FAFE20BD -P 9050 6100 -F 0 "#P+07" H 9050 6100 50 0001 C CNN -F 1 "VCC" V 8950 6000 59 0000 L BNN -F 2 "" H 9050 6100 50 0001 C CNN -F 3 "" H 9050 6100 50 0001 C CNN - 1 9050 6100 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP24 -U 1 0 211071EA -P 2550 4900 -F 0 "JP24" H 2300 5025 59 0001 L BNN -F 1 "PINx1" H 2300 4700 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 2550 4900 50 0001 C CNN -F 3 "" H 2550 4900 50 0001 C CNN - 1 2550 4900 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP25 -U 1 0 CD247A09 -P 2550 5150 -F 0 "JP25" H 2300 5275 59 0001 L BNN -F 1 "PINx1" H 2300 4950 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 2550 5150 50 0001 C CNN -F 3 "" H 2550 5150 50 0001 C CNN - 1 2550 5150 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP26 -U 1 0 02F38983 -P 2550 5400 -F 0 "JP26" H 2300 5525 59 0001 L BNN -F 1 "PINx1" H 2300 5200 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 2550 5400 50 0001 C CNN -F 3 "" H 2550 5400 50 0001 C CNN - 1 2550 5400 - -1 0 0 1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP27 -U 1 0 AB274EC9 -P 9650 5900 -F 0 "JP27" H 9400 6025 59 0001 L BNN -F 1 "PINx1" H 9400 5700 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 9650 5900 50 0001 C CNN -F 3 "" H 9650 5900 50 0001 C CNN - 1 9650 5900 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP28 -U 1 0 7D22D023 -P 8550 4000 -F 0 "JP28" H 8300 4125 59 0001 L BNN -F 1 "PINx1" H 8300 3800 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 8550 4000 50 0001 C CNN -F 3 "" H 8550 4000 50 0001 C CNN - 1 8550 4000 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP10 -U 1 0 391CE814 -P 2650 750 -F 0 "JP10" H 2400 875 59 0001 L BNN -F 1 "PINx1" H 2400 550 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 2650 750 50 0001 C CNN -F 3 "" H 2650 750 50 0001 C CNN - 1 2650 750 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:PINHD-1X1 JP29 -U 1 0 1A752D3A -P 2850 750 -F 0 "JP29" H 2600 875 59 0001 L BNN -F 1 "PINx1" H 2600 550 59 0001 L BNN -F 2 "M644_breakout_v1.2d:1X01" H 2850 750 50 0001 C CNN -F 3 "" H 2850 750 50 0001 C CNN - 1 2850 750 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:VCC #P+08 -U 1 0 E32DC4A8 -P 4100 5050 -F 0 "#P+08" H 4100 5050 50 0001 C CNN -F 1 "VCC" V 4000 4850 59 0000 L BNN -F 2 "" H 4100 5050 50 0001 C CNN -F 3 "" H 4100 5050 50 0001 C CNN - 1 4100 5050 - 0 1 1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805 R7 -U 1 0 6C5D1C71 -P 7450 5600 -F 0 "R7" H 7590 5619 59 0000 L BNN -F 1 "1Kom" H 7580 5520 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805" H 7450 5600 50 0001 C CNN -F 3 "" H 7450 5600 50 0001 C CNN - 1 7450 5600 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805 R8 -U 1 0 B110DF28 -P 7450 5800 -F 0 "R8" H 7590 5819 59 0000 L BNN -F 1 "1Kom" H 7580 5720 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805" H 7450 5800 50 0001 C CNN -F 3 "" H 7450 5800 50 0001 C CNN - 1 7450 5800 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R9 -U 1 0 F96F0265 -P 8450 5200 -F 0 "R9" H 8250 5250 59 0000 L BNN -F 1 "2Kom" H 8450 5250 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 8450 5200 50 0001 C CNN -F 3 "" H 8450 5200 50 0001 C CNN - 1 8450 5200 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:R-EU_R0805H R10 -U 1 0 1B221D8E -P 8500 5700 -F 0 "R10" H 8400 5750 59 0000 L BNN -F 1 "2Kom" H 8600 5750 59 0000 L BNN -F 2 "M644_breakout_v1.2d:R0805H" H 8500 5700 50 0001 C CNN -F 3 "" H 8500 5700 50 0001 C CNN - 1 8500 5700 - 1 0 0 -1 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND09 -U 1 0 FD0A31A1 -P 8800 5200 -F 0 "#GND09" H 8800 5200 50 0001 C CNN -F 1 "GND" H 8700 5100 59 0000 L BNN -F 2 "" H 8800 5200 50 0001 C CNN -F 3 "" H 8800 5200 50 0001 C CNN - 1 8800 5200 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND010 -U 1 0 0087CD10 -P 8850 5700 -F 0 "#GND010" H 8850 5700 50 0001 C CNN -F 1 "GND" H 8750 5600 59 0000 L BNN -F 2 "" H 8850 5700 50 0001 C CNN -F 3 "" H 8850 5700 50 0001 C CNN - 1 8850 5700 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:LEDCHIPLED_1206 LED1_SMD1 -U 1 0 DD7CFDEC -P 8300 4950 -F 0 "LED1_SMD1" V 8390 4670 59 0001 L BNN -F 1 "LED_RED/PC4/20" V 8450 4250 59 0000 L BNN -F 2 "M644_breakout_v1.2d:CHIPLED_1206" H 8300 4950 50 0001 C CNN -F 3 "" H 8300 4950 50 0001 C CNN - 1 8300 4950 - 0 -1 -1 0 -$EndComp -$Comp -L M644_breakout_v1.2d-eagle-import:GND #GND011 -U 1 0 5518330F -P 8650 4950 -F 0 "#GND011" H 8650 4950 50 0001 C CNN -F 1 "GND" H 8550 4850 59 0000 L BNN -F 2 "" H 8650 4950 50 0001 C CNN -F 3 "" H 8650 4950 50 0001 C CNN - 1 8650 4950 - 0 -1 -1 0 -$EndComp -Text Notes 4950 1300 0 59 ~ 0 -+5V -Text Notes 2050 6500 0 86 ~ 17 -M16/M32/M324/M644/M1284 breakout board v1.2d -Text Notes 2250 6700 0 86 ~ 17 -26/01/2019 Ibragimov M. -Text Notes 1850 1750 0 59 ~ 0 -PWR -Text Notes 2550 650 0 59 ~ 0 -+12-9V -Wire Wire Line - 4500 2000 5050 2000 -Wire Wire Line - 4350 4150 4350 4300 -Wire Wire Line - 7300 2550 7800 2550 -Wire Wire Line - 3450 2600 4350 2600 -Wire Wire Line - 7150 3900 7800 3900 -Wire Wire Line - 7300 2750 7800 2750 -Wire Wire Line - 4500 1400 5050 1400 -Wire Wire Line - 4150 1400 4500 1400 -Wire Wire Line - 3550 5250 3800 5250 -Wire Wire Line - 2850 1100 2850 1400 -Text GLabel 8550 1500 0 50 Input ~ 0 -SCK -Text GLabel 8550 2250 0 50 Input ~ 0 -MISO -Text GLabel 7850 1600 2 50 Input ~ 0 -SCK -Text GLabel 7850 1700 2 50 Input ~ 0 -MISO -Connection ~ 8800 3200 -Text GLabel 8550 3000 0 50 Input ~ 0 -MOSI -Text GLabel 7100 1600 0 50 Input ~ 0 -MOSI -Text Label 8100 4000 0 50 ~ 0 -PC4 -Text GLabel 6550 3600 2 50 Input ~ 0 -MISO -Text GLabel 6550 3700 2 50 Input ~ 0 -MOSI -Text GLabel 6550 3500 2 50 Input ~ 0 -SCK -Text GLabel 7850 1500 2 50 Input ~ 0 -RESET -Wire Wire Line - 3800 5450 3800 5250 -Text GLabel 2950 4900 2 50 Input ~ 0 -PD2 -Text GLabel 2950 5150 2 50 Input ~ 0 -PD3 -Text GLabel 2950 5400 2 50 Input ~ 0 -PD4 -Wire Wire Line - 4000 5050 3800 5050 -Wire Wire Line - 4400 5250 4650 5250 -Connection ~ 4650 5250 -Wire Wire Line - 4650 5250 4650 5050 -Wire Wire Line - 4800 5050 4650 5050 -Text GLabel 4700 2600 0 50 Input ~ 0 -RESET -Text GLabel 4400 3600 0 50 Input ~ 0 -AREF -Wire Wire Line - 4700 3300 4750 3300 -Wire Wire Line - 4800 4100 4800 3500 -Wire Wire Line - 4400 3600 4750 3600 -Wire Wire Line - 4750 3600 4750 3300 -Connection ~ 4750 3300 -Wire Wire Line - 4750 3300 4950 3300 -Text GLabel 7550 2650 0 50 Input ~ 0 -AREF -Wire Wire Line - 8750 5700 8700 5700 -Wire Wire Line - 2600 1400 2850 1400 -Connection ~ 2250 1400 -Connection ~ 2250 2000 -Wire Wire Line - 2250 2000 2850 2000 -Wire Bus Line - 7050 1850 7050 6150 -$EndSCHEMATC diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GBL b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GBL deleted file mode 100644 index c3aeb93..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GBL +++ /dev/null @@ -1,3152 +0,0 @@ -G75* -G70* -%OFA0B0*% -%FSLAX24Y24*% -%IPPOS*% -%LPD*% -%AMOC8* -5,1,8,0,0,1.08239X$1,22.5* -% -%ADD10C,0.0000*% -%ADD11C,0.0160*% -%ADD12R,0.0591X0.0197*% -%ADD13R,0.0197X0.0591*% -%ADD14C,0.0560*% -%ADD15R,0.0560X0.0280*% -%ADD16R,0.0280X0.0560*% -%ADD17R,0.0660X0.0660*% -%ADD18OC8,0.0660*% -%ADD19C,0.0600*% -%ADD20R,0.0630X0.0472*% -%ADD21OC8,0.0700*% -%ADD22C,0.0705*% -%ADD23R,0.0701X0.0850*% -%ADD24R,0.1063X0.1004*% -%ADD25OC8,0.0709*% -%ADD26R,0.0866X0.0709*% -%ADD27R,0.0709X0.0866*% -%ADD28R,0.0591X0.0512*% -%ADD29C,0.0240*% -%ADD30C,0.0150*% -%ADD31C,0.0120*% -%ADD32OC8,0.0760*% -%ADD33C,0.0500*% -%ADD34C,0.0320*% -%ADD35C,0.0400*% -%ADD36C,0.0100*% -%ADD37OC8,0.0500*% -%ADD38OC8,0.3000*% -D10* -X005060Y005553D02* -X005060Y023270D01* -X026560Y023270D01* -X026560Y005553D01* -X005060Y005553D01* -D11* -X008560Y006553D02* -X008560Y007053D01* -X009060Y008053D01* -X009060Y009053D01* -X011970Y011393D01* -X011985Y011770D01* -X011485Y012053D02* -X012235Y012603D01* -X013235Y012603D01* -X013242Y012603D01* -X013230Y014053D01* -X013510Y014003D01* -X013510Y014053D01* -X013510Y015628D01* -X013560Y015978D02* -X013560Y016337D01* -X013560Y017553D01* -X013010Y017523D02* -X013245Y017038D01* -X013245Y016337D01* -X012930Y016337D02* -X012920Y016923D01* -X012560Y017553D01* -X011560Y020053D01* -X011560Y022053D01* -X012560Y022053D02* -X012560Y021053D01* -X014200Y019343D01* -X014200Y017463D01* -X013870Y016993D01* -X013874Y016337D01* -X014189Y016337D02* -X014180Y016953D01* -X014520Y017393D01* -X014520Y019413D01* -X013550Y021123D01* -X013560Y022053D01* -X014560Y022053D02* -X014560Y020553D01* -X014840Y019773D01* -X014840Y019783D01* -X014830Y017313D01* -X014490Y016893D01* -X014504Y016337D01* -X014819Y016337D02* -X014820Y016853D01* -X015180Y017323D01* -X015560Y020053D01* -X015560Y022053D01* -X016560Y022053D02* -X016560Y020053D01* -X015560Y017303D01* -X015144Y016788D01* -X015134Y016337D01* -X015472Y016338D02* -X015474Y016364D01* -X015480Y016389D01* -X015489Y016413D01* -X015503Y016435D01* -X015519Y016454D01* -X015538Y016472D01* -X015560Y016486D01* -X015583Y016496D01* -X015608Y016503D01* -X015634Y016506D01* -X015659Y016505D01* -X015685Y016500D01* -X015709Y016491D01* -X015731Y016479D01* -X015752Y016463D01* -X015770Y016445D01* -X015784Y016424D01* -X015796Y016401D01* -X015804Y016376D01* -X015808Y016351D01* -X015808Y016325D01* -X015804Y016300D01* -X015796Y016275D01* -X015784Y016252D01* -X015770Y016231D01* -X015752Y016213D01* -X015731Y016197D01* -X015709Y016185D01* -X015685Y016176D01* -X015659Y016171D01* -X015634Y016170D01* -X015608Y016173D01* -X015583Y016180D01* -X015560Y016190D01* -X015538Y016204D01* -X015519Y016222D01* -X015503Y016241D01* -X015489Y016263D01* -X015480Y016287D01* -X015474Y016312D01* -X015472Y016338D01* -X016165Y015678D02* -X016330Y017703D01* -X017060Y019553D01* -X018060Y019553D01* -X019060Y019553D01* -X020435Y021303D01* -X021310Y021303D01* -X021560Y021053D01* -X021560Y020053D01* -X022060Y019553D01* -X022060Y018553D02* -X021185Y016053D01* -X020060Y015603D02* -X020058Y015603D01* -X020028Y015399D01* -X017685Y015398D01* -X016745Y014363D01* -X016060Y014353D01* -X015843Y014368D01* -X015843Y013738D02* -X016135Y013728D01* -X017085Y013733D01* -X017735Y014038D01* -X019060Y014053D01* -X017965Y013128D02* -X017735Y013138D01* -X017855Y013168D02* -X017965Y013128D01* -X018230Y012063D02* -X019060Y012053D01* -X019310Y011978D01* -X020390Y011978D01* -X019670Y010413D02* -X022247Y012991D01* -X022310Y013053D01* -X022328Y013053D01* -X022436Y013161D01* -X019670Y010413D02* -X019670Y008043D01* -X019160Y007503D02* -X019160Y009003D01* -X017560Y012053D01* -X016560Y013053D01* -X015843Y013109D01* -X015843Y013423D02* -X016135Y013428D01* -X016680Y013413D01* -X018230Y012063D01* -X016560Y010803D02* -X016560Y010503D01* -X016560Y010803D02* -X015810Y011553D01* -X015810Y011803D01* -X013810Y013803D01* -X013810Y014053D01* -X012710Y013123D02* -X011850Y013123D01* -X011276Y013109D01* -X011276Y013423D02* -X011800Y013423D01* -X012260Y013603D01* -X011276Y013738D02* -X011261Y013753D01* -X010910Y013753D01* -X010360Y013203D01* -X010160Y013183D01* -X010150Y013213D01* -X008960Y013313D01* -X008660Y012753D02* -X008060Y013353D01* -X008060Y013553D01* -X008660Y012753D02* -X009360Y012753D01* -X009480Y012873D01* -X009550Y012873D01* -X010580Y012873D01* -X011276Y012794D01* -X011276Y012479D02* -X010610Y012593D01* -X009730Y012593D01* -X009109Y010538D01* -X009094Y010553D01* -X008780Y010553D01* -X009109Y010538D02* -X009030Y010273D01* -X009030Y010023D01* -X008980Y009973D01* -X008560Y009553D01* -X008060Y009553D01* -X007880Y010553D02* -X008060Y011553D01* -X010160Y012283D02* -X010235Y012228D01* -X010235Y012053D01* -X011485Y012053D01* -X012300Y011770D02* -X012290Y011183D01* -X010060Y009053D01* -X010060Y008053D01* -X009560Y006553D01* -X010560Y006553D02* -X010560Y007553D01* -X012560Y011053D01* -X012615Y011770D01* -X012930Y011770D02* -X012900Y011053D01* -X011560Y007053D01* -X011560Y006553D01* -X012560Y006553D02* -X012560Y007553D01* -X013060Y008053D01* -X013545Y008046D01* -X013661Y008120D01* -X013671Y008143D01* -X014060Y009553D01* -X014060Y010863D01* -X013880Y011253D01* -X013874Y011770D01* -X013560Y011770D02* -X013560Y011028D01* -X013775Y010813D01* -X013770Y010803D01* -X013770Y009828D01* -X013747Y009766D01* -X013610Y009628D01* -X013260Y009578D01* -X013260Y010478D02* -X013260Y010978D01* -X013245Y011770D01* -X013235Y011780D01* -X013245Y012133D01* -X014189Y011770D02* -X014200Y011273D01* -X014330Y011053D01* -X014330Y009323D01* -X013930Y007633D01* -X013570Y007263D01* -X013560Y006553D01* -X014560Y006553D02* -X014600Y009143D01* -X014600Y011133D01* -X014510Y011353D01* -X014504Y011770D01* -X014819Y011770D02* -X014820Y011363D01* -X014980Y010793D01* -X015560Y007553D01* -X015560Y006553D01* -X016560Y006553D02* -X016560Y007553D01* -X016560Y008219D01* -X016644Y008303D01* -X016935Y008303D01* -X017060Y008428D01* -X017060Y009303D01* -X017010Y009353D01* -X016560Y009603D01* -X016060Y009053D02* -X016310Y008803D01* -X016475Y008803D01* -X016560Y008888D01* -X016060Y009053D02* -X015810Y009553D01* -X015130Y011383D01* -X015134Y011770D01* -X015843Y012479D02* -X016260Y012353D01* -X017560Y009553D01* -X017560Y007553D01* -X017560Y006553D01* -X017560Y007553D01* -X018290Y007573D02* -X018560Y007303D01* -X018560Y006553D01* -X019560Y006553D02* -X019160Y007503D01* -X018770Y008043D02* -X018304Y008043D01* -X018290Y008029D01* -X018290Y007573D01* -X018290Y008698D02* -X018310Y008718D01* -X018310Y009503D01* -X016450Y012753D01* -X015843Y012794D01* -X016635Y014678D02* -X017500Y015683D01* -X019150Y015683D01* -X019810Y016553D01* -X020060Y016503D01* -X021060Y018553D01* -X021060Y019553D02* -X019310Y017303D01* -X018310Y017303D01* -X018060Y016553D01* -X019060Y016553D01* -X018060Y016553D02* -X017060Y016553D01* -X016970Y015663D01* -X016520Y015003D01* -X016085Y015003D01* -X015885Y014978D02* -X015843Y014998D01* -X015843Y015313D02* -X016238Y015306D01* -X016464Y015544D01* -X016570Y017153D01* -X017060Y018053D01* -X018060Y018053D01* -X019060Y018053D01* -X021060Y020553D01* -X022060Y020553D02* -X023060Y019053D01* -X023060Y018053D01* -X013560Y018453D02* -X013210Y018453D01* -X013010Y017873D01* -X013010Y017523D01* -X012620Y016863D02* -X010560Y020553D01* -X010560Y022053D01* -X009560Y022053D02* -X009560Y020553D01* -X012300Y016803D01* -X012300Y016337D01* -X012615Y016337D02* -X012620Y016863D01* -X011980Y016653D02* -X011985Y016337D01* -X011980Y016653D02* -X008560Y020553D01* -X008560Y022053D01* -X010060Y017553D02* -X006560Y017553D01* -X006560Y016553D02* -X007560Y016553D01* -X010110Y016553D01* -X010910Y015653D01* -X011276Y015628D01* -X011276Y015313D02* -X010810Y015303D01* -X010260Y015903D01* -X009810Y015903D01* -X009420Y015563D01* -X006560Y015553D01* -X006060Y015053D02* -X007560Y015053D01* -X007800Y015193D01* -X008350Y015193D01* -X008580Y015033D01* -X009280Y015023D01* -X009610Y014828D01* -X009685Y014828D01* -X010010Y014503D01* -X010010Y014303D01* -X010260Y014053D01* -X010510Y014053D01* -X011276Y014053D01* -X011276Y014368D02* -X010945Y014368D01* -X010610Y014603D01* -X010560Y014778D01* -X010510Y014828D01* -X010060Y015403D01* -X009269Y014394D02* -X009610Y014053D01* -X009269Y014394D02* -X008960Y014494D01* -X011276Y014683D02* -X012240Y014673D01* -X011880Y015086D02* -X011880Y015673D01* -X010060Y017553D01* -X011276Y014998D02* -X011777Y014986D01* -X011880Y015086D01* -D12* -X011276Y014998D03* -X011276Y014683D03* -X011276Y014368D03* -X011276Y014053D03* -X011276Y013738D03* -X011276Y013423D03* -X011276Y013109D03* -X011276Y012794D03* -X011276Y012479D03* -X011276Y015313D03* -X011276Y015628D03* -X015843Y015628D03* -X015843Y015313D03* -X015843Y014998D03* -X015843Y014683D03* -X015843Y014368D03* -X015843Y014053D03* -X015843Y013738D03* -X015843Y013423D03* -X015843Y013109D03* -X015843Y012794D03* -X015843Y012479D03* -D13* -X015134Y011770D03* -X014819Y011770D03* -X014504Y011770D03* -X014189Y011770D03* -X013874Y011770D03* -X013560Y011770D03* -X013245Y011770D03* -X012930Y011770D03* -X012615Y011770D03* -X012300Y011770D03* -X011985Y011770D03* -X011985Y016337D03* -X012300Y016337D03* -X012615Y016337D03* -X012930Y016337D03* -X013245Y016337D03* -X013560Y016337D03* -X013874Y016337D03* -X014189Y016337D03* -X014504Y016337D03* -X014819Y016337D03* -X015134Y016337D03* -D14* -X018780Y014053D02* -X019340Y014053D01* -X019340Y012053D02* -X018780Y012053D01* -X023544Y007553D02* -X025060Y008053D01* -D15* -X025490Y012153D03* -X026060Y012153D03* -X026060Y013053D03* -X025490Y013053D03* -X021100Y014103D03* -X020430Y014103D03* -X020430Y015003D03* -X021100Y015003D03* -X020060Y015603D03* -X020060Y016503D03* -X017735Y014038D03* -X017735Y013138D03* -X016560Y010503D03* -X016560Y009603D03* -X013260Y009578D03* -X013260Y010478D03* -X010160Y012283D03* -X010160Y013183D03* -X013560Y017553D03* -X013560Y018453D03* -X020390Y012878D03* -X020390Y011978D03* -D16* -X019670Y008043D03* -X018770Y008043D03* -X010510Y014053D03* -X010510Y014828D03* -X009610Y014828D03* -X009610Y014053D03* -X008780Y010553D03* -X007880Y010553D03* -D17* -X021060Y020553D03* -D18* -X022060Y020553D03* -X022060Y019553D03* -X022060Y018553D03* -X021060Y018553D03* -X021060Y019553D03* -X008060Y012553D03* -X008060Y011553D03* -D19* -X024610Y012053D02* -X025210Y012053D01* -X025210Y013053D02* -X024610Y013053D01* -X024610Y014053D02* -X025210Y014053D01* -D20* -X008960Y014494D03* -X008960Y013313D03* -D21* -X006560Y013553D03* -X006560Y014553D03* -X006560Y015553D03* -X006560Y016553D03* -X006560Y017553D03* -X008560Y022053D03* -X009560Y022053D03* -X010560Y022053D03* -X011560Y022053D03* -X012560Y022053D03* -X013560Y022053D03* -X014560Y022053D03* -X015560Y022053D03* -X016560Y022053D03* -X006560Y012553D03* -X006560Y011553D03* -X006560Y010553D03* -X006560Y009553D03* -X008560Y006553D03* -X009560Y006553D03* -X010560Y006553D03* -X011560Y006553D03* -X012560Y006553D03* -X013560Y006553D03* -X014560Y006553D03* -X015560Y006553D03* -X016560Y006553D03* -X017560Y006553D03* -X018560Y006553D03* -X019560Y006553D03* -D22* -X021575Y007201D02* -X021575Y007906D01* -X023544Y007906D02* -X023544Y007201D01* -D23* -X023363Y006553D03* -X021760Y006553D03* -D24* -X022250Y013323D03* -X022250Y015823D03* -D25* -X024060Y016553D03* -X025060Y016553D03* -X025060Y017553D03* -X025060Y018553D03* -X025060Y019553D03* -X024060Y019553D03* -X024060Y018553D03* -X024060Y017553D03* -X019060Y018053D03* -X018060Y018053D03* -X017060Y018053D03* -X017060Y016553D03* -X018060Y016553D03* -X019060Y016553D03* -X019060Y019553D03* -X018060Y019553D03* -X017060Y019553D03* -X025060Y010803D03* -X026060Y010803D03* -X017560Y007553D03* -X016560Y007553D03* -X015560Y007553D03* -X008060Y009553D03* -X008060Y013553D03* -D26* -X020760Y009057D03* -X020760Y007049D03* -X023610Y009949D03* -X023610Y011957D03* -D27* -X023613Y009103D03* -X021606Y009103D03* -D28* -X018290Y008698D03* -X018290Y008029D03* -X016560Y008219D03* -X016560Y008888D03* -D29* -X013245Y012133D02* -X013242Y012603D01* -X013230Y014053D02* -X011625Y014053D01* -X013510Y014053D02* -X013810Y014053D01* -X015843Y014053D01* -X016860Y014063D01* -X018010Y014928D01* -X019441Y014930D01* -X020025Y014450D01* -X020041Y014450D01* -X020041Y014103D01* -X020041Y014053D01* -X020041Y013553D01* -X019810Y013303D01* -X020390Y012878D01* -X019810Y013303D02* -X019360Y012878D01* -X018435Y012878D01* -X017965Y013128D01* -X013510Y015628D02* -X013560Y015978D01* -X008960Y014494D02* -X008060Y014553D01* -X006560Y014553D01* -X006060Y015053D02* -X005560Y014553D01* -X005560Y013053D01* -X006560Y012553D01* -X008060Y012553D01* -D30* -X011276Y014053D02* -X011625Y014053D01* -X015843Y014683D02* -X015860Y014678D01* -X016635Y014678D01* -X016085Y015003D02* -X015960Y015003D01* -X015843Y014998D01* -X015850Y015618D02* -X015843Y015628D01* -X015850Y015618D02* -X016165Y015678D01* -X013635Y019078D02* -X013560Y019053D01* -X013747Y009766D02* -X013760Y009753D01* -D31* -X014810Y012553D02* -X012310Y012553D01* -X012060Y012803D01* -X012060Y012863D01* -X012361Y012863D01* -X012531Y012693D01* -X012888Y012693D01* -X013139Y012945D01* -X013139Y013301D01* -X012888Y013553D01* -X012689Y013553D01* -X012689Y013781D01* -X012438Y014033D01* -X012081Y014033D01* -X012060Y014011D01* -X012060Y014245D01* -X012061Y014243D01* -X012418Y014243D01* -X012669Y014495D01* -X012669Y014851D01* -X012418Y015103D01* -X012310Y015103D01* -X012310Y015603D01* -X014810Y015603D01* -X015060Y015303D01* -X015060Y012803D01* -X014810Y012553D01* -X014922Y012666D02* -X012197Y012666D01* -X012078Y012785D02* -X012440Y012785D01* -X012979Y012785D02* -X015041Y012785D01* -X015060Y012903D02* -X013097Y012903D01* -X013139Y013022D02* -X015060Y013022D01* -X015060Y013140D02* -X013139Y013140D01* -X013139Y013259D02* -X015060Y013259D01* -X015060Y013377D02* -X013064Y013377D01* -X012945Y013496D02* -X015060Y013496D01* -X015060Y013614D02* -X012689Y013614D01* -X012689Y013733D02* -X015060Y013733D01* -X015060Y013851D02* -X012620Y013851D01* -X012501Y013970D02* -X015060Y013970D01* -X015060Y014089D02* -X012060Y014089D01* -X012060Y014207D02* -X015060Y014207D01* -X015060Y014326D02* -X012500Y014326D01* -X012618Y014444D02* -X015060Y014444D01* -X015060Y014563D02* -X012669Y014563D01* -X012669Y014681D02* -X015060Y014681D01* -X015060Y014800D02* -X012669Y014800D01* -X012603Y014918D02* -X015060Y014918D01* -X015060Y015037D02* -X012484Y015037D01* -X012310Y015155D02* -X015060Y015155D01* -X015060Y015274D02* -X012310Y015274D01* -X012310Y015392D02* -X014985Y015392D01* -X014886Y015511D02* -X012310Y015511D01* -D32* -X013560Y019053D03* -X008060Y014553D03* -X013060Y008803D03* -X021185Y013053D03* -X021185Y016053D03* -X023060Y016053D03* -X023060Y017053D03* -X023060Y018053D03* -X026060Y017553D03* -X026060Y018553D03* -X026060Y019553D03* -X026060Y016553D03* -X026060Y009553D03* -X026060Y008553D03* -X026060Y007553D03* -X026060Y006553D03* -X025060Y006553D03* -X025060Y007553D03* -X025060Y008553D03* -X025060Y009553D03* -D33* -X026060Y009553D01* -X026060Y008553D01* -X026060Y007553D01* -X026060Y006553D01* -X025060Y006553D01* -X025060Y007553D01* -X025060Y008053D01* -X025060Y008553D01* -X025060Y009553D01* -X025060Y010803D02* -X026060Y010803D01* -X025060Y010803D02* -X025060Y010956D01* -X024027Y011988D01* -X024910Y012053D01* -X024560Y011953D01* -X024027Y011988D02* -X023610Y011957D01* -X023560Y013053D02* -X022560Y013053D01* -X022436Y013161D01* -X022250Y013323D01* -X022360Y013473D01* -X022060Y013553D01* -X022560Y012653D02* -X022560Y008553D01* -X023544Y007553D01* -X023363Y006553D01* -X021760Y006553D02* -X021575Y007553D01* -X020760Y007049D01* -X020760Y009057D02* -X021606Y009103D01* -X023613Y009103D02* -X023610Y009949D01* -X022560Y012653D02* -X023560Y013053D01* -X024910Y013053D01* -X024910Y014053D02* -X026060Y015453D01* -X026060Y016553D01* -X026060Y017553D01* -X026060Y018553D01* -X026060Y019553D01* -X023060Y018053D02* -X023060Y017053D01* -X023060Y016053D01* -X023060Y015553D01* -X023060Y015203D01* -X023040Y015233D01* -X024910Y014053D01* -D34* -X024910Y013053D02* -X025490Y013053D01* -X026060Y013053D01* -X026060Y012153D02* -X025490Y012153D01* -X024910Y012053D01* -X024780Y012063D01* -X024672Y012041D02* -X024910Y012053D01* -X022247Y012991D02* -X021950Y013043D01* -X021185Y013053D01* -X021100Y014103D02* -X020430Y014103D01* -X020041Y014103D01* -X020041Y014053D01* -X020430Y015003D02* -X021100Y015003D01* -X020430Y015003D02* -X020028Y015399D01* -X013560Y018453D02* -X013560Y019053D01* -X013260Y009578D02* -X013060Y008803D01* -D35* -X021100Y014103D02* -X022060Y013553D01* -X021100Y015003D02* -X022250Y015823D01* -X023060Y015553D01* -X025060Y016553D02* -X025060Y017553D01* -X026060Y017553D01* -X026060Y018553D02* -X025060Y018553D01* -X025060Y017553D01* -X025060Y018553D02* -X025060Y019553D01* -X026060Y019553D01* -X026060Y016553D02* -X025060Y016553D01* -D36* -X024604Y016098D02* -X024317Y016098D01* -X024268Y016049D02* -X024461Y016241D01* -X024793Y015909D01* -X025326Y015909D01* -X025481Y016063D01* -X025520Y016063D01* -X025520Y015647D01* -X024795Y014764D01* -X023599Y015519D01* -X023599Y015646D01* -X023729Y015776D01* -X023729Y016170D01* -X023851Y016049D01* -X024021Y016049D01* -X024021Y016515D01* -X024098Y016515D01* -X024098Y016049D01* -X024268Y016049D01* -X024098Y016098D02* -X024021Y016098D01* -X024021Y016196D02* -X024098Y016196D01* -X024098Y016295D02* -X024021Y016295D01* -X024021Y016393D02* -X024098Y016393D01* -X024098Y016492D02* -X024021Y016492D01* -X024021Y016592D02* -X024021Y017058D01* -X024021Y017515D01* -X024098Y017515D01* -X024098Y017058D01* -X024098Y016592D01* -X024021Y016592D01* -X024021Y016689D02* -X024098Y016689D01* -X024098Y016787D02* -X024021Y016787D01* -X024021Y016886D02* -X024098Y016886D01* -X024098Y016984D02* -X024021Y016984D01* -X024021Y017083D02* -X024098Y017083D01* -X024098Y017181D02* -X024021Y017181D01* -X024021Y017280D02* -X024098Y017280D01* -X024098Y017379D02* -X024021Y017379D01* -X024021Y017477D02* -X024098Y017477D01* -X024098Y017592D02* -X024021Y017592D01* -X024021Y018049D01* -X024021Y018515D01* -X023555Y018515D01* -X023555Y018505D01* -X023429Y018631D01* -X023429Y019017D01* -X023437Y019053D01* -X023429Y019090D01* -X023429Y019127D01* -X023415Y019161D01* -X023408Y019197D01* -X023387Y019229D01* -X023373Y019263D01* -X023347Y019289D01* -X022677Y020294D01* -X022679Y020297D01* -X022679Y020810D01* -X022316Y021173D01* -X021910Y021173D01* -X021873Y021263D01* -X021769Y021367D01* -X021519Y021617D01* -X021383Y021673D01* -X021236Y021673D01* -X020485Y021673D01* -X020464Y021679D01* -X020412Y021673D01* -X020361Y021673D01* -X020340Y021665D01* -X020317Y021662D01* -X020273Y021637D01* -X020225Y021617D01* -X020209Y021601D01* -X020189Y021590D01* -X020157Y021549D01* -X020121Y021513D01* -X020112Y021492D01* -X019095Y020198D01* -X018793Y020198D01* -X018559Y019965D01* -X018326Y020198D01* -X017793Y020198D01* -X017559Y019965D01* -X017326Y020198D01* -X016929Y020198D01* -X016929Y021518D01* -X017199Y021788D01* -X017199Y022318D01* -X016825Y022693D01* -X016294Y022693D01* -X016060Y022458D01* -X015825Y022693D01* -X015294Y022693D01* -X015060Y022458D01* -X014825Y022693D01* -X014294Y022693D01* -X014060Y022458D01* -X013825Y022693D01* -X013294Y022693D01* -X013060Y022458D01* -X012825Y022693D01* -X012294Y022693D01* -X012060Y022458D01* -X011825Y022693D01* -X011294Y022693D01* -X011060Y022458D01* -X010825Y022693D01* -X010294Y022693D01* -X010060Y022458D01* -X009825Y022693D01* -X009294Y022693D01* -X009060Y022458D01* -X008825Y022693D01* -X008294Y022693D01* -X008228Y022627D01* -X007874Y022980D01* -X023735Y022980D01* -X023260Y022505D01* -X023260Y021022D01* -X024224Y020058D01* -X024098Y020058D01* -X024098Y019592D01* -X024021Y019592D01* -X024021Y020058D01* -X023851Y020058D01* -X023555Y019762D01* -X023555Y019592D01* -X024021Y019592D01* -X024021Y019515D01* -X023555Y019515D01* -X023555Y019344D01* -X023846Y019053D01* -X023555Y018762D01* -X023555Y018592D01* -X024021Y018592D01* -X024021Y019058D01* -X024021Y019515D01* -X024098Y019515D01* -X024098Y019049D01* -X024098Y018592D01* -X024021Y018592D01* -X024021Y018515D01* -X024098Y018515D01* -X024098Y018058D01* -X024098Y017592D01* -X024098Y017674D02* -X024021Y017674D01* -X024021Y017773D02* -X024098Y017773D01* -X024098Y017871D02* -X024021Y017871D01* -X024021Y017970D02* -X024098Y017970D01* -X024098Y018068D02* -X024021Y018068D01* -X024021Y018167D02* -X024098Y018167D01* -X024098Y018265D02* -X024021Y018265D01* -X024021Y018364D02* -X024098Y018364D01* -X024098Y018463D02* -X024021Y018463D01* -X024021Y018561D02* -X023499Y018561D01* -X023555Y018660D02* -X023429Y018660D01* -X023429Y018758D02* -X023555Y018758D01* -X023650Y018857D02* -X023429Y018857D01* -X023429Y018955D02* -X023748Y018955D01* -X023846Y019054D02* -X023437Y019054D01* -X023419Y019152D02* -X023747Y019152D01* -X023649Y019251D02* -X023378Y019251D01* -X023307Y019349D02* -X023555Y019349D01* -X023555Y019448D02* -X023241Y019448D01* -X023175Y019547D02* -X024021Y019547D01* -X024021Y019645D02* -X024098Y019645D01* -X024098Y019744D02* -X024021Y019744D01* -X024021Y019842D02* -X024098Y019842D01* -X024098Y019941D02* -X024021Y019941D01* -X024021Y020039D02* -X024098Y020039D01* -X024144Y020138D02* -X022781Y020138D01* -X022716Y020236D02* -X024045Y020236D01* -X023947Y020335D02* -X022679Y020335D01* -X022679Y020433D02* -X023848Y020433D01* -X023749Y020532D02* -X022679Y020532D01* -X022679Y020631D02* -X023651Y020631D01* -X023552Y020729D02* -X022679Y020729D01* -X022662Y020828D02* -X023454Y020828D01* -X023355Y020926D02* -X022564Y020926D01* -X022465Y021025D02* -X023260Y021025D01* -X023260Y021123D02* -X022366Y021123D01* -X021890Y021222D02* -X023260Y021222D01* -X023260Y021320D02* -X021816Y021320D01* -X021717Y021419D02* -X023260Y021419D01* -X023260Y021517D02* -X021619Y021517D01* -X021520Y021616D02* -X023260Y021616D01* -X023260Y021714D02* -X017126Y021714D01* -X017199Y021813D02* -X023260Y021813D01* -X023260Y021912D02* -X017199Y021912D01* -X017199Y022010D02* -X023260Y022010D01* -X023260Y022109D02* -X017199Y022109D01* -X017199Y022207D02* -X023260Y022207D01* -X023260Y022306D02* -X017199Y022306D01* -X017114Y022404D02* -X023260Y022404D01* -X023260Y022503D02* -X017015Y022503D01* -X016917Y022601D02* -X023356Y022601D01* -X023455Y022700D02* -X008154Y022700D01* -X008056Y022798D02* -X023553Y022798D01* -X023652Y022897D02* -X007957Y022897D01* -X008917Y022601D02* -X009202Y022601D01* -X009104Y022503D02* -X009015Y022503D01* -X009917Y022601D02* -X010202Y022601D01* -X010104Y022503D02* -X010015Y022503D01* -X010917Y022601D02* -X011202Y022601D01* -X011104Y022503D02* -X011015Y022503D01* -X011917Y022601D02* -X012202Y022601D01* -X012104Y022503D02* -X012015Y022503D01* -X012917Y022601D02* -X013202Y022601D01* -X013104Y022503D02* -X013015Y022503D01* -X013917Y022601D02* -X014202Y022601D01* -X014104Y022503D02* -X014015Y022503D01* -X014917Y022601D02* -X015202Y022601D01* -X015104Y022503D02* -X015015Y022503D01* -X015917Y022601D02* -X016202Y022601D01* -X016104Y022503D02* -X016015Y022503D01* -X017027Y021616D02* -X020224Y021616D01* -X020125Y021517D02* -X016929Y021517D01* -X016929Y021419D02* -X020055Y021419D01* -X019977Y021320D02* -X016929Y021320D01* -X016929Y021222D02* -X019900Y021222D01* -X019822Y021123D02* -X016929Y021123D01* -X016929Y021025D02* -X019745Y021025D01* -X019668Y020926D02* -X016929Y020926D01* -X016929Y020828D02* -X019590Y020828D01* -X019513Y020729D02* -X016929Y020729D01* -X016929Y020631D02* -X019435Y020631D01* -X019358Y020532D02* -X016929Y020532D01* -X016929Y020433D02* -X019280Y020433D01* -X019203Y020335D02* -X016929Y020335D01* -X016929Y020236D02* -X019126Y020236D01* -X018733Y020138D02* -X018386Y020138D01* -X018485Y020039D02* -X018634Y020039D01* -X017733Y020138D02* -X017386Y020138D01* -X017485Y020039D02* -X017634Y020039D01* -X021169Y017933D02* -X020601Y016770D01* -X020629Y016701D01* -X020629Y016306D01* -X020599Y016233D01* -X020599Y015874D01* -X020629Y015801D01* -X020629Y015453D01* -X020887Y015453D01* -X021428Y015839D01* -X021428Y016383D01* -X021472Y016490D01* -X021554Y016571D01* -X021660Y016615D01* -X022520Y016615D01* -X022520Y016646D01* -X022390Y016776D01* -X022390Y017331D01* -X022520Y017461D01* -X022520Y017646D01* -X022390Y017776D01* -X022390Y018205D01* -X022258Y018073D01* -X022100Y018073D01* -X022100Y018513D01* -X022100Y018593D01* -X022539Y018593D01* -X022539Y018752D01* -X022337Y018954D01* -X022543Y019161D01* -X022690Y018941D01* -X022690Y018631D01* -X022539Y018481D01* -X022539Y018513D01* -X022100Y018513D01* -X022019Y018513D01* -X022019Y018073D01* -X021861Y018073D01* -X021659Y018276D01* -X021316Y017933D01* -X021169Y017933D01* -X021138Y017871D02* -X022390Y017871D01* -X022393Y017773D02* -X021090Y017773D01* -X021042Y017674D02* -X022491Y017674D01* -X022520Y017576D02* -X020994Y017576D01* -X020946Y017477D02* -X022520Y017477D01* -X022437Y017379D02* -X020898Y017379D01* -X020850Y017280D02* -X022390Y017280D01* -X022390Y017181D02* -X020802Y017181D01* -X020754Y017083D02* -X022390Y017083D01* -X022390Y016984D02* -X020706Y016984D01* -X020658Y016886D02* -X022390Y016886D01* -X022390Y016787D02* -X020610Y016787D01* -X020629Y016689D02* -X022477Y016689D01* -X021600Y016590D02* -X020629Y016590D01* -X020629Y016492D02* -X021474Y016492D01* -X021432Y016393D02* -X020629Y016393D01* -X020625Y016295D02* -X021428Y016295D01* -X021428Y016196D02* -X020599Y016196D01* -X020599Y016098D02* -X021428Y016098D01* -X021428Y015999D02* -X020599Y015999D01* -X020599Y015900D02* -X021428Y015900D01* -X021375Y015802D02* -X020629Y015802D01* -X020629Y015703D02* -X021237Y015703D01* -X021099Y015605D02* -X020629Y015605D01* -X020629Y015506D02* -X020961Y015506D01* -X021669Y014808D02* -X021983Y015031D01* -X022529Y015031D01* -X022531Y015023D01* -X022535Y015017D01* -X022537Y015009D01* -X022582Y014945D01* -X022602Y014897D01* -X022640Y014859D01* -X022670Y014814D01* -X022715Y014784D01* -X022754Y014746D01* -X022803Y014725D01* -X022848Y014695D01* -X022896Y014685D01* -X024020Y013976D01* -X024020Y013936D01* -X024109Y013719D01* -X024275Y013553D01* -X024458Y013478D01* -X024355Y013435D01* -X024228Y013308D01* -X024160Y013143D01* -X024160Y013103D01* -X024859Y013103D01* -X024859Y013003D01* -X024160Y013003D01* -X024160Y012964D01* -X024228Y012798D01* -X024355Y012672D01* -X024458Y012629D01* -X024275Y012554D01* -X024269Y012547D01* -X024220Y012544D01* -X024207Y012557D01* -X024100Y012602D01* -X023119Y012602D01* -X023012Y012557D01* -X022931Y012476D01* -X022886Y012369D01* -X022886Y011545D01* -X022931Y011439D01* -X023012Y011357D01* -X023119Y011313D01* -X023939Y011313D01* -X024415Y010837D01* -X024415Y010536D01* -X024793Y010159D01* -X025326Y010159D01* -X025431Y010263D01* -X025688Y010263D01* -X025793Y010159D01* -X026270Y010159D01* -X026270Y005843D01* -X023010Y005843D01* -X023055Y005889D01* -X023092Y005978D01* -X023313Y005978D01* -X023313Y006503D01* -X023413Y006503D01* -X023413Y006603D01* -X023863Y006603D01* -X023863Y006809D01* -X023970Y006916D01* -X024046Y007101D01* -X024046Y007503D01* -X023594Y007503D01* -X023594Y007603D01* -X024046Y007603D01* -X024046Y008006D01* -X023970Y008191D01* -X023828Y008332D01* -X023711Y008380D01* -X024025Y008380D01* -X024132Y008424D01* -X024214Y008506D01* -X024258Y008613D01* -X024258Y009400D01* -X024288Y009431D01* -X024333Y009537D01* -X024333Y010361D01* -X024288Y010468D01* -X024207Y010550D01* -X024100Y010594D01* -X023119Y010594D01* -X023012Y010550D01* -X022931Y010468D01* -X022886Y010361D01* -X022886Y009537D01* -X022931Y009431D01* -X022969Y009392D01* -X022969Y008613D01* -X023013Y008506D01* -X023095Y008424D01* -X023201Y008380D01* -X023376Y008380D01* -X023259Y008332D01* -X023118Y008191D01* -X023041Y008006D01* -X023041Y007603D01* -X023494Y007603D01* -X023494Y007503D01* -X023041Y007503D01* -X023041Y007129D01* -X022950Y007129D01* -X022901Y007079D01* -X022867Y007093D01* -X022377Y007093D01* -X022357Y007143D01* -X022275Y007224D01* -X022218Y007248D01* -X022218Y008034D01* -X022120Y008270D01* -X022009Y008380D01* -X022018Y008380D01* -X022124Y008424D01* -X022206Y008506D01* -X022250Y008613D01* -X022250Y009594D01* -X022206Y009701D01* -X022124Y009782D01* -X022018Y009826D01* -X021194Y009826D01* -X021087Y009782D01* -X021006Y009702D01* -X020269Y009702D01* -X020162Y009657D01* -X020081Y009576D01* -X020036Y009469D01* -X020036Y008645D01* -X020081Y008539D01* -X020108Y008512D01* -X020064Y008468D01* -X020020Y008361D01* -X020020Y007746D01* -X020064Y007639D01* -X020108Y007595D01* -X020081Y007568D01* -X020036Y007461D01* -X020036Y006981D01* -X019825Y007193D01* -X019691Y007193D01* -X019529Y007578D01* -X019529Y007613D01* -X019649Y007613D01* -X019649Y008023D01* -X019690Y008023D01* -X019690Y008063D01* -X019959Y008063D01* -X019959Y008386D01* -X019872Y008473D01* -X019690Y008473D01* -X019690Y008064D01* -X019649Y008064D01* -X019649Y008473D01* -X019529Y008473D01* -X019529Y008947D01* -X019535Y008963D01* -X019529Y009020D01* -X019529Y009077D01* -X019523Y009093D01* -X019521Y009110D01* -X019495Y009161D01* -X019473Y009213D01* -X019461Y009225D01* -X018166Y011694D01* -X018167Y011694D01* -X018182Y011689D01* -X018240Y011693D01* -X018335Y011692D01* -X018457Y011570D01* -X018666Y011483D01* -X019453Y011483D01* -X019662Y011570D01* -X019701Y011608D01* -X019929Y011608D01* -X019945Y011593D01* -X020052Y011548D01* -X020727Y011548D01* -X020834Y011593D01* -X020915Y011674D01* -X020959Y011781D01* -X020959Y012176D01* -X020929Y012249D01* -X020929Y012601D01* -X020885Y012708D01* -X020819Y012773D01* -X020819Y012858D01* -X020410Y012858D01* -X020410Y012898D01* -X020819Y012898D01* -X020819Y013081D01* -X020732Y013168D01* -X020410Y013168D01* -X020410Y012899D01* -X020369Y012899D01* -X020369Y013168D01* -X020047Y013168D01* -X019960Y013081D01* -X019960Y012898D01* -X020369Y012898D01* -X020369Y012858D01* -X019960Y012858D01* -X019960Y012774D01* -X019894Y012708D01* -X019850Y012601D01* -X019850Y012348D01* -X019834Y012348D01* -X019823Y012376D01* -X019662Y012537D01* -X019453Y012623D01* -X018666Y012623D01* -X018457Y012537D01* -X018360Y012440D01* -X017891Y012848D01* -X018077Y012848D01* -X018164Y012936D01* -X018164Y013058D01* -X018245Y013139D01* -X018289Y013246D01* -X018289Y013675D01* -X018351Y013675D01* -X018457Y013570D01* -X018666Y013483D01* -X019453Y013483D01* -X019662Y013570D01* -X019823Y013730D01* -X019909Y013940D01* -X019909Y014167D01* -X019823Y014376D01* -X019662Y014537D01* -X019453Y014623D01* -X018666Y014623D01* -X018457Y014537D01* -X018335Y014415D01* -X018189Y014414D01* -X018179Y014424D01* -X018072Y014468D01* -X017397Y014468D01* -X017305Y014430D01* -X017848Y015028D01* -X019762Y015029D01* -X019860Y014933D01* -X019860Y014806D01* -X019890Y014733D01* -X019890Y014276D01* -X019934Y014169D01* -X020015Y014088D01* -X020026Y014083D01* -X020000Y014083D01* -X020000Y013901D01* -X020087Y013813D01* -X020409Y013813D01* -X020409Y014043D01* -X020450Y014043D01* -X020450Y013813D01* -X020757Y013813D01* -X021079Y013813D01* -X021079Y014023D01* -X021120Y014023D01* -X021120Y013813D01* -X021442Y013813D01* -X021529Y013901D01* -X021529Y014083D01* -X021520Y014083D01* -X021585Y014149D01* -X021629Y014256D01* -X021629Y014709D01* -X021669Y014806D01* -X021669Y014808D01* -X021681Y014816D02* -X022668Y014816D01* -X022594Y014915D02* -X021820Y014915D01* -X021958Y015014D02* -X022536Y015014D01* -X022814Y014718D02* -X021633Y014718D01* -X021629Y014619D02* -X023001Y014619D01* -X023157Y014521D02* -X021629Y014521D01* -X021629Y014422D02* -X023313Y014422D01* -X023469Y014324D02* -X021629Y014324D01* -X021617Y014225D02* -X023625Y014225D01* -X023781Y014127D02* -X021563Y014127D01* -X021529Y014028D02* -X023938Y014028D01* -X024022Y013930D02* -X022889Y013930D01* -X022931Y013887D02* -X022843Y013975D01* -X022299Y013975D01* -X022299Y013374D01* -X022200Y013374D01* -X022200Y013975D01* -X021656Y013975D01* -X021568Y013887D01* -X021568Y013373D01* -X022199Y013373D01* -X022199Y013273D01* -X021568Y013273D01* -X021568Y012759D01* -X021656Y012671D01* -X022200Y012671D01* -X022200Y013273D01* -X022299Y013273D01* -X022299Y012671D01* -X022843Y012671D01* -X022931Y012759D01* -X022931Y013273D01* -X022300Y013273D01* -X022300Y013373D01* -X022931Y013373D01* -X022931Y013887D01* -X022931Y013831D02* -X024063Y013831D01* -X024104Y013732D02* -X022931Y013732D01* -X022931Y013634D02* -X024195Y013634D01* -X024318Y013535D02* -X022931Y013535D01* -X022931Y013437D02* -X024359Y013437D01* -X024258Y013338D02* -X022300Y013338D01* -X022299Y013240D02* -X022200Y013240D01* -X022199Y013338D02* -X018289Y013338D01* -X018287Y013240D02* -X021568Y013240D01* -X021568Y013141D02* -X020759Y013141D01* -X020819Y013043D02* -X021568Y013043D01* -X021568Y012944D02* -X020819Y012944D01* -X020819Y012846D02* -X021568Y012846D01* -X021580Y012747D02* -X020846Y012747D01* -X020910Y012649D02* -X024411Y012649D01* -X024279Y012747D02* -X022919Y012747D01* -X022931Y012846D02* -X024209Y012846D01* -X024168Y012944D02* -X022931Y012944D01* -X022931Y013043D02* -X024859Y013043D01* -X024960Y013043D02* -X025469Y013043D01* -X025469Y013033D02* -X025060Y013033D01* -X025060Y013003D01* -X024960Y013003D01* -X024960Y013103D01* -X025060Y013103D01* -X025060Y013073D01* -X025469Y013073D01* -X025469Y013033D01* -X025556Y013343D02* -X025464Y013435D01* -X025361Y013478D01* -X025544Y013553D01* -X025710Y013719D01* -X025799Y013936D01* -X025799Y014171D01* -X025768Y014247D01* -X026270Y014858D01* -X026270Y013343D01* -X026080Y013343D01* -X026080Y013143D01* -X026039Y013143D01* -X026039Y013343D01* -X025832Y013343D01* -X025774Y013343D01* -X025717Y013343D01* -X025556Y013343D01* -X025460Y013437D02* -X026270Y013437D01* -X026270Y013535D02* -X025501Y013535D01* -X025624Y013634D02* -X026270Y013634D01* -X026270Y013732D02* -X025715Y013732D01* -X025756Y013831D02* -X026270Y013831D01* -X026270Y013930D02* -X025797Y013930D01* -X025799Y014028D02* -X026270Y014028D01* -X026270Y014127D02* -X025799Y014127D01* -X025777Y014225D02* -X026270Y014225D01* -X026270Y014324D02* -X025830Y014324D01* -X025911Y014422D02* -X026270Y014422D01* -X026270Y014521D02* -X025992Y014521D01* -X026073Y014619D02* -X026270Y014619D01* -X026270Y014718D02* -X026154Y014718D01* -X026235Y014816D02* -X026270Y014816D01* -X025485Y015605D02* -X023599Y015605D01* -X023619Y015506D02* -X025404Y015506D01* -X025323Y015408D02* -X023775Y015408D01* -X023931Y015309D02* -X025242Y015309D01* -X025161Y015211D02* -X024087Y015211D01* -X024244Y015112D02* -X025080Y015112D01* -X024999Y015014D02* -X024400Y015014D01* -X024556Y014915D02* -X024919Y014915D01* -X024838Y014816D02* -X024712Y014816D01* -X025520Y015703D02* -X023657Y015703D01* -X023729Y015802D02* -X025520Y015802D01* -X025520Y015900D02* -X023729Y015900D01* -X023729Y015999D02* -X024703Y015999D01* -X024506Y016196D02* -X024415Y016196D01* -X023802Y016098D02* -X023729Y016098D01* -X025416Y015999D02* -X025520Y015999D01* -X026039Y013338D02* -X026080Y013338D01* -X026080Y013240D02* -X026039Y013240D01* -X024200Y013240D02* -X022931Y013240D01* -X022931Y013141D02* -X024160Y013141D01* -X024214Y012550D02* -X024272Y012550D01* -X023005Y012550D02* -X020929Y012550D01* -X020929Y012451D02* -X022920Y012451D01* -X022886Y012353D02* -X020929Y012353D01* -X020929Y012254D02* -X022886Y012254D01* -X022886Y012156D02* -X020959Y012156D01* -X020959Y012057D02* -X022886Y012057D01* -X022886Y011959D02* -X020959Y011959D01* -X020959Y011860D02* -X022886Y011860D01* -X022886Y011762D02* -X020952Y011762D01* -X020904Y011663D02* -X022886Y011663D01* -X022886Y011565D02* -X020766Y011565D01* -X020013Y011565D02* -X019649Y011565D01* -X019832Y012353D02* -X019850Y012353D01* -X019850Y012451D02* -X019748Y012451D01* -X019850Y012550D02* -X019630Y012550D01* -X019869Y012649D02* -X018121Y012649D01* -X018008Y012747D02* -X019933Y012747D01* -X019960Y012846D02* -X017895Y012846D01* -X018164Y012944D02* -X019960Y012944D01* -X019960Y013043D02* -X018164Y013043D01* -X018246Y013141D02* -X020020Y013141D01* -X020369Y013141D02* -X020410Y013141D01* -X020410Y013043D02* -X020369Y013043D01* -X020369Y012944D02* -X020410Y012944D01* -X019824Y013732D02* -X021568Y013732D01* -X021568Y013634D02* -X019726Y013634D01* -X019578Y013535D02* -X021568Y013535D01* -X021568Y013437D02* -X018289Y013437D01* -X018289Y013535D02* -X018541Y013535D01* -X018393Y013634D02* -X018289Y013634D01* -X018342Y014422D02* -X018181Y014422D01* -X018441Y014521D02* -X017387Y014521D01* -X017477Y014619D02* -X018657Y014619D01* -X019463Y014619D02* -X019890Y014619D01* -X019890Y014521D02* -X019678Y014521D01* -X019777Y014422D02* -X019890Y014422D01* -X019890Y014324D02* -X019844Y014324D01* -X019885Y014225D02* -X019910Y014225D01* -X019909Y014127D02* -X019976Y014127D01* -X020000Y014028D02* -X019909Y014028D01* -X019905Y013930D02* -X020000Y013930D01* -X020070Y013831D02* -X019864Y013831D01* -X020409Y013831D02* -X020450Y013831D01* -X020450Y013930D02* -X020409Y013930D01* -X020409Y014028D02* -X020450Y014028D01* -X021079Y013930D02* -X021120Y013930D01* -X021120Y013831D02* -X021079Y013831D01* -X021459Y013831D02* -X021568Y013831D01* -X021529Y013930D02* -X021610Y013930D01* -X022200Y013930D02* -X022299Y013930D01* -X022299Y013831D02* -X022200Y013831D01* -X022200Y013732D02* -X022299Y013732D01* -X022299Y013634D02* -X022200Y013634D01* -X022200Y013535D02* -X022299Y013535D01* -X022299Y013437D02* -X022200Y013437D01* -X022200Y013141D02* -X022299Y013141D01* -X022299Y013043D02* -X022200Y013043D01* -X022200Y012944D02* -X022299Y012944D01* -X022299Y012846D02* -X022200Y012846D01* -X022200Y012747D02* -X022299Y012747D01* -X022919Y011466D02* -X018285Y011466D01* -X018234Y011565D02* -X018470Y011565D01* -X018364Y011663D02* -X018182Y011663D01* -X018337Y011367D02* -X023002Y011367D01* -X023083Y010579D02* -X018751Y010579D01* -X018802Y010481D02* -X022943Y010481D01* -X022895Y010382D02* -X018854Y010382D01* -X018906Y010283D02* -X022886Y010283D01* -X022886Y010185D02* -X018957Y010185D01* -X019009Y010086D02* -X022886Y010086D01* -X022886Y009988D02* -X019061Y009988D01* -X019113Y009889D02* -X022886Y009889D01* -X022886Y009791D02* -X022104Y009791D01* -X022209Y009692D02* -X022886Y009692D01* -X022886Y009594D02* -X022250Y009594D01* -X022250Y009495D02* -X022904Y009495D01* -X022965Y009397D02* -X022250Y009397D01* -X022250Y009298D02* -X022969Y009298D01* -X022969Y009199D02* -X022250Y009199D01* -X022250Y009101D02* -X022969Y009101D01* -X022969Y009002D02* -X022250Y009002D01* -X022250Y008904D02* -X022969Y008904D01* -X022969Y008805D02* -X022250Y008805D01* -X022250Y008707D02* -X022969Y008707D01* -X022971Y008608D02* -X022248Y008608D01* -X022207Y008510D02* -X023012Y008510D01* -X023127Y008411D02* -X022092Y008411D01* -X022077Y008313D02* -X023240Y008313D01* -X023141Y008214D02* -X022143Y008214D01* -X022184Y008116D02* -X023087Y008116D01* -X023046Y008017D02* -X022218Y008017D01* -X022218Y007918D02* -X023041Y007918D01* -X023041Y007820D02* -X022218Y007820D01* -X022218Y007721D02* -X023041Y007721D01* -X023041Y007623D02* -X022218Y007623D01* -X022218Y007524D02* -X023494Y007524D01* -X023594Y007524D02* -X026270Y007524D01* -X026270Y007426D02* -X024046Y007426D01* -X024046Y007327D02* -X026270Y007327D01* -X026270Y007229D02* -X024046Y007229D01* -X024046Y007130D02* -X026270Y007130D01* -X026270Y007032D02* -X024018Y007032D01* -X023977Y006933D02* -X026270Y006933D01* -X026270Y006834D02* -X023888Y006834D01* -X023863Y006736D02* -X026270Y006736D01* -X026270Y006637D02* -X023863Y006637D01* -X023863Y006503D02* -X023413Y006503D01* -X023413Y005978D01* -X023775Y005978D01* -X023863Y006066D01* -X023863Y006503D01* -X023863Y006440D02* -X026270Y006440D01* -X026270Y006342D02* -X023863Y006342D01* -X023863Y006243D02* -X026270Y006243D01* -X026270Y006145D02* -X023863Y006145D01* -X023843Y006046D02* -X026270Y006046D01* -X026270Y005948D02* -X023080Y005948D01* -X023015Y005849D02* -X026270Y005849D01* -X026270Y006539D02* -X023413Y006539D01* -X023413Y006440D02* -X023313Y006440D01* -X023313Y006342D02* -X023413Y006342D01* -X023413Y006243D02* -X023313Y006243D01* -X023313Y006145D02* -X023413Y006145D01* -X023413Y006046D02* -X023313Y006046D01* -X023041Y007130D02* -X022362Y007130D01* -X022265Y007229D02* -X023041Y007229D01* -X023041Y007327D02* -X022218Y007327D01* -X022218Y007426D02* -X023041Y007426D01* -X024001Y008116D02* -X026270Y008116D01* -X026270Y008214D02* -X023946Y008214D01* -X023848Y008313D02* -X026270Y008313D01* -X026270Y008411D02* -X024100Y008411D01* -X024215Y008510D02* -X026270Y008510D01* -X026270Y008608D02* -X024256Y008608D01* -X024258Y008707D02* -X026270Y008707D01* -X026270Y008805D02* -X024258Y008805D01* -X024258Y008904D02* -X026270Y008904D01* -X026270Y009002D02* -X024258Y009002D01* -X024258Y009101D02* -X026270Y009101D01* -X026270Y009199D02* -X024258Y009199D01* -X024258Y009298D02* -X026270Y009298D01* -X026270Y009397D02* -X024258Y009397D01* -X024315Y009495D02* -X026270Y009495D01* -X026270Y009594D02* -X024333Y009594D01* -X024333Y009692D02* -X026270Y009692D01* -X026270Y009791D02* -X024333Y009791D01* -X024333Y009889D02* -X026270Y009889D01* -X026270Y009988D02* -X024333Y009988D01* -X024333Y010086D02* -X026270Y010086D01* -X025767Y010185D02* -X025352Y010185D01* -X024767Y010185D02* -X024333Y010185D01* -X024333Y010283D02* -X024668Y010283D01* -X024570Y010382D02* -X024324Y010382D01* -X024276Y010481D02* -X024471Y010481D01* -X024415Y010579D02* -X024136Y010579D01* -X024415Y010678D02* -X018699Y010678D01* -X018647Y010776D02* -X024415Y010776D01* -X024377Y010875D02* -X018596Y010875D01* -X018544Y010973D02* -X024279Y010973D01* -X024180Y011072D02* -X018492Y011072D01* -X018441Y011170D02* -X024082Y011170D01* -X023983Y011269D02* -X018389Y011269D01* -X018347Y012451D02* -X018371Y012451D01* -X018489Y012550D02* -X018234Y012550D01* -X015994Y012047D02* -X016580Y010786D01* -X016580Y010573D01* -X016539Y010573D01* -X016539Y010793D01* -X016217Y010793D01* -X016130Y010706D01* -X016130Y010523D01* -X016149Y010523D01* -X016074Y010448D01* -X016030Y010341D01* -X016030Y010023D01* -X015517Y011403D01* -X015523Y011417D01* -X015523Y012090D01* -X015850Y012090D01* -X015994Y012047D01* -X015959Y012057D02* -X015523Y012057D01* -X015523Y011959D02* -X016035Y011959D01* -X016081Y011860D02* -X015523Y011860D01* -X015523Y011762D02* -X016126Y011762D01* -X016172Y011663D02* -X015523Y011663D01* -X015523Y011565D02* -X016218Y011565D01* -X016264Y011466D02* -X015523Y011466D01* -X015530Y011367D02* -X016309Y011367D01* -X016355Y011269D02* -X015567Y011269D01* -X015603Y011170D02* -X016401Y011170D01* -X016447Y011072D02* -X015640Y011072D01* -X015677Y010973D02* -X016492Y010973D01* -X016538Y010875D02* -X015713Y010875D01* -X015750Y010776D02* -X016200Y010776D01* -X016130Y010678D02* -X015786Y010678D01* -X015823Y010579D02* -X016130Y010579D01* -X016107Y010481D02* -X015860Y010481D01* -X015896Y010382D02* -X016046Y010382D01* -X016030Y010283D02* -X015933Y010283D01* -X015970Y010185D02* -X016030Y010185D01* -X016030Y010086D02* -X016006Y010086D01* -X016539Y010579D02* -X016580Y010579D01* -X016580Y010678D02* -X016539Y010678D01* -X016539Y010776D02* -X016580Y010776D01* -X015258Y012355D02* -X014978Y012355D01* -X014977Y012355D01* -X014975Y012355D01* -X014663Y012355D01* -X014662Y012355D01* -X014661Y012355D01* -X014348Y012355D01* -X014347Y012355D01* -X014346Y012355D01* -X014033Y012355D01* -X014032Y012355D01* -X014031Y012355D01* -X013718Y012355D01* -X013717Y012355D01* -X013716Y012355D01* -X013403Y012355D01* -X013297Y012311D01* -X013245Y012259D01* -X013192Y012311D01* -X013086Y012355D01* -X012773Y012355D01* -X012772Y012355D01* -X012771Y012355D01* -X012459Y012355D01* -X012457Y012355D01* -X012456Y012355D01* -X012144Y012355D01* -X012142Y012355D01* -X012141Y012355D01* -X011861Y012355D01* -X011861Y012635D01* -X011861Y012636D01* -X011861Y012637D01* -X011861Y012753D01* -X012316Y012753D01* -X012486Y012583D01* -X012933Y012583D01* -X013249Y012900D01* -X013249Y013347D01* -X012933Y013663D01* -X012799Y013663D01* -X012799Y013827D01* -X012483Y014143D01* -X012473Y014143D01* -X012779Y014450D01* -X012779Y014897D01* -X012463Y015213D01* -X012249Y015213D01* -X012249Y015671D01* -X012251Y015741D01* -X012249Y015744D01* -X012249Y015747D01* -X012248Y015752D01* -X012456Y015752D01* -X012457Y015752D01* -X012459Y015752D01* -X012771Y015752D01* -X012772Y015752D01* -X012773Y015752D01* -X013086Y015752D01* -X013087Y015752D01* -X013088Y015752D01* -X013401Y015752D01* -X013507Y015796D01* -X013560Y015848D01* -X013612Y015796D01* -X013718Y015752D01* -X014031Y015752D01* -X014032Y015752D01* -X014033Y015752D01* -X014346Y015752D01* -X014347Y015752D01* -X014348Y015752D01* -X014661Y015752D01* -X014662Y015752D01* -X014663Y015752D01* -X014975Y015752D01* -X014977Y015752D01* -X014978Y015752D01* -X015258Y015752D01* -X015258Y015472D01* -X015258Y015471D01* -X015258Y015469D01* -X015258Y015157D01* -X015258Y015156D01* -X015258Y015154D01* -X015258Y014842D01* -X015258Y014841D01* -X015258Y014839D01* -X015258Y014527D01* -X015258Y014526D01* -X015258Y014524D01* -X015258Y014212D01* -X015302Y014106D01* -X015354Y014053D01* -X015302Y014001D01* -X015258Y013895D01* -X015258Y013582D01* -X015258Y013581D01* -X015258Y013580D01* -X015258Y013267D01* -X015258Y013266D01* -X015258Y013265D01* -X015258Y012952D01* -X015258Y012951D01* -X015258Y012950D01* -X015258Y012637D01* -X015258Y012636D01* -X015258Y012635D01* -X015258Y012355D01* -X015258Y012451D02* -X011861Y012451D01* -X011861Y012550D02* -X015258Y012550D01* -X015258Y012649D02* -X012998Y012649D01* -X013097Y012747D02* -X015258Y012747D01* -X015258Y012846D02* -X013195Y012846D01* -X013249Y012944D02* -X015258Y012944D01* -X015258Y013043D02* -X013249Y013043D01* -X013249Y013141D02* -X015258Y013141D01* -X015258Y013240D02* -X013249Y013240D01* -X013249Y013338D02* -X015258Y013338D01* -X015258Y013437D02* -X013160Y013437D01* -X013061Y013535D02* -X015258Y013535D01* -X015258Y013634D02* -X012963Y013634D01* -X012799Y013732D02* -X015258Y013732D01* -X015258Y013831D02* -X012795Y013831D01* -X012697Y013930D02* -X015272Y013930D01* -X015329Y014028D02* -X012598Y014028D01* -X012500Y014127D02* -X015293Y014127D01* -X015258Y014225D02* -X012555Y014225D01* -X012653Y014324D02* -X015258Y014324D01* -X015258Y014422D02* -X012752Y014422D01* -X012779Y014521D02* -X015258Y014521D01* -X015258Y014619D02* -X012779Y014619D01* -X012779Y014718D02* -X015258Y014718D01* -X015258Y014816D02* -X012779Y014816D01* -X012761Y014915D02* -X015258Y014915D01* -X015258Y015014D02* -X012663Y015014D01* -X012564Y015112D02* -X015258Y015112D01* -X015258Y015211D02* -X012466Y015211D01* -X012249Y015309D02* -X015258Y015309D01* -X015258Y015408D02* -X012249Y015408D01* -X012249Y015506D02* -X015258Y015506D01* -X015258Y015605D02* -X012249Y015605D01* -X012250Y015703D02* -X015258Y015703D01* -X013606Y015802D02* -X013513Y015802D01* -X011596Y016498D02* -X010374Y017760D01* -X010373Y017763D01* -X010323Y017813D01* -X010274Y017864D01* -X010271Y017865D01* -X010269Y017867D01* -X010203Y017894D01* -X010139Y017922D01* -X010136Y017922D01* -X010133Y017923D01* -X010062Y017923D01* -X009992Y017924D01* -X009989Y017923D01* -X007095Y017923D01* -X006825Y018193D01* -X006294Y018193D01* -X005920Y017818D01* -X005920Y017288D01* -X006154Y017053D01* -X005920Y016818D01* -X005920Y016288D01* -X006154Y016053D01* -X005920Y015818D01* -X005920Y015288D01* -X006154Y015053D01* -X005920Y014818D01* -X005920Y014288D01* -X006154Y014053D01* -X005920Y013818D01* -X005920Y013288D01* -X006253Y012954D01* -X006060Y012760D01* -X006060Y012603D01* -X006509Y012603D01* -X006509Y012503D01* -X006060Y012503D01* -X006060Y012346D01* -X006253Y012152D01* -X005920Y011818D01* -X005920Y011288D01* -X006154Y011053D01* -X005920Y010818D01* -X005920Y010288D01* -X006154Y010053D01* -X005920Y009818D01* -X005920Y009288D01* -X006294Y008913D01* -X006825Y008913D01* -X007199Y009288D01* -X007199Y009818D01* -X006965Y010053D01* -X007199Y010288D01* -X007199Y010818D01* -X006965Y011053D01* -X007199Y011288D01* -X007199Y011818D01* -X006866Y012152D01* -X007059Y012346D01* -X007059Y012503D01* -X006610Y012503D01* -X006610Y012603D01* -X007059Y012603D01* -X007059Y012760D01* -X006866Y012954D01* -X007199Y013288D01* -X007199Y013818D01* -X006965Y014053D01* -X007055Y014143D01* -X007522Y014143D01* -X007630Y014035D01* -X007415Y013820D01* -X007415Y013286D01* -X007765Y012937D01* -X007580Y012752D01* -X007580Y012583D01* -X008029Y012583D01* -X008029Y012523D01* -X007580Y012523D01* -X007580Y012355D01* -X007782Y012152D01* -X007440Y011810D01* -X007440Y011297D01* -X007607Y011129D01* -X007600Y011089D01* -X007575Y011079D01* -X007494Y010998D01* -X007450Y010891D01* -X007450Y010216D01* -X007494Y010109D01* -X007575Y010028D01* -X007609Y010014D01* -X007415Y009820D01* -X007415Y009286D01* -X007793Y008909D01* -X008326Y008909D01* -X008601Y009183D01* -X008633Y009183D01* -X008729Y009223D01* -X008725Y009214D01* -X008700Y009166D01* -X008697Y009146D01* -X008690Y009127D01* -X008690Y009073D01* -X008684Y009020D01* -X008690Y009000D01* -X008690Y008141D01* -X008349Y007461D01* -X008349Y007795D01* -X007301Y008843D01* -X005818Y008843D01* -X005349Y008375D01* -X005349Y020442D01* -X005818Y019973D01* -X007301Y019973D01* -X008190Y020862D01* -X008190Y020566D01* -X008186Y020504D01* -X008190Y020492D01* -X008190Y020480D01* -X008213Y020423D01* -X008233Y020365D01* -X008241Y020355D01* -X008246Y020344D01* -X008289Y020300D01* -X011596Y016529D01* -X011596Y016498D01* -X011543Y016590D02* -X011507Y016590D01* -X011456Y016689D02* -X011411Y016689D01* -X011370Y016787D02* -X011316Y016787D01* -X011284Y016886D02* -X011221Y016886D01* -X011197Y016984D02* -X011125Y016984D01* -X011111Y017083D02* -X011030Y017083D01* -X011024Y017181D02* -X010934Y017181D01* -X010938Y017280D02* -X010839Y017280D01* -X010851Y017379D02* -X010744Y017379D01* -X010765Y017477D02* -X010648Y017477D01* -X010679Y017576D02* -X010553Y017576D01* -X010592Y017674D02* -X010457Y017674D01* -X010506Y017773D02* -X010363Y017773D01* -X010419Y017871D02* -X010259Y017871D01* -X010333Y017970D02* -X007048Y017970D01* -X006950Y018068D02* -X010247Y018068D01* -X010160Y018167D02* -X006851Y018167D01* -X006268Y018167D02* -X005349Y018167D01* -X005349Y018265D02* -X010074Y018265D01* -X009987Y018364D02* -X005349Y018364D01* -X005349Y018463D02* -X009901Y018463D01* -X009814Y018561D02* -X005349Y018561D01* -X005349Y018660D02* -X009728Y018660D01* -X009642Y018758D02* -X005349Y018758D01* -X005349Y018857D02* -X009555Y018857D01* -X009469Y018955D02* -X005349Y018955D01* -X005349Y019054D02* -X009382Y019054D01* -X009296Y019152D02* -X005349Y019152D01* -X005349Y019251D02* -X009210Y019251D01* -X009123Y019349D02* -X005349Y019349D01* -X005349Y019448D02* -X009037Y019448D01* -X008950Y019547D02* -X005349Y019547D01* -X005349Y019645D02* -X008864Y019645D01* -X008778Y019744D02* -X005349Y019744D01* -X005349Y019842D02* -X008691Y019842D01* -X008605Y019941D02* -X005349Y019941D01* -X005349Y020039D02* -X005752Y020039D01* -X005654Y020138D02* -X005349Y020138D01* -X005349Y020236D02* -X005555Y020236D01* -X005457Y020335D02* -X005349Y020335D01* -X005349Y020433D02* -X005358Y020433D01* -X007367Y020039D02* -X008518Y020039D01* -X008432Y020138D02* -X007465Y020138D01* -X007564Y020236D02* -X008345Y020236D01* -X008255Y020335D02* -X007662Y020335D01* -X007761Y020433D02* -X008209Y020433D01* -X008187Y020532D02* -X007859Y020532D01* -X007958Y020631D02* -X008190Y020631D01* -X008190Y020729D02* -X008057Y020729D01* -X008155Y020828D02* -X008190Y020828D01* -X006169Y018068D02* -X005349Y018068D01* -X005349Y017970D02* -X006071Y017970D01* -X005972Y017871D02* -X005349Y017871D01* -X005349Y017773D02* -X005920Y017773D01* -X005920Y017674D02* -X005349Y017674D01* -X005349Y017576D02* -X005920Y017576D01* -X005920Y017477D02* -X005349Y017477D01* -X005349Y017379D02* -X005920Y017379D01* -X005928Y017280D02* -X005349Y017280D01* -X005349Y017181D02* -X006026Y017181D01* -X006125Y017083D02* -X005349Y017083D01* -X005349Y016984D02* -X006085Y016984D01* -X005987Y016886D02* -X005349Y016886D01* -X005349Y016787D02* -X005920Y016787D01* -X005920Y016689D02* -X005349Y016689D01* -X005349Y016590D02* -X005920Y016590D01* -X005920Y016492D02* -X005349Y016492D01* -X005349Y016393D02* -X005920Y016393D01* -X005920Y016295D02* -X005349Y016295D01* -X005349Y016196D02* -X006012Y016196D01* -X006110Y016098D02* -X005349Y016098D01* -X005349Y015999D02* -X006100Y015999D01* -X006001Y015900D02* -X005349Y015900D01* -X005349Y015802D02* -X005920Y015802D01* -X005920Y015703D02* -X005349Y015703D01* -X005349Y015605D02* -X005920Y015605D01* -X005920Y015506D02* -X005349Y015506D01* -X005349Y015408D02* -X005920Y015408D01* -X005920Y015309D02* -X005349Y015309D01* -X005349Y015211D02* -X005997Y015211D01* -X006096Y015112D02* -X005349Y015112D01* -X005349Y015014D02* -X006115Y015014D01* -X006016Y014915D02* -X005349Y014915D01* -X005349Y014816D02* -X005920Y014816D01* -X005920Y014718D02* -X005349Y014718D01* -X005349Y014619D02* -X005920Y014619D01* -X005920Y014521D02* -X005349Y014521D01* -X005349Y014422D02* -X005920Y014422D01* -X005920Y014324D02* -X005349Y014324D01* -X005349Y014225D02* -X005983Y014225D01* -X006081Y014127D02* -X005349Y014127D01* -X005349Y014028D02* -X006129Y014028D01* -X006031Y013930D02* -X005349Y013930D01* -X005349Y013831D02* -X005932Y013831D01* -X005920Y013732D02* -X005349Y013732D01* -X005349Y013634D02* -X005920Y013634D01* -X005920Y013535D02* -X005349Y013535D01* -X005349Y013437D02* -X005920Y013437D01* -X005920Y013338D02* -X005349Y013338D01* -X005349Y013240D02* -X005968Y013240D01* -X006067Y013141D02* -X005349Y013141D01* -X005349Y013043D02* -X006165Y013043D01* -X006243Y012944D02* -X005349Y012944D01* -X005349Y012846D02* -X006145Y012846D01* -X006060Y012747D02* -X005349Y012747D01* -X005349Y012649D02* -X006060Y012649D01* -X006060Y012451D02* -X005349Y012451D01* -X005349Y012353D02* -X006060Y012353D01* -X006151Y012254D02* -X005349Y012254D01* -X005349Y012156D02* -X006250Y012156D01* -X006158Y012057D02* -X005349Y012057D01* -X005349Y011959D02* -X006060Y011959D01* -X005961Y011860D02* -X005349Y011860D01* -X005349Y011762D02* -X005920Y011762D01* -X005920Y011663D02* -X005349Y011663D01* -X005349Y011565D02* -X005920Y011565D01* -X005920Y011466D02* -X005349Y011466D01* -X005349Y011367D02* -X005920Y011367D01* -X005939Y011269D02* -X005349Y011269D01* -X005349Y011170D02* -X006037Y011170D01* -X006136Y011072D02* -X005349Y011072D01* -X005349Y010973D02* -X006074Y010973D01* -X005976Y010875D02* -X005349Y010875D01* -X005349Y010776D02* -X005920Y010776D01* -X005920Y010678D02* -X005349Y010678D01* -X005349Y010579D02* -X005920Y010579D01* -X005920Y010481D02* -X005349Y010481D01* -X005349Y010382D02* -X005920Y010382D01* -X005924Y010283D02* -X005349Y010283D01* -X005349Y010185D02* -X006023Y010185D01* -X006121Y010086D02* -X005349Y010086D01* -X005349Y009988D02* -X006089Y009988D01* -X005990Y009889D02* -X005349Y009889D01* -X005349Y009791D02* -X005920Y009791D01* -X005920Y009692D02* -X005349Y009692D01* -X005349Y009594D02* -X005920Y009594D01* -X005920Y009495D02* -X005349Y009495D01* -X005349Y009397D02* -X005920Y009397D01* -X005920Y009298D02* -X005349Y009298D01* -X005349Y009199D02* -X006008Y009199D01* -X006107Y009101D02* -X005349Y009101D01* -X005349Y009002D02* -X006205Y009002D01* -X005780Y008805D02* -X005349Y008805D01* -X005349Y008707D02* -X005682Y008707D01* -X005583Y008608D02* -X005349Y008608D01* -X005349Y008510D02* -X005484Y008510D01* -X005386Y008411D02* -X005349Y008411D01* -X005349Y008904D02* -X008690Y008904D01* -X008689Y009002D02* -X008420Y009002D01* -X008518Y009101D02* -X008690Y009101D01* -X008672Y009199D02* -X008718Y009199D01* -X008690Y008805D02* -X007339Y008805D01* -X007438Y008707D02* -X008690Y008707D01* -X008690Y008608D02* -X007536Y008608D01* -X007635Y008510D02* -X008690Y008510D01* -X008690Y008411D02* -X007733Y008411D01* -X007832Y008313D02* -X008690Y008313D01* -X008690Y008214D02* -X007930Y008214D01* -X008029Y008116D02* -X008677Y008116D01* -X008628Y008017D02* -X008127Y008017D01* -X008226Y007918D02* -X008578Y007918D01* -X008529Y007820D02* -X008324Y007820D01* -X008349Y007721D02* -X008480Y007721D01* -X008431Y007623D02* -X008349Y007623D01* -X008349Y007524D02* -X008381Y007524D01* -X007699Y009002D02* -X006914Y009002D01* -X007012Y009101D02* -X007601Y009101D01* -X007502Y009199D02* -X007111Y009199D01* -X007199Y009298D02* -X007415Y009298D01* -X007415Y009397D02* -X007199Y009397D01* -X007199Y009495D02* -X007415Y009495D01* -X007415Y009594D02* -X007199Y009594D01* -X007199Y009692D02* -X007415Y009692D01* -X007415Y009791D02* -X007199Y009791D01* -X007129Y009889D02* -X007484Y009889D01* -X007583Y009988D02* -X007030Y009988D01* -X006998Y010086D02* -X007516Y010086D01* -X007462Y010185D02* -X007096Y010185D01* -X007195Y010283D02* -X007450Y010283D01* -X007450Y010382D02* -X007199Y010382D01* -X007199Y010481D02* -X007450Y010481D01* -X007450Y010579D02* -X007199Y010579D01* -X007199Y010678D02* -X007450Y010678D01* -X007450Y010776D02* -X007199Y010776D01* -X007143Y010875D02* -X007450Y010875D01* -X007484Y010973D02* -X007045Y010973D01* -X006983Y011072D02* -X007568Y011072D01* -X007566Y011170D02* -X007082Y011170D01* -X007180Y011269D02* -X007467Y011269D01* -X007440Y011367D02* -X007199Y011367D01* -X007199Y011466D02* -X007440Y011466D01* -X007440Y011565D02* -X007199Y011565D01* -X007199Y011663D02* -X007440Y011663D01* -X007440Y011762D02* -X007199Y011762D01* -X007158Y011860D02* -X007490Y011860D01* -X007588Y011959D02* -X007059Y011959D01* -X006961Y012057D02* -X007687Y012057D01* -X007778Y012156D02* -X006869Y012156D01* -X006968Y012254D02* -X007680Y012254D01* -X007581Y012353D02* -X007059Y012353D01* -X007059Y012451D02* -X007580Y012451D01* -X007580Y012649D02* -X007059Y012649D01* -X007059Y012747D02* -X007580Y012747D01* -X007673Y012846D02* -X006974Y012846D01* -X006876Y012944D02* -X007758Y012944D01* -X007659Y013043D02* -X006954Y013043D01* -X007052Y013141D02* -X007560Y013141D01* -X007462Y013240D02* -X007151Y013240D01* -X007199Y013338D02* -X007415Y013338D01* -X007415Y013437D02* -X007199Y013437D01* -X007199Y013535D02* -X007415Y013535D01* -X007415Y013634D02* -X007199Y013634D01* -X007199Y013732D02* -X007415Y013732D01* -X007426Y013831D02* -X007187Y013831D01* -X007088Y013930D02* -X007525Y013930D01* -X007623Y014028D02* -X006990Y014028D01* -X007038Y014127D02* -X007539Y014127D01* -X007522Y014963D02* -X007055Y014963D01* -X006965Y015053D01* -X007096Y015185D01* -X007746Y015188D01* -X007522Y014963D01* -X007572Y015014D02* -X007004Y015014D01* -X007023Y015112D02* -X007671Y015112D01* -X008371Y015190D02* -X009342Y015193D01* -X009320Y015171D01* -X009320Y015020D01* -X008587Y015020D01* -X008554Y015006D01* -X008371Y015190D01* -X008448Y015112D02* -X009320Y015112D01* -X008571Y015014D02* -X008547Y015014D01* -X008029Y012550D02* -X006610Y012550D01* -X006509Y012550D02* -X005349Y012550D01* -X009049Y009520D02* -X009189Y009660D01* -X009239Y009710D01* -X009343Y009814D01* -X009399Y009950D01* -X009399Y010219D01* -X009458Y010414D01* -X009479Y010465D01* -X009479Y010484D01* -X009485Y010502D01* -X009935Y011993D01* -X010139Y011993D01* -X010139Y012223D01* -X010180Y012223D01* -X010180Y011993D01* -X010502Y011993D01* -X010589Y012081D01* -X010589Y012221D01* -X010759Y012192D01* -X010816Y012134D01* -X010923Y012090D01* -X011596Y012090D01* -X011596Y011568D01* -X009049Y009520D01* -X009123Y009594D02* -X009141Y009594D01* -X009222Y009692D02* -X009264Y009692D01* -X009320Y009791D02* -X009386Y009791D01* -X009374Y009889D02* -X009509Y009889D01* -X009399Y009988D02* -X009631Y009988D01* -X009754Y010086D02* -X009399Y010086D01* -X009399Y010185D02* -X009876Y010185D01* -X009999Y010283D02* -X009419Y010283D01* -X009449Y010382D02* -X010121Y010382D01* -X010244Y010481D02* -X009479Y010481D01* -X009485Y010502D02* -X009485Y010502D01* -X009508Y010579D02* -X010367Y010579D01* -X010489Y010678D02* -X009538Y010678D01* -X009568Y010776D02* -X010612Y010776D01* -X010734Y010875D02* -X009597Y010875D01* -X009627Y010973D02* -X010857Y010973D01* -X010979Y011072D02* -X009657Y011072D01* -X009687Y011170D02* -X011102Y011170D01* -X011224Y011269D02* -X009716Y011269D01* -X009746Y011367D02* -X011347Y011367D01* -X011469Y011466D02* -X009776Y011466D01* -X009806Y011565D02* -X011592Y011565D01* -X011596Y011663D02* -X009835Y011663D01* -X009865Y011762D02* -X011596Y011762D01* -X011596Y011860D02* -X009895Y011860D01* -X009924Y011959D02* -X011596Y011959D01* -X011596Y012057D02* -X010566Y012057D01* -X010589Y012156D02* -X010795Y012156D01* -X010180Y012156D02* -X010139Y012156D01* -X010139Y012057D02* -X010180Y012057D01* -X011861Y012649D02* -X012421Y012649D01* -X012322Y012747D02* -X011861Y012747D01* -X013091Y012353D02* -X013398Y012353D01* -X017566Y014718D02* -X019890Y014718D01* -X019860Y014816D02* -X017656Y014816D01* -X017745Y014915D02* -X019860Y014915D01* -X019778Y015014D02* -X017835Y015014D01* -X021353Y017970D02* -X022390Y017970D01* -X022390Y018068D02* -X021451Y018068D01* -X021550Y018167D02* -X021767Y018167D01* -X021669Y018265D02* -X021648Y018265D01* -X022019Y018265D02* -X022100Y018265D01* -X022100Y018167D02* -X022019Y018167D01* -X022019Y018364D02* -X022100Y018364D01* -X022100Y018463D02* -X022019Y018463D01* -X022100Y018561D02* -X022620Y018561D01* -X022690Y018660D02* -X022539Y018660D01* -X022533Y018758D02* -X022690Y018758D01* -X022690Y018857D02* -X022435Y018857D01* -X022338Y018955D02* -X022680Y018955D01* -X022614Y019054D02* -X022437Y019054D01* -X022535Y019152D02* -X022549Y019152D01* -X023110Y019645D02* -X023555Y019645D01* -X023555Y019744D02* -X023044Y019744D01* -X022978Y019842D02* -X023635Y019842D01* -X023734Y019941D02* -X022913Y019941D01* -X022847Y020039D02* -X023832Y020039D01* -X024021Y019448D02* -X024098Y019448D01* -X024098Y019349D02* -X024021Y019349D01* -X024021Y019251D02* -X024098Y019251D01* -X024098Y019152D02* -X024021Y019152D01* -X024021Y019054D02* -X024098Y019054D01* -X024098Y018955D02* -X024021Y018955D01* -X024021Y018857D02* -X024098Y018857D01* -X024098Y018758D02* -X024021Y018758D01* -X024021Y018660D02* -X024098Y018660D01* -X022390Y018167D02* -X022352Y018167D01* -X021107Y009791D02* -X019164Y009791D01* -X019216Y009692D02* -X020246Y009692D01* -X020098Y009594D02* -X019268Y009594D01* -X019319Y009495D02* -X020047Y009495D01* -X020036Y009397D02* -X019371Y009397D01* -X019423Y009298D02* -X020036Y009298D01* -X020036Y009199D02* -X019479Y009199D01* -X019522Y009101D02* -X020036Y009101D01* -X020036Y009002D02* -X019531Y009002D01* -X019529Y008904D02* -X020036Y008904D01* -X020036Y008805D02* -X019529Y008805D01* -X019529Y008707D02* -X020036Y008707D01* -X020052Y008608D02* -X019529Y008608D01* -X019529Y008510D02* -X020106Y008510D01* -X020040Y008411D02* -X019934Y008411D01* -X019959Y008313D02* -X020020Y008313D01* -X020020Y008214D02* -X019959Y008214D01* -X019959Y008116D02* -X020020Y008116D01* -X020020Y008017D02* -X019959Y008017D01* -X019959Y008023D02* -X019959Y007701D01* -X019872Y007613D01* -X019690Y007613D01* -X019690Y008023D01* -X019959Y008023D01* -X019959Y007918D02* -X020020Y007918D01* -X020020Y007820D02* -X019959Y007820D01* -X019959Y007721D02* -X020030Y007721D01* -X020080Y007623D02* -X019881Y007623D01* -X019690Y007623D02* -X019649Y007623D01* -X019649Y007721D02* -X019690Y007721D01* -X019690Y007820D02* -X019649Y007820D01* -X019649Y007918D02* -X019690Y007918D01* -X019690Y008017D02* -X019649Y008017D01* -X019649Y008116D02* -X019690Y008116D01* -X019690Y008214D02* -X019649Y008214D01* -X019649Y008313D02* -X019690Y008313D01* -X019690Y008411D02* -X019649Y008411D01* -X019552Y007524D02* -X020062Y007524D01* -X020036Y007426D02* -X019594Y007426D01* -X019635Y007327D02* -X020036Y007327D01* -X020036Y007229D02* -X019677Y007229D01* -X019888Y007130D02* -X020036Y007130D01* -X020036Y007032D02* -X019986Y007032D01* -X024046Y007623D02* -X026270Y007623D01* -X026270Y007721D02* -X024046Y007721D01* -X024046Y007820D02* -X026270Y007820D01* -X026270Y007918D02* -X024046Y007918D01* -X024042Y008017D02* -X026270Y008017D01* -D37* -X012710Y013123D03* -X012260Y013603D03* -X012240Y014673D03* -X010060Y015403D03* -D38* -X006560Y021763D03* -X006560Y007053D03* -X025050Y021763D03* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GBS b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GBS deleted file mode 100644 index 38ee70f..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GBS +++ /dev/null @@ -1,255 +0,0 @@ -G75* -G70* -%OFA0B0*% -%FSLAX24Y24*% -%IPPOS*% -%LPD*% -%AMOC8* -5,1,8,0,0,1.08239X$1,22.5* -% -%ADD10C,0.0000*% -%ADD11R,0.0631X0.0237*% -%ADD12R,0.0237X0.0631*% -%ADD13C,0.0600*% -%ADD14R,0.0600X0.0320*% -%ADD15R,0.0320X0.0600*% -%ADD16R,0.0700X0.0700*% -%ADD17OC8,0.0700*% -%ADD18C,0.0640*% -%ADD19R,0.0670X0.0512*% -%ADD20OC8,0.0740*% -%ADD21C,0.0745*% -%ADD22R,0.0741X0.0890*% -%ADD23R,0.1103X0.1044*% -%ADD24OC8,0.0749*% -%ADD25R,0.0906X0.0749*% -%ADD26R,0.0749X0.0906*% -%ADD27R,0.0631X0.0552*% -%ADD28OC8,0.0760*% -%ADD29OC8,0.0500*% -%ADD30OC8,0.3000*% -%ADD31OC8,0.3040*% -D10* -X005060Y005553D02* -X005060Y023270D01* -X026560Y023270D01* -X026560Y005553D01* -X005060Y005553D01* -D11* -X011276Y012479D03* -X011276Y012794D03* -X011276Y013109D03* -X011276Y013423D03* -X011276Y013738D03* -X011276Y014053D03* -X011276Y014368D03* -X011276Y014683D03* -X011276Y014998D03* -X011276Y015313D03* -X011276Y015628D03* -X015843Y015628D03* -X015843Y015313D03* -X015843Y014998D03* -X015843Y014683D03* -X015843Y014368D03* -X015843Y014053D03* -X015843Y013738D03* -X015843Y013423D03* -X015843Y013109D03* -X015843Y012794D03* -X015843Y012479D03* -D12* -X015134Y011770D03* -X014819Y011770D03* -X014504Y011770D03* -X014189Y011770D03* -X013874Y011770D03* -X013560Y011770D03* -X013245Y011770D03* -X012930Y011770D03* -X012615Y011770D03* -X012300Y011770D03* -X011985Y011770D03* -X011985Y016337D03* -X012300Y016337D03* -X012615Y016337D03* -X012930Y016337D03* -X013245Y016337D03* -X013560Y016337D03* -X013874Y016337D03* -X014189Y016337D03* -X014504Y016337D03* -X014819Y016337D03* -X015134Y016337D03* -D13* -X018780Y014053D02* -X019340Y014053D01* -X019340Y012053D02* -X018780Y012053D01* -D14* -X017735Y013138D03* -X017735Y014038D03* -X020060Y015603D03* -X020430Y015003D03* -X021100Y015003D03* -X021100Y014103D03* -X020430Y014103D03* -X020390Y012878D03* -X020390Y011978D03* -X016560Y010503D03* -X016560Y009603D03* -X013260Y009578D03* -X013260Y010478D03* -X010160Y012283D03* -X010160Y013183D03* -X013560Y017553D03* -X013560Y018453D03* -X020060Y016503D03* -X025490Y013053D03* -X026060Y013053D03* -X026060Y012153D03* -X025490Y012153D03* -D15* -X019670Y008043D03* -X018770Y008043D03* -X010510Y014053D03* -X010510Y014828D03* -X009610Y014828D03* -X009610Y014053D03* -X008780Y010553D03* -X007880Y010553D03* -D16* -X021060Y020553D03* -D17* -X022060Y020553D03* -X022060Y019553D03* -X022060Y018553D03* -X021060Y018553D03* -X021060Y019553D03* -X008060Y012553D03* -X008060Y011553D03* -D18* -X024610Y012053D02* -X025210Y012053D01* -X025210Y013053D02* -X024610Y013053D01* -X024610Y014053D02* -X025210Y014053D01* -D19* -X008960Y014494D03* -X008960Y013313D03* -D20* -X006560Y013553D03* -X006560Y014553D03* -X006560Y015553D03* -X006560Y016553D03* -X006560Y017553D03* -X008560Y022053D03* -X009560Y022053D03* -X010560Y022053D03* -X011560Y022053D03* -X012560Y022053D03* -X013560Y022053D03* -X014560Y022053D03* -X015560Y022053D03* -X016560Y022053D03* -X006560Y012553D03* -X006560Y011553D03* -X006560Y010553D03* -X006560Y009553D03* -X008560Y006553D03* -X009560Y006553D03* -X010560Y006553D03* -X011560Y006553D03* -X012560Y006553D03* -X013560Y006553D03* -X014560Y006553D03* -X015560Y006553D03* -X016560Y006553D03* -X017560Y006553D03* -X018560Y006553D03* -X019560Y006553D03* -D21* -X021575Y007201D02* -X021575Y007906D01* -X023544Y007906D02* -X023544Y007201D01* -D22* -X023363Y006553D03* -X021760Y006553D03* -D23* -X022250Y013323D03* -X022250Y015823D03* -D24* -X024060Y016553D03* -X025060Y016553D03* -X025060Y017553D03* -X025060Y018553D03* -X025060Y019553D03* -X024060Y019553D03* -X024060Y018553D03* -X024060Y017553D03* -X019060Y018053D03* -X018060Y018053D03* -X017060Y018053D03* -X017060Y016553D03* -X018060Y016553D03* -X019060Y016553D03* -X019060Y019553D03* -X018060Y019553D03* -X017060Y019553D03* -X025060Y010803D03* -X026060Y010803D03* -X017560Y007553D03* -X016560Y007553D03* -X015560Y007553D03* -X008060Y009553D03* -X008060Y013553D03* -D25* -X020760Y009057D03* -X020760Y007049D03* -X023610Y009949D03* -X023610Y011957D03* -D26* -X023613Y009103D03* -X021606Y009103D03* -D27* -X018290Y008698D03* -X018290Y008029D03* -X016560Y008219D03* -X016560Y008888D03* -D28* -X013060Y008803D03* -X008060Y014553D03* -X013560Y019053D03* -X021185Y016053D03* -X023060Y016053D03* -X023060Y017053D03* -X023060Y018053D03* -X026060Y017553D03* -X026060Y018553D03* -X026060Y019553D03* -X026060Y016553D03* -X021185Y013053D03* -X025060Y009553D03* -X026060Y009553D03* -X026060Y008553D03* -X026060Y007553D03* -X026060Y006553D03* -X025060Y006553D03* -X025060Y007553D03* -X025060Y008553D03* -D29* -X012710Y013123D03* -X012260Y013603D03* -X012240Y014673D03* -X010060Y015403D03* -D30* -X006560Y021763D03* -X006560Y007053D03* -X025050Y021763D03* -D31* -X025050Y021763D03* -X006560Y021763D03* -X006560Y007053D03* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTL b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTL deleted file mode 100644 index 9999720..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTL +++ /dev/null @@ -1,274 +0,0 @@ -G75* -G70* -%OFA0B0*% -%FSLAX24Y24*% -%IPPOS*% -%LPD*% -%AMOC8* -5,1,8,0,0,1.08239X$1,22.5* -% -%ADD10C,0.0000*% -%ADD11C,0.0560*% -%ADD12R,0.0660X0.0660*% -%ADD13OC8,0.0660*% -%ADD14C,0.0600*% -%ADD15OC8,0.0700*% -%ADD16C,0.0705*% -%ADD17OC8,0.0709*% -%ADD18R,0.0669X0.0394*% -%ADD19R,0.0560X0.0280*% -%ADD20R,0.0280X0.0560*% -%ADD21R,0.0591X0.0591*% -%ADD22OC8,0.0760*% -%ADD23C,0.0160*% -%ADD24C,0.0320*% -%ADD25C,0.0400*% -%ADD26C,0.0240*% -%ADD27OC8,0.0500*% -%ADD28OC8,0.3000*% -D10* -X005060Y005553D02* -X005060Y023270D01* -X026560Y023270D01* -X026560Y005553D01* -X005060Y005553D01* -D11* -X018780Y012053D02* -X019340Y012053D01* -X019340Y014053D02* -X018780Y014053D01* -D12* -X021060Y020553D03* -D13* -X022060Y020553D03* -X022060Y019553D03* -X022060Y018553D03* -X021060Y018553D03* -X021060Y019553D03* -X008060Y012553D03* -X008060Y011553D03* -D14* -X024610Y012053D02* -X025210Y012053D01* -X025210Y013053D02* -X024610Y013053D01* -X024610Y014053D02* -X025210Y014053D01* -D15* -X019560Y006553D03* -X018560Y006553D03* -X017560Y006553D03* -X016560Y006553D03* -X015560Y006553D03* -X014560Y006553D03* -X013560Y006553D03* -X012560Y006553D03* -X011560Y006553D03* -X010560Y006553D03* -X009560Y006553D03* -X008560Y006553D03* -X006560Y009553D03* -X006560Y010553D03* -X006560Y011553D03* -X006560Y012553D03* -X006560Y013553D03* -X006560Y014553D03* -X006560Y015553D03* -X006560Y016553D03* -X006560Y017553D03* -X008560Y022053D03* -X009560Y022053D03* -X010560Y022053D03* -X011560Y022053D03* -X012560Y022053D03* -X013560Y022053D03* -X014560Y022053D03* -X015560Y022053D03* -X016560Y022053D03* -D16* -X021575Y007906D02* -X021575Y007201D01* -X023544Y007201D02* -X023544Y007906D01* -D17* -X025060Y010803D03* -X026060Y010803D03* -X025060Y016553D03* -X024060Y016553D03* -X024060Y017553D03* -X025060Y017553D03* -X025060Y018553D03* -X025060Y019553D03* -X024060Y019553D03* -X024060Y018553D03* -X019060Y018053D03* -X018060Y018053D03* -X017060Y018053D03* -X017060Y016553D03* -X018060Y016553D03* -X019060Y016553D03* -X019060Y019553D03* -X018060Y019553D03* -X017060Y019553D03* -X008060Y013553D03* -X008060Y009553D03* -X015560Y007553D03* -X016560Y007553D03* -X017560Y007553D03* -D18* -X010800Y018305D03* -X010800Y019801D03* -X008319Y019801D03* -X008319Y018305D03* -D19* -X007810Y017253D03* -X007810Y016353D03* -X017060Y009503D03* -X017060Y008603D03* -X019310Y008603D03* -X019310Y009503D03* -D20* -X009510Y017053D03* -X008610Y017053D03* -D21* -X008720Y012562D03* -X008720Y011184D03* -D22* -X008060Y014553D03* -X013560Y019053D03* -X021185Y016053D03* -X023060Y016053D03* -X023060Y017053D03* -X023060Y018053D03* -X026060Y017553D03* -X026060Y018553D03* -X026060Y019553D03* -X026060Y016553D03* -X021185Y013053D03* -X025060Y009553D03* -X026060Y009553D03* -X026060Y008553D03* -X026060Y007553D03* -X026060Y006553D03* -X025060Y006553D03* -X025060Y007553D03* -X025060Y008553D03* -X013060Y008803D03* -D23* -X009540Y010623D02* -X009050Y010123D01* -X007050Y010123D01* -X006560Y010553D01* -X006560Y009553D02* -X007560Y008553D01* -X008560Y008553D01* -X009060Y008553D01* -X012710Y013123D01* -X012260Y013603D02* -X009540Y010623D01* -X009070Y010643D02* -X012240Y014673D01* -X010060Y015403D02* -X008810Y013053D01* -X007360Y013053D01* -X006560Y013553D01* -X007460Y014153D02* -X007460Y015703D01* -X007810Y016053D01* -X008485Y016053D01* -X008610Y016178D01* -X008610Y017053D01* -X007810Y017253D02* -X007810Y017546D01* -X008319Y018305D01* -X010800Y018305D01* -X010310Y017303D02* -X010060Y017053D01* -X009510Y017053D01* -X007810Y016353D02* -X007810Y016053D01* -X007460Y014153D02* -X008060Y013553D01* -X006560Y012553D02* -X005560Y013053D01* -X005560Y019502D01* -X005811Y019752D01* -X008138Y019741D01* -X008319Y019801D01* -X010800Y019801D01* -X006560Y011553D02* -X007570Y010643D01* -X009070Y010643D01* -X017060Y011053D02* -X017060Y009503D01* -X017060Y008603D02* -X017060Y008053D01* -X017560Y007553D01* -X017560Y007303D01* -X017560Y006553D01* -X019560Y006553D02* -X019310Y007553D01* -X019310Y008603D01* -X019310Y009503D02* -X019310Y011053D01* -X021185Y013053D02* -X021185Y016053D01* -D24* -X024560Y013053D02* -X024910Y013053D01* -D25* -X024560Y013053D02* -X023810Y013553D01* -X023810Y014803D01* -X024060Y015053D01* -X024060Y016553D01* -X024060Y017553D01* -X024060Y018553D01* -X024060Y019553D01* -D26* -X023060Y019553D02* -X023060Y020803D01* -X022560Y021303D01* -X022593Y021303D01* -X022560Y021303D02* -X017810Y021303D01* -X017060Y020553D01* -X013810Y020553D01* -X013560Y020303D01* -X013560Y019053D01* -X010310Y017303D02* -X008060Y014553D01* -X008060Y012553D02* -X008060Y012552D01* -X008720Y012562D01* -X008310Y011553D02* -X008060Y011553D01* -X008310Y011553D02* -X008639Y011224D01* -X008720Y011184D01* -X013060Y008803D02* -X014810Y011053D01* -X017060Y011053D01* -X019310Y011053D01* -X021310Y012303D01* -X022060Y012303D01* -X023060Y013553D01* -X023060Y015303D01* -X023060Y015553D01* -X023060Y016053D01* -X023060Y017053D02* -X022560Y017053D01* -X022310Y017303D01* -X010310Y017303D01* -X023060Y018053D02* -X023060Y019553D01* -D27* -X012710Y013123D03* -X012260Y013603D03* -X012240Y014673D03* -X010060Y015403D03* -D28* -X006560Y021763D03* -X006560Y007053D03* -X025050Y021763D03* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTO b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTO deleted file mode 100644 index 8eded07..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTO +++ /dev/null @@ -1,782 +0,0 @@ -G75* -G70* -%OFA0B0*% -%FSLAX24Y24*% -%IPPOS*% -%LPD*% -%AMOC8* -5,1,8,0,0,1.08239X$1,22.5* -% -%ADD10C,0.0000*% -%ADD11C,0.0130*% -%ADD12C,0.0100*% -%ADD13C,0.0080*% -%ADD14C,0.0160*% -D10* -X005060Y005553D02* -X005060Y023270D01* -X026560Y023270D01* -X026560Y005553D01* -X005060Y005553D01* -D11* -X012625Y011548D02* -X013005Y011928D01* -X013005Y012023D01* -X012910Y012118D01* -X012720Y012118D01* -X012625Y012023D01* -X012625Y011548D02* -X013005Y011548D01* -X013269Y011643D02* -X013269Y011833D01* -X013554Y011833D01* -X013649Y011738D01* -X013649Y011643D01* -X013554Y011548D01* -X013364Y011548D01* -X013269Y011643D01* -X013269Y011833D02* -X013459Y012023D01* -X013649Y012118D01* -X013914Y011548D02* -X014294Y012118D01* -X014558Y012023D02* -X014653Y012118D01* -X014843Y012118D01* -X014938Y012023D01* -X014558Y011643D01* -X014653Y011548D01* -X014843Y011548D01* -X014938Y011643D01* -X014938Y012023D01* -X015203Y011928D02* -X015393Y012118D01* -X015393Y011548D01* -X015203Y011548D02* -X015583Y011548D01* -X015847Y011548D02* -X016227Y012118D01* -X016492Y011928D02* -X016682Y012118D01* -X016682Y011548D01* -X016492Y011548D02* -X016872Y011548D01* -X017136Y011643D02* -X017231Y011548D01* -X017421Y011548D01* -X017517Y011643D01* -X017517Y012023D01* -X017421Y012118D01* -X017231Y012118D01* -X017136Y012023D01* -X017136Y011928D01* -X017231Y011833D01* -X017517Y011833D01* -X014558Y011643D02* -X014558Y012023D01* -X014566Y020618D02* -X014376Y020618D01* -X014281Y020713D01* -X014281Y020809D01* -X014376Y020904D01* -X014566Y020904D01* -X014661Y020809D01* -X014661Y020713D01* -X014566Y020618D01* -X014566Y020904D02* -X014661Y020999D01* -X014661Y021094D01* -X014566Y021189D01* -X014376Y021189D01* -X014281Y021094D01* -X014281Y020999D01* -X014376Y020904D01* -X014017Y020999D02* -X014017Y021094D01* -X013921Y021189D01* -X013731Y021189D01* -X013636Y021094D01* -X013182Y021189D02* -X013182Y020618D01* -X012992Y020618D02* -X013372Y020618D01* -X013636Y020618D02* -X014017Y020999D01* -X014017Y020618D02* -X013636Y020618D01* -X013182Y021189D02* -X012992Y020999D01* -X012727Y021189D02* -X012727Y020618D01* -X012347Y020618D02* -X012347Y021189D01* -X012537Y020999D01* -X012727Y021189D01* -X012083Y021189D02* -X011703Y020618D01* -X011343Y020618D02* -X011343Y021189D01* -X011058Y020904D01* -X011438Y020904D01* -X010794Y020904D02* -X010414Y020904D01* -X010699Y021189D01* -X010699Y020618D01* -X010149Y020713D02* -X010054Y020618D01* -X009864Y020618D01* -X009769Y020713D01* -X009769Y020904D01* -X010054Y020904D01* -X010149Y020809D01* -X010149Y020713D01* -X009959Y021094D02* -X009769Y020904D01* -X009959Y021094D02* -X010149Y021189D01* -X009505Y021189D02* -X009505Y020618D01* -X009125Y020618D02* -X009125Y021189D01* -X009315Y020999D01* -X009505Y021189D01* -X014925Y020904D02* -X015306Y020904D01* -X015211Y021189D02* -X015211Y020618D01* -X014925Y020904D02* -X015211Y021189D01* -X016214Y020999D02* -X016404Y020618D01* -X016595Y020999D01* -X016859Y020999D02* -X017049Y021189D01* -X017049Y020618D01* -X016859Y020618D02* -X017239Y020618D01* -X017503Y020618D02* -X017503Y020713D01* -X017598Y020713D01* -X017598Y020618D01* -X017503Y020618D01* -X017826Y020618D02* -X018206Y020999D01* -X018206Y021094D01* -X018111Y021189D01* -X017921Y021189D01* -X017826Y021094D01* -X017826Y020618D02* -X018206Y020618D01* -X018470Y020713D02* -X018470Y020904D01* -X018565Y020999D01* -X018850Y020999D01* -X018850Y021189D02* -X018850Y020618D01* -X018565Y020618D01* -X018470Y020713D01* -D12* -X020060Y020303D02* -X020060Y022303D01* -X022560Y022303D01* -X022560Y016803D01* -X020060Y016803D01* -X020060Y018803D01* -X020560Y018803D01* -X020560Y020303D01* -X020060Y020303D01* -X020060Y018803D01* -X023453Y015727D02* -X023453Y015420D01* -X023529Y015343D01* -X023683Y015343D01* -X023760Y015420D01* -X023760Y015574D01* -X023606Y015574D01* -X023453Y015727D02* -X023529Y015804D01* -X023683Y015804D01* -X023760Y015727D01* -X023968Y015804D02* -X024275Y015343D01* -X024275Y015804D01* -X024484Y015804D02* -X024484Y015343D01* -X024714Y015343D01* -X024791Y015420D01* -X024791Y015727D01* -X024714Y015804D01* -X024484Y015804D01* -X023968Y015804D02* -X023968Y015343D01* -X025043Y015594D02* -X025350Y015594D01* -X025558Y015594D02* -X025558Y015824D01* -X025865Y015824D01* -X025788Y015670D02* -X025865Y015594D01* -X025865Y015440D01* -X025788Y015363D01* -X025635Y015363D01* -X025558Y015440D01* -X025558Y015594D02* -X025712Y015670D01* -X025788Y015670D01* -X026074Y015517D02* -X026227Y015363D01* -X026381Y015517D01* -X026381Y015824D01* -X026074Y015824D02* -X026074Y015517D01* -X025196Y015440D02* -X025196Y015747D01* -X024308Y010664D02* -X024308Y010357D01* -X024154Y010203D01* -X024001Y010357D01* -X024001Y010664D01* -X023792Y010587D02* -X023715Y010664D01* -X023562Y010664D01* -X023485Y010587D01* -X023485Y010510D01* -X023562Y010434D01* -X023792Y010434D01* -X023792Y010587D02* -X023792Y010280D01* -X023715Y010203D01* -X023562Y010203D01* -X023485Y010280D01* -X023276Y010434D02* -X022970Y010434D01* -X023123Y010587D02* -X023123Y010280D01* -X023296Y009764D02* -X023220Y009687D01* -X023220Y009380D01* -X023296Y009303D01* -X023450Y009303D01* -X023526Y009380D01* -X023526Y009534D01* -X023373Y009534D01* -X023526Y009687D02* -X023450Y009764D01* -X023296Y009764D01* -X023735Y009764D02* -X023735Y009303D01* -X024042Y009303D02* -X023735Y009764D01* -X024042Y009764D02* -X024042Y009303D01* -X024251Y009303D02* -X024481Y009303D01* -X024558Y009380D01* -X024558Y009687D01* -X024481Y009764D01* -X024251Y009764D01* -X024251Y009303D01* -X024510Y006403D02* -X024510Y005703D01* -X020560Y005703D01* -X020560Y006453D01* -X020140Y008272D02* -X019833Y008272D01* -X019986Y008272D02* -X019833Y008426D01* -X019833Y008503D01* -X019833Y008702D02* -X020140Y009009D01* -X020063Y009218D02* -X019756Y009525D01* -X020063Y009525D01* -X020140Y009448D01* -X020140Y009294D01* -X020063Y009218D01* -X019756Y009218D01* -X019679Y009294D01* -X019679Y009448D01* -X019756Y009525D01* -X019833Y009009D02* -X020140Y008702D01* -X018760Y008552D02* -X018453Y008859D01* -X018376Y009068D02* -X018299Y009144D01* -X018299Y009298D01* -X018376Y009375D01* -X018683Y009068D01* -X018760Y009144D01* -X018760Y009298D01* -X018683Y009375D01* -X018376Y009375D01* -X018376Y009068D02* -X018683Y009068D01* -X018760Y008859D02* -X018453Y008552D01* -X018453Y008362D02* -X018453Y008208D01* -X018376Y008285D02* -X018683Y008285D01* -X018760Y008362D01* -X017880Y008283D02* -X017573Y008283D01* -X017726Y008283D02* -X017573Y008437D01* -X017573Y008514D01* -X017573Y008713D02* -X017880Y009020D01* -X017880Y009229D02* -X017880Y009536D01* -X017880Y009382D02* -X017419Y009382D01* -X017573Y009229D01* -X017573Y009020D02* -X017880Y008713D01* -X016640Y008642D02* -X016333Y008949D01* -X016333Y009158D02* -X016179Y009311D01* -X016640Y009311D01* -X016640Y009158D02* -X016640Y009465D01* -X016640Y008949D02* -X016333Y008642D01* -X016333Y008452D02* -X016333Y008298D01* -X016256Y008375D02* -X016563Y008375D01* -X016640Y008452D01* -X015720Y008554D02* -X015413Y008247D01* -X015720Y008247D02* -X015413Y008554D01* -X015489Y008762D02* -X015643Y008762D01* -X015720Y008839D01* -X015720Y009069D01* -X015720Y009278D02* -X015259Y009278D01* -X015413Y009069D02* -X015413Y008839D01* -X015489Y008762D01* -X015566Y009278D02* -X015413Y009508D01* -X015413Y009708D02* -X015259Y009861D01* -X015720Y009861D01* -X015720Y009708D02* -X015720Y010015D01* -X015720Y009508D02* -X015566Y009278D01* -X011680Y008568D02* -X011680Y008415D01* -X011680Y008491D02* -X011219Y008491D01* -X011219Y008415D01* -X011373Y008206D02* -X011373Y007976D01* -X011449Y007899D01* -X011603Y007899D01* -X011680Y007976D01* -X011680Y008206D01* -X011603Y007690D02* -X011526Y007614D01* -X011526Y007460D01* -X011449Y007383D01* -X011373Y007460D01* -X011373Y007690D01* -X011603Y007690D02* -X011680Y007614D01* -X011680Y007383D01* -X010650Y007276D02* -X010650Y007507D01* -X010573Y007583D01* -X010496Y007507D01* -X010496Y007353D01* -X010419Y007276D01* -X010343Y007353D01* -X010343Y007583D01* -X010419Y007792D02* -X010343Y007869D01* -X010343Y008099D01* -X010189Y008099D02* -X010650Y008099D01* -X010650Y007869D01* -X010573Y007792D01* -X010419Y007792D01* -X010573Y008308D02* -X010496Y008384D01* -X010496Y008615D01* -X010419Y008615D02* -X010650Y008615D01* -X010650Y008384D01* -X010573Y008308D01* -X010343Y008384D02* -X010343Y008538D01* -X010419Y008615D01* -X009700Y009393D02* -X009700Y009700D01* -X009700Y009909D02* -X009239Y009909D01* -X009239Y010216D01* -X009239Y010425D02* -X009239Y010655D01* -X009316Y010732D01* -X009623Y010732D01* -X009700Y010655D01* -X009700Y010425D01* -X009239Y010425D01* -X009700Y010216D02* -X009700Y009909D01* -X009469Y009909D02* -X009469Y010062D01* -X009239Y009393D02* -X009700Y009393D01* -X009700Y010940D02* -X009239Y011247D01* -X009239Y011456D02* -X009239Y011686D01* -X009316Y011763D01* -X009469Y011763D01* -X009546Y011686D01* -X009546Y011456D01* -X009700Y011456D02* -X009239Y011456D01* -X009316Y011972D02* -X009623Y011972D01* -X009700Y012048D01* -X009700Y012202D01* -X009623Y012278D01* -X009469Y012487D02* -X009469Y012794D01* -X009239Y012717D02* -X009469Y012487D01* -X009316Y012278D02* -X009239Y012202D01* -X009239Y012048D01* -X009316Y011972D01* -X009239Y012717D02* -X009700Y012717D01* -X009243Y013194D02* -X009320Y013271D01* -X009320Y013424D01* -X009243Y013501D01* -X009166Y013501D01* -X009089Y013424D01* -X009089Y013271D01* -X009013Y013194D01* -X008936Y013194D01* -X008859Y013271D01* -X008859Y013424D01* -X008936Y013501D01* -X008859Y013710D02* -X009320Y013710D01* -X009166Y013863D01* -X009320Y014016D01* -X008859Y014016D01* -X009013Y014225D02* -X008859Y014379D01* -X009320Y014379D01* -X009320Y014532D02* -X009320Y014225D01* -X009320Y014741D02* -X008859Y015048D01* -X008859Y015256D02* -X008859Y015487D01* -X008936Y015563D01* -X009089Y015563D01* -X009166Y015487D01* -X009166Y015256D01* -X009320Y015256D02* -X008859Y015256D01* -X008936Y015772D02* -X009243Y015772D01* -X009320Y015849D01* -X009320Y016002D01* -X009243Y016079D01* -X009243Y016288D02* -X009320Y016364D01* -X009320Y016518D01* -X009243Y016595D01* -X009089Y016595D01* -X009013Y016518D01* -X009013Y016441D01* -X009089Y016288D01* -X008859Y016288D01* -X008859Y016595D01* -X008936Y016079D02* -X008859Y016002D01* -X008859Y015849D01* -X008936Y015772D01* -X005810Y013225D02* -X005733Y013302D01* -X005426Y013302D01* -X005349Y013225D01* -X005349Y012995D01* -X005810Y012995D01* -X005810Y013225D01* -X005810Y012786D02* -X005349Y012786D01* -X005349Y012479D02* -X005810Y012786D01* -X005810Y012479D02* -X005349Y012479D01* -X005426Y012270D02* -X005349Y012194D01* -X005349Y012040D01* -X005426Y011963D01* -X005733Y011963D01* -X005810Y012040D01* -X005810Y012194D01* -X005733Y012270D01* -X005579Y012270D01* -X005579Y012117D01* -X012443Y018457D02* -X012750Y018764D01* -X012673Y018972D02* -X012750Y019049D01* -X012750Y019279D01* -X012750Y019488D02* -X012289Y019488D01* -X012443Y019279D02* -X012443Y019049D01* -X012519Y018972D01* -X012673Y018972D01* -X012443Y018764D02* -X012750Y018457D01* -X012596Y019488D02* -X012443Y019718D01* -X012366Y019918D02* -X012289Y019994D01* -X012289Y020148D01* -X012366Y020225D01* -X012673Y019918D01* -X012750Y019994D01* -X012750Y020148D01* -X012673Y020225D01* -X012366Y020225D01* -X012366Y019918D02* -X012673Y019918D01* -X012750Y019718D02* -X012596Y019488D01* -X014359Y019304D02* -X014359Y018843D01* -X014666Y018843D02* -X014666Y019304D01* -X014512Y019150D01* -X014359Y019304D01* -X014874Y019227D02* -X014874Y018920D01* -X014951Y018843D01* -X015105Y018843D01* -X015181Y018920D01* -X015181Y019227D01* -X015105Y019304D01* -X014951Y019304D01* -X014874Y019227D01* -X015390Y019227D02* -X015390Y019150D01* -X015467Y019074D01* -X015620Y019074D01* -X015697Y018997D01* -X015697Y018920D01* -X015620Y018843D01* -X015467Y018843D01* -X015390Y018920D01* -X015390Y019227D02* -X015467Y019304D01* -X015620Y019304D01* -X015697Y019227D01* -X015906Y019304D02* -X016059Y019304D01* -X015982Y019304D02* -X015982Y018843D01* -X015906Y018843D02* -X016059Y018843D01* -X015964Y017804D02* -X015811Y017804D01* -X015734Y017727D01* -X015734Y017420D01* -X015811Y017343D01* -X015964Y017343D01* -X016041Y017420D01* -X016041Y017727D01* -X015964Y017804D01* -X015525Y017727D02* -X015448Y017804D01* -X015295Y017804D01* -X015218Y017727D01* -X015218Y017650D01* -X015295Y017574D01* -X015448Y017574D01* -X015525Y017497D01* -X015525Y017420D01* -X015448Y017343D01* -X015295Y017343D01* -X015218Y017420D01* -X015028Y017343D02* -X014874Y017343D01* -X014951Y017343D02* -X014951Y017804D01* -X014874Y017804D02* -X015028Y017804D01* -X014666Y017804D02* -X014666Y017343D01* -X014359Y017343D02* -X014359Y017804D01* -X014512Y017650D01* -X014666Y017804D01* -X014779Y016804D02* -X014703Y016727D01* -X014703Y016650D01* -X014779Y016574D01* -X014933Y016574D01* -X015010Y016497D01* -X015010Y016420D01* -X014933Y016343D01* -X014779Y016343D01* -X014703Y016420D01* -X014779Y016804D02* -X014933Y016804D01* -X015010Y016727D01* -X015218Y016727D02* -X015218Y016420D01* -X015295Y016343D01* -X015448Y016343D01* -X015525Y016420D01* -X015734Y016343D02* -X015734Y016804D01* -X015525Y016727D02* -X015448Y016804D01* -X015295Y016804D01* -X015218Y016727D01* -X015734Y016497D02* -X016041Y016804D01* -X015811Y016574D02* -X016041Y016343D01* -D13* -X005830Y014988D02* -X005669Y014828D01* -X005349Y014828D01* -X005349Y014632D02* -X005349Y014312D01* -X005589Y014312D01* -X005509Y014472D01* -X005509Y014552D01* -X005589Y014632D01* -X005749Y014632D01* -X005830Y014552D01* -X005830Y014392D01* -X005749Y014312D01* -X005589Y014117D02* -X005589Y013796D01* -X005429Y013957D02* -X005749Y013957D01* -X005830Y014988D02* -X005669Y015148D01* -X005349Y015148D01* -D14* -X019110Y021853D02* -X019112Y021884D01* -X019118Y021915D01* -X019128Y021945D01* -X019141Y021973D01* -X019158Y022000D01* -X019178Y022024D01* -X019201Y022046D01* -X019226Y022064D01* -X019254Y022079D01* -X019283Y022091D01* -X019313Y022099D01* -X019344Y022103D01* -X019376Y022103D01* -X019407Y022099D01* -X019437Y022091D01* -X019466Y022079D01* -X019494Y022064D01* -X019519Y022046D01* -X019542Y022024D01* -X019562Y022000D01* -X019579Y021973D01* -X019592Y021945D01* -X019602Y021915D01* -X019608Y021884D01* -X019610Y021853D01* -X019608Y021822D01* -X019602Y021791D01* -X019592Y021761D01* -X019579Y021733D01* -X019562Y021706D01* -X019542Y021682D01* -X019519Y021660D01* -X019494Y021642D01* -X019466Y021627D01* -X019437Y021615D01* -X019407Y021607D01* -X019376Y021603D01* -X019344Y021603D01* -X019313Y021607D01* -X019283Y021615D01* -X019254Y021627D01* -X019226Y021642D01* -X019201Y021660D01* -X019178Y021682D01* -X019158Y021706D01* -X019141Y021733D01* -X019128Y021761D01* -X019118Y021791D01* -X019112Y021822D01* -X019110Y021853D01* -X025660Y011603D02* -X025662Y011634D01* -X025668Y011665D01* -X025678Y011695D01* -X025691Y011723D01* -X025708Y011750D01* -X025728Y011774D01* -X025751Y011796D01* -X025776Y011814D01* -X025804Y011829D01* -X025833Y011841D01* -X025863Y011849D01* -X025894Y011853D01* -X025926Y011853D01* -X025957Y011849D01* -X025987Y011841D01* -X026016Y011829D01* -X026044Y011814D01* -X026069Y011796D01* -X026092Y011774D01* -X026112Y011750D01* -X026129Y011723D01* -X026142Y011695D01* -X026152Y011665D01* -X026158Y011634D01* -X026160Y011603D01* -X026158Y011572D01* -X026152Y011541D01* -X026142Y011511D01* -X026129Y011483D01* -X026112Y011456D01* -X026092Y011432D01* -X026069Y011410D01* -X026044Y011392D01* -X026016Y011377D01* -X025987Y011365D01* -X025957Y011357D01* -X025926Y011353D01* -X025894Y011353D01* -X025863Y011357D01* -X025833Y011365D01* -X025804Y011377D01* -X025776Y011392D01* -X025751Y011410D01* -X025728Y011432D01* -X025708Y011456D01* -X025691Y011483D01* -X025678Y011511D01* -X025668Y011541D01* -X025662Y011572D01* -X025660Y011603D01* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTS b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTS deleted file mode 100644 index 8f22c11..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.GTS +++ /dev/null @@ -1,167 +0,0 @@ -G75* -G70* -%OFA0B0*% -%FSLAX24Y24*% -%IPPOS*% -%LPD*% -%AMOC8* -5,1,8,0,0,1.08239X$1,22.5* -% -%ADD10C,0.0000*% -%ADD11C,0.0600*% -%ADD12R,0.0700X0.0700*% -%ADD13OC8,0.0700*% -%ADD14C,0.0640*% -%ADD15OC8,0.0740*% -%ADD16C,0.0745*% -%ADD17OC8,0.0749*% -%ADD18R,0.0709X0.0434*% -%ADD19R,0.0600X0.0320*% -%ADD20R,0.0320X0.0600*% -%ADD21R,0.0631X0.0631*% -%ADD22OC8,0.0760*% -%ADD23OC8,0.0500*% -%ADD24OC8,0.3000*% -%ADD25OC8,0.3040*% -D10* -X005060Y005553D02* -X005060Y023270D01* -X026560Y023270D01* -X026560Y005553D01* -X005060Y005553D01* -D11* -X018780Y012053D02* -X019340Y012053D01* -X019340Y014053D02* -X018780Y014053D01* -D12* -X021060Y020553D03* -D13* -X022060Y020553D03* -X022060Y019553D03* -X022060Y018553D03* -X021060Y018553D03* -X021060Y019553D03* -X008060Y012553D03* -X008060Y011553D03* -D14* -X024610Y012053D02* -X025210Y012053D01* -X025210Y013053D02* -X024610Y013053D01* -X024610Y014053D02* -X025210Y014053D01* -D15* -X019560Y006553D03* -X018560Y006553D03* -X017560Y006553D03* -X016560Y006553D03* -X015560Y006553D03* -X014560Y006553D03* -X013560Y006553D03* -X012560Y006553D03* -X011560Y006553D03* -X010560Y006553D03* -X009560Y006553D03* -X008560Y006553D03* -X006560Y009553D03* -X006560Y010553D03* -X006560Y011553D03* -X006560Y012553D03* -X006560Y013553D03* -X006560Y014553D03* -X006560Y015553D03* -X006560Y016553D03* -X006560Y017553D03* -X008560Y022053D03* -X009560Y022053D03* -X010560Y022053D03* -X011560Y022053D03* -X012560Y022053D03* -X013560Y022053D03* -X014560Y022053D03* -X015560Y022053D03* -X016560Y022053D03* -D16* -X021575Y007906D02* -X021575Y007201D01* -X023544Y007201D02* -X023544Y007906D01* -D17* -X025060Y010803D03* -X026060Y010803D03* -X025060Y016553D03* -X024060Y016553D03* -X024060Y017553D03* -X025060Y017553D03* -X025060Y018553D03* -X025060Y019553D03* -X024060Y019553D03* -X024060Y018553D03* -X019060Y018053D03* -X018060Y018053D03* -X017060Y018053D03* -X017060Y016553D03* -X018060Y016553D03* -X019060Y016553D03* -X019060Y019553D03* -X018060Y019553D03* -X017060Y019553D03* -X008060Y013553D03* -X008060Y009553D03* -X015560Y007553D03* -X016560Y007553D03* -X017560Y007553D03* -D18* -X010800Y018305D03* -X010800Y019801D03* -X008319Y019801D03* -X008319Y018305D03* -D19* -X007810Y017253D03* -X007810Y016353D03* -X017060Y009503D03* -X017060Y008603D03* -X019310Y008603D03* -X019310Y009503D03* -D20* -X009510Y017053D03* -X008610Y017053D03* -D21* -X008720Y012562D03* -X008720Y011184D03* -D22* -X008060Y014553D03* -X013560Y019053D03* -X021185Y016053D03* -X023060Y016053D03* -X023060Y017053D03* -X023060Y018053D03* -X026060Y017553D03* -X026060Y018553D03* -X026060Y019553D03* -X026060Y016553D03* -X021185Y013053D03* -X025060Y009553D03* -X026060Y009553D03* -X026060Y008553D03* -X026060Y007553D03* -X026060Y006553D03* -X025060Y006553D03* -X025060Y007553D03* -X025060Y008553D03* -X013060Y008803D03* -D23* -X012710Y013123D03* -X012260Y013603D03* -X012240Y014673D03* -X010060Y015403D03* -D24* -X006560Y021763D03* -X006560Y007053D03* -X025050Y021763D03* -D25* -X025050Y021763D03* -X006560Y021763D03* -X006560Y007053D03* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.TXT b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.TXT deleted file mode 100644 index f51185e..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.TXT +++ /dev/null @@ -1,117 +0,0 @@ -% -M48 -M72 -T01C0.0236 -T02C0.0276 -T03C0.0320 -T04C0.0354 -T05C0.0360 -T06C0.0400 -T07C0.0470 -T08C0.1260 -% -T01 -X5000Y9850 -X7180Y9120 -X7200Y8050 -X7650Y7570 -T02 -X14000Y6500 -X14000Y8500 -X16125Y7500 -X16125Y10500 -X8500Y13500 -X8000Y3250 -X3000Y9000 -X18000Y10500 -X18000Y11500 -X18000Y12500 -T03 -X3000Y6000 -X3000Y7000 -T04 -X12000Y11000 -X13000Y11000 -X13000Y12500 -X12000Y12500 -X12000Y14000 -X13000Y14000 -X14000Y11000 -X14000Y12500 -X14000Y14000 -X20000Y14000 -X20000Y13000 -X20000Y12000 -X20000Y11000 -X19000Y14000 -X19000Y13000 -X19000Y12000 -X19000Y11000 -X12500Y2000 -X11500Y2000 -X10500Y2000 -X3000Y8000 -X3000Y4000 -X20000Y5250 -X21000Y5250 -X21000Y3000 -X21000Y2000 -X21000Y1000 -X21000Y4000 -X20000Y1000 -X20000Y2000 -X20000Y3000 -X20000Y4000 -X21000Y13000 -X21000Y12000 -X21000Y11000 -X21000Y14000 -T05 -X16000Y15000 -X17000Y15000 -X16000Y14000 -X17000Y14000 -X16000Y13000 -X17000Y13000 -T06 -X19850Y6500 -X19850Y7500 -X19850Y8500 -X11500Y16500 -X10500Y16500 -X9500Y16500 -X8500Y16500 -X7500Y16500 -X6500Y16500 -X5500Y16500 -X4500Y16500 -X3500Y16500 -X1500Y12000 -X1500Y11000 -X1500Y10000 -X1500Y9000 -X1500Y8000 -X1500Y7000 -X1500Y6000 -X1500Y5000 -X1500Y4000 -X14500Y1000 -X13500Y1000 -X12500Y1000 -X11500Y1000 -X10500Y1000 -X9500Y1000 -X8500Y1000 -X7500Y1000 -X6500Y1000 -X5500Y1000 -X4500Y1000 -X3500Y1000 -T07 -X18484Y2000 -X16516Y2000 -T08 -X1500Y16210 -X1500Y1500 -X19990Y16210 -M30 diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.do b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.do deleted file mode 100644 index 399a566..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.do +++ /dev/null @@ -1,3502 +0,0 @@ -G75* -G70* -%OFA0B0*% -%FSLAX24Y24*% -%IPPOS*% -%LPD*% -%AMOC8* -5,1,8,0,0,1.08239X$1,22.5* -% -%ADD10C,0.0000*% -%ADD11C,0.0010*% -D10* -X005060Y005553D02* -X005060Y023270D01* -X026560Y023270D01* -X026560Y005553D01* -X005060Y005553D01* -D11* -X006160Y007053D02* -X006960Y007053D01* -X006560Y006653D02* -X006560Y007453D01* -X006170Y007053D02* -X006172Y007092D01* -X006178Y007130D01* -X006187Y007168D01* -X006201Y007204D01* -X006217Y007240D01* -X006238Y007273D01* -X006261Y007304D01* -X006288Y007332D01* -X006317Y007358D01* -X006348Y007381D01* -X006382Y007400D01* -X006418Y007416D01* -X006454Y007428D01* -X006492Y007437D01* -X006531Y007442D01* -X006570Y007443D01* -X006608Y007440D01* -X006647Y007433D01* -X006684Y007423D01* -X006720Y007408D01* -X006755Y007391D01* -X006788Y007370D01* -X006818Y007345D01* -X006846Y007318D01* -X006871Y007288D01* -X006893Y007256D01* -X006911Y007222D01* -X006926Y007186D01* -X006938Y007149D01* -X006946Y007111D01* -X006950Y007072D01* -X006950Y007034D01* -X006946Y006995D01* -X006938Y006957D01* -X006926Y006920D01* -X006911Y006884D01* -X006893Y006850D01* -X006871Y006818D01* -X006846Y006788D01* -X006818Y006761D01* -X006788Y006736D01* -X006755Y006715D01* -X006720Y006698D01* -X006684Y006683D01* -X006647Y006673D01* -X006608Y006666D01* -X006570Y006663D01* -X006531Y006664D01* -X006492Y006669D01* -X006454Y006678D01* -X006418Y006690D01* -X006382Y006706D01* -X006348Y006725D01* -X006317Y006748D01* -X006288Y006774D01* -X006261Y006802D01* -X006238Y006833D01* -X006217Y006866D01* -X006201Y006902D01* -X006187Y006938D01* -X006178Y006976D01* -X006172Y007014D01* -X006170Y007053D01* -X006365Y007053D02* -X006367Y007081D01* -X006373Y007108D01* -X006383Y007134D01* -X006396Y007158D01* -X006413Y007181D01* -X006432Y007200D01* -X006455Y007217D01* -X006479Y007230D01* -X006505Y007240D01* -X006532Y007246D01* -X006560Y007248D01* -X006588Y007246D01* -X006615Y007240D01* -X006641Y007230D01* -X006665Y007217D01* -X006688Y007200D01* -X006707Y007181D01* -X006724Y007158D01* -X006737Y007134D01* -X006747Y007108D01* -X006753Y007081D01* -X006755Y007053D01* -X006753Y007025D01* -X006747Y006998D01* -X006737Y006972D01* -X006724Y006948D01* -X006707Y006925D01* -X006688Y006906D01* -X006665Y006889D01* -X006641Y006876D01* -X006615Y006866D01* -X006588Y006860D01* -X006560Y006858D01* -X006532Y006860D01* -X006505Y006866D01* -X006479Y006876D01* -X006455Y006889D01* -X006432Y006906D01* -X006413Y006925D01* -X006396Y006948D01* -X006383Y006972D01* -X006373Y006998D01* -X006367Y007025D01* -X006365Y007053D01* -X008170Y006553D02* -X008172Y006592D01* -X008178Y006630D01* -X008187Y006668D01* -X008201Y006704D01* -X008217Y006740D01* -X008238Y006773D01* -X008261Y006804D01* -X008288Y006832D01* -X008317Y006858D01* -X008348Y006881D01* -X008382Y006900D01* -X008418Y006916D01* -X008454Y006928D01* -X008492Y006937D01* -X008531Y006942D01* -X008570Y006943D01* -X008608Y006940D01* -X008647Y006933D01* -X008684Y006923D01* -X008720Y006908D01* -X008755Y006891D01* -X008788Y006870D01* -X008818Y006845D01* -X008846Y006818D01* -X008871Y006788D01* -X008893Y006756D01* -X008911Y006722D01* -X008926Y006686D01* -X008938Y006649D01* -X008946Y006611D01* -X008950Y006572D01* -X008950Y006534D01* -X008946Y006495D01* -X008938Y006457D01* -X008926Y006420D01* -X008911Y006384D01* -X008893Y006350D01* -X008871Y006318D01* -X008846Y006288D01* -X008818Y006261D01* -X008788Y006236D01* -X008755Y006215D01* -X008720Y006198D01* -X008684Y006183D01* -X008647Y006173D01* -X008608Y006166D01* -X008570Y006163D01* -X008531Y006164D01* -X008492Y006169D01* -X008454Y006178D01* -X008418Y006190D01* -X008382Y006206D01* -X008348Y006225D01* -X008317Y006248D01* -X008288Y006274D01* -X008261Y006302D01* -X008238Y006333D01* -X008217Y006366D01* -X008201Y006402D01* -X008187Y006438D01* -X008178Y006476D01* -X008172Y006514D01* -X008170Y006553D01* -X008160Y006153D02* -X008960Y006953D01* -X009170Y006553D02* -X009172Y006592D01* -X009178Y006630D01* -X009187Y006668D01* -X009201Y006704D01* -X009217Y006740D01* -X009238Y006773D01* -X009261Y006804D01* -X009288Y006832D01* -X009317Y006858D01* -X009348Y006881D01* -X009382Y006900D01* -X009418Y006916D01* -X009454Y006928D01* -X009492Y006937D01* -X009531Y006942D01* -X009570Y006943D01* -X009608Y006940D01* -X009647Y006933D01* -X009684Y006923D01* -X009720Y006908D01* -X009755Y006891D01* -X009788Y006870D01* -X009818Y006845D01* -X009846Y006818D01* -X009871Y006788D01* -X009893Y006756D01* -X009911Y006722D01* -X009926Y006686D01* -X009938Y006649D01* -X009946Y006611D01* -X009950Y006572D01* -X009950Y006534D01* -X009946Y006495D01* -X009938Y006457D01* -X009926Y006420D01* -X009911Y006384D01* -X009893Y006350D01* -X009871Y006318D01* -X009846Y006288D01* -X009818Y006261D01* -X009788Y006236D01* -X009755Y006215D01* -X009720Y006198D01* -X009684Y006183D01* -X009647Y006173D01* -X009608Y006166D01* -X009570Y006163D01* -X009531Y006164D01* -X009492Y006169D01* -X009454Y006178D01* -X009418Y006190D01* -X009382Y006206D01* -X009348Y006225D01* -X009317Y006248D01* -X009288Y006274D01* -X009261Y006302D01* -X009238Y006333D01* -X009217Y006366D01* -X009201Y006402D01* -X009187Y006438D01* -X009178Y006476D01* -X009172Y006514D01* -X009170Y006553D01* -X009160Y006153D02* -X009960Y006953D01* -X010170Y006553D02* -X010172Y006592D01* -X010178Y006630D01* -X010187Y006668D01* -X010201Y006704D01* -X010217Y006740D01* -X010238Y006773D01* -X010261Y006804D01* -X010288Y006832D01* -X010317Y006858D01* -X010348Y006881D01* -X010382Y006900D01* -X010418Y006916D01* -X010454Y006928D01* -X010492Y006937D01* -X010531Y006942D01* -X010570Y006943D01* -X010608Y006940D01* -X010647Y006933D01* -X010684Y006923D01* -X010720Y006908D01* -X010755Y006891D01* -X010788Y006870D01* -X010818Y006845D01* -X010846Y006818D01* -X010871Y006788D01* -X010893Y006756D01* -X010911Y006722D01* -X010926Y006686D01* -X010938Y006649D01* -X010946Y006611D01* -X010950Y006572D01* -X010950Y006534D01* -X010946Y006495D01* -X010938Y006457D01* -X010926Y006420D01* -X010911Y006384D01* -X010893Y006350D01* -X010871Y006318D01* -X010846Y006288D01* -X010818Y006261D01* -X010788Y006236D01* -X010755Y006215D01* -X010720Y006198D01* -X010684Y006183D01* -X010647Y006173D01* -X010608Y006166D01* -X010570Y006163D01* -X010531Y006164D01* -X010492Y006169D01* -X010454Y006178D01* -X010418Y006190D01* -X010382Y006206D01* -X010348Y006225D01* -X010317Y006248D01* -X010288Y006274D01* -X010261Y006302D01* -X010238Y006333D01* -X010217Y006366D01* -X010201Y006402D01* -X010187Y006438D01* -X010178Y006476D01* -X010172Y006514D01* -X010170Y006553D01* -X010160Y006153D02* -X010960Y006953D01* -X011170Y006553D02* -X011172Y006592D01* -X011178Y006630D01* -X011187Y006668D01* -X011201Y006704D01* -X011217Y006740D01* -X011238Y006773D01* -X011261Y006804D01* -X011288Y006832D01* -X011317Y006858D01* -X011348Y006881D01* -X011382Y006900D01* -X011418Y006916D01* -X011454Y006928D01* -X011492Y006937D01* -X011531Y006942D01* -X011570Y006943D01* -X011608Y006940D01* -X011647Y006933D01* -X011684Y006923D01* -X011720Y006908D01* -X011755Y006891D01* -X011788Y006870D01* -X011818Y006845D01* -X011846Y006818D01* -X011871Y006788D01* -X011893Y006756D01* -X011911Y006722D01* -X011926Y006686D01* -X011938Y006649D01* -X011946Y006611D01* -X011950Y006572D01* -X011950Y006534D01* -X011946Y006495D01* -X011938Y006457D01* -X011926Y006420D01* -X011911Y006384D01* -X011893Y006350D01* -X011871Y006318D01* -X011846Y006288D01* -X011818Y006261D01* -X011788Y006236D01* -X011755Y006215D01* -X011720Y006198D01* -X011684Y006183D01* -X011647Y006173D01* -X011608Y006166D01* -X011570Y006163D01* -X011531Y006164D01* -X011492Y006169D01* -X011454Y006178D01* -X011418Y006190D01* -X011382Y006206D01* -X011348Y006225D01* -X011317Y006248D01* -X011288Y006274D01* -X011261Y006302D01* -X011238Y006333D01* -X011217Y006366D01* -X011201Y006402D01* -X011187Y006438D01* -X011178Y006476D01* -X011172Y006514D01* -X011170Y006553D01* -X011160Y006153D02* -X011960Y006953D01* -X012170Y006553D02* -X012172Y006592D01* -X012178Y006630D01* -X012187Y006668D01* -X012201Y006704D01* -X012217Y006740D01* -X012238Y006773D01* -X012261Y006804D01* -X012288Y006832D01* -X012317Y006858D01* -X012348Y006881D01* -X012382Y006900D01* -X012418Y006916D01* -X012454Y006928D01* -X012492Y006937D01* -X012531Y006942D01* -X012570Y006943D01* -X012608Y006940D01* -X012647Y006933D01* -X012684Y006923D01* -X012720Y006908D01* -X012755Y006891D01* -X012788Y006870D01* -X012818Y006845D01* -X012846Y006818D01* -X012871Y006788D01* -X012893Y006756D01* -X012911Y006722D01* -X012926Y006686D01* -X012938Y006649D01* -X012946Y006611D01* -X012950Y006572D01* -X012950Y006534D01* -X012946Y006495D01* -X012938Y006457D01* -X012926Y006420D01* -X012911Y006384D01* -X012893Y006350D01* -X012871Y006318D01* -X012846Y006288D01* -X012818Y006261D01* -X012788Y006236D01* -X012755Y006215D01* -X012720Y006198D01* -X012684Y006183D01* -X012647Y006173D01* -X012608Y006166D01* -X012570Y006163D01* -X012531Y006164D01* -X012492Y006169D01* -X012454Y006178D01* -X012418Y006190D01* -X012382Y006206D01* -X012348Y006225D01* -X012317Y006248D01* -X012288Y006274D01* -X012261Y006302D01* -X012238Y006333D01* -X012217Y006366D01* -X012201Y006402D01* -X012187Y006438D01* -X012178Y006476D01* -X012172Y006514D01* -X012170Y006553D01* -X012160Y006153D02* -X012960Y006953D01* -X013170Y006553D02* -X013172Y006592D01* -X013178Y006630D01* -X013187Y006668D01* -X013201Y006704D01* -X013217Y006740D01* -X013238Y006773D01* -X013261Y006804D01* -X013288Y006832D01* -X013317Y006858D01* -X013348Y006881D01* -X013382Y006900D01* -X013418Y006916D01* -X013454Y006928D01* -X013492Y006937D01* -X013531Y006942D01* -X013570Y006943D01* -X013608Y006940D01* -X013647Y006933D01* -X013684Y006923D01* -X013720Y006908D01* -X013755Y006891D01* -X013788Y006870D01* -X013818Y006845D01* -X013846Y006818D01* -X013871Y006788D01* -X013893Y006756D01* -X013911Y006722D01* -X013926Y006686D01* -X013938Y006649D01* -X013946Y006611D01* -X013950Y006572D01* -X013950Y006534D01* -X013946Y006495D01* -X013938Y006457D01* -X013926Y006420D01* -X013911Y006384D01* -X013893Y006350D01* -X013871Y006318D01* -X013846Y006288D01* -X013818Y006261D01* -X013788Y006236D01* -X013755Y006215D01* -X013720Y006198D01* -X013684Y006183D01* -X013647Y006173D01* -X013608Y006166D01* -X013570Y006163D01* -X013531Y006164D01* -X013492Y006169D01* -X013454Y006178D01* -X013418Y006190D01* -X013382Y006206D01* -X013348Y006225D01* -X013317Y006248D01* -X013288Y006274D01* -X013261Y006302D01* -X013238Y006333D01* -X013217Y006366D01* -X013201Y006402D01* -X013187Y006438D01* -X013178Y006476D01* -X013172Y006514D01* -X013170Y006553D01* -X013160Y006153D02* -X013960Y006953D01* -X014170Y006553D02* -X014172Y006592D01* -X014178Y006630D01* -X014187Y006668D01* -X014201Y006704D01* -X014217Y006740D01* -X014238Y006773D01* -X014261Y006804D01* -X014288Y006832D01* -X014317Y006858D01* -X014348Y006881D01* -X014382Y006900D01* -X014418Y006916D01* -X014454Y006928D01* -X014492Y006937D01* -X014531Y006942D01* -X014570Y006943D01* -X014608Y006940D01* -X014647Y006933D01* -X014684Y006923D01* -X014720Y006908D01* -X014755Y006891D01* -X014788Y006870D01* -X014818Y006845D01* -X014846Y006818D01* -X014871Y006788D01* -X014893Y006756D01* -X014911Y006722D01* -X014926Y006686D01* -X014938Y006649D01* -X014946Y006611D01* -X014950Y006572D01* -X014950Y006534D01* -X014946Y006495D01* -X014938Y006457D01* -X014926Y006420D01* -X014911Y006384D01* -X014893Y006350D01* -X014871Y006318D01* -X014846Y006288D01* -X014818Y006261D01* -X014788Y006236D01* -X014755Y006215D01* -X014720Y006198D01* -X014684Y006183D01* -X014647Y006173D01* -X014608Y006166D01* -X014570Y006163D01* -X014531Y006164D01* -X014492Y006169D01* -X014454Y006178D01* -X014418Y006190D01* -X014382Y006206D01* -X014348Y006225D01* -X014317Y006248D01* -X014288Y006274D01* -X014261Y006302D01* -X014238Y006333D01* -X014217Y006366D01* -X014201Y006402D01* -X014187Y006438D01* -X014178Y006476D01* -X014172Y006514D01* -X014170Y006553D01* -X014160Y006153D02* -X014960Y006953D01* -X015170Y006553D02* -X015172Y006592D01* -X015178Y006630D01* -X015187Y006668D01* -X015201Y006704D01* -X015217Y006740D01* -X015238Y006773D01* -X015261Y006804D01* -X015288Y006832D01* -X015317Y006858D01* -X015348Y006881D01* -X015382Y006900D01* -X015418Y006916D01* -X015454Y006928D01* -X015492Y006937D01* -X015531Y006942D01* -X015570Y006943D01* -X015608Y006940D01* -X015647Y006933D01* -X015684Y006923D01* -X015720Y006908D01* -X015755Y006891D01* -X015788Y006870D01* -X015818Y006845D01* -X015846Y006818D01* -X015871Y006788D01* -X015893Y006756D01* -X015911Y006722D01* -X015926Y006686D01* -X015938Y006649D01* -X015946Y006611D01* -X015950Y006572D01* -X015950Y006534D01* -X015946Y006495D01* -X015938Y006457D01* -X015926Y006420D01* -X015911Y006384D01* -X015893Y006350D01* -X015871Y006318D01* -X015846Y006288D01* -X015818Y006261D01* -X015788Y006236D01* -X015755Y006215D01* -X015720Y006198D01* -X015684Y006183D01* -X015647Y006173D01* -X015608Y006166D01* -X015570Y006163D01* -X015531Y006164D01* -X015492Y006169D01* -X015454Y006178D01* -X015418Y006190D01* -X015382Y006206D01* -X015348Y006225D01* -X015317Y006248D01* -X015288Y006274D01* -X015261Y006302D01* -X015238Y006333D01* -X015217Y006366D01* -X015201Y006402D01* -X015187Y006438D01* -X015178Y006476D01* -X015172Y006514D01* -X015170Y006553D01* -X015160Y006153D02* -X015960Y006953D01* -X016170Y006553D02* -X016172Y006592D01* -X016178Y006630D01* -X016187Y006668D01* -X016201Y006704D01* -X016217Y006740D01* -X016238Y006773D01* -X016261Y006804D01* -X016288Y006832D01* -X016317Y006858D01* -X016348Y006881D01* -X016382Y006900D01* -X016418Y006916D01* -X016454Y006928D01* -X016492Y006937D01* -X016531Y006942D01* -X016570Y006943D01* -X016608Y006940D01* -X016647Y006933D01* -X016684Y006923D01* -X016720Y006908D01* -X016755Y006891D01* -X016788Y006870D01* -X016818Y006845D01* -X016846Y006818D01* -X016871Y006788D01* -X016893Y006756D01* -X016911Y006722D01* -X016926Y006686D01* -X016938Y006649D01* -X016946Y006611D01* -X016950Y006572D01* -X016950Y006534D01* -X016946Y006495D01* -X016938Y006457D01* -X016926Y006420D01* -X016911Y006384D01* -X016893Y006350D01* -X016871Y006318D01* -X016846Y006288D01* -X016818Y006261D01* -X016788Y006236D01* -X016755Y006215D01* -X016720Y006198D01* -X016684Y006183D01* -X016647Y006173D01* -X016608Y006166D01* -X016570Y006163D01* -X016531Y006164D01* -X016492Y006169D01* -X016454Y006178D01* -X016418Y006190D01* -X016382Y006206D01* -X016348Y006225D01* -X016317Y006248D01* -X016288Y006274D01* -X016261Y006302D01* -X016238Y006333D01* -X016217Y006366D01* -X016201Y006402D01* -X016187Y006438D01* -X016178Y006476D01* -X016172Y006514D01* -X016170Y006553D01* -X016160Y006153D02* -X016960Y006953D01* -X017170Y006553D02* -X017172Y006592D01* -X017178Y006630D01* -X017187Y006668D01* -X017201Y006704D01* -X017217Y006740D01* -X017238Y006773D01* -X017261Y006804D01* -X017288Y006832D01* -X017317Y006858D01* -X017348Y006881D01* -X017382Y006900D01* -X017418Y006916D01* -X017454Y006928D01* -X017492Y006937D01* -X017531Y006942D01* -X017570Y006943D01* -X017608Y006940D01* -X017647Y006933D01* -X017684Y006923D01* -X017720Y006908D01* -X017755Y006891D01* -X017788Y006870D01* -X017818Y006845D01* -X017846Y006818D01* -X017871Y006788D01* -X017893Y006756D01* -X017911Y006722D01* -X017926Y006686D01* -X017938Y006649D01* -X017946Y006611D01* -X017950Y006572D01* -X017950Y006534D01* -X017946Y006495D01* -X017938Y006457D01* -X017926Y006420D01* -X017911Y006384D01* -X017893Y006350D01* -X017871Y006318D01* -X017846Y006288D01* -X017818Y006261D01* -X017788Y006236D01* -X017755Y006215D01* -X017720Y006198D01* -X017684Y006183D01* -X017647Y006173D01* -X017608Y006166D01* -X017570Y006163D01* -X017531Y006164D01* -X017492Y006169D01* -X017454Y006178D01* -X017418Y006190D01* -X017382Y006206D01* -X017348Y006225D01* -X017317Y006248D01* -X017288Y006274D01* -X017261Y006302D01* -X017238Y006333D01* -X017217Y006366D01* -X017201Y006402D01* -X017187Y006438D01* -X017178Y006476D01* -X017172Y006514D01* -X017170Y006553D01* -X017160Y006153D02* -X017960Y006953D01* -X018170Y006553D02* -X018172Y006592D01* -X018178Y006630D01* -X018187Y006668D01* -X018201Y006704D01* -X018217Y006740D01* -X018238Y006773D01* -X018261Y006804D01* -X018288Y006832D01* -X018317Y006858D01* -X018348Y006881D01* -X018382Y006900D01* -X018418Y006916D01* -X018454Y006928D01* -X018492Y006937D01* -X018531Y006942D01* -X018570Y006943D01* -X018608Y006940D01* -X018647Y006933D01* -X018684Y006923D01* -X018720Y006908D01* -X018755Y006891D01* -X018788Y006870D01* -X018818Y006845D01* -X018846Y006818D01* -X018871Y006788D01* -X018893Y006756D01* -X018911Y006722D01* -X018926Y006686D01* -X018938Y006649D01* -X018946Y006611D01* -X018950Y006572D01* -X018950Y006534D01* -X018946Y006495D01* -X018938Y006457D01* -X018926Y006420D01* -X018911Y006384D01* -X018893Y006350D01* -X018871Y006318D01* -X018846Y006288D01* -X018818Y006261D01* -X018788Y006236D01* -X018755Y006215D01* -X018720Y006198D01* -X018684Y006183D01* -X018647Y006173D01* -X018608Y006166D01* -X018570Y006163D01* -X018531Y006164D01* -X018492Y006169D01* -X018454Y006178D01* -X018418Y006190D01* -X018382Y006206D01* -X018348Y006225D01* -X018317Y006248D01* -X018288Y006274D01* -X018261Y006302D01* -X018238Y006333D01* -X018217Y006366D01* -X018201Y006402D01* -X018187Y006438D01* -X018178Y006476D01* -X018172Y006514D01* -X018170Y006553D01* -X018160Y006153D02* -X018960Y006953D01* -X019170Y006553D02* -X019172Y006592D01* -X019178Y006630D01* -X019187Y006668D01* -X019201Y006704D01* -X019217Y006740D01* -X019238Y006773D01* -X019261Y006804D01* -X019288Y006832D01* -X019317Y006858D01* -X019348Y006881D01* -X019382Y006900D01* -X019418Y006916D01* -X019454Y006928D01* -X019492Y006937D01* -X019531Y006942D01* -X019570Y006943D01* -X019608Y006940D01* -X019647Y006933D01* -X019684Y006923D01* -X019720Y006908D01* -X019755Y006891D01* -X019788Y006870D01* -X019818Y006845D01* -X019846Y006818D01* -X019871Y006788D01* -X019893Y006756D01* -X019911Y006722D01* -X019926Y006686D01* -X019938Y006649D01* -X019946Y006611D01* -X019950Y006572D01* -X019950Y006534D01* -X019946Y006495D01* -X019938Y006457D01* -X019926Y006420D01* -X019911Y006384D01* -X019893Y006350D01* -X019871Y006318D01* -X019846Y006288D01* -X019818Y006261D01* -X019788Y006236D01* -X019755Y006215D01* -X019720Y006198D01* -X019684Y006183D01* -X019647Y006173D01* -X019608Y006166D01* -X019570Y006163D01* -X019531Y006164D01* -X019492Y006169D01* -X019454Y006178D01* -X019418Y006190D01* -X019382Y006206D01* -X019348Y006225D01* -X019317Y006248D01* -X019288Y006274D01* -X019261Y006302D01* -X019238Y006333D01* -X019217Y006366D01* -X019201Y006402D01* -X019187Y006438D01* -X019178Y006476D01* -X019172Y006514D01* -X019170Y006553D01* -X019160Y006153D02* -X019960Y006953D01* -X021185Y007553D02* -X021187Y007592D01* -X021193Y007630D01* -X021202Y007668D01* -X021216Y007704D01* -X021232Y007740D01* -X021253Y007773D01* -X021276Y007804D01* -X021303Y007832D01* -X021332Y007858D01* -X021363Y007881D01* -X021397Y007900D01* -X021433Y007916D01* -X021469Y007928D01* -X021507Y007937D01* -X021546Y007942D01* -X021585Y007943D01* -X021623Y007940D01* -X021662Y007933D01* -X021699Y007923D01* -X021735Y007908D01* -X021770Y007891D01* -X021803Y007870D01* -X021833Y007845D01* -X021861Y007818D01* -X021886Y007788D01* -X021908Y007756D01* -X021926Y007722D01* -X021941Y007686D01* -X021953Y007649D01* -X021961Y007611D01* -X021965Y007572D01* -X021965Y007534D01* -X021961Y007495D01* -X021953Y007457D01* -X021941Y007420D01* -X021926Y007384D01* -X021908Y007350D01* -X021886Y007318D01* -X021861Y007288D01* -X021833Y007261D01* -X021803Y007236D01* -X021770Y007215D01* -X021735Y007198D01* -X021699Y007183D01* -X021662Y007173D01* -X021623Y007166D01* -X021585Y007163D01* -X021546Y007164D01* -X021507Y007169D01* -X021469Y007178D01* -X021433Y007190D01* -X021397Y007206D01* -X021363Y007225D01* -X021332Y007248D01* -X021303Y007274D01* -X021276Y007302D01* -X021253Y007333D01* -X021232Y007366D01* -X021216Y007402D01* -X021202Y007438D01* -X021193Y007476D01* -X021187Y007514D01* -X021185Y007553D01* -X021175Y007153D02* -X021975Y007953D01* -X023154Y007553D02* -X023156Y007592D01* -X023162Y007630D01* -X023171Y007668D01* -X023185Y007704D01* -X023201Y007740D01* -X023222Y007773D01* -X023245Y007804D01* -X023272Y007832D01* -X023301Y007858D01* -X023332Y007881D01* -X023366Y007900D01* -X023402Y007916D01* -X023438Y007928D01* -X023476Y007937D01* -X023515Y007942D01* -X023554Y007943D01* -X023592Y007940D01* -X023631Y007933D01* -X023668Y007923D01* -X023704Y007908D01* -X023739Y007891D01* -X023772Y007870D01* -X023802Y007845D01* -X023830Y007818D01* -X023855Y007788D01* -X023877Y007756D01* -X023895Y007722D01* -X023910Y007686D01* -X023922Y007649D01* -X023930Y007611D01* -X023934Y007572D01* -X023934Y007534D01* -X023930Y007495D01* -X023922Y007457D01* -X023910Y007420D01* -X023895Y007384D01* -X023877Y007350D01* -X023855Y007318D01* -X023830Y007288D01* -X023802Y007261D01* -X023772Y007236D01* -X023739Y007215D01* -X023704Y007198D01* -X023668Y007183D01* -X023631Y007173D01* -X023592Y007166D01* -X023554Y007163D01* -X023515Y007164D01* -X023476Y007169D01* -X023438Y007178D01* -X023402Y007190D01* -X023366Y007206D01* -X023332Y007225D01* -X023301Y007248D01* -X023272Y007274D01* -X023245Y007302D01* -X023222Y007333D01* -X023201Y007366D01* -X023185Y007402D01* -X023171Y007438D01* -X023162Y007476D01* -X023156Y007514D01* -X023154Y007553D01* -X023144Y007153D02* -X023944Y007953D01* -X024660Y007153D02* -X025460Y007953D01* -X024660Y007953D01* -X025460Y007153D01* -X024660Y007153D01* -X025460Y006953D02* -X024660Y006153D01* -X024660Y006953D02* -X025460Y006953D01* -X024660Y006953D02* -X025460Y006153D01* -X024660Y006153D01* -X025660Y006153D02* -X026460Y006953D01* -X025660Y006953D01* -X026460Y006153D01* -X025660Y006153D01* -X025660Y007153D02* -X026460Y007953D01* -X025660Y007953D01* -X026460Y007153D01* -X025660Y007153D01* -X025660Y008153D02* -X026460Y008953D01* -X025660Y008953D01* -X026460Y008153D01* -X025660Y008153D01* -X025460Y008953D02* -X024660Y008153D01* -X024660Y008953D02* -X025460Y008953D01* -X024660Y008953D02* -X025460Y008153D01* -X024660Y008153D01* -X024660Y009153D02* -X025460Y009953D01* -X024660Y009953D01* -X025460Y009153D01* -X024660Y009153D01* -X025660Y009153D02* -X026460Y009953D01* -X025660Y009953D01* -X026460Y009153D01* -X025660Y009153D01* -X025660Y010403D02* -X026460Y011203D01* -X025660Y011203D01* -X026460Y010403D01* -X025660Y010403D01* -X025460Y011203D02* -X024660Y010403D01* -X024660Y011203D02* -X025460Y011203D01* -X024660Y011203D02* -X025460Y010403D01* -X024660Y010403D01* -X024520Y012053D02* -X024522Y012092D01* -X024528Y012130D01* -X024537Y012168D01* -X024551Y012204D01* -X024567Y012240D01* -X024588Y012273D01* -X024611Y012304D01* -X024638Y012332D01* -X024667Y012358D01* -X024698Y012381D01* -X024732Y012400D01* -X024768Y012416D01* -X024804Y012428D01* -X024842Y012437D01* -X024881Y012442D01* -X024920Y012443D01* -X024958Y012440D01* -X024997Y012433D01* -X025034Y012423D01* -X025070Y012408D01* -X025105Y012391D01* -X025138Y012370D01* -X025168Y012345D01* -X025196Y012318D01* -X025221Y012288D01* -X025243Y012256D01* -X025261Y012222D01* -X025276Y012186D01* -X025288Y012149D01* -X025296Y012111D01* -X025300Y012072D01* -X025300Y012034D01* -X025296Y011995D01* -X025288Y011957D01* -X025276Y011920D01* -X025261Y011884D01* -X025243Y011850D01* -X025221Y011818D01* -X025196Y011788D01* -X025168Y011761D01* -X025138Y011736D01* -X025105Y011715D01* -X025070Y011698D01* -X025034Y011683D01* -X024997Y011673D01* -X024958Y011666D01* -X024920Y011663D01* -X024881Y011664D01* -X024842Y011669D01* -X024804Y011678D01* -X024768Y011690D01* -X024732Y011706D01* -X024698Y011725D01* -X024667Y011748D01* -X024638Y011774D01* -X024611Y011802D01* -X024588Y011833D01* -X024567Y011866D01* -X024551Y011902D01* -X024537Y011938D01* -X024528Y011976D01* -X024522Y012014D01* -X024520Y012053D01* -X024510Y011653D02* -X025310Y012453D01* -X024520Y013053D02* -X024522Y013092D01* -X024528Y013130D01* -X024537Y013168D01* -X024551Y013204D01* -X024567Y013240D01* -X024588Y013273D01* -X024611Y013304D01* -X024638Y013332D01* -X024667Y013358D01* -X024698Y013381D01* -X024732Y013400D01* -X024768Y013416D01* -X024804Y013428D01* -X024842Y013437D01* -X024881Y013442D01* -X024920Y013443D01* -X024958Y013440D01* -X024997Y013433D01* -X025034Y013423D01* -X025070Y013408D01* -X025105Y013391D01* -X025138Y013370D01* -X025168Y013345D01* -X025196Y013318D01* -X025221Y013288D01* -X025243Y013256D01* -X025261Y013222D01* -X025276Y013186D01* -X025288Y013149D01* -X025296Y013111D01* -X025300Y013072D01* -X025300Y013034D01* -X025296Y012995D01* -X025288Y012957D01* -X025276Y012920D01* -X025261Y012884D01* -X025243Y012850D01* -X025221Y012818D01* -X025196Y012788D01* -X025168Y012761D01* -X025138Y012736D01* -X025105Y012715D01* -X025070Y012698D01* -X025034Y012683D01* -X024997Y012673D01* -X024958Y012666D01* -X024920Y012663D01* -X024881Y012664D01* -X024842Y012669D01* -X024804Y012678D01* -X024768Y012690D01* -X024732Y012706D01* -X024698Y012725D01* -X024667Y012748D01* -X024638Y012774D01* -X024611Y012802D01* -X024588Y012833D01* -X024567Y012866D01* -X024551Y012902D01* -X024537Y012938D01* -X024528Y012976D01* -X024522Y013014D01* -X024520Y013053D01* -X024510Y012653D02* -X025310Y013453D01* -X024520Y014053D02* -X024522Y014092D01* -X024528Y014130D01* -X024537Y014168D01* -X024551Y014204D01* -X024567Y014240D01* -X024588Y014273D01* -X024611Y014304D01* -X024638Y014332D01* -X024667Y014358D01* -X024698Y014381D01* -X024732Y014400D01* -X024768Y014416D01* -X024804Y014428D01* -X024842Y014437D01* -X024881Y014442D01* -X024920Y014443D01* -X024958Y014440D01* -X024997Y014433D01* -X025034Y014423D01* -X025070Y014408D01* -X025105Y014391D01* -X025138Y014370D01* -X025168Y014345D01* -X025196Y014318D01* -X025221Y014288D01* -X025243Y014256D01* -X025261Y014222D01* -X025276Y014186D01* -X025288Y014149D01* -X025296Y014111D01* -X025300Y014072D01* -X025300Y014034D01* -X025296Y013995D01* -X025288Y013957D01* -X025276Y013920D01* -X025261Y013884D01* -X025243Y013850D01* -X025221Y013818D01* -X025196Y013788D01* -X025168Y013761D01* -X025138Y013736D01* -X025105Y013715D01* -X025070Y013698D01* -X025034Y013683D01* -X024997Y013673D01* -X024958Y013666D01* -X024920Y013663D01* -X024881Y013664D01* -X024842Y013669D01* -X024804Y013678D01* -X024768Y013690D01* -X024732Y013706D01* -X024698Y013725D01* -X024667Y013748D01* -X024638Y013774D01* -X024611Y013802D01* -X024588Y013833D01* -X024567Y013866D01* -X024551Y013902D01* -X024537Y013938D01* -X024528Y013976D01* -X024522Y014014D01* -X024520Y014053D01* -X024510Y013653D02* -X025310Y014453D01* -X024660Y016153D02* -X025460Y016953D01* -X024660Y016953D01* -X025460Y016153D01* -X024660Y016153D01* -X024460Y016953D02* -X023660Y016153D01* -X023660Y016953D02* -X024460Y016953D01* -X023660Y016953D02* -X024460Y016153D01* -X023660Y016153D01* -X023060Y016053D02* -X023060Y016453D01* -X023460Y016453D01* -X023460Y015653D01* -X022660Y015653D01* -X022660Y016453D01* -X023060Y016453D01* -X023060Y017053D02* -X023060Y017453D01* -X023460Y017453D01* -X023460Y016653D01* -X022660Y016653D01* -X022660Y017453D01* -X023060Y017453D01* -X023060Y018053D02* -X023060Y018453D01* -X023460Y018453D01* -X023460Y017653D01* -X022660Y017653D01* -X022660Y018453D01* -X023060Y018453D01* -X021670Y018553D02* -X021672Y018592D01* -X021678Y018630D01* -X021687Y018668D01* -X021701Y018704D01* -X021717Y018740D01* -X021738Y018773D01* -X021761Y018804D01* -X021788Y018832D01* -X021817Y018858D01* -X021848Y018881D01* -X021882Y018900D01* -X021918Y018916D01* -X021954Y018928D01* -X021992Y018937D01* -X022031Y018942D01* -X022070Y018943D01* -X022108Y018940D01* -X022147Y018933D01* -X022184Y018923D01* -X022220Y018908D01* -X022255Y018891D01* -X022288Y018870D01* -X022318Y018845D01* -X022346Y018818D01* -X022371Y018788D01* -X022393Y018756D01* -X022411Y018722D01* -X022426Y018686D01* -X022438Y018649D01* -X022446Y018611D01* -X022450Y018572D01* -X022450Y018534D01* -X022446Y018495D01* -X022438Y018457D01* -X022426Y018420D01* -X022411Y018384D01* -X022393Y018350D01* -X022371Y018318D01* -X022346Y018288D01* -X022318Y018261D01* -X022288Y018236D01* -X022255Y018215D01* -X022220Y018198D01* -X022184Y018183D01* -X022147Y018173D01* -X022108Y018166D01* -X022070Y018163D01* -X022031Y018164D01* -X021992Y018169D01* -X021954Y018178D01* -X021918Y018190D01* -X021882Y018206D01* -X021848Y018225D01* -X021817Y018248D01* -X021788Y018274D01* -X021761Y018302D01* -X021738Y018333D01* -X021717Y018366D01* -X021701Y018402D01* -X021687Y018438D01* -X021678Y018476D01* -X021672Y018514D01* -X021670Y018553D01* -X021660Y018153D02* -X022460Y018953D01* -X021670Y019553D02* -X021672Y019592D01* -X021678Y019630D01* -X021687Y019668D01* -X021701Y019704D01* -X021717Y019740D01* -X021738Y019773D01* -X021761Y019804D01* -X021788Y019832D01* -X021817Y019858D01* -X021848Y019881D01* -X021882Y019900D01* -X021918Y019916D01* -X021954Y019928D01* -X021992Y019937D01* -X022031Y019942D01* -X022070Y019943D01* -X022108Y019940D01* -X022147Y019933D01* -X022184Y019923D01* -X022220Y019908D01* -X022255Y019891D01* -X022288Y019870D01* -X022318Y019845D01* -X022346Y019818D01* -X022371Y019788D01* -X022393Y019756D01* -X022411Y019722D01* -X022426Y019686D01* -X022438Y019649D01* -X022446Y019611D01* -X022450Y019572D01* -X022450Y019534D01* -X022446Y019495D01* -X022438Y019457D01* -X022426Y019420D01* -X022411Y019384D01* -X022393Y019350D01* -X022371Y019318D01* -X022346Y019288D01* -X022318Y019261D01* -X022288Y019236D01* -X022255Y019215D01* -X022220Y019198D01* -X022184Y019183D01* -X022147Y019173D01* -X022108Y019166D01* -X022070Y019163D01* -X022031Y019164D01* -X021992Y019169D01* -X021954Y019178D01* -X021918Y019190D01* -X021882Y019206D01* -X021848Y019225D01* -X021817Y019248D01* -X021788Y019274D01* -X021761Y019302D01* -X021738Y019333D01* -X021717Y019366D01* -X021701Y019402D01* -X021687Y019438D01* -X021678Y019476D01* -X021672Y019514D01* -X021670Y019553D01* -X021660Y019153D02* -X022460Y019953D01* -X021670Y020553D02* -X021672Y020592D01* -X021678Y020630D01* -X021687Y020668D01* -X021701Y020704D01* -X021717Y020740D01* -X021738Y020773D01* -X021761Y020804D01* -X021788Y020832D01* -X021817Y020858D01* -X021848Y020881D01* -X021882Y020900D01* -X021918Y020916D01* -X021954Y020928D01* -X021992Y020937D01* -X022031Y020942D01* -X022070Y020943D01* -X022108Y020940D01* -X022147Y020933D01* -X022184Y020923D01* -X022220Y020908D01* -X022255Y020891D01* -X022288Y020870D01* -X022318Y020845D01* -X022346Y020818D01* -X022371Y020788D01* -X022393Y020756D01* -X022411Y020722D01* -X022426Y020686D01* -X022438Y020649D01* -X022446Y020611D01* -X022450Y020572D01* -X022450Y020534D01* -X022446Y020495D01* -X022438Y020457D01* -X022426Y020420D01* -X022411Y020384D01* -X022393Y020350D01* -X022371Y020318D01* -X022346Y020288D01* -X022318Y020261D01* -X022288Y020236D01* -X022255Y020215D01* -X022220Y020198D01* -X022184Y020183D01* -X022147Y020173D01* -X022108Y020166D01* -X022070Y020163D01* -X022031Y020164D01* -X021992Y020169D01* -X021954Y020178D01* -X021918Y020190D01* -X021882Y020206D01* -X021848Y020225D01* -X021817Y020248D01* -X021788Y020274D01* -X021761Y020302D01* -X021738Y020333D01* -X021717Y020366D01* -X021701Y020402D01* -X021687Y020438D01* -X021678Y020476D01* -X021672Y020514D01* -X021670Y020553D01* -X021660Y020153D02* -X022460Y020953D01* -X020670Y020553D02* -X020672Y020592D01* -X020678Y020630D01* -X020687Y020668D01* -X020701Y020704D01* -X020717Y020740D01* -X020738Y020773D01* -X020761Y020804D01* -X020788Y020832D01* -X020817Y020858D01* -X020848Y020881D01* -X020882Y020900D01* -X020918Y020916D01* -X020954Y020928D01* -X020992Y020937D01* -X021031Y020942D01* -X021070Y020943D01* -X021108Y020940D01* -X021147Y020933D01* -X021184Y020923D01* -X021220Y020908D01* -X021255Y020891D01* -X021288Y020870D01* -X021318Y020845D01* -X021346Y020818D01* -X021371Y020788D01* -X021393Y020756D01* -X021411Y020722D01* -X021426Y020686D01* -X021438Y020649D01* -X021446Y020611D01* -X021450Y020572D01* -X021450Y020534D01* -X021446Y020495D01* -X021438Y020457D01* -X021426Y020420D01* -X021411Y020384D01* -X021393Y020350D01* -X021371Y020318D01* -X021346Y020288D01* -X021318Y020261D01* -X021288Y020236D01* -X021255Y020215D01* -X021220Y020198D01* -X021184Y020183D01* -X021147Y020173D01* -X021108Y020166D01* -X021070Y020163D01* -X021031Y020164D01* -X020992Y020169D01* -X020954Y020178D01* -X020918Y020190D01* -X020882Y020206D01* -X020848Y020225D01* -X020817Y020248D01* -X020788Y020274D01* -X020761Y020302D01* -X020738Y020333D01* -X020717Y020366D01* -X020701Y020402D01* -X020687Y020438D01* -X020678Y020476D01* -X020672Y020514D01* -X020670Y020553D01* -X020660Y020153D02* -X021460Y020953D01* -X020670Y019553D02* -X020672Y019592D01* -X020678Y019630D01* -X020687Y019668D01* -X020701Y019704D01* -X020717Y019740D01* -X020738Y019773D01* -X020761Y019804D01* -X020788Y019832D01* -X020817Y019858D01* -X020848Y019881D01* -X020882Y019900D01* -X020918Y019916D01* -X020954Y019928D01* -X020992Y019937D01* -X021031Y019942D01* -X021070Y019943D01* -X021108Y019940D01* -X021147Y019933D01* -X021184Y019923D01* -X021220Y019908D01* -X021255Y019891D01* -X021288Y019870D01* -X021318Y019845D01* -X021346Y019818D01* -X021371Y019788D01* -X021393Y019756D01* -X021411Y019722D01* -X021426Y019686D01* -X021438Y019649D01* -X021446Y019611D01* -X021450Y019572D01* -X021450Y019534D01* -X021446Y019495D01* -X021438Y019457D01* -X021426Y019420D01* -X021411Y019384D01* -X021393Y019350D01* -X021371Y019318D01* -X021346Y019288D01* -X021318Y019261D01* -X021288Y019236D01* -X021255Y019215D01* -X021220Y019198D01* -X021184Y019183D01* -X021147Y019173D01* -X021108Y019166D01* -X021070Y019163D01* -X021031Y019164D01* -X020992Y019169D01* -X020954Y019178D01* -X020918Y019190D01* -X020882Y019206D01* -X020848Y019225D01* -X020817Y019248D01* -X020788Y019274D01* -X020761Y019302D01* -X020738Y019333D01* -X020717Y019366D01* -X020701Y019402D01* -X020687Y019438D01* -X020678Y019476D01* -X020672Y019514D01* -X020670Y019553D01* -X020660Y019153D02* -X021460Y019953D01* -X020670Y018553D02* -X020672Y018592D01* -X020678Y018630D01* -X020687Y018668D01* -X020701Y018704D01* -X020717Y018740D01* -X020738Y018773D01* -X020761Y018804D01* -X020788Y018832D01* -X020817Y018858D01* -X020848Y018881D01* -X020882Y018900D01* -X020918Y018916D01* -X020954Y018928D01* -X020992Y018937D01* -X021031Y018942D01* -X021070Y018943D01* -X021108Y018940D01* -X021147Y018933D01* -X021184Y018923D01* -X021220Y018908D01* -X021255Y018891D01* -X021288Y018870D01* -X021318Y018845D01* -X021346Y018818D01* -X021371Y018788D01* -X021393Y018756D01* -X021411Y018722D01* -X021426Y018686D01* -X021438Y018649D01* -X021446Y018611D01* -X021450Y018572D01* -X021450Y018534D01* -X021446Y018495D01* -X021438Y018457D01* -X021426Y018420D01* -X021411Y018384D01* -X021393Y018350D01* -X021371Y018318D01* -X021346Y018288D01* -X021318Y018261D01* -X021288Y018236D01* -X021255Y018215D01* -X021220Y018198D01* -X021184Y018183D01* -X021147Y018173D01* -X021108Y018166D01* -X021070Y018163D01* -X021031Y018164D01* -X020992Y018169D01* -X020954Y018178D01* -X020918Y018190D01* -X020882Y018206D01* -X020848Y018225D01* -X020817Y018248D01* -X020788Y018274D01* -X020761Y018302D01* -X020738Y018333D01* -X020717Y018366D01* -X020701Y018402D01* -X020687Y018438D01* -X020678Y018476D01* -X020672Y018514D01* -X020670Y018553D01* -X020660Y018153D02* -X021460Y018953D01* -X019460Y019953D02* -X018660Y019153D01* -X018660Y019953D02* -X019460Y019953D01* -X018660Y019953D02* -X019460Y019153D01* -X018660Y019153D01* -X018460Y019953D02* -X017660Y019153D01* -X017660Y019953D02* -X018460Y019953D01* -X017660Y019953D02* -X018460Y019153D01* -X017660Y019153D01* -X017460Y019953D02* -X016660Y019153D01* -X016660Y019953D02* -X017460Y019953D01* -X016660Y019953D02* -X017460Y019153D01* -X016660Y019153D01* -X017460Y018453D02* -X016660Y017653D01* -X016660Y018453D02* -X017460Y018453D01* -X016660Y018453D02* -X017460Y017653D01* -X016660Y017653D01* -X017460Y016953D02* -X016660Y016153D01* -X016660Y016953D02* -X017460Y016953D01* -X016660Y016953D02* -X017460Y016153D01* -X016660Y016153D01* -X017660Y016153D02* -X018460Y016953D01* -X017660Y016953D01* -X018460Y016153D01* -X017660Y016153D01* -X018660Y016153D02* -X019460Y016953D01* -X018660Y016953D01* -X019460Y016153D01* -X018660Y016153D01* -X018660Y017653D02* -X019460Y018453D01* -X018660Y018453D01* -X019460Y017653D01* -X018660Y017653D01* -X018460Y018453D02* -X017660Y017653D01* -X017660Y018453D02* -X018460Y018453D01* -X017660Y018453D02* -X018460Y017653D01* -X017660Y017653D01* -X021185Y016453D02* -X021185Y016053D01* -X021185Y016453D02* -X021585Y016453D01* -X021585Y015653D01* -X020785Y015653D01* -X020785Y016453D01* -X021185Y016453D01* -X019060Y014453D02* -X019060Y014053D01* -X019060Y014453D02* -X019460Y014453D01* -X019460Y013653D01* -X018660Y013653D01* -X018660Y014453D01* -X019060Y014453D01* -X021185Y013453D02* -X021185Y013053D01* -X021185Y013453D02* -X021585Y013453D01* -X021585Y012653D01* -X020785Y012653D01* -X020785Y013453D01* -X021185Y013453D01* -X019060Y012453D02* -X019060Y012053D01* -X019060Y012453D02* -X019460Y012453D01* -X019460Y011653D01* -X018660Y011653D01* -X018660Y012453D01* -X019060Y012453D01* -X017960Y007953D02* -X017160Y007153D01* -X017160Y007953D02* -X017960Y007953D01* -X017160Y007953D02* -X017960Y007153D01* -X017160Y007153D01* -X016960Y007953D02* -X016160Y007153D01* -X016160Y007953D02* -X016960Y007953D01* -X016160Y007953D02* -X016960Y007153D01* -X016160Y007153D01* -X015960Y007953D02* -X015160Y007153D01* -X015160Y007953D02* -X015960Y007953D01* -X015160Y007953D02* -X015960Y007153D01* -X015160Y007153D01* -X013060Y008803D02* -X013060Y009203D01* -X013460Y009203D01* -X013460Y008403D01* -X012660Y008403D01* -X012660Y009203D01* -X013060Y009203D01* -X013110Y012723D02* -X012310Y013523D01* -X012310Y012723D02* -X013110Y013523D01* -X012660Y013203D02* -X011860Y014003D01* -X011860Y013203D02* -X012660Y014003D01* -X012640Y014273D02* -X011840Y015073D01* -X011840Y014273D02* -X012640Y015073D01* -X010460Y015003D02* -X009660Y015803D01* -X009660Y015003D02* -X010460Y015803D01* -X008060Y014953D02* -X008060Y014553D01* -X008060Y014953D02* -X008460Y014953D01* -X008460Y014153D01* -X007660Y014153D01* -X007660Y014953D01* -X008060Y014953D01* -X008460Y013953D02* -X007660Y013153D01* -X007660Y013953D02* -X008460Y013953D01* -X007660Y013953D02* -X008460Y013153D01* -X007660Y013153D01* -X007670Y012553D02* -X007672Y012592D01* -X007678Y012630D01* -X007687Y012668D01* -X007701Y012704D01* -X007717Y012740D01* -X007738Y012773D01* -X007761Y012804D01* -X007788Y012832D01* -X007817Y012858D01* -X007848Y012881D01* -X007882Y012900D01* -X007918Y012916D01* -X007954Y012928D01* -X007992Y012937D01* -X008031Y012942D01* -X008070Y012943D01* -X008108Y012940D01* -X008147Y012933D01* -X008184Y012923D01* -X008220Y012908D01* -X008255Y012891D01* -X008288Y012870D01* -X008318Y012845D01* -X008346Y012818D01* -X008371Y012788D01* -X008393Y012756D01* -X008411Y012722D01* -X008426Y012686D01* -X008438Y012649D01* -X008446Y012611D01* -X008450Y012572D01* -X008450Y012534D01* -X008446Y012495D01* -X008438Y012457D01* -X008426Y012420D01* -X008411Y012384D01* -X008393Y012350D01* -X008371Y012318D01* -X008346Y012288D01* -X008318Y012261D01* -X008288Y012236D01* -X008255Y012215D01* -X008220Y012198D01* -X008184Y012183D01* -X008147Y012173D01* -X008108Y012166D01* -X008070Y012163D01* -X008031Y012164D01* -X007992Y012169D01* -X007954Y012178D01* -X007918Y012190D01* -X007882Y012206D01* -X007848Y012225D01* -X007817Y012248D01* -X007788Y012274D01* -X007761Y012302D01* -X007738Y012333D01* -X007717Y012366D01* -X007701Y012402D01* -X007687Y012438D01* -X007678Y012476D01* -X007672Y012514D01* -X007670Y012553D01* -X007660Y012153D02* -X008460Y012953D01* -X007670Y011553D02* -X007672Y011592D01* -X007678Y011630D01* -X007687Y011668D01* -X007701Y011704D01* -X007717Y011740D01* -X007738Y011773D01* -X007761Y011804D01* -X007788Y011832D01* -X007817Y011858D01* -X007848Y011881D01* -X007882Y011900D01* -X007918Y011916D01* -X007954Y011928D01* -X007992Y011937D01* -X008031Y011942D01* -X008070Y011943D01* -X008108Y011940D01* -X008147Y011933D01* -X008184Y011923D01* -X008220Y011908D01* -X008255Y011891D01* -X008288Y011870D01* -X008318Y011845D01* -X008346Y011818D01* -X008371Y011788D01* -X008393Y011756D01* -X008411Y011722D01* -X008426Y011686D01* -X008438Y011649D01* -X008446Y011611D01* -X008450Y011572D01* -X008450Y011534D01* -X008446Y011495D01* -X008438Y011457D01* -X008426Y011420D01* -X008411Y011384D01* -X008393Y011350D01* -X008371Y011318D01* -X008346Y011288D01* -X008318Y011261D01* -X008288Y011236D01* -X008255Y011215D01* -X008220Y011198D01* -X008184Y011183D01* -X008147Y011173D01* -X008108Y011166D01* -X008070Y011163D01* -X008031Y011164D01* -X007992Y011169D01* -X007954Y011178D01* -X007918Y011190D01* -X007882Y011206D01* -X007848Y011225D01* -X007817Y011248D01* -X007788Y011274D01* -X007761Y011302D01* -X007738Y011333D01* -X007717Y011366D01* -X007701Y011402D01* -X007687Y011438D01* -X007678Y011476D01* -X007672Y011514D01* -X007670Y011553D01* -X007660Y011153D02* -X008460Y011953D01* -X006170Y011553D02* -X006172Y011592D01* -X006178Y011630D01* -X006187Y011668D01* -X006201Y011704D01* -X006217Y011740D01* -X006238Y011773D01* -X006261Y011804D01* -X006288Y011832D01* -X006317Y011858D01* -X006348Y011881D01* -X006382Y011900D01* -X006418Y011916D01* -X006454Y011928D01* -X006492Y011937D01* -X006531Y011942D01* -X006570Y011943D01* -X006608Y011940D01* -X006647Y011933D01* -X006684Y011923D01* -X006720Y011908D01* -X006755Y011891D01* -X006788Y011870D01* -X006818Y011845D01* -X006846Y011818D01* -X006871Y011788D01* -X006893Y011756D01* -X006911Y011722D01* -X006926Y011686D01* -X006938Y011649D01* -X006946Y011611D01* -X006950Y011572D01* -X006950Y011534D01* -X006946Y011495D01* -X006938Y011457D01* -X006926Y011420D01* -X006911Y011384D01* -X006893Y011350D01* -X006871Y011318D01* -X006846Y011288D01* -X006818Y011261D01* -X006788Y011236D01* -X006755Y011215D01* -X006720Y011198D01* -X006684Y011183D01* -X006647Y011173D01* -X006608Y011166D01* -X006570Y011163D01* -X006531Y011164D01* -X006492Y011169D01* -X006454Y011178D01* -X006418Y011190D01* -X006382Y011206D01* -X006348Y011225D01* -X006317Y011248D01* -X006288Y011274D01* -X006261Y011302D01* -X006238Y011333D01* -X006217Y011366D01* -X006201Y011402D01* -X006187Y011438D01* -X006178Y011476D01* -X006172Y011514D01* -X006170Y011553D01* -X006160Y011153D02* -X006960Y011953D01* -X006170Y012553D02* -X006172Y012592D01* -X006178Y012630D01* -X006187Y012668D01* -X006201Y012704D01* -X006217Y012740D01* -X006238Y012773D01* -X006261Y012804D01* -X006288Y012832D01* -X006317Y012858D01* -X006348Y012881D01* -X006382Y012900D01* -X006418Y012916D01* -X006454Y012928D01* -X006492Y012937D01* -X006531Y012942D01* -X006570Y012943D01* -X006608Y012940D01* -X006647Y012933D01* -X006684Y012923D01* -X006720Y012908D01* -X006755Y012891D01* -X006788Y012870D01* -X006818Y012845D01* -X006846Y012818D01* -X006871Y012788D01* -X006893Y012756D01* -X006911Y012722D01* -X006926Y012686D01* -X006938Y012649D01* -X006946Y012611D01* -X006950Y012572D01* -X006950Y012534D01* -X006946Y012495D01* -X006938Y012457D01* -X006926Y012420D01* -X006911Y012384D01* -X006893Y012350D01* -X006871Y012318D01* -X006846Y012288D01* -X006818Y012261D01* -X006788Y012236D01* -X006755Y012215D01* -X006720Y012198D01* -X006684Y012183D01* -X006647Y012173D01* -X006608Y012166D01* -X006570Y012163D01* -X006531Y012164D01* -X006492Y012169D01* -X006454Y012178D01* -X006418Y012190D01* -X006382Y012206D01* -X006348Y012225D01* -X006317Y012248D01* -X006288Y012274D01* -X006261Y012302D01* -X006238Y012333D01* -X006217Y012366D01* -X006201Y012402D01* -X006187Y012438D01* -X006178Y012476D01* -X006172Y012514D01* -X006170Y012553D01* -X006160Y012153D02* -X006960Y012953D01* -X006170Y013553D02* -X006172Y013592D01* -X006178Y013630D01* -X006187Y013668D01* -X006201Y013704D01* -X006217Y013740D01* -X006238Y013773D01* -X006261Y013804D01* -X006288Y013832D01* -X006317Y013858D01* -X006348Y013881D01* -X006382Y013900D01* -X006418Y013916D01* -X006454Y013928D01* -X006492Y013937D01* -X006531Y013942D01* -X006570Y013943D01* -X006608Y013940D01* -X006647Y013933D01* -X006684Y013923D01* -X006720Y013908D01* -X006755Y013891D01* -X006788Y013870D01* -X006818Y013845D01* -X006846Y013818D01* -X006871Y013788D01* -X006893Y013756D01* -X006911Y013722D01* -X006926Y013686D01* -X006938Y013649D01* -X006946Y013611D01* -X006950Y013572D01* -X006950Y013534D01* -X006946Y013495D01* -X006938Y013457D01* -X006926Y013420D01* -X006911Y013384D01* -X006893Y013350D01* -X006871Y013318D01* -X006846Y013288D01* -X006818Y013261D01* -X006788Y013236D01* -X006755Y013215D01* -X006720Y013198D01* -X006684Y013183D01* -X006647Y013173D01* -X006608Y013166D01* -X006570Y013163D01* -X006531Y013164D01* -X006492Y013169D01* -X006454Y013178D01* -X006418Y013190D01* -X006382Y013206D01* -X006348Y013225D01* -X006317Y013248D01* -X006288Y013274D01* -X006261Y013302D01* -X006238Y013333D01* -X006217Y013366D01* -X006201Y013402D01* -X006187Y013438D01* -X006178Y013476D01* -X006172Y013514D01* -X006170Y013553D01* -X006160Y013153D02* -X006960Y013953D01* -X006170Y014553D02* -X006172Y014592D01* -X006178Y014630D01* -X006187Y014668D01* -X006201Y014704D01* -X006217Y014740D01* -X006238Y014773D01* -X006261Y014804D01* -X006288Y014832D01* -X006317Y014858D01* -X006348Y014881D01* -X006382Y014900D01* -X006418Y014916D01* -X006454Y014928D01* -X006492Y014937D01* -X006531Y014942D01* -X006570Y014943D01* -X006608Y014940D01* -X006647Y014933D01* -X006684Y014923D01* -X006720Y014908D01* -X006755Y014891D01* -X006788Y014870D01* -X006818Y014845D01* -X006846Y014818D01* -X006871Y014788D01* -X006893Y014756D01* -X006911Y014722D01* -X006926Y014686D01* -X006938Y014649D01* -X006946Y014611D01* -X006950Y014572D01* -X006950Y014534D01* -X006946Y014495D01* -X006938Y014457D01* -X006926Y014420D01* -X006911Y014384D01* -X006893Y014350D01* -X006871Y014318D01* -X006846Y014288D01* -X006818Y014261D01* -X006788Y014236D01* -X006755Y014215D01* -X006720Y014198D01* -X006684Y014183D01* -X006647Y014173D01* -X006608Y014166D01* -X006570Y014163D01* -X006531Y014164D01* -X006492Y014169D01* -X006454Y014178D01* -X006418Y014190D01* -X006382Y014206D01* -X006348Y014225D01* -X006317Y014248D01* -X006288Y014274D01* -X006261Y014302D01* -X006238Y014333D01* -X006217Y014366D01* -X006201Y014402D01* -X006187Y014438D01* -X006178Y014476D01* -X006172Y014514D01* -X006170Y014553D01* -X006160Y014153D02* -X006960Y014953D01* -X006170Y015553D02* -X006172Y015592D01* -X006178Y015630D01* -X006187Y015668D01* -X006201Y015704D01* -X006217Y015740D01* -X006238Y015773D01* -X006261Y015804D01* -X006288Y015832D01* -X006317Y015858D01* -X006348Y015881D01* -X006382Y015900D01* -X006418Y015916D01* -X006454Y015928D01* -X006492Y015937D01* -X006531Y015942D01* -X006570Y015943D01* -X006608Y015940D01* -X006647Y015933D01* -X006684Y015923D01* -X006720Y015908D01* -X006755Y015891D01* -X006788Y015870D01* -X006818Y015845D01* -X006846Y015818D01* -X006871Y015788D01* -X006893Y015756D01* -X006911Y015722D01* -X006926Y015686D01* -X006938Y015649D01* -X006946Y015611D01* -X006950Y015572D01* -X006950Y015534D01* -X006946Y015495D01* -X006938Y015457D01* -X006926Y015420D01* -X006911Y015384D01* -X006893Y015350D01* -X006871Y015318D01* -X006846Y015288D01* -X006818Y015261D01* -X006788Y015236D01* -X006755Y015215D01* -X006720Y015198D01* -X006684Y015183D01* -X006647Y015173D01* -X006608Y015166D01* -X006570Y015163D01* -X006531Y015164D01* -X006492Y015169D01* -X006454Y015178D01* -X006418Y015190D01* -X006382Y015206D01* -X006348Y015225D01* -X006317Y015248D01* -X006288Y015274D01* -X006261Y015302D01* -X006238Y015333D01* -X006217Y015366D01* -X006201Y015402D01* -X006187Y015438D01* -X006178Y015476D01* -X006172Y015514D01* -X006170Y015553D01* -X006160Y015153D02* -X006960Y015953D01* -X006170Y016553D02* -X006172Y016592D01* -X006178Y016630D01* -X006187Y016668D01* -X006201Y016704D01* -X006217Y016740D01* -X006238Y016773D01* -X006261Y016804D01* -X006288Y016832D01* -X006317Y016858D01* -X006348Y016881D01* -X006382Y016900D01* -X006418Y016916D01* -X006454Y016928D01* -X006492Y016937D01* -X006531Y016942D01* -X006570Y016943D01* -X006608Y016940D01* -X006647Y016933D01* -X006684Y016923D01* -X006720Y016908D01* -X006755Y016891D01* -X006788Y016870D01* -X006818Y016845D01* -X006846Y016818D01* -X006871Y016788D01* -X006893Y016756D01* -X006911Y016722D01* -X006926Y016686D01* -X006938Y016649D01* -X006946Y016611D01* -X006950Y016572D01* -X006950Y016534D01* -X006946Y016495D01* -X006938Y016457D01* -X006926Y016420D01* -X006911Y016384D01* -X006893Y016350D01* -X006871Y016318D01* -X006846Y016288D01* -X006818Y016261D01* -X006788Y016236D01* -X006755Y016215D01* -X006720Y016198D01* -X006684Y016183D01* -X006647Y016173D01* -X006608Y016166D01* -X006570Y016163D01* -X006531Y016164D01* -X006492Y016169D01* -X006454Y016178D01* -X006418Y016190D01* -X006382Y016206D01* -X006348Y016225D01* -X006317Y016248D01* -X006288Y016274D01* -X006261Y016302D01* -X006238Y016333D01* -X006217Y016366D01* -X006201Y016402D01* -X006187Y016438D01* -X006178Y016476D01* -X006172Y016514D01* -X006170Y016553D01* -X006160Y016153D02* -X006960Y016953D01* -X006170Y017553D02* -X006172Y017592D01* -X006178Y017630D01* -X006187Y017668D01* -X006201Y017704D01* -X006217Y017740D01* -X006238Y017773D01* -X006261Y017804D01* -X006288Y017832D01* -X006317Y017858D01* -X006348Y017881D01* -X006382Y017900D01* -X006418Y017916D01* -X006454Y017928D01* -X006492Y017937D01* -X006531Y017942D01* -X006570Y017943D01* -X006608Y017940D01* -X006647Y017933D01* -X006684Y017923D01* -X006720Y017908D01* -X006755Y017891D01* -X006788Y017870D01* -X006818Y017845D01* -X006846Y017818D01* -X006871Y017788D01* -X006893Y017756D01* -X006911Y017722D01* -X006926Y017686D01* -X006938Y017649D01* -X006946Y017611D01* -X006950Y017572D01* -X006950Y017534D01* -X006946Y017495D01* -X006938Y017457D01* -X006926Y017420D01* -X006911Y017384D01* -X006893Y017350D01* -X006871Y017318D01* -X006846Y017288D01* -X006818Y017261D01* -X006788Y017236D01* -X006755Y017215D01* -X006720Y017198D01* -X006684Y017183D01* -X006647Y017173D01* -X006608Y017166D01* -X006570Y017163D01* -X006531Y017164D01* -X006492Y017169D01* -X006454Y017178D01* -X006418Y017190D01* -X006382Y017206D01* -X006348Y017225D01* -X006317Y017248D01* -X006288Y017274D01* -X006261Y017302D01* -X006238Y017333D01* -X006217Y017366D01* -X006201Y017402D01* -X006187Y017438D01* -X006178Y017476D01* -X006172Y017514D01* -X006170Y017553D01* -X006160Y017153D02* -X006960Y017953D01* -X006960Y021763D02* -X006160Y021763D01* -X006560Y021363D02* -X006560Y022163D01* -X006170Y021763D02* -X006172Y021802D01* -X006178Y021840D01* -X006187Y021878D01* -X006201Y021914D01* -X006217Y021950D01* -X006238Y021983D01* -X006261Y022014D01* -X006288Y022042D01* -X006317Y022068D01* -X006348Y022091D01* -X006382Y022110D01* -X006418Y022126D01* -X006454Y022138D01* -X006492Y022147D01* -X006531Y022152D01* -X006570Y022153D01* -X006608Y022150D01* -X006647Y022143D01* -X006684Y022133D01* -X006720Y022118D01* -X006755Y022101D01* -X006788Y022080D01* -X006818Y022055D01* -X006846Y022028D01* -X006871Y021998D01* -X006893Y021966D01* -X006911Y021932D01* -X006926Y021896D01* -X006938Y021859D01* -X006946Y021821D01* -X006950Y021782D01* -X006950Y021744D01* -X006946Y021705D01* -X006938Y021667D01* -X006926Y021630D01* -X006911Y021594D01* -X006893Y021560D01* -X006871Y021528D01* -X006846Y021498D01* -X006818Y021471D01* -X006788Y021446D01* -X006755Y021425D01* -X006720Y021408D01* -X006684Y021393D01* -X006647Y021383D01* -X006608Y021376D01* -X006570Y021373D01* -X006531Y021374D01* -X006492Y021379D01* -X006454Y021388D01* -X006418Y021400D01* -X006382Y021416D01* -X006348Y021435D01* -X006317Y021458D01* -X006288Y021484D01* -X006261Y021512D01* -X006238Y021543D01* -X006217Y021576D01* -X006201Y021612D01* -X006187Y021648D01* -X006178Y021686D01* -X006172Y021724D01* -X006170Y021763D01* -X006365Y021763D02* -X006367Y021791D01* -X006373Y021818D01* -X006383Y021844D01* -X006396Y021868D01* -X006413Y021891D01* -X006432Y021910D01* -X006455Y021927D01* -X006479Y021940D01* -X006505Y021950D01* -X006532Y021956D01* -X006560Y021958D01* -X006588Y021956D01* -X006615Y021950D01* -X006641Y021940D01* -X006665Y021927D01* -X006688Y021910D01* -X006707Y021891D01* -X006724Y021868D01* -X006737Y021844D01* -X006747Y021818D01* -X006753Y021791D01* -X006755Y021763D01* -X006753Y021735D01* -X006747Y021708D01* -X006737Y021682D01* -X006724Y021658D01* -X006707Y021635D01* -X006688Y021616D01* -X006665Y021599D01* -X006641Y021586D01* -X006615Y021576D01* -X006588Y021570D01* -X006560Y021568D01* -X006532Y021570D01* -X006505Y021576D01* -X006479Y021586D01* -X006455Y021599D01* -X006432Y021616D01* -X006413Y021635D01* -X006396Y021658D01* -X006383Y021682D01* -X006373Y021708D01* -X006367Y021735D01* -X006365Y021763D01* -X008170Y022053D02* -X008172Y022092D01* -X008178Y022130D01* -X008187Y022168D01* -X008201Y022204D01* -X008217Y022240D01* -X008238Y022273D01* -X008261Y022304D01* -X008288Y022332D01* -X008317Y022358D01* -X008348Y022381D01* -X008382Y022400D01* -X008418Y022416D01* -X008454Y022428D01* -X008492Y022437D01* -X008531Y022442D01* -X008570Y022443D01* -X008608Y022440D01* -X008647Y022433D01* -X008684Y022423D01* -X008720Y022408D01* -X008755Y022391D01* -X008788Y022370D01* -X008818Y022345D01* -X008846Y022318D01* -X008871Y022288D01* -X008893Y022256D01* -X008911Y022222D01* -X008926Y022186D01* -X008938Y022149D01* -X008946Y022111D01* -X008950Y022072D01* -X008950Y022034D01* -X008946Y021995D01* -X008938Y021957D01* -X008926Y021920D01* -X008911Y021884D01* -X008893Y021850D01* -X008871Y021818D01* -X008846Y021788D01* -X008818Y021761D01* -X008788Y021736D01* -X008755Y021715D01* -X008720Y021698D01* -X008684Y021683D01* -X008647Y021673D01* -X008608Y021666D01* -X008570Y021663D01* -X008531Y021664D01* -X008492Y021669D01* -X008454Y021678D01* -X008418Y021690D01* -X008382Y021706D01* -X008348Y021725D01* -X008317Y021748D01* -X008288Y021774D01* -X008261Y021802D01* -X008238Y021833D01* -X008217Y021866D01* -X008201Y021902D01* -X008187Y021938D01* -X008178Y021976D01* -X008172Y022014D01* -X008170Y022053D01* -X008160Y021653D02* -X008960Y022453D01* -X009170Y022053D02* -X009172Y022092D01* -X009178Y022130D01* -X009187Y022168D01* -X009201Y022204D01* -X009217Y022240D01* -X009238Y022273D01* -X009261Y022304D01* -X009288Y022332D01* -X009317Y022358D01* -X009348Y022381D01* -X009382Y022400D01* -X009418Y022416D01* -X009454Y022428D01* -X009492Y022437D01* -X009531Y022442D01* -X009570Y022443D01* -X009608Y022440D01* -X009647Y022433D01* -X009684Y022423D01* -X009720Y022408D01* -X009755Y022391D01* -X009788Y022370D01* -X009818Y022345D01* -X009846Y022318D01* -X009871Y022288D01* -X009893Y022256D01* -X009911Y022222D01* -X009926Y022186D01* -X009938Y022149D01* -X009946Y022111D01* -X009950Y022072D01* -X009950Y022034D01* -X009946Y021995D01* -X009938Y021957D01* -X009926Y021920D01* -X009911Y021884D01* -X009893Y021850D01* -X009871Y021818D01* -X009846Y021788D01* -X009818Y021761D01* -X009788Y021736D01* -X009755Y021715D01* -X009720Y021698D01* -X009684Y021683D01* -X009647Y021673D01* -X009608Y021666D01* -X009570Y021663D01* -X009531Y021664D01* -X009492Y021669D01* -X009454Y021678D01* -X009418Y021690D01* -X009382Y021706D01* -X009348Y021725D01* -X009317Y021748D01* -X009288Y021774D01* -X009261Y021802D01* -X009238Y021833D01* -X009217Y021866D01* -X009201Y021902D01* -X009187Y021938D01* -X009178Y021976D01* -X009172Y022014D01* -X009170Y022053D01* -X009160Y021653D02* -X009960Y022453D01* -X010170Y022053D02* -X010172Y022092D01* -X010178Y022130D01* -X010187Y022168D01* -X010201Y022204D01* -X010217Y022240D01* -X010238Y022273D01* -X010261Y022304D01* -X010288Y022332D01* -X010317Y022358D01* -X010348Y022381D01* -X010382Y022400D01* -X010418Y022416D01* -X010454Y022428D01* -X010492Y022437D01* -X010531Y022442D01* -X010570Y022443D01* -X010608Y022440D01* -X010647Y022433D01* -X010684Y022423D01* -X010720Y022408D01* -X010755Y022391D01* -X010788Y022370D01* -X010818Y022345D01* -X010846Y022318D01* -X010871Y022288D01* -X010893Y022256D01* -X010911Y022222D01* -X010926Y022186D01* -X010938Y022149D01* -X010946Y022111D01* -X010950Y022072D01* -X010950Y022034D01* -X010946Y021995D01* -X010938Y021957D01* -X010926Y021920D01* -X010911Y021884D01* -X010893Y021850D01* -X010871Y021818D01* -X010846Y021788D01* -X010818Y021761D01* -X010788Y021736D01* -X010755Y021715D01* -X010720Y021698D01* -X010684Y021683D01* -X010647Y021673D01* -X010608Y021666D01* -X010570Y021663D01* -X010531Y021664D01* -X010492Y021669D01* -X010454Y021678D01* -X010418Y021690D01* -X010382Y021706D01* -X010348Y021725D01* -X010317Y021748D01* -X010288Y021774D01* -X010261Y021802D01* -X010238Y021833D01* -X010217Y021866D01* -X010201Y021902D01* -X010187Y021938D01* -X010178Y021976D01* -X010172Y022014D01* -X010170Y022053D01* -X010160Y021653D02* -X010960Y022453D01* -X011170Y022053D02* -X011172Y022092D01* -X011178Y022130D01* -X011187Y022168D01* -X011201Y022204D01* -X011217Y022240D01* -X011238Y022273D01* -X011261Y022304D01* -X011288Y022332D01* -X011317Y022358D01* -X011348Y022381D01* -X011382Y022400D01* -X011418Y022416D01* -X011454Y022428D01* -X011492Y022437D01* -X011531Y022442D01* -X011570Y022443D01* -X011608Y022440D01* -X011647Y022433D01* -X011684Y022423D01* -X011720Y022408D01* -X011755Y022391D01* -X011788Y022370D01* -X011818Y022345D01* -X011846Y022318D01* -X011871Y022288D01* -X011893Y022256D01* -X011911Y022222D01* -X011926Y022186D01* -X011938Y022149D01* -X011946Y022111D01* -X011950Y022072D01* -X011950Y022034D01* -X011946Y021995D01* -X011938Y021957D01* -X011926Y021920D01* -X011911Y021884D01* -X011893Y021850D01* -X011871Y021818D01* -X011846Y021788D01* -X011818Y021761D01* -X011788Y021736D01* -X011755Y021715D01* -X011720Y021698D01* -X011684Y021683D01* -X011647Y021673D01* -X011608Y021666D01* -X011570Y021663D01* -X011531Y021664D01* -X011492Y021669D01* -X011454Y021678D01* -X011418Y021690D01* -X011382Y021706D01* -X011348Y021725D01* -X011317Y021748D01* -X011288Y021774D01* -X011261Y021802D01* -X011238Y021833D01* -X011217Y021866D01* -X011201Y021902D01* -X011187Y021938D01* -X011178Y021976D01* -X011172Y022014D01* -X011170Y022053D01* -X011160Y021653D02* -X011960Y022453D01* -X012170Y022053D02* -X012172Y022092D01* -X012178Y022130D01* -X012187Y022168D01* -X012201Y022204D01* -X012217Y022240D01* -X012238Y022273D01* -X012261Y022304D01* -X012288Y022332D01* -X012317Y022358D01* -X012348Y022381D01* -X012382Y022400D01* -X012418Y022416D01* -X012454Y022428D01* -X012492Y022437D01* -X012531Y022442D01* -X012570Y022443D01* -X012608Y022440D01* -X012647Y022433D01* -X012684Y022423D01* -X012720Y022408D01* -X012755Y022391D01* -X012788Y022370D01* -X012818Y022345D01* -X012846Y022318D01* -X012871Y022288D01* -X012893Y022256D01* -X012911Y022222D01* -X012926Y022186D01* -X012938Y022149D01* -X012946Y022111D01* -X012950Y022072D01* -X012950Y022034D01* -X012946Y021995D01* -X012938Y021957D01* -X012926Y021920D01* -X012911Y021884D01* -X012893Y021850D01* -X012871Y021818D01* -X012846Y021788D01* -X012818Y021761D01* -X012788Y021736D01* -X012755Y021715D01* -X012720Y021698D01* -X012684Y021683D01* -X012647Y021673D01* -X012608Y021666D01* -X012570Y021663D01* -X012531Y021664D01* -X012492Y021669D01* -X012454Y021678D01* -X012418Y021690D01* -X012382Y021706D01* -X012348Y021725D01* -X012317Y021748D01* -X012288Y021774D01* -X012261Y021802D01* -X012238Y021833D01* -X012217Y021866D01* -X012201Y021902D01* -X012187Y021938D01* -X012178Y021976D01* -X012172Y022014D01* -X012170Y022053D01* -X012160Y021653D02* -X012960Y022453D01* -X013170Y022053D02* -X013172Y022092D01* -X013178Y022130D01* -X013187Y022168D01* -X013201Y022204D01* -X013217Y022240D01* -X013238Y022273D01* -X013261Y022304D01* -X013288Y022332D01* -X013317Y022358D01* -X013348Y022381D01* -X013382Y022400D01* -X013418Y022416D01* -X013454Y022428D01* -X013492Y022437D01* -X013531Y022442D01* -X013570Y022443D01* -X013608Y022440D01* -X013647Y022433D01* -X013684Y022423D01* -X013720Y022408D01* -X013755Y022391D01* -X013788Y022370D01* -X013818Y022345D01* -X013846Y022318D01* -X013871Y022288D01* -X013893Y022256D01* -X013911Y022222D01* -X013926Y022186D01* -X013938Y022149D01* -X013946Y022111D01* -X013950Y022072D01* -X013950Y022034D01* -X013946Y021995D01* -X013938Y021957D01* -X013926Y021920D01* -X013911Y021884D01* -X013893Y021850D01* -X013871Y021818D01* -X013846Y021788D01* -X013818Y021761D01* -X013788Y021736D01* -X013755Y021715D01* -X013720Y021698D01* -X013684Y021683D01* -X013647Y021673D01* -X013608Y021666D01* -X013570Y021663D01* -X013531Y021664D01* -X013492Y021669D01* -X013454Y021678D01* -X013418Y021690D01* -X013382Y021706D01* -X013348Y021725D01* -X013317Y021748D01* -X013288Y021774D01* -X013261Y021802D01* -X013238Y021833D01* -X013217Y021866D01* -X013201Y021902D01* -X013187Y021938D01* -X013178Y021976D01* -X013172Y022014D01* -X013170Y022053D01* -X013160Y021653D02* -X013960Y022453D01* -X014170Y022053D02* -X014172Y022092D01* -X014178Y022130D01* -X014187Y022168D01* -X014201Y022204D01* -X014217Y022240D01* -X014238Y022273D01* -X014261Y022304D01* -X014288Y022332D01* -X014317Y022358D01* -X014348Y022381D01* -X014382Y022400D01* -X014418Y022416D01* -X014454Y022428D01* -X014492Y022437D01* -X014531Y022442D01* -X014570Y022443D01* -X014608Y022440D01* -X014647Y022433D01* -X014684Y022423D01* -X014720Y022408D01* -X014755Y022391D01* -X014788Y022370D01* -X014818Y022345D01* -X014846Y022318D01* -X014871Y022288D01* -X014893Y022256D01* -X014911Y022222D01* -X014926Y022186D01* -X014938Y022149D01* -X014946Y022111D01* -X014950Y022072D01* -X014950Y022034D01* -X014946Y021995D01* -X014938Y021957D01* -X014926Y021920D01* -X014911Y021884D01* -X014893Y021850D01* -X014871Y021818D01* -X014846Y021788D01* -X014818Y021761D01* -X014788Y021736D01* -X014755Y021715D01* -X014720Y021698D01* -X014684Y021683D01* -X014647Y021673D01* -X014608Y021666D01* -X014570Y021663D01* -X014531Y021664D01* -X014492Y021669D01* -X014454Y021678D01* -X014418Y021690D01* -X014382Y021706D01* -X014348Y021725D01* -X014317Y021748D01* -X014288Y021774D01* -X014261Y021802D01* -X014238Y021833D01* -X014217Y021866D01* -X014201Y021902D01* -X014187Y021938D01* -X014178Y021976D01* -X014172Y022014D01* -X014170Y022053D01* -X014160Y021653D02* -X014960Y022453D01* -X015170Y022053D02* -X015172Y022092D01* -X015178Y022130D01* -X015187Y022168D01* -X015201Y022204D01* -X015217Y022240D01* -X015238Y022273D01* -X015261Y022304D01* -X015288Y022332D01* -X015317Y022358D01* -X015348Y022381D01* -X015382Y022400D01* -X015418Y022416D01* -X015454Y022428D01* -X015492Y022437D01* -X015531Y022442D01* -X015570Y022443D01* -X015608Y022440D01* -X015647Y022433D01* -X015684Y022423D01* -X015720Y022408D01* -X015755Y022391D01* -X015788Y022370D01* -X015818Y022345D01* -X015846Y022318D01* -X015871Y022288D01* -X015893Y022256D01* -X015911Y022222D01* -X015926Y022186D01* -X015938Y022149D01* -X015946Y022111D01* -X015950Y022072D01* -X015950Y022034D01* -X015946Y021995D01* -X015938Y021957D01* -X015926Y021920D01* -X015911Y021884D01* -X015893Y021850D01* -X015871Y021818D01* -X015846Y021788D01* -X015818Y021761D01* -X015788Y021736D01* -X015755Y021715D01* -X015720Y021698D01* -X015684Y021683D01* -X015647Y021673D01* -X015608Y021666D01* -X015570Y021663D01* -X015531Y021664D01* -X015492Y021669D01* -X015454Y021678D01* -X015418Y021690D01* -X015382Y021706D01* -X015348Y021725D01* -X015317Y021748D01* -X015288Y021774D01* -X015261Y021802D01* -X015238Y021833D01* -X015217Y021866D01* -X015201Y021902D01* -X015187Y021938D01* -X015178Y021976D01* -X015172Y022014D01* -X015170Y022053D01* -X015160Y021653D02* -X015960Y022453D01* -X016170Y022053D02* -X016172Y022092D01* -X016178Y022130D01* -X016187Y022168D01* -X016201Y022204D01* -X016217Y022240D01* -X016238Y022273D01* -X016261Y022304D01* -X016288Y022332D01* -X016317Y022358D01* -X016348Y022381D01* -X016382Y022400D01* -X016418Y022416D01* -X016454Y022428D01* -X016492Y022437D01* -X016531Y022442D01* -X016570Y022443D01* -X016608Y022440D01* -X016647Y022433D01* -X016684Y022423D01* -X016720Y022408D01* -X016755Y022391D01* -X016788Y022370D01* -X016818Y022345D01* -X016846Y022318D01* -X016871Y022288D01* -X016893Y022256D01* -X016911Y022222D01* -X016926Y022186D01* -X016938Y022149D01* -X016946Y022111D01* -X016950Y022072D01* -X016950Y022034D01* -X016946Y021995D01* -X016938Y021957D01* -X016926Y021920D01* -X016911Y021884D01* -X016893Y021850D01* -X016871Y021818D01* -X016846Y021788D01* -X016818Y021761D01* -X016788Y021736D01* -X016755Y021715D01* -X016720Y021698D01* -X016684Y021683D01* -X016647Y021673D01* -X016608Y021666D01* -X016570Y021663D01* -X016531Y021664D01* -X016492Y021669D01* -X016454Y021678D01* -X016418Y021690D01* -X016382Y021706D01* -X016348Y021725D01* -X016317Y021748D01* -X016288Y021774D01* -X016261Y021802D01* -X016238Y021833D01* -X016217Y021866D01* -X016201Y021902D01* -X016187Y021938D01* -X016178Y021976D01* -X016172Y022014D01* -X016170Y022053D01* -X016160Y021653D02* -X016960Y022453D01* -X013560Y019453D02* -X013560Y019053D01* -X013560Y019453D02* -X013960Y019453D01* -X013960Y018653D01* -X013160Y018653D01* -X013160Y019453D01* -X013560Y019453D01* -X006170Y010553D02* -X006172Y010592D01* -X006178Y010630D01* -X006187Y010668D01* -X006201Y010704D01* -X006217Y010740D01* -X006238Y010773D01* -X006261Y010804D01* -X006288Y010832D01* -X006317Y010858D01* -X006348Y010881D01* -X006382Y010900D01* -X006418Y010916D01* -X006454Y010928D01* -X006492Y010937D01* -X006531Y010942D01* -X006570Y010943D01* -X006608Y010940D01* -X006647Y010933D01* -X006684Y010923D01* -X006720Y010908D01* -X006755Y010891D01* -X006788Y010870D01* -X006818Y010845D01* -X006846Y010818D01* -X006871Y010788D01* -X006893Y010756D01* -X006911Y010722D01* -X006926Y010686D01* -X006938Y010649D01* -X006946Y010611D01* -X006950Y010572D01* -X006950Y010534D01* -X006946Y010495D01* -X006938Y010457D01* -X006926Y010420D01* -X006911Y010384D01* -X006893Y010350D01* -X006871Y010318D01* -X006846Y010288D01* -X006818Y010261D01* -X006788Y010236D01* -X006755Y010215D01* -X006720Y010198D01* -X006684Y010183D01* -X006647Y010173D01* -X006608Y010166D01* -X006570Y010163D01* -X006531Y010164D01* -X006492Y010169D01* -X006454Y010178D01* -X006418Y010190D01* -X006382Y010206D01* -X006348Y010225D01* -X006317Y010248D01* -X006288Y010274D01* -X006261Y010302D01* -X006238Y010333D01* -X006217Y010366D01* -X006201Y010402D01* -X006187Y010438D01* -X006178Y010476D01* -X006172Y010514D01* -X006170Y010553D01* -X006160Y010153D02* -X006960Y010953D01* -X006170Y009553D02* -X006172Y009592D01* -X006178Y009630D01* -X006187Y009668D01* -X006201Y009704D01* -X006217Y009740D01* -X006238Y009773D01* -X006261Y009804D01* -X006288Y009832D01* -X006317Y009858D01* -X006348Y009881D01* -X006382Y009900D01* -X006418Y009916D01* -X006454Y009928D01* -X006492Y009937D01* -X006531Y009942D01* -X006570Y009943D01* -X006608Y009940D01* -X006647Y009933D01* -X006684Y009923D01* -X006720Y009908D01* -X006755Y009891D01* -X006788Y009870D01* -X006818Y009845D01* -X006846Y009818D01* -X006871Y009788D01* -X006893Y009756D01* -X006911Y009722D01* -X006926Y009686D01* -X006938Y009649D01* -X006946Y009611D01* -X006950Y009572D01* -X006950Y009534D01* -X006946Y009495D01* -X006938Y009457D01* -X006926Y009420D01* -X006911Y009384D01* -X006893Y009350D01* -X006871Y009318D01* -X006846Y009288D01* -X006818Y009261D01* -X006788Y009236D01* -X006755Y009215D01* -X006720Y009198D01* -X006684Y009183D01* -X006647Y009173D01* -X006608Y009166D01* -X006570Y009163D01* -X006531Y009164D01* -X006492Y009169D01* -X006454Y009178D01* -X006418Y009190D01* -X006382Y009206D01* -X006348Y009225D01* -X006317Y009248D01* -X006288Y009274D01* -X006261Y009302D01* -X006238Y009333D01* -X006217Y009366D01* -X006201Y009402D01* -X006187Y009438D01* -X006178Y009476D01* -X006172Y009514D01* -X006170Y009553D01* -X006160Y009153D02* -X006960Y009953D01* -X007660Y009153D02* -X008460Y009953D01* -X007660Y009953D01* -X008460Y009153D01* -X007660Y009153D01* -X023660Y017153D02* -X024460Y017953D01* -X023660Y017953D01* -X024460Y017153D01* -X023660Y017153D01* -X024660Y017153D02* -X025460Y017953D01* -X024660Y017953D01* -X025460Y017153D01* -X024660Y017153D01* -X025660Y017153D02* -X026460Y017953D01* -X025660Y017953D01* -X026460Y017153D01* -X025660Y017153D01* -X026460Y016953D02* -X025660Y016153D01* -X025660Y016953D02* -X026460Y016953D01* -X025660Y016953D02* -X026460Y016153D01* -X025660Y016153D01* -X025660Y018153D02* -X026460Y018953D01* -X025660Y018953D01* -X026460Y018153D01* -X025660Y018153D01* -X025460Y018953D02* -X024660Y018153D01* -X024660Y018953D02* -X025460Y018953D01* -X024660Y018953D02* -X025460Y018153D01* -X024660Y018153D01* -X024460Y018953D02* -X023660Y018153D01* -X023660Y018953D02* -X024460Y018953D01* -X023660Y018953D02* -X024460Y018153D01* -X023660Y018153D01* -X023660Y019153D02* -X024460Y019953D01* -X023660Y019953D01* -X024460Y019153D01* -X023660Y019153D01* -X024660Y019153D02* -X025460Y019953D01* -X024660Y019953D01* -X025460Y019153D01* -X024660Y019153D01* -X025660Y019153D02* -X026460Y019953D01* -X025660Y019953D01* -X026460Y019153D01* -X025660Y019153D01* -X025450Y021763D02* -X024650Y021763D01* -X025050Y021363D02* -X025050Y022163D01* -X024660Y021763D02* -X024662Y021802D01* -X024668Y021840D01* -X024677Y021878D01* -X024691Y021914D01* -X024707Y021950D01* -X024728Y021983D01* -X024751Y022014D01* -X024778Y022042D01* -X024807Y022068D01* -X024838Y022091D01* -X024872Y022110D01* -X024908Y022126D01* -X024944Y022138D01* -X024982Y022147D01* -X025021Y022152D01* -X025060Y022153D01* -X025098Y022150D01* -X025137Y022143D01* -X025174Y022133D01* -X025210Y022118D01* -X025245Y022101D01* -X025278Y022080D01* -X025308Y022055D01* -X025336Y022028D01* -X025361Y021998D01* -X025383Y021966D01* -X025401Y021932D01* -X025416Y021896D01* -X025428Y021859D01* -X025436Y021821D01* -X025440Y021782D01* -X025440Y021744D01* -X025436Y021705D01* -X025428Y021667D01* -X025416Y021630D01* -X025401Y021594D01* -X025383Y021560D01* -X025361Y021528D01* -X025336Y021498D01* -X025308Y021471D01* -X025278Y021446D01* -X025245Y021425D01* -X025210Y021408D01* -X025174Y021393D01* -X025137Y021383D01* -X025098Y021376D01* -X025060Y021373D01* -X025021Y021374D01* -X024982Y021379D01* -X024944Y021388D01* -X024908Y021400D01* -X024872Y021416D01* -X024838Y021435D01* -X024807Y021458D01* -X024778Y021484D01* -X024751Y021512D01* -X024728Y021543D01* -X024707Y021576D01* -X024691Y021612D01* -X024677Y021648D01* -X024668Y021686D01* -X024662Y021724D01* -X024660Y021763D01* -X024855Y021763D02* -X024857Y021791D01* -X024863Y021818D01* -X024873Y021844D01* -X024886Y021868D01* -X024903Y021891D01* -X024922Y021910D01* -X024945Y021927D01* -X024969Y021940D01* -X024995Y021950D01* -X025022Y021956D01* -X025050Y021958D01* -X025078Y021956D01* -X025105Y021950D01* -X025131Y021940D01* -X025155Y021927D01* -X025178Y021910D01* -X025197Y021891D01* -X025214Y021868D01* -X025227Y021844D01* -X025237Y021818D01* -X025243Y021791D01* -X025245Y021763D01* -X025243Y021735D01* -X025237Y021708D01* -X025227Y021682D01* -X025214Y021658D01* -X025197Y021635D01* -X025178Y021616D01* -X025155Y021599D01* -X025131Y021586D01* -X025105Y021576D01* -X025078Y021570D01* -X025050Y021568D01* -X025022Y021570D01* -X024995Y021576D01* -X024969Y021586D01* -X024945Y021599D01* -X024922Y021616D01* -X024903Y021635D01* -X024886Y021658D01* -X024873Y021682D01* -X024863Y021708D01* -X024857Y021735D01* -X024855Y021763D01* -M02* diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.dri b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.dri deleted file mode 100644 index 18b0117..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_factory_gerbers/M644_breakout_v1.2d.dri +++ /dev/null @@ -1,43 +0,0 @@ -Generated by EAGLE CAM Processor 5.6.0 - -Drill Station Info File: E:/Working/Eagle_5_6_0/projects/MEGA644-1284/M644_breakout_v1.2d.dri - - Date : 27.01.2019 20:15:27 - Drills : generated - Device : Excellon drill station - -Parameter settings: - - Tolerance Drill + : 0.00 % - Tolerance Drill - : 0.00 % - Rotate : no - Mirror : no - Optimize : no - Auto fit : no - OffsetX : 0inch - OffsetY : 0inch - Layers : Drills Holes - -Drill File Info: - - Data Mode : Absolute - Units : 1/10000 Inch - -Drills used: - - Code Size used - - T01 0.0236inch 4 - T02 0.0276inch 10 - T03 0.0320inch 2 - T04 0.0354inch 36 - T05 0.0360inch 6 - T06 0.0400inch 33 - T07 0.0470inch 2 - T08 0.1260inch 3 - -Total number of drills: 96 - -Plotfiles: - - E:/Working/Eagle_5_6_0/projects/MEGA644-1284/M644_breakout_v1.2d.TXT diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_pinmap.kicad_pcb b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_pinmap.kicad_pcb deleted file mode 100644 index e06cc01..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_pinmap.kicad_pcb +++ /dev/null @@ -1,3776 +0,0 @@ -(kicad_pcb (version 20171130) (host pcbnew "(5.0.2)-1") - - (general - (thickness 1.6) - (drawings 118) - (tracks 486) - (zones 0) - (modules 64) - (nets 51) - ) - - (page A4) - (title_block - (title "M644/M1284 breakout (Eagle 6.5 exported)") - (date 2019-03-07) - (rev v1.2d) - (company "(c) Ibragimov M. Russia Togliatty") - ) - - (layers - (0 Top signal) - (31 Bottom signal) - (32 B.Adhes user) - (33 F.Adhes user) - (34 B.Paste user) - (35 F.Paste user) - (36 B.SilkS user) - (37 F.SilkS user) - (38 B.Mask user) - (39 F.Mask user) - (40 Dwgs.User user) - (41 Cmts.User user) - (42 Eco1.User user) - (43 Eco2.User user) - (44 Edge.Cuts user) - (45 Margin user) - (46 B.CrtYd user) - (47 F.CrtYd user) - (48 B.Fab user) - (49 F.Fab user) - ) - - (setup - (last_trace_width 0.25) - (user_trace_width 0.4064) - (user_trace_width 0.6096) - (user_trace_width 1.016) - (trace_clearance 0.1524) - (zone_clearance 0.508) - (zone_45_only no) - (trace_min 0.2) - (segment_width 0.2) - (edge_width 0.15) - (via_size 0.8) - (via_drill 0.4) - (via_min_size 0.4) - (via_min_drill 0.3) - (uvia_size 0.3) - (uvia_drill 0.1) - (uvias_allowed no) - (uvia_min_size 0.2) - (uvia_min_drill 0.1) - (pcb_text_width 0.3) - (pcb_text_size 1.5 1.5) - (mod_edge_width 0.15) - (mod_text_size 1 1) - (mod_text_width 0.15) - (pad_size 1.7 1.7) - (pad_drill 1) - (pad_to_mask_clearance 0.051) - (solder_mask_min_width 0.25) - (aux_axis_origin 0 0) - (grid_origin 130.0861 124.9636) - (visible_elements 7FFFFFFF) - (pcbplotparams - (layerselection 0x010fc_ffffffff) - (usegerberextensions false) - (usegerberattributes false) - (usegerberadvancedattributes false) - (creategerberjobfile false) - (excludeedgelayer true) - (linewidth 0.100000) - (plotframeref false) - (viasonmask false) - (mode 1) - (useauxorigin false) - (hpglpennumber 1) - (hpglpenspeed 20) - (hpglpendiameter 15.000000) - (psnegative false) - (psa4output false) - (plotreference true) - (plotvalue true) - (plotinvisibletext false) - (padsonsilk false) - (subtractmaskfromsilk false) - (outputformat 1) - (mirror false) - (drillshape 1) - (scaleselection 1) - (outputdirectory "")) - ) - - (net 0 "") - (net 1 GND) - (net 2 VCC) - (net 3 N$7) - (net 4 N$8) - (net 5 N$9) - (net 6 /PB4) - (net 7 /PB3) - (net 8 /PB2) - (net 9 /PB1) - (net 10 /PB0) - (net 11 /PA0) - (net 12 /PA1) - (net 13 /PA2) - (net 14 /PA3) - (net 15 /PA4) - (net 16 /PA5) - (net 17 /PA6) - (net 18 /PA7) - (net 19 /AREF) - (net 20 "Net-(C11-PadP$1)") - (net 21 /PC7) - (net 22 /PC6) - (net 23 /PC5) - (net 24 /PC4) - (net 25 /PC3) - (net 26 /PC2) - (net 27 /PC1) - (net 28 /PC0) - (net 29 /PD7) - (net 30 /PD6) - (net 31 /PD5) - (net 32 /PD4) - (net 33 /PD3) - (net 34 /PD2) - (net 35 /PD1) - (net 36 /PD0) - (net 37 "Net-(C2-PadP$1)") - (net 38 "Net-(C1-PadP$1)") - (net 39 /RESET) - (net 40 /SCK) - (net 41 /MISO) - (net 42 /MOSI) - (net 43 "Net-(C4-PadP$1)") - (net 44 "Net-(LED1-PadA)") - (net 45 /PD3') - (net 46 /PD1') - (net 47 "Net-(D1-PadA)") - (net 48 "Net-(D1-PadC)") - (net 49 "Net-(D2-PadC)") - (net 50 "Net-(R3-PadP$1)") - - (net_class Default "This is the default net class." - (clearance 0.1524) - (trace_width 0.25) - (via_dia 0.8) - (via_drill 0.4) - (uvia_dia 0.3) - (uvia_drill 0.1) - (add_net /AREF) - (add_net /MISO) - (add_net /MOSI) - (add_net /PA0) - (add_net /PA1) - (add_net /PA2) - (add_net /PA3) - (add_net /PA4) - (add_net /PA5) - (add_net /PA6) - (add_net /PA7) - (add_net /PB0) - (add_net /PB1) - (add_net /PB2) - (add_net /PB3) - (add_net /PB4) - (add_net /PC0) - (add_net /PC1) - (add_net /PC2) - (add_net /PC3) - (add_net /PC4) - (add_net /PC5) - (add_net /PC6) - (add_net /PC7) - (add_net /PD0) - (add_net /PD1) - (add_net /PD1') - (add_net /PD2) - (add_net /PD3) - (add_net /PD3') - (add_net /PD4) - (add_net /PD5) - (add_net /PD6) - (add_net /PD7) - (add_net /RESET) - (add_net /SCK) - (add_net GND) - (add_net N$7) - (add_net N$8) - (add_net N$9) - (add_net "Net-(C1-PadP$1)") - (add_net "Net-(C11-PadP$1)") - (add_net "Net-(C2-PadP$1)") - (add_net "Net-(C4-PadP$1)") - (add_net "Net-(D1-PadA)") - (add_net "Net-(D1-PadC)") - (add_net "Net-(D2-PadC)") - (add_net "Net-(LED1-PadA)") - (add_net "Net-(R3-PadP$1)") - (add_net VCC) - ) - - (module M644_breakout_v1.2d:SMBJ (layer Bottom) (tedit 5C814E5A) (tstamp 5C811BDF) - (at 165.6461 124.9636) - (descr "DO-214AA Modified J_BEND

\nSource: www.rsonline.de .. SMBJ12/C/15/C/24/C/30/C/5.0/C/7.5/C Voltage Suppressor. Data Sheet") - (path /76CA823F) - (fp_text reference D3 (at 2.794 -0.5036) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value SM6T15CA (at -1.905 -3.81) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 2.25 -1.1) (xy 2.8 -1.1) (xy 2.8 1.1) (xy 2.25 1.1)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.8 -1.1) (xy -2.25 -1.1) (xy -2.25 1.1) (xy -2.8 1.1)) (layer B.Fab) (width 0)) - (fp_line (start -2.24 1.92) (end 2.24 1.92) (layer B.SilkS) (width 0.1016)) - (fp_line (start -2.24 -1.92) (end -2.24 1.92) (layer B.Fab) (width 0.1016)) - (fp_line (start 2.24 -1.92) (end -2.24 -1.92) (layer B.SilkS) (width 0.1016)) - (fp_line (start 2.24 1.92) (end 2.24 -1.92) (layer B.Fab) (width 0.1016)) - (pad A smd rect (at 2.04 0 180) (size 1.78 2.16) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad C smd rect (at -2.03 0) (size 1.78 2.16) (layers Bottom B.Paste B.Mask) - (net 47 "Net-(D1-PadA)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_SMB.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:DO214AA (layer Bottom) (tedit 5C814E61) (tstamp 5C811C44) - (at 161.0741 121.1536 270) - (descr DIODE) - (path /C7EBFCBF) - (fp_text reference D1 (at 5.8464 0.4191 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value SM4007 (at -2.64 -2.706 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top mirror)) - ) - (fp_poly (pts (xy -1.4 -1.05) (xy -1.1 -1.05) (xy -1.1 1.05) (xy -1.4 1.05)) (layer B.SilkS) (width 0)) - (fp_poly (pts (xy 2.5 -0.7) (xy 2.75 -0.7) (xy 2.75 0.65) (xy 2.5 0.65)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.75 -0.7) (xy -2.5 -0.7) (xy -2.5 0.65) (xy -2.75 0.65)) (layer B.Fab) (width 0)) - (fp_line (start 0.05 -0.7) (end -1.2 0) (layer B.SilkS) (width 0.254)) - (fp_line (start 0.05 0.7) (end 0.05 -0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -1.2 0) (end 0.05 0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -2.4 -1.1) (end -2.4 1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 -1.1) (end -2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 1.1) (end 2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start -2.4 1.1) (end 2.4 1.1) (layer B.Fab) (width 0.254)) - (pad A smd rect (at 2.55 0 270) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 47 "Net-(D1-PadA)") (solder_mask_margin 0.0508)) - (pad C smd rect (at -2.55 0 270) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 48 "Net-(D1-PadC)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_MELF.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:DO214AA (layer Bottom) (tedit 5C814E54) (tstamp 5C811C53) - (at 165.7731 118.4866 180) - (descr DIODE) - (path /0CCA2570) - (fp_text reference D2 (at -0.5969 1.6466) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value SM4007 (at -2.64 -2.706) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -1.4 -1.05) (xy -1.1 -1.05) (xy -1.1 1.05) (xy -1.4 1.05)) (layer B.SilkS) (width 0)) - (fp_poly (pts (xy 2.5 -0.7) (xy 2.75 -0.7) (xy 2.75 0.65) (xy 2.5 0.65)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.75 -0.7) (xy -2.5 -0.7) (xy -2.5 0.65) (xy -2.75 0.65)) (layer B.Fab) (width 0)) - (fp_line (start 0.05 -0.7) (end -1.2 0) (layer B.SilkS) (width 0.254)) - (fp_line (start 0.05 0.7) (end 0.05 -0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -1.2 0) (end 0.05 0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -2.4 -1.1) (end -2.4 1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 -1.1) (end -2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 1.1) (end 2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start -2.4 1.1) (end 2.4 1.1) (layer B.Fab) (width 0.254)) - (pad A smd rect (at 2.55 0 180) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 48 "Net-(D1-PadC)") (solder_mask_margin 0.0508)) - (pad C smd rect (at -2.55 0 180) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 49 "Net-(D2-PadC)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_MELF.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:DO214AA (layer Bottom) (tedit 5C814E41) (tstamp 5C811C62) - (at 168.3131 113.7876 270) - (descr DIODE) - (path /0427F97B) - (fp_text reference D4 (at 0.5124 2.5781 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value SM4007 (at -2.64 -2.706 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top mirror)) - ) - (fp_poly (pts (xy -1.4 -1.05) (xy -1.1 -1.05) (xy -1.1 1.05) (xy -1.4 1.05)) (layer B.SilkS) (width 0)) - (fp_poly (pts (xy 2.5 -0.7) (xy 2.75 -0.7) (xy 2.75 0.65) (xy 2.5 0.65)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.75 -0.7) (xy -2.5 -0.7) (xy -2.5 0.65) (xy -2.75 0.65)) (layer B.Fab) (width 0)) - (fp_line (start 0.05 -0.7) (end -1.2 0) (layer B.SilkS) (width 0.254)) - (fp_line (start 0.05 0.7) (end 0.05 -0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -1.2 0) (end 0.05 0.7) (layer B.SilkS) (width 0.254)) - (fp_line (start -2.4 -1.1) (end -2.4 1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 -1.1) (end -2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start 2.4 1.1) (end 2.4 -1.1) (layer B.Fab) (width 0.254)) - (fp_line (start -2.4 1.1) (end 2.4 1.1) (layer B.Fab) (width 0.254)) - (pad A smd rect (at 2.55 0 270) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 49 "Net-(D2-PadC)") (solder_mask_margin 0.0508)) - (pad C smd rect (at -2.55 0 270) (size 1.8 2.2) (layers Bottom B.Paste B.Mask) - (net 43 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Diode_SMD.3dshapes/D_MELF.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:D_7343-31R (layer Bottom) (tedit 5C814E3B) (tstamp 5C811BEA) - (at 164.8587 104.5928 90) - (descr "Chip Capacitor Type KEMET D / EIA 7343-21

\nKEMET V / EIA 7343-20, KEMET X / EIA 7343-43 Reflow solder") - (path /FFB33241) - (fp_text reference C12 (at -6.5322 1.5113 180) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 100uF (at -3.65 -3.575 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 2.675 -2.125) (xy 3.15 -2.125) (xy 3.15 2.125) (xy 2.675 2.125)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3.5 -1.2) (xy 3.65 -1.2) (xy 3.65 1.2) (xy 3.5 1.2)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -3.65 -1.2) (xy -3.5 -1.2) (xy -3.5 1.2) (xy -3.65 1.2)) (layer B.Fab) (width 0)) - (fp_line (start -3.45 -2.1) (end -3.45 2.1) (layer B.Fab) (width 0.1016)) - (fp_line (start 3.45 -2.1) (end -3.45 -2.1) (layer B.Fab) (width 0.1016)) - (fp_line (start 3.45 2.1) (end 3.45 -2.1) (layer B.Fab) (width 0.1016)) - (fp_line (start -3.45 2.1) (end 3.45 2.1) (layer B.Fab) (width 0.1016)) - (pad - smd rect (at -3.175 0 90) (size 2.55 2.7) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad + smd rect (at 3.175 0 90) (size 2.55 2.7) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_Tantalum_SMD.3dshapes/CP_EIA-7343-31_Kemet-D.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:CHIPLED_1206 (layer Top) (tedit 5C8136C2) (tstamp 5C811DE2) - (at 130.4925 111.4508) - (descr "CHIPLED

\nSource: http://www.osram.convergy.de/ ... LG_LY N971.pdf") - (path /DD7CFDEC) - (fp_text reference LED1_SMD1 (at -1.27 1.27 90) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_text value LED_RED/PC4/20 (at 2.54 1.27 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.175 0) (xy 0.175 0) (xy 0.175 -0.35) (xy -0.175 -0.35)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy 0.525 -0.35) (xy 0.85 -0.35) (xy 0.85 -0.775) (xy 0.525 -0.775)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -0.85 -0.35) (xy -0.525 -0.35) (xy -0.525 -0.775) (xy -0.85 -0.775)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -0.85 1.65) (xy 0.85 1.65) (xy 0.85 0.95) (xy -0.85 0.95)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -0.95) (xy 0.85 -0.95) (xy 0.85 -1.25) (xy -0.85 -1.25)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.25 -1.225) (xy 0.85 -1.225) (xy 0.85 -1.35) (xy 0.25 -1.35)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.35 -1.3) (xy 0.85 -1.3) (xy 0.85 -1.65) (xy 0.35 -1.65)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.65 -1.225) (xy -0.225 -1.225) (xy -0.225 -1.35) (xy -0.65 -1.35)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.45 -1.225) (xy -0.325 -1.225) (xy -0.325 -1.45) (xy -0.45 -1.45)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -1.225) (xy -0.625 -1.225) (xy -0.625 -1.55) (xy -0.85 -1.55)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.85 -1.525) (xy -0.35 -1.525) (xy -0.35 -1.65) (xy -0.85 -1.65)) (layer F.Fab) (width 0)) - (fp_circle (center -0.55 -1.425) (end -0.45 -1.425) (layer F.Fab) (width 0.1016)) - (fp_line (start 0.8 -0.95) (end 0.8 0.95) (layer F.Fab) (width 0.1016)) - (fp_line (start -0.8 0.95) (end -0.8 -0.95) (layer F.Fab) (width 0.1016)) - (fp_arc (start 0 -1.625799) (end -0.4 -1.6) (angle -172.619069) (layer F.Fab) (width 0.1016)) - (pad A smd rect (at 0 1.75) (size 1.5 1.5) (layers Top F.Paste F.Mask) - (net 44 "Net-(LED1-PadA)") (solder_mask_margin 0.0508)) - (pad C smd rect (at 0 -1.75) (size 1.5 1.5) (layers Top F.Paste F.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/LED_SMD.3dshapes/LED_1206_3216Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:L3216C (layer Bottom) (tedit 5C814DB8) (tstamp 5C811AEE) - (at 131.1021 106.2946 270) - (descr "INDUCTOR

\nchip") - (path /EA05AC24) - (fp_text reference L2 (at -1.5196 2.1971 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 10uH (at -1.524 -2.413 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy -0.4001 -0.5999) (xy 0.4001 -0.5999) (xy 0.4001 0.5999) (xy -0.4001 0.5999)) (layer B.Adhes) (width 0)) - (fp_poly (pts (xy 1.2446 -0.9525) (xy 1.7447 -0.9525) (xy 1.7447 0.9474) (xy 1.2446 0.9474)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.7526 -0.9525) (xy -1.2525 -0.9525) (xy -1.2525 0.9474) (xy -1.7526 0.9474)) (layer B.Fab) (width 0)) - (fp_line (start -0.762 -0.883) (end 0.762 -0.883) (layer B.SilkS) (width 0.1016)) - (fp_line (start -0.762 0.896) (end 0.762 0.896) (layer B.SilkS) (width 0.1016)) - (fp_line (start 2.473 1.483) (end 2.473 -1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.27 -0.883) (end 1.27 -0.883) (layer B.Fab) (width 0.1016)) - (fp_line (start -1.27 0.896) (end 1.27 0.896) (layer B.Fab) (width 0.1016)) - (fp_line (start -2.473 -1.483) (end -2.473 1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 2.473 -1.483) (end -2.473 -1.483) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -2.473 1.483) (end 2.473 1.483) (layer Dwgs.User) (width 0.0508)) - (pad 2 smd rect (at 1.5 0 270) (size 1.2 1.6) (layers Bottom B.Paste B.Mask) - (net 20 "Net-(C11-PadP$1)") (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -1.5 0 270) (size 1.2 1.6) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Inductor_SMD.3dshapes/L_1206_3216Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:SW_TACT_SMALL (layer Top) (tedit 5C81489F) (tstamp 5C811C71) - (at 132.6261 91.9436 180) - (path /21BF7E4D) - (fp_text reference SW1/PC5 (at -3.04 -2.9825) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value SMD_TACT_4x4 (at 0 0 180) (layer F.SilkS) hide - (effects (font (size 1.27 1.27) (thickness 0.15)) (justify right top)) - ) - (fp_poly (pts (xy 1.3003 2.1) (xy 3.3 2.1) (xy 3.3 1.6) (xy 1.8003 1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.3003 -2.1) (xy -3.3 -2.1) (xy -3.3 -1.6) (xy -1.8003 -1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.3003 2.1) (xy -3.3 2.1) (xy -3.3 1.6) (xy -1.8003 1.6)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.3003 -2.1) (xy 3.3 -2.1) (xy 3.3 -1.6) (xy 1.8003 -1.6)) (layer F.Fab) (width 0)) - (fp_circle (center 0 0) (end 0.865 0) (layer F.SilkS) (width 0.0762)) - (fp_circle (center 0 0) (end 1 0) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.645 0.9958) (end 0.9958 1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.645 -0.9958) (end 1.645 0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start -0.9958 1.645) (end -1.645 0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start 0.9958 1.645) (end -0.9958 1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.645 -0.9958) (end -0.9958 -1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.645 0.9958) (end -1.645 -0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start 0.9958 -1.645) (end 1.645 -0.9958) (layer F.SilkS) (width 0.0762)) - (fp_line (start -0.9958 -1.645) (end 0.9958 -1.645) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.812 1.065) (end 1.065 1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.812 -1.065) (end 1.812 1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.065 1.812) (end -1.812 1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.065 1.812) (end -1.065 1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.812 -1.065) (end -1.065 -1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.812 1.065) (end -1.812 -1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start 1.065 -1.812) (end 1.812 -1.065) (layer F.SilkS) (width 0.0762)) - (fp_line (start -1.065 -1.812) (end 1.065 -1.812) (layer F.SilkS) (width 0.0762)) - (fp_line (start 2.5 1.1335) (end 2.181 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.5 -1.1335) (end 2.5 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.1335) (end 2.5 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.1335) (end 2.182 1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 -1.2183) (end 2.182 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.5 -1.1335) (end -2.181 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.5 1.1335) (end -2.5 -1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.1335) (end -2.5 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.1335) (end -2.182 -1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 1.2183) (end -2.182 1.1335) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 2.5) (end -1.1335 2.181) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.5) (end -1.1335 2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.182) (end 1.1335 2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 2.182) (end -1.2183 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.2183 2.182) (end 1.1335 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.1335 -2.5) (end 1.1335 -2.181) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.5) (end 1.1335 -2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.182) (end -1.1335 -2.5) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.182 -1.2183) (end -1.2183 -2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.2183 2.182) (end -2.182 1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.182 1.2183) (end 1.2183 2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.2183 -2.182) (end 2.182 -1.2183) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.1335 -2.182) (end 1.2183 -2.182) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.2183 -2.182) (end -1.1335 -2.182) (layer F.SilkS) (width 0.1524)) - (pad 4 smd rect (at 3.15 1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 3 smd rect (at -3.15 1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 2 smd rect (at 3.15 -1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 50 "Net-(R3-PadP$1)") (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -3.15 -1.9 270) (size 1 1.7) (layers Top F.Paste F.Mask) - (net 50 "Net-(R3-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Button_Switch_SMD.3dshapes/SW_SPST_TL3342.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:TO220V (layer Top) (tedit 5C81480A) (tstamp 5C811A9B) - (at 169.0751 108.4536 90) - (descr "TO 200 vertical") - (path /BC34DC86) - (fp_text reference IC2 (at 1.1386 6.0452 90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 78TV (at -5.08 7.62 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_poly (pts (xy 1.651 1.27) (xy 3.429 1.27) (xy 3.429 0.762) (xy 1.651 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.889 1.27) (xy 0.889 1.27) (xy 0.889 0.762) (xy -0.889 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.429 1.27) (xy 5.334 1.27) (xy 5.334 0.762) (xy 3.429 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy 0.889 1.27) (xy 1.651 1.27) (xy 1.651 0.762) (xy 0.889 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -3.429 1.27) (xy -1.651 1.27) (xy -1.651 0.762) (xy -3.429 0.762)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.651 1.27) (xy -0.889 1.27) (xy -0.889 0.762) (xy -1.651 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -5.334 1.27) (xy -3.429 1.27) (xy -3.429 0.762) (xy -5.334 0.762)) (layer F.SilkS) (width 0)) - (fp_poly (pts (xy -5.334 0.762) (xy 5.334 0.762) (xy 5.334 0) (xy -5.334 0)) (layer F.SilkS) (width 0)) - (fp_text user 3 (at 1.905 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 2 (at -0.635 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 1 (at -3.175 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_circle (center -4.4958 3.7084) (end -4.2418 3.7084) (layer F.SilkS) (width 0.127)) - (fp_line (start -4.953 4.064) (end -5.08 1.143) (layer F.SilkS) (width 0.127)) - (fp_line (start -4.953 4.064) (end -4.699 4.318) (layer F.SilkS) (width 0.127)) - (fp_line (start 4.699 4.318) (end -4.699 4.318) (layer F.SilkS) (width 0.127)) - (fp_line (start 4.699 4.318) (end 4.953 4.064) (layer F.SilkS) (width 0.127)) - (fp_line (start 5.08 1.143) (end 4.953 4.064) (layer F.SilkS) (width 0.127)) - (pad 3 thru_hole oval (at 2.54 2.54 180) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 2 thru_hole oval (at 0 2.54 180) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 1 thru_hole oval (at -2.54 2.54 180) (size 3.048 1.524) (drill 1.016) (layers *.Cu *.Mask) - (net 43 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Package_TO_SOT_THT.3dshapes/TO-220-3_Horizontal_TabDown.wrl - (offset (xyz -2.5 -2.5 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:ML6 (layer Top) (tedit 5C8147EA) (tstamp 5C811A62) - (at 163.1061 91.9436 270) - (descr HARTING) - (path /03BB57A4) - (fp_text reference SV1 (at -5.5836 9.4361) (layer F.SilkS) - (effects (font (size 1.6891 1.6891) (thickness 0.3)) (justify left bottom)) - ) - (fp_text value ISP_6PIN (at 0.635 -5.08) (layer F.Fab) - (effects (font (size 1.6891 1.6891) (thickness 0.16891)) (justify left bottom)) - ) - (fp_poly (pts (xy 2.286 1.524) (xy 2.794 1.524) (xy 2.794 1.016) (xy 2.286 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 1.524) (xy -2.286 1.524) (xy -2.286 1.016) (xy -2.794 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 1.524) (xy 0.254 1.524) (xy 0.254 1.016) (xy -0.254 1.016)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 -1.016) (xy 2.794 -1.016) (xy 2.794 -1.524) (xy 2.286 -1.524)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 -1.016) (xy -2.286 -1.016) (xy -2.286 -1.524) (xy -2.794 -1.524)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 -1.016) (xy 0.254 -1.016) (xy 0.254 -1.524) (xy -0.254 -1.524)) (layer F.Fab) (width 0)) - (fp_text user 6 (at -0.381 4.064 270) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 2 (at -5.08 -0.635 270) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 1 (at -5.08 1.905 270) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_line (start -3.81 4.445) (end -7.62 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.81 4.445) (end -3.81 4.318) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 4.318) (end -3.81 4.318) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 4.318) (end -2.54 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 4.445) (end -2.54 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.429) (end -2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.604 3.429) (end -2.032 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start -6.604 -3.429) (end -6.604 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 6.604 -3.429) (end -6.604 -3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 6.604 3.429) (end 6.604 -3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 2.032 3.429) (end 6.604 3.429) (layer F.SilkS) (width 0.0508)) - (fp_line (start 2.032 3.429) (end 2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 3.175) (end 2.032 3.429) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 3.175) (end 2.032 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 4.445) (end -2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 4.445) (end 2.032 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.445) (end -0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.699) (end -5.08 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -4.699) (end -6.35 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -4.699) (end -6.35 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -4.699) (end -0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.445) (end 5.08 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.699) (end 0.635 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -4.699) (end -0.635 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.445) (end 7.62 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -4.445) (end 5.08 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.699) (end 5.08 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 -4.445) (end 6.35 -4.699) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -2.032 3.429) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -6.35 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.032 3.175) (end -2.032 2.413) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 2.413) (end -2.032 2.413) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.032 2.413) (end 2.032 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -4.445) (end -7.62 4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 4.445) (end 7.62 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -4.445) (end -6.35 -4.445) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -3.175) (end -6.35 3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.35 3.175) (end 6.35 -3.175) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.35 -3.175) (end 6.35 -3.175) (layer F.SilkS) (width 0.1524)) - (pad 6 thru_hole circle (at 2.54 -1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 2.54 1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 39 /RESET) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at 0 -1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 42 /MOSI) (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at 0 1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 40 /SCK) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -2.54 -1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -2.54 1.27 270) (size 1.6764 1.6764) (drill 0.9144) (layers *.Cu *.Mask) - (net 41 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_IDC.3dshapes/IDC-Header_2x03_P2.54mm_Vertical.wrl - (offset (xyz -2.5 -1.5 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 -90)) - ) - ) - - (module M644_breakout_v1.2d:1X12 (layer Top) (tedit 5C8136DB) (tstamp 5C811B39) - (at 144.0561 124.9636 180) - (descr "PIN HEADER") - (path /B09918B6) - (fp_text reference JP3 (at -15.3162 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x12 (at -15.24 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy 13.716 0.254) (xy 14.224 0.254) (xy 14.224 -0.254) (xy 13.716 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -14.224 0.254) (xy -13.716 0.254) (xy -13.716 -0.254) (xy -14.224 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -11.684 0.254) (xy -11.176 0.254) (xy -11.176 -0.254) (xy -11.684 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -9.144 0.254) (xy -8.636 0.254) (xy -8.636 -0.254) (xy -9.144 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -6.604 0.254) (xy -6.096 0.254) (xy -6.096 -0.254) (xy -6.604 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -4.064 0.254) (xy -3.556 0.254) (xy -3.556 -0.254) (xy -4.064 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -1.524 0.254) (xy -1.016 0.254) (xy -1.016 -0.254) (xy -1.524 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 1.016 0.254) (xy 1.524 0.254) (xy 1.524 -0.254) (xy 1.016 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 3.556 0.254) (xy 4.064 0.254) (xy 4.064 -0.254) (xy 3.556 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 6.096 0.254) (xy 6.604 0.254) (xy 6.604 -0.254) (xy 6.096 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 8.636 0.254) (xy 9.144 0.254) (xy 9.144 -0.254) (xy 8.636 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 11.176 0.254) (xy 11.684 0.254) (xy 11.684 -0.254) (xy 11.176 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 13.335 1.27) (end 12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 14.605 1.27) (end 13.335 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 15.24 0.635) (end 14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 15.24 -0.635) (end 15.24 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 14.605 -1.27) (end 15.24 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 13.335 -1.27) (end 14.605 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 -0.635) (end 13.335 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -13.335 1.27) (end -14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -15.24 0.635) (end -14.605 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -14.605 -1.27) (end -15.24 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -15.24 -0.635) (end -15.24 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.065 1.27) (end -12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.795 1.27) (end -12.065 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 0.635) (end -10.795 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 -0.635) (end -10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.795 -1.27) (end -10.16 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.065 -1.27) (end -10.795 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 -0.635) (end -12.065 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 0.635) (end -13.335 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -12.7 -0.635) (end -12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -13.335 -1.27) (end -12.7 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -14.605 -1.27) (end -13.335 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.715 1.27) (end -6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 0.635) (end -6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.985 -1.27) (end -7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -9.525 1.27) (end -10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -8.255 1.27) (end -9.525 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 0.635) (end -8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -7.62 -0.635) (end -7.62 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -8.255 -1.27) (end -7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -9.525 -1.27) (end -8.255 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -10.16 -0.635) (end -9.525 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.445 1.27) (end -5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.175 1.27) (end -4.445 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 0.635) (end -3.175 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 -0.635) (end -2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.175 -1.27) (end -2.54 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.445 -1.27) (end -3.175 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -0.635) (end -4.445 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 0.635) (end -5.715 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.08 -0.635) (end -5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -5.715 -1.27) (end -5.08 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -6.985 -1.27) (end -5.715 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.905 1.27) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 0 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.905 1.27) (end -2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 1.27) (end -1.905 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0 -0.635) (end 0 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.905 -1.27) (end -0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -2.54 -0.635) (end -1.905 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.175 1.27) (end 2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.445 1.27) (end 3.175 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 0.635) (end 4.445 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -0.635) (end 5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.445 -1.27) (end 5.08 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.175 -1.27) (end 4.445 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 -0.635) (end 3.175 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 0.635) (end 1.905 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 2.54 -0.635) (end 2.54 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.905 -1.27) (end 2.54 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.905 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 9.525 1.27) (end 8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 0.635) (end 8.255 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 8.255 -1.27) (end 7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.715 1.27) (end 5.08 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.985 1.27) (end 5.715 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 0.635) (end 6.985 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 7.62 -0.635) (end 7.62 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 6.985 -1.27) (end 7.62 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.715 -1.27) (end 6.985 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 5.08 -0.635) (end 5.715 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.795 1.27) (end 10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.065 1.27) (end 10.795 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 0.635) (end 12.065 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.7 -0.635) (end 12.7 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 12.065 -1.27) (end 12.7 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.795 -1.27) (end 12.065 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 -0.635) (end 10.795 -1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 0.635) (end 9.525 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 10.16 -0.635) (end 10.16 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 9.525 -1.27) (end 10.16 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 8.255 -1.27) (end 9.525 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 12 thru_hole circle (at 13.97 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 25 /PC3) (solder_mask_margin 0.0508)) - (pad 11 thru_hole circle (at 11.43 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 26 /PC2) (solder_mask_margin 0.0508)) - (pad 10 thru_hole circle (at 8.89 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 27 /PC1) (solder_mask_margin 0.0508)) - (pad 9 thru_hole circle (at 6.35 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 28 /PC0) (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 3.81 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 29 /PD7) (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 1.27 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 30 /PD6) (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at -1.27 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 31 /PD5) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at -3.81 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 32 /PD4) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -6.35 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 45 /PD3') (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -8.89 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 34 /PD2) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -11.43 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 46 /PD1') (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -13.97 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 36 /PD0) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x12_P2.54mm_Vertical.wrl - (offset (xyz 14 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:TQFP44 (layer Bottom) (tedit 5C814DE3) (tstamp 5C8119C4) - (at 142.7861 105.9136 180) - (descr "Thin Plasic Quad Flat Package") - (path /0232E636) - (fp_text reference IC1 (at -5.1689 6.985) (layer B.SilkS) - (effects (font (size 1.6891 1.6891) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value ATMEGA16/32/644/1284 (at -4.445 -8.7551) (layer B.Fab) - (effects (font (size 1.35128 1.35128) (thickness 0.108102)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -4.1999 4.95) (xy -3.8001 4.95) (xy -3.8001 6.1001) (xy -4.1999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -3.4 4.95) (xy -3 4.95) (xy -3 6.1001) (xy -3.4 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.5999 4.95) (xy -2.1999 4.95) (xy -2.1999 6.1001) (xy -2.5999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.8001 4.95) (xy -1.4 4.95) (xy -1.4 6.1001) (xy -1.8001 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1 4.95) (xy -0.5999 4.95) (xy -0.5999 6.1001) (xy -1 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -0.1999 4.95) (xy 0.1999 4.95) (xy 0.1999 6.1001) (xy -0.1999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.5999 4.95) (xy 1 4.95) (xy 1 6.1001) (xy 0.5999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 1.4 4.95) (xy 1.8001 4.95) (xy 1.8001 6.1001) (xy 1.4 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 2.1999 4.95) (xy 2.5999 4.95) (xy 2.5999 6.1001) (xy 2.1999 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3 4.95) (xy 3.4 4.95) (xy 3.4 6.1001) (xy 3 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3.8001 4.95) (xy 4.1999 4.95) (xy 4.1999 6.1001) (xy 3.8001 6.1001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 3.8001) (xy 6.1001 3.8001) (xy 6.1001 4.1999) (xy 4.95 4.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 3) (xy 6.1001 3) (xy 6.1001 3.4) (xy 4.95 3.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 2.1999) (xy 6.1001 2.1999) (xy 6.1001 2.5999) (xy 4.95 2.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 1.4) (xy 6.1001 1.4) (xy 6.1001 1.8001) (xy 4.95 1.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 0.5999) (xy 6.1001 0.5999) (xy 6.1001 1) (xy 4.95 1)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -0.1999) (xy 6.1001 -0.1999) (xy 6.1001 0.1999) (xy 4.95 0.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -1) (xy 6.1001 -1) (xy 6.1001 -0.5999) (xy 4.95 -0.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -1.8001) (xy 6.1001 -1.8001) (xy 6.1001 -1.4) (xy 4.95 -1.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -2.5999) (xy 6.1001 -2.5999) (xy 6.1001 -2.1999) (xy 4.95 -2.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -3.4) (xy 6.1001 -3.4) (xy 6.1001 -3) (xy 4.95 -3)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 4.95 -4.1999) (xy 6.1001 -4.1999) (xy 6.1001 -3.8001) (xy 4.95 -3.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3.8001 -6.1001) (xy 4.1999 -6.1001) (xy 4.1999 -4.95) (xy 3.8001 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 3 -6.1001) (xy 3.4 -6.1001) (xy 3.4 -4.95) (xy 3 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 2.1999 -6.1001) (xy 2.5999 -6.1001) (xy 2.5999 -4.95) (xy 2.1999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 1.4 -6.1001) (xy 1.8001 -6.1001) (xy 1.8001 -4.95) (xy 1.4 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.5999 -6.1001) (xy 1 -6.1001) (xy 1 -4.95) (xy 0.5999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -0.1999 -6.1001) (xy 0.1999 -6.1001) (xy 0.1999 -4.95) (xy -0.1999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1 -6.1001) (xy -0.5999 -6.1001) (xy -0.5999 -4.95) (xy -1 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.8001 -6.1001) (xy -1.4 -6.1001) (xy -1.4 -4.95) (xy -1.8001 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -2.5999 -6.1001) (xy -2.1999 -6.1001) (xy -2.1999 -4.95) (xy -2.5999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -3.4 -6.1001) (xy -3 -6.1001) (xy -3 -4.95) (xy -3.4 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -4.1999 -6.1001) (xy -3.8001 -6.1001) (xy -3.8001 -4.95) (xy -4.1999 -4.95)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -4.1999) (xy -4.95 -4.1999) (xy -4.95 -3.8001) (xy -6.1001 -3.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -3.4) (xy -4.95 -3.4) (xy -4.95 -3) (xy -6.1001 -3)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -2.5999) (xy -4.95 -2.5999) (xy -4.95 -2.1999) (xy -6.1001 -2.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -1.8001) (xy -4.95 -1.8001) (xy -4.95 -1.4) (xy -6.1001 -1.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -1) (xy -4.95 -1) (xy -4.95 -0.5999) (xy -6.1001 -0.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 -0.1999) (xy -4.95 -0.1999) (xy -4.95 0.1999) (xy -6.1001 0.1999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 0.5999) (xy -4.95 0.5999) (xy -4.95 1) (xy -6.1001 1)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 1.4) (xy -4.95 1.4) (xy -4.95 1.8001) (xy -6.1001 1.8001)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 2.1999) (xy -4.95 2.1999) (xy -4.95 2.5999) (xy -6.1001 2.5999)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 3) (xy -4.95 3) (xy -4.95 3.4) (xy -6.1001 3.4)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -6.1001 3.8001) (xy -4.95 3.8001) (xy -4.95 4.1999) (xy -6.1001 4.1999)) (layer B.Fab) (width 0)) - (fp_circle (center -4 4) (end -3.7173 4) (layer B.SilkS) (width 0.254)) - (fp_line (start -4.8 -4.4) (end -4.8 4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start -4.4 -4.8) (end -4.8 -4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.4 -4.8) (end -4.4 -4.8) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.8 -4.4) (end 4.4 -4.8) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.8 4.4) (end 4.8 -4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start 4.4 4.8) (end 4.8 4.4) (layer B.SilkS) (width 0.2032)) - (fp_line (start -4.4 4.8) (end 4.4 4.8) (layer B.SilkS) (width 0.2032)) - (fp_line (start -4.8 4.4) (end -4.4 4.8) (layer B.SilkS) (width 0.2032)) - (pad 44 smd rect (at -4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 6 /PB4) (solder_mask_margin 0.0508)) - (pad 43 smd rect (at -3.2 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 7 /PB3) (solder_mask_margin 0.0508)) - (pad 42 smd rect (at -2.4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 8 /PB2) (solder_mask_margin 0.0508)) - (pad 41 smd rect (at -1.6 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 9 /PB1) (solder_mask_margin 0.0508)) - (pad 40 smd rect (at -0.8 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 10 /PB0) (solder_mask_margin 0.0508)) - (pad 39 smd rect (at 0 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 38 smd rect (at 0.8 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 37 smd rect (at 1.6 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 11 /PA0) (solder_mask_margin 0.0508)) - (pad 36 smd rect (at 2.4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 12 /PA1) (solder_mask_margin 0.0508)) - (pad 35 smd rect (at 3.2 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 13 /PA2) (solder_mask_margin 0.0508)) - (pad 34 smd rect (at 4 5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 14 /PA3) (solder_mask_margin 0.0508)) - (pad 33 smd rect (at 5.8 4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 15 /PA4) (solder_mask_margin 0.0508)) - (pad 32 smd rect (at 5.8 3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 16 /PA5) (solder_mask_margin 0.0508)) - (pad 31 smd rect (at 5.8 2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 17 /PA6) (solder_mask_margin 0.0508)) - (pad 30 smd rect (at 5.8 1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 18 /PA7) (solder_mask_margin 0.0508)) - (pad 29 smd rect (at 5.8 0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 19 /AREF) (solder_mask_margin 0.0508)) - (pad 28 smd rect (at 5.8 0 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 27 smd rect (at 5.8 -0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 20 "Net-(C11-PadP$1)") (solder_mask_margin 0.0508)) - (pad 26 smd rect (at 5.8 -1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 21 /PC7) (solder_mask_margin 0.0508)) - (pad 25 smd rect (at 5.8 -2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 22 /PC6) (solder_mask_margin 0.0508)) - (pad 24 smd rect (at 5.8 -3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 23 /PC5) (solder_mask_margin 0.0508)) - (pad 23 smd rect (at 5.8 -4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 24 /PC4) (solder_mask_margin 0.0508)) - (pad 22 smd rect (at 4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 25 /PC3) (solder_mask_margin 0.0508)) - (pad 21 smd rect (at 3.2 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 26 /PC2) (solder_mask_margin 0.0508)) - (pad 20 smd rect (at 2.4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 27 /PC1) (solder_mask_margin 0.0508)) - (pad 19 smd rect (at 1.6 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 28 /PC0) (solder_mask_margin 0.0508)) - (pad 18 smd rect (at 0.8 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 17 smd rect (at 0 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 16 smd rect (at -0.8 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 29 /PD7) (solder_mask_margin 0.0508)) - (pad 15 smd rect (at -1.6 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 30 /PD6) (solder_mask_margin 0.0508)) - (pad 14 smd rect (at -2.4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 31 /PD5) (solder_mask_margin 0.0508)) - (pad 13 smd rect (at -3.2 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 32 /PD4) (solder_mask_margin 0.0508)) - (pad 12 smd rect (at -4 -5.8 180) (size 0.5 1.5) (layers Bottom B.Paste B.Mask) - (net 33 /PD3) (solder_mask_margin 0.0508)) - (pad 11 smd rect (at -5.8 -4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 34 /PD2) (solder_mask_margin 0.0508)) - (pad 10 smd rect (at -5.8 -3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 35 /PD1) (solder_mask_margin 0.0508)) - (pad 9 smd rect (at -5.8 -2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 36 /PD0) (solder_mask_margin 0.0508)) - (pad 8 smd rect (at -5.8 -1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 37 "Net-(C2-PadP$1)") (solder_mask_margin 0.0508)) - (pad 7 smd rect (at -5.8 -0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 38 "Net-(C1-PadP$1)") (solder_mask_margin 0.0508)) - (pad 6 smd rect (at -5.8 0 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 5 smd rect (at -5.8 0.8 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 4 smd rect (at -5.8 1.6 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 39 /RESET) (solder_mask_margin 0.0508)) - (pad 3 smd rect (at -5.8 2.4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 40 /SCK) (solder_mask_margin 0.0508)) - (pad 2 smd rect (at -5.8 3.2 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 41 /MISO) (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -5.8 4 180) (size 1.5 0.5) (layers Bottom B.Paste B.Mask) - (net 42 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Package_QFP.3dshapes/TQFP-44_10x10mm_P0.8mm.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814E22) (tstamp 5C811A50) - (at 159.2961 100.8336 270) - (descr LYT) - (path /120B1331) - (fp_text reference R2 (at -1.7736 0.5461 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 4.7KOm (at -0.762 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 39 /RESET) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814DC4) (tstamp 5C811BA9) - (at 129.5019 114.8036 180) - (descr LYT) - (path /DE40310A) - (fp_text reference R1 (at -3.2131 -2.6714) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 1Kom (at -0.762 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 44 "Net-(LED1-PadA)") (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 24 /PC4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C814899) (tstamp 5C811CA6) - (at 128.1811 98.9286 270) - (descr LYT) - (path /EA9A6EB6) - (fp_text reference R3 (at 3.3064 0.5461) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 510Om (at -0.762 2.286) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 23 /PC5) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 50 "Net-(R3-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C81486B) (tstamp 5C811CD6) - (at 157.3911 118.6136 90) - (descr LYT) - (path /292B8E46) - (fp_text reference R4 (at 1.7736 0.7239 90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 10KOm (at -0.762 2.286 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 36 /PD0) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C814862) (tstamp 5C811CDF) - (at 151.6761 118.6136 90) - (descr LYT) - (path /59505C8B) - (fp_text reference R5 (at 1.7736 0.7239 90) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom)) - ) - (fp_text value 10KOm (at -0.762 2.286 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 34 /PD2) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Top) (tedit 5C8148A8) (tstamp 5C811D50) - (at 131.3561 98.2936 180) - (descr LYT) - (path /9C9DB109) - (fp_text reference R6 (at -3.8989 -1.016) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value 10kOm (at -0.762 2.286) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy -1.0668 0.6985) (xy -0.4168 0.6985) (xy -0.4168 -0.7015) (xy -1.0668 -0.7015)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 0.6985) (xy 1.0564 0.6985) (xy 1.0564 -0.7015) (xy 0.4064 -0.7015)) (layer F.Fab) (width 0)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer F.Fab) (width 0.1524)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer F.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 270) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 23 /PC5) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 270) (size 1.4224 0.7112) (layers Top F.Paste F.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814DF7) (tstamp 5C811DD0) - (at 150.4061 116.0736 90) - (descr LYT) - (path /F96F0265) - (fp_text reference R9 (at 4.3136 0.7239 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 2Kom (at -0.762 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 45 /PD3') (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805H (layer Bottom) (tedit 5C814E10) (tstamp 5C811DD9) - (at 157.1625 121.179) - (descr LYT) - (path /1B221D8E) - (fp_text reference R10 (at 1.5875 2.646) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 2Kom (at -0.762 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad P$2 smd rect (at 1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 46 /PD1') (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:QS (layer Bottom) (tedit 5C814DF0) (tstamp 5C811A28) - (at 156.7561 108.4536 90) - (descr CRYSTAL) - (path /098A5C63) - (fp_text reference Q1 (at -1.4014 -3.0861 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 16Mhz (at -5.08 -3.937 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom mirror)) - ) - (fp_arc (start -3.429 0) (end -3.429 1.778) (angle 180) (layer B.SilkS) (width 0.0508)) - (fp_arc (start -3.429 0) (end -3.429 2.286) (angle 180) (layer B.SilkS) (width 0.1524)) - (fp_arc (start 3.429 0) (end 3.429 2.286) (angle -180) (layer B.SilkS) (width 0.1524)) - (fp_arc (start 3.429 0) (end 3.429 1.778) (angle -180) (layer B.SilkS) (width 0.0508)) - (fp_line (start 3.429 1.778) (end -3.429 1.778) (layer B.SilkS) (width 0.0508)) - (fp_line (start -3.429 -1.778) (end 3.429 -1.778) (layer B.SilkS) (width 0.0508)) - (fp_line (start 3.429 2.286) (end -3.429 2.286) (layer B.SilkS) (width 0.1524)) - (fp_line (start -3.429 -2.286) (end 3.429 -2.286) (layer B.SilkS) (width 0.1524)) - (pad 2 thru_hole oval (at 2.54 0) (size 2.8448 1.4224) (drill 0.7) (layers *.Cu *.Mask) - (net 38 "Net-(C1-PadP$1)") (solder_mask_margin 0.0508)) - (pad 1 thru_hole oval (at -2.54 0) (size 2.8448 1.4224) (drill 0.7) (layers *.Cu *.Mask) - (net 37 "Net-(C2-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Crystal.3dshapes/Crystal_HC49-4H_Vertical.step - (offset (xyz -2.5 0 0)) - (scale (xyz 1 1 0.8)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E35) (tstamp 5C811A35) - (at 160.1343 110.0411 90) - (descr LYT) - (path /B2C130AB) - (fp_text reference C2 (at -1.7189 0.5207 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 18pf (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 37 "Net-(C2-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DE9) (tstamp 5C811A3E) - (at 153.3906 107.0947 270) - (descr LYT) - (path /D645821B) - (fp_text reference C1 (at -1.6847 0.9906 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 18pf (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 38 "Net-(C1-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E2F) (tstamp 5C811A47) - (at 160.2359 104.6436 270) - (descr LYT) - (path /A401EF9C) - (fp_text reference C7 (at 1.4014 -0.4191 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DBD) (tstamp 5C811A59) - (at 133.8961 103.9451) - (descr LYT) - (path /ED3BBF87) - (fp_text reference C3 (at -1.1811 -1.0751 -90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 19 /AREF) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 270) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E4C) (tstamp 5C811AB2) - (at 173.0883 109.5966 90) - (descr LYT) - (path /4EACBEDA) - (fp_text reference C5 (at -3.4334 2.1717 180) (layer B.SilkS) - (effects (font (size 1.2 1.2) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 43 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:LED3MM (layer Top) (tedit 5C8148C1) (tstamp 5C811ABB) - (at 128.8161 110.9936 90) - (descr "LED

\n3 mm, round") - (path /F50B0571) - (fp_text reference LED1 (at -1.4014 7.0739) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value LED_RED/PC4/20 (at 1.905 1.651) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_arc (start 0 0.000083) (end -2.032 0) (angle -31.60822) (layer F.Fab) (width 0.254)) - (fp_arc (start 0 0.000002) (end -2.032 0) (angle 28.301701) (layer F.Fab) (width 0.254)) - (fp_arc (start -0.000056 0) (end -1.7643 1.0082) (angle -60.255215) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.000037 0) (end 0 2.032) (angle -49.763022) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.00006 0) (end -1.7929 -0.9562) (angle 61.926949) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0.000012 0) (end 0 -2.032) (angle 50.193108) (layer F.SilkS) (width 0.254)) - (fp_arc (start 0 0) (end 0 1.016) (angle -90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end 0 0.635) (angle -90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end -1.016 0) (angle 90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0) (end -0.635 0) (angle 90) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0.000008 0) (end -1.203 0.9356) (angle -52.126876) (layer F.SilkS) (width 0.1524)) - (fp_arc (start -0.000008 0) (end 0 1.524) (angle -52.126876) (layer F.SilkS) (width 0.1524)) - (fp_arc (start 0 0) (end -1.2192 -0.9144) (angle 53.130102) (layer F.SilkS) (width 0.1524)) - (fp_arc (start -0.000034 0) (end 0 -1.524) (angle 54.461337) (layer F.SilkS) (width 0.1524)) - (fp_arc (start 0 -0.000004) (end 1.1708 0.9756) (angle -39.80361) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000014) (end 1.1571 -0.9918) (angle 40.601165) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000063) (end -1.524 0) (angle -41.633208) (layer F.Fab) (width 0.1524)) - (fp_arc (start 0 0.000004) (end -1.524 0) (angle 39.80361) (layer F.Fab) (width 0.1524)) - (fp_line (start 1.5748 1.27) (end 1.5748 -1.27) (layer F.Fab) (width 0.254)) - (pad K thru_hole circle (at 1.27 0 90) (size 1.6764 1.6764) (drill 0.8128) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad A thru_hole circle (at -1.27 0 90) (size 1.6764 1.6764) (drill 0.8128) (layers *.Cu *.Mask) - (net 44 "Net-(LED1-PadA)") (solder_mask_margin 0.0508)) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DB1) (tstamp 5C811AD3) - (at 133.8961 105.9136 180) - (descr LYT) - (path /C2BBB70B) - (fp_text reference C8 (at 1.8161 -3.3064 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 90) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DCC) (tstamp 5C811ADC) - (at 142.0241 116.1371 270) - (descr LYT) - (path /90B5D1B4) - (fp_text reference C9 (at -1.2021 -2.7559 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 270) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DDC) (tstamp 5C811AE5) - (at 142.7861 95.8806 90) - (descr LYT) - (path /0BB7FF73) - (fp_text reference C10 (at 1.9006 -1.1811 90) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814DAB) (tstamp 5C811AFE) - (at 134.1501 109.2664 270) - (descr LYT) - (path /31DB2A51) - (fp_text reference C11 (at 1.8586 1.4351 180) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 0.1mF (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 20 "Net-(C11-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X09-BIG (layer Top) (tedit 5C81367B) (tstamp 5C811B07) - (at 140.2461 86.8636 180) - (path /A13C1BE3) - (fp_text reference JP1 (at -10.2362 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x9 (at -10.16 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy 9.906 0.254) (xy 10.414 0.254) (xy 10.414 -0.254) (xy 9.906 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 7.366 0.254) (xy 7.874 0.254) (xy 7.874 -0.254) (xy 7.366 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -10.414 0.254) (xy -9.906 0.254) (xy -9.906 -0.254) (xy -10.414 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -7.874 0.254) (xy -7.366 0.254) (xy -7.366 -0.254) (xy -7.874 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -5.334 0.254) (xy -4.826 0.254) (xy -4.826 -0.254) (xy -5.334 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 0.254) (xy -2.286 0.254) (xy -2.286 -0.254) (xy -2.794 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 0.254) (xy 2.794 0.254) (xy 2.794 -0.254) (xy 2.286 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.826 0.254) (xy 5.334 0.254) (xy 5.334 -0.254) (xy 4.826 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start -11.43 1.27) (end -11.43 -1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 1.27) (end -11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 -1.27) (end 11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start -11.43 -1.27) (end 11.43 -1.27) (layer F.SilkS) (width 0.127)) - (pad 9 thru_hole circle (at 10.16 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 14 /PA3) (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 7.62 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 13 /PA2) (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 5.08 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 12 /PA1) (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at 2.54 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 11 /PA0) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 0 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 10 /PB0) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -2.54 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 9 /PB1) (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -5.08 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 8 /PB2) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -7.62 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 7 /PB3) (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -10.16 0 270) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 6 /PB4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x09_P2.54mm_Vertical.wrl - (offset (xyz 10 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:1X09-BIG (layer Top) (tedit 5C813684) (tstamp 5C811B20) - (at 125.0061 107.1836 270) - (path /10A664E2) - (fp_text reference JP2 (at -15.1086 0.5461 90) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text value PIN1x9 (at -10.16 3.175 90) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify right top)) - ) - (fp_poly (pts (xy 9.906 0.254) (xy 10.414 0.254) (xy 10.414 -0.254) (xy 9.906 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 7.366 0.254) (xy 7.874 0.254) (xy 7.874 -0.254) (xy 7.366 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -10.414 0.254) (xy -9.906 0.254) (xy -9.906 -0.254) (xy -10.414 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -7.874 0.254) (xy -7.366 0.254) (xy -7.366 -0.254) (xy -7.874 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -5.334 0.254) (xy -4.826 0.254) (xy -4.826 -0.254) (xy -5.334 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -2.794 0.254) (xy -2.286 0.254) (xy -2.286 -0.254) (xy -2.794 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 2.286 0.254) (xy 2.794 0.254) (xy 2.794 -0.254) (xy 2.286 -0.254)) (layer F.Fab) (width 0)) - (fp_poly (pts (xy 4.826 0.254) (xy 5.334 0.254) (xy 5.334 -0.254) (xy 4.826 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start -11.43 1.27) (end -11.43 -1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 1.27) (end -11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start 11.43 -1.27) (end 11.43 1.27) (layer F.SilkS) (width 0.127)) - (fp_line (start -11.43 -1.27) (end 11.43 -1.27) (layer F.SilkS) (width 0.127)) - (pad 9 thru_hole circle (at 10.16 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 22 /PC6) (solder_mask_margin 0.0508)) - (pad 8 thru_hole circle (at 7.62 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 21 /PC7) (solder_mask_margin 0.0508)) - (pad 7 thru_hole circle (at 5.08 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 18 /PA7) (solder_mask_margin 0.0508)) - (pad 6 thru_hole circle (at 2.54 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad 5 thru_hole circle (at 0 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 19 /AREF) (solder_mask_margin 0.0508)) - (pad 4 thru_hole circle (at -2.54 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (pad 3 thru_hole circle (at -5.08 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 16 /PA5) (solder_mask_margin 0.0508)) - (pad 2 thru_hole circle (at -7.62 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 15 /PA4) (solder_mask_margin 0.0508)) - (pad 1 thru_hole circle (at -10.16 0) (size 1.778 1.778) (drill 1.016) (layers *.Cu *.Mask) - (net 17 /PA6) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x09_P2.54mm_Vertical.wrl - (offset (xyz 10 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 90)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E47) (tstamp 5C811BB2) - (at 174.5361 109.5966 90) - (descr LYT) - (path /487BCAB4) - (fp_text reference C4 (at 1.6466 0.7239 180) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 10uF (at -0.889 -2.286 90) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 43 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:C0805H (layer Bottom) (tedit 5C814E29) (tstamp 5C811BBB) - (at 161.9377 104.6436 270) - (descr LYT) - (path /04BD8970) - (fp_text reference C6 (at -2.4086 0.6477 270) (layer B.SilkS) - (effects (font (size 0.9652 0.9652) (thickness 0.2)) (justify right top mirror)) - ) - (fp_text value 22uF (at -0.889 -2.286 180) (layer B.Fab) - (effects (font (size 0.9652 0.9652) (thickness 0.077216)) (justify right top mirror)) - ) - (fp_poly (pts (xy 0.3556 -0.7239) (xy 1.1057 -0.7239) (xy 1.1057 0.7262) (xy 0.3556 0.7262)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy -1.0922 -0.7239) (xy -0.3421 -0.7239) (xy -0.3421 0.7262) (xy -1.0922 0.7262)) (layer B.Fab) (width 0)) - (fp_line (start -0.356 -0.66) (end 0.381 -0.66) (layer B.Fab) (width 0.1016)) - (fp_line (start -0.381 0.66) (end 0.381 0.66) (layer B.Fab) (width 0.1016)) - (pad P$2 smd rect (at 1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (pad P$1 smd rect (at -1.143 0 180) (size 1.4224 0.7112) (layers Bottom B.Paste B.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Capacitor_SMD.3dshapes/C_0805_2012Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:W237-102 (layer Top) (tedit 5C814829) (tstamp 5C8E7C86) - (at 165.6461 123.6936 180) - (descr "WAGO SCREW CLAMP") - (path /484D9DCB) - (fp_text reference X2 (at 1.778 7.62) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify right top)) - ) - (fp_text value DG300-5.0-02P-12 (at -5.04 7.62) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify right top)) - ) - (fp_text user 2 (at 0.421 -0.635 180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_text user 1 (at -4.532 -0.635 180) (layer F.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.127)) (justify left bottom)) - ) - (fp_circle (center 2.5038 -2.2098) (end 3.0118 -2.2098) (layer F.SilkS) (width 0.1524)) - (fp_circle (center 2.5038 1.27) (end 4.0024 1.27) (layer F.Fab) (width 0.1524)) - (fp_circle (center -2.5 -2.2098) (end -1.992 -2.2098) (layer F.SilkS) (width 0.1524)) - (fp_circle (center -2.5 1.27) (end -1.0014 1.27) (layer F.Fab) (width 0.1524)) - (fp_line (start 1.615 3.073) (end 3.393 3.073) (layer F.Fab) (width 0.1524)) - (fp_line (start 4.993 -3.531) (end 4.993 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 -3.531) (end -4.989 -3.734) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 -3.531) (end 4.993 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 3.073) (end 4.993 5.461) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 3.073) (end -4.989 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start 3.393 3.073) (end 4.993 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.611 3.073) (end 1.615 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -3.389 3.073) (end -1.611 3.073) (layer F.Fab) (width 0.1524)) - (fp_line (start -4.989 3.073) (end -3.389 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 5.461) (end -4.989 3.073) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 -3.734) (end -4.989 -3.734) (layer F.SilkS) (width 0.1524)) - (fp_line (start 4.993 -3.734) (end 4.993 -3.531) (layer F.SilkS) (width 0.1524)) - (fp_line (start -4.989 5.461) (end 4.993 5.461) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.488 2.261) (end 3.469 0.254) (layer F.Fab) (width 0.254)) - (fp_line (start -3.491 2.286) (end -1.484 0.279) (layer F.Fab) (width 0.254)) - (pad 2 thru_hole oval (at 2.5 1.27 270) (size 3.5814 1.7907) (drill 1.1938) (layers *.Cu *.Mask) - (net 47 "Net-(D1-PadA)") (solder_mask_margin 0.0508)) - (pad 1 thru_hole oval (at -2.5 1.27 270) (size 3.5814 1.7907) (drill 1.1938) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KIPRJMOD}/3d_terminal_blocks/300_2_5.wrl - (offset (xyz 7.8 -1.8 7.5)) - (scale (xyz 0.4 0.4 0.4)) - (rotate (xyz -90 0 180)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135FC) (tstamp 5C811BF6) - (at 150.4061 97.0236) - (descr "PIN HEADER") - (path /81FCD7AF) - (fp_text reference JP4 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 40 /SCK) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813605) (tstamp 5C811C03) - (at 152.9461 97.0236) - (descr "PIN HEADER") - (path /9DADB6DD) - (fp_text reference JP5 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 40 /SCK) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135F0) (tstamp 5C811C10) - (at 152.9461 94.4836) - (descr "PIN HEADER") - (path /3ADBB494) - (fp_text reference JP6 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 41 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135E8) (tstamp 5C811C1D) - (at 150.4061 94.4836) - (descr "PIN HEADER") - (path /350157B3) - (fp_text reference JP7 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 41 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135B1) (tstamp 5C811C2A) - (at 150.4061 91.9436) - (descr "PIN HEADER") - (path /ADB8D889) - (fp_text reference JP8 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 42 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135B9) (tstamp 5C8E5AA9) - (at 152.9461 91.9436) - (descr "PIN HEADER") - (path /50718617) - (fp_text reference JP9 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 42 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813610) (tstamp 5C811CAF) - (at 155.4861 97.0236) - (descr "PIN HEADER") - (path /71218B71) - (fp_text reference JP11 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 40 /SCK) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8135F7) (tstamp 5C811CBC) - (at 155.4861 94.4836) - (descr "PIN HEADER") - (path /81AF9221) - (fp_text reference JP12 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 41 /MISO) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C81361A) (tstamp 5C8E5AF0) - (at 155.4861 91.9436) - (descr "PIN HEADER") - (path /03497A6C) - (fp_text reference JP13 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 42 /MOSI) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813753) (tstamp 5C811CE8) - (at 171.9961 91.9436) - (descr "PIN HEADER") - (path /679AEFF0) - (fp_text reference JP14 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8137D2) (tstamp 5C811CF5) - (at 171.9961 94.4836) - (descr "PIN HEADER") - (path /D0A47C9F) - (fp_text reference JP15 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8137DC) (tstamp 5C811D02) - (at 171.9961 97.0236) - (descr "PIN HEADER") - (path /C3CE8354) - (fp_text reference JP16 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8137E3) (tstamp 5C811D0F) - (at 171.9961 99.5636) - (descr "PIN HEADER") - (path /BAC3901A) - (fp_text reference JP17 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 2 VCC) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C81374F) (tstamp 5C811D1C) - (at 169.4561 91.9436) - (descr "PIN HEADER") - (path /14CC0547) - (fp_text reference JP19 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8CF7C1) (tstamp 5C811D29) - (at 169.4561 94.4836) - (descr "PIN HEADER") - (path /5467ECB4) - (fp_text reference JP20 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8CF7C3) (tstamp 5C811D36) - (at 169.4561 97.0236) - (descr "PIN HEADER") - (path /3FA45B4D) - (fp_text reference JP21 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8CF7C7) (tstamp 5C811D43) - (at 169.4561 99.5636) - (descr "PIN HEADER") - (path /1375B3FD) - (fp_text reference JP22 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 1 GND) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136F9) (tstamp 5C811D59) - (at 152.9461 122.4236) - (descr "PIN HEADER") - (path /211071EA) - (fp_text reference JP24 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 34 /PD2) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136E7) (tstamp 5C811D66) - (at 150.4061 122.4236) - (descr "PIN HEADER") - (path /CD247A09) - (fp_text reference JP25 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 45 /PD3') (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136D4) (tstamp 5C811D73) - (at 147.8661 122.4236) - (descr "PIN HEADER") - (path /02F38983) - (fp_text reference JP26 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 32 /PD4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C8136A1) (tstamp 5C811D80) - (at 127.5461 107.1836) - (descr "PIN HEADER") - (path /AB274EC9) - (fp_text reference JP27 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 23 /PC5) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813696) (tstamp 5C811D8D) - (at 127.5461 117.3436) - (descr "PIN HEADER") - (path /7D22D023) - (fp_text reference JP28 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 24 /PC4) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813716) (tstamp 5C811D9A) - (at 171.9961 114.1686) - (descr "PIN HEADER") - (path /391CE814) - (fp_text reference JP10 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 43 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:1X01 (layer Top) (tedit 5C813724) (tstamp 5C811DA7) - (at 174.5361 114.1686) - (descr "PIN HEADER") - (path /1A752D3A) - (fp_text reference JP29 (at -1.3462 -1.8288) (layer F.SilkS) hide - (effects (font (size 1.2065 1.2065) (thickness 0.12065)) (justify left bottom)) - ) - (fp_text value PINx1 (at -1.27 3.175) (layer F.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.09652)) (justify left bottom)) - ) - (fp_poly (pts (xy -0.254 0.254) (xy 0.254 0.254) (xy 0.254 -0.254) (xy -0.254 -0.254)) (layer F.Fab) (width 0)) - (fp_line (start 0.635 1.27) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 0.635) (end -0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end -1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -1.27 -0.635) (end -1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 0.635) (end 0.635 1.27) (layer F.SilkS) (width 0.1524)) - (fp_line (start 1.27 -0.635) (end 1.27 0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start 0.635 -1.27) (end 1.27 -0.635) (layer F.SilkS) (width 0.1524)) - (fp_line (start -0.635 -1.27) (end 0.635 -1.27) (layer F.SilkS) (width 0.1524)) - (pad 1 thru_hole circle (at 0 0) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask) - (net 43 "Net-(C4-PadP$1)") (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x01_P2.54mm_Vertical.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805 (layer Bottom) (tedit 5C814E04) (tstamp 5C811DB4) - (at 150.4061 119.8836 270) - (descr "RESISTOR

\nchip") - (path /6C5D1C71) - (fp_text reference R7 (at -1.1386 1.016 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 1Kom (at -0.762 -2.286 270) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -0.1999 -0.5001) (xy 0.1999 -0.5001) (xy 0.1999 0.5001) (xy -0.1999 0.5001)) (layer B.Adhes) (width 0)) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -1.973 -0.983) (end -1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 -0.983) (end -1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 0.983) (end 1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.973 0.983) (end 1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad 2 smd rect (at 0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 45 /PD3') (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 33 /PD3) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module M644_breakout_v1.2d:R0805 (layer Bottom) (tedit 5C814E0A) (tstamp 5C811DC2) - (at 154.8003 120.3662 270) - (descr "RESISTOR

\nchip") - (path /B110DF28) - (fp_text reference R8 (at -1.6212 1.016 270) (layer B.SilkS) - (effects (font (size 1.2065 1.2065) (thickness 0.2)) (justify left bottom mirror)) - ) - (fp_text value 1Kom (at -0.762 -2.286 270) (layer B.Fab) - (effects (font (size 1.2065 1.2065) (thickness 0.1016)) (justify left bottom mirror)) - ) - (fp_poly (pts (xy -0.1999 -0.5001) (xy 0.1999 -0.5001) (xy 0.1999 0.5001) (xy -0.1999 0.5001)) (layer B.Adhes) (width 0)) - (fp_poly (pts (xy -1.0668 -0.6985) (xy -0.4168 -0.6985) (xy -0.4168 0.7015) (xy -1.0668 0.7015)) (layer B.Fab) (width 0)) - (fp_poly (pts (xy 0.4064 -0.6985) (xy 1.0564 -0.6985) (xy 1.0564 0.7015) (xy 0.4064 0.7015)) (layer B.Fab) (width 0)) - (fp_line (start -1.973 -0.983) (end -1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 -0.983) (end -1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start 1.973 0.983) (end 1.973 -0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -1.973 0.983) (end 1.973 0.983) (layer Dwgs.User) (width 0.0508)) - (fp_line (start -0.41 -0.635) (end 0.41 -0.635) (layer B.Fab) (width 0.1524)) - (fp_line (start -0.41 0.635) (end 0.41 0.635) (layer B.Fab) (width 0.1524)) - (pad 2 smd rect (at 0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 46 /PD1') (solder_mask_margin 0.0508)) - (pad 1 smd rect (at -0.85 0 270) (size 1.3 1.5) (layers Bottom B.Paste B.Mask) - (net 35 /PD1) (solder_mask_margin 0.0508)) - (model ${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0805_2012Metric.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module Pin_Headers:Pin_Header_Straight_2x04_Pitch2.54mm (layer Top) (tedit 5C8E6EA2) (tstamp 5C8E7144) - (at 171.9961 117.3436) - (descr "Through hole straight pin header, 2x04, 2.54mm pitch, double rows") - (tags "Through hole pin header THT 2x04 2.54mm double row") - (fp_text reference REF** (at 1.27 -2.33) (layer F.SilkS) hide - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_text value Pin_Header_Straight_2x04_Pitch2.54mm (at 1.27 9.95) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_line (start 0 -1.27) (end 3.81 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start 3.81 -1.27) (end 3.81 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start 3.81 8.89) (end -1.27 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 8.89) (end -1.27 0) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 0) (end 0 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start -1.33 8.95) (end 3.87 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end -1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start 3.87 -1.33) (end 3.87 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end 1.27 1.27) (layer F.SilkS) (width 0.12)) - (fp_line (start 1.27 1.27) (end 1.27 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start 1.27 -1.33) (end 3.87 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 0) (end -1.33 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 -1.33) (end 0 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.8 -1.8) (end -1.8 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start -1.8 9.4) (end 4.35 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start 4.35 9.4) (end 4.35 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_line (start 4.35 -1.8) (end -1.8 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_text user %R (at 1.27 3.81 90) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (pad 1 thru_hole rect (at 0 0) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 2 thru_hole oval (at 2.54 0) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 3 thru_hole oval (at 0 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 4 thru_hole oval (at 2.54 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 5 thru_hole oval (at 0 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 6 thru_hole oval (at 2.54 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 7 thru_hole oval (at 0 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (pad 8 thru_hole oval (at 2.54 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 1 GND)) - (model ${KISYS3DMOD}/Pin_Headers.3dshapes/Pin_Header_Straight_2x04_Pitch2.54mm.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_2x04_P2.54mm_Vertical.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (module Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm (layer Top) (tedit 5C8E715B) (tstamp 5C8E7C22) - (at 174.5361 91.9436) - (descr "Through hole straight pin header, 1x04, 2.54mm pitch, single row") - (tags "Through hole pin header THT 1x04 2.54mm single row") - (fp_text reference REF** (at 0 -2.33) (layer F.SilkS) hide - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_text value Pin_Header_Straight_1x04_Pitch2.54mm (at 0 9.95) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_line (start -0.635 -1.27) (end 1.27 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start 1.27 -1.27) (end 1.27 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start 1.27 8.89) (end -1.27 8.89) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 8.89) (end -1.27 -0.635) (layer F.Fab) (width 0.1)) - (fp_line (start -1.27 -0.635) (end -0.635 -1.27) (layer F.Fab) (width 0.1)) - (fp_line (start -1.33 8.95) (end 1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end -1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start 1.33 1.27) (end 1.33 8.95) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 1.27) (end 1.33 1.27) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 0) (end -1.33 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.33 -1.33) (end 0 -1.33) (layer F.SilkS) (width 0.12)) - (fp_line (start -1.8 -1.8) (end -1.8 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start -1.8 9.4) (end 1.8 9.4) (layer F.CrtYd) (width 0.05)) - (fp_line (start 1.8 9.4) (end 1.8 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_line (start 1.8 -1.8) (end -1.8 -1.8) (layer F.CrtYd) (width 0.05)) - (fp_text user %R (at 0 3.81 90) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (pad 1 thru_hole rect (at 0 0) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (pad 2 thru_hole oval (at 0 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (pad 3 thru_hole oval (at 0 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (pad 4 thru_hole oval (at 0 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask) - (net 2 VCC)) - (model ${KISYS3DMOD}/Pin_Headers.3dshapes/Pin_Header_Straight_1x04_Pitch2.54mm.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - (model ${KISYS3DMOD}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x04_P2.54mm_Vertical.step - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) - ) - - (gr_line (start 121.1961 127.5036) (end 176.0601 127.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109CD970)) - (gr_line (start 176.0601 127.5036) (end 176.0601 82.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109CD8D0)) - (gr_line (start 176.0601 82.5036) (end 121.1961 82.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109CD830)) - (gr_line (start 121.1961 82.5036) (end 121.1961 127.5036) (layer Edge.Cuts) (width 0.15) (tstamp 109DEDB0)) - (gr_line (start 149.1361 91.9436) (end 145.9611 89.4036) (layer F.SilkS) (width 0.15) (tstamp 5C8E8346)) - (gr_line (start 145.9611 89.4036) (end 121.8311 89.4036) (layer F.SilkS) (width 0.15) (tstamp 109DEC70)) - (gr_line (start 149.1361 94.4836) (end 145.9611 91.9436) (layer F.SilkS) (width 0.15) (tstamp 109DEBD0)) - (gr_line (start 145.9611 91.9436) (end 121.8311 91.9436) (layer F.SilkS) (width 0.15) (tstamp 109DEB30)) - (gr_line (start 149.1361 97.0236) (end 145.9611 94.4836) (layer F.SilkS) (width 0.15) (tstamp 109E0070)) - (gr_line (start 145.9611 94.4836) (end 121.8311 94.4836) (layer F.SilkS) (width 0.15) (tstamp 109DFFD0)) - (gr_line (start 176.4411 91.9436) (end 176.4411 94.4836) (layer Cmts.User) (width 0.15) (tstamp 109DFF30)) - (gr_line (start 176.4411 94.4836) (end 176.4411 97.0236) (layer Cmts.User) (width 0.15) (tstamp 109DFE90)) - (gr_line (start 176.4411 97.0236) (end 176.4411 99.5636) (layer Cmts.User) (width 0.15) (tstamp 109DFDF0)) - (gr_line (start 176.4411 91.9436) (end 175.8061 91.9436) (layer Cmts.User) (width 0.15) (tstamp 109DFA30)) - (gr_line (start 175.8061 94.4836) (end 176.4411 94.4836) (layer Cmts.User) (width 0.15) (tstamp 109DF990)) - (gr_line (start 175.8061 97.0236) (end 176.4411 97.0236) (layer Cmts.User) (width 0.15) (tstamp 109DF8F0)) - (gr_line (start 175.8061 99.5636) (end 176.4411 99.5636) (layer Cmts.User) (width 0.15) (tstamp 109DF850)) - (gr_line (start 176.4411 117.3436) (end 176.4411 119.8836) (layer Cmts.User) (width 0.15) (tstamp 109DF7B0)) - (gr_line (start 176.4411 119.8836) (end 176.4411 122.4236) (layer Cmts.User) (width 0.15) (tstamp 109DF3F0)) - (gr_line (start 176.4411 122.4236) (end 176.4411 124.9636) (layer Cmts.User) (width 0.15) (tstamp 109DF350)) - (gr_line (start 176.4411 117.3436) (end 175.8061 117.3436) (layer Cmts.User) (width 0.15) (tstamp 109DF2B0)) - (gr_line (start 175.8061 119.8836) (end 176.4411 119.8836) (layer Cmts.User) (width 0.15) (tstamp 109DF210)) - (gr_line (start 175.8061 122.4236) (end 176.4411 122.4236) (layer Cmts.User) (width 0.15) (tstamp 109DF170)) - (gr_line (start 175.8061 124.9636) (end 176.4411 124.9636) (layer Cmts.User) (width 0.15) (tstamp 109DE770)) - (gr_line (start 127.5461 118.6136) (end 126.2761 119.8836) (layer F.SilkS) (width 0.15) (tstamp 109DE6D0)) - (gr_line (start 126.2761 119.8836) (end 121.1961 119.8836) (layer F.SilkS) (width 0.15) (tstamp 109DE630)) - (gr_line (start 121.1961 122.4236) (end 131.3561 122.4236) (layer F.SilkS) (width 0.15) (tstamp 109DE590)) - (gr_line (start 131.3561 122.4236) (end 136.4361 117.3436) (layer F.SilkS) (width 0.15) (tstamp 109DE4F0)) - (gr_line (start 136.4361 117.3436) (end 136.4361 112.8986) (layer F.SilkS) (width 0.15) (tstamp 109D6430)) - (gr_line (start 136.4361 112.8986) (end 128.8161 107.1836) (layer F.SilkS) (width 0.15) (tstamp 109D6390)) - (gr_line (start 159.2961 98.9286) (end 159.2961 93.8486) (layer Dwgs.User) (width 0.15) (tstamp 109D62F0)) - (gr_line (start 159.2961 93.8486) (end 159.2961 90.0386) (layer Dwgs.User) (width 0.15) (tstamp 109D6250)) - (gr_line (start 159.2961 90.0386) (end 159.2961 84.9586) (layer Dwgs.User) (width 0.15) (tstamp 109D61B0)) - (gr_line (start 159.2961 84.9586) (end 165.6461 84.9586) (layer Dwgs.User) (width 0.15) (tstamp 109D4B30)) - (gr_line (start 165.6461 84.9586) (end 165.6461 98.9286) (layer Dwgs.User) (width 0.15) (tstamp 109D4A90)) - (gr_line (start 165.6461 98.9286) (end 159.2961 98.9286) (layer Dwgs.User) (width 0.15) (tstamp 109D49F0)) - (gr_line (start 159.2961 90.0386) (end 160.5661 90.0386) (layer Dwgs.User) (width 0.15) (tstamp 109D4950)) - (gr_line (start 160.5661 90.0386) (end 160.5661 93.8486) (layer Dwgs.User) (width 0.15) (tstamp 109D48B0)) - (gr_line (start 160.5661 93.8486) (end 159.2961 93.8486) (layer Dwgs.User) (width 0.15) (tstamp 109CAEF0)) - (gr_line (start 160.5661 125.2176) (end 160.5661 127.1226) (layer Dwgs.User) (width 0.15) (tstamp 109CAE50)) - (gr_line (start 160.5661 127.1226) (end 170.5991 127.1226) (layer Dwgs.User) (width 0.15) (tstamp 109CADB0)) - (gr_line (start 170.5991 127.1226) (end 170.5991 125.3446) (layer Dwgs.User) (width 0.15) (tstamp 109CAD10)) - (gr_circle (center 148.0693 100.1097) (end 148.4952 100.1097) (layer Bottom) (width 0.4064) (tstamp 109CAC70)) - (gr_circle (center 159.2961 97.0236) (end 159.8961 97.0236) (layer Dwgs.User) (width 0.5) (tstamp 109CB530)) - (gr_circle (center 159.2961 94.4836) (end 159.8961 94.4836) (layer Dwgs.User) (width 0.5) (tstamp 109CB490)) - (gr_circle (center 161.8361 91.9436) (end 162.4361 91.9436) (layer Dwgs.User) (width 0.5) (tstamp 109CB3F0)) - (gr_circle (center 161.8361 94.4836) (end 162.4361 94.4836) (layer Dwgs.User) (width 0.5) (tstamp 109CB350)) - (gr_circle (center 161.8361 97.0236) (end 162.4361 97.0236) (layer Dwgs.User) (width 0.5) (tstamp 109CB2B0)) - (gr_circle (center 157.4419 87.8288) (end 157.9251 87.8288) (layer F.SilkS) (width 0.6096) (tstamp 109CE730)) - (gr_circle (center 161.8615 112.9494) (end 162.6554 112.9494) (layer Dwgs.User) (width 0.6096) (tstamp 109CE690)) - (gr_circle (center 161.8615 114.8544) (end 162.6554 114.8544) (layer Dwgs.User) (width 0.6096) (tstamp 109CE5F0)) - (gr_circle (center 171.0309 117.1912) (end 171.8248 117.1912) (layer Dwgs.User) (width 0.6096) (tstamp 109CE550)) - (gr_circle (center 161.8615 125.0144) (end 162.6554 125.0144) (layer Dwgs.User) (width 0.6096) (tstamp 109CE4B0)) - (gr_circle (center 159.2961 91.9436) (end 159.8961 91.9436) (layer Dwgs.User) (width 0.5) (tstamp 109D3870)) - (gr_circle (center 172.1739 112.9367) (end 172.5998 112.9367) (layer F.SilkS) (width 0.4064) (tstamp 109D37D0)) - (gr_circle (center 157.5181 86.1016) (end 158.1531 86.1016) (layer Dwgs.User) (width 0.4064) (tstamp 109D3730)) - (gr_circle (center 174.1551 112.1366) (end 174.7901 112.1366) (layer Dwgs.User) (width 0.4064) (tstamp 109D3690)) - (gr_text "M644/M1284 v1.2d" (at 126.365 104.775) (layer F.SilkS) (tstamp 5C81D4C7) - (effects (font (size 1.6891 1.6891) (thickness 0.32004)) (justify left bottom)) - ) - (gr_text 26/01/19 (at 138.43 107.95) (layer F.SilkS) (tstamp 109D50D0) - (effects (font (size 1.6891 1.6891) (thickness 0.32004)) (justify left bottom)) - ) - (gr_text rx0 (at 158.2039 117.0134 90) (layer F.SilkS) (tstamp 109D4F90) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text tx0 (at 154.6987 117.3944 90) (layer F.SilkS) (tstamp 109E1FB0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text tx1 (at 149.3139 117.1658 90) (layer F.SilkS) (tstamp 109E1E70) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text rx1 (at 153.8859 120.6964 90) (layer F.SilkS) (tstamp 109E1D30) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text xck1 (at 146.9771 115.7688 90) (layer F.SilkS) (tstamp 109E18D0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text xck0 (at 139.4333 89.8354 90) (layer F.SilkS) (tstamp 109E1790) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text PB4/4/SS (at 151.0411 82.4186 90) (layer F.SilkS) (tstamp 109E1330) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB3/3 (at 148.5011 82.4186 90) (layer F.SilkS) (tstamp 109E11F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB2/2 (at 145.9611 82.4186 90) (layer F.SilkS) (tstamp 109E10B0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB1/1 (at 143.4211 82.4186 90) (layer F.SilkS) (tstamp 109CBAD0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA0/31/A0 (at 138.3411 82.4186 90) (layer F.SilkS) (tstamp 109CB990) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA1/30/A1 (at 135.8011 82.4186 90) (layer F.SilkS) (tstamp 109CCE30) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA2/29/A2 (at 133.2611 82.4186 90) (layer F.SilkS) (tstamp 109CCCF0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA3/28/A3 (at 130.7211 82.4186 90) (layer F.SilkS) (tstamp 109CCBB0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB0/0/XCK0 (at 140.8811 82.4186 90) (layer F.SilkS) (tstamp 109CC110) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text GND (at 177.0761 119.8836 90) (layer F.SilkS) (tstamp 109CBFD0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify right top)) - ) - (gr_text +5V (at 177.0761 93.2136 90) (layer F.SilkS) (tstamp 109CD470) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify right top)) - ) - (gr_text PA6/25/A6 (at 109.1311 97.6586) (layer F.SilkS) (tstamp 109CD330) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA4/27/A4 (at 109.1311 100.1986) (layer F.SilkS) (tstamp 109CD1F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA5/26/A5 (at 109.1311 102.7386) (layer F.SilkS) (tstamp 109E2550) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text +5V (at 116.7511 105.2786) (layer F.SilkS) (tstamp 109E2410) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text AREF (at 116.7511 107.8186) (layer F.SilkS) (tstamp 109DA8F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text GND (at 116.7511 110.3586) (layer F.SilkS) (tstamp 109DA7B0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC5/21 (at 112.9411 123.0586) (layer F.SilkS) (tstamp 109DA670) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC4/20 (at 112.9411 120.5186) (layer F.SilkS) (tstamp 109DA210) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC3/19 (at 130.7211 135.7586 90) (layer F.SilkS) (tstamp 109DA0D0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC2/18 (at 133.2611 135.7586 90) (layer F.SilkS) (tstamp 109D9C70) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC1/17/SDA (at 135.8011 140.8386 90) (layer F.SilkS) (tstamp 109D9B30) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC0/16/SCL (at 138.3411 140.8386 90) (layer F.SilkS) (tstamp 109D99F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD7/15 (at 140.8811 135.7586 90) (layer F.SilkS) (tstamp 109D9590) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD6/14 (at 143.4211 135.7586 90) (layer F.SilkS) (tstamp 109D9450) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD5/13 (at 145.9611 135.7586 90) (layer F.SilkS) (tstamp 109D8FF0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD4/12/XCK1 (at 148.5011 140.8386 90) (layer F.SilkS) (tstamp 109D8EB0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD3/11/TX1 (at 151.0411 140.8386 90) (layer F.SilkS) (tstamp 109D8D70) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD2/10/RX1 (at 153.5811 140.8386 90) (layer F.SilkS) (tstamp 109D7C90) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD1/9/TX0 (at 156.1211 140.8386 90) (layer F.SilkS) (tstamp 109D7B50) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PD0/8/RX0 (at 158.6611 140.8386 90) (layer F.SilkS) (tstamp 109D8370) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB5/5/MOSI (at 109.1311 90.0386) (layer F.SilkS) (tstamp 109D8230) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB6/6/MISO (at 109.1311 92.5786) (layer F.SilkS) (tstamp 109D80F0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PB7/7/SCK (at 109.1311 95.1186) (layer F.SilkS) (tstamp 109D05D0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text +12V (at 160.5661 129.4086) (layer F.SilkS) (tstamp 109D0490) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text GND (at 167.5511 129.4086) (layer F.SilkS) (tstamp 109D0030) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PA7/24/A7 (at 109.1311 112.8986) (layer F.SilkS) (tstamp 109CFEF0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC7/23 (at 112.9411 115.4386) (layer F.SilkS) (tstamp 109CFDB0) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text PC6/22 (at 112.9411 117.9786) (layer F.SilkS) (tstamp 109E4850) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify left bottom)) - ) - (gr_text SW1/PC5 (at 130.7211 99.0556 90) (layer Dwgs.User) (tstamp 109E4710) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text LED/PC4 (at 133.1087 117.877 90) (layer Dwgs.User) (tstamp 109E45D0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text scl (at 138.1379 122.9824 90) (layer F.SilkS) (tstamp 109E4490) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text sda (at 134.0993 119.3248 90) (layer F.SilkS) (tstamp 109E4350) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text 5V (at 173.8757 101.0114 90) (layer F.SilkS) (tstamp 109BE0B0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text GND (at 166.4081 117.3436) (layer F.SilkS) (tstamp 5C8E764B) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text +5V (at 121.8311 102.7386 90) (layer F.SilkS) (tstamp 109BDE30) - (effects (font (size 1.35128 1.35128) (thickness 0.21336)) (justify right top)) - ) - (gr_text GND (at 123.2281 111.3492 90) (layer F.SilkS) (tstamp 109BDCF0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - (gr_text MOSI (at 148.6281 91.1816) (layer F.SilkS) (tstamp 109BDBB0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text MISO (at 148.6281 93.9756) (layer F.SilkS) (tstamp 109BDA70) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text SCK (at 148.3741 96.5156) (layer F.SilkS) (tstamp 109B48D0) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text +5V (at 175.7553 101.2908) (layer Dwgs.User) (tstamp 109B4790) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text GND (at 171.7167 101.3416) (layer Dwgs.User) (tstamp 109B4650) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify right top)) - ) - (gr_text +9V (at 166.1541 115.5656) (layer F.SilkS) (tstamp 109B4510) - (effects (font (size 1.35128 1.35128) (thickness 0.256032)) (justify left bottom)) - ) - - (segment (start 141.9785 109.5968) (end 141.986 110.7904) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D9770)) - (segment (start 141.9479 105.9136) (end 141.9785 109.5968) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D98B0)) - (segment (start 137.8712 105.9136) (end 141.9479 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D96D0)) - (segment (start 142.6591 106.0406) (end 142.6591 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D91D0)) - (segment (start 142.6591 105.9136) (end 142.6591 101.9131) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D9310)) - (segment (start 142.6591 101.9131) (end 142.7861 101.0241) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D9130)) - (segment (start 141.9479 105.9136) (end 142.6591 106.0406) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D9270)) - (segment (start 137.5156 110.9936) (end 134.3406 110.9936) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D9090)) - (segment (start 139.4206 109.5966) (end 137.5156 110.9936) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D7F10)) - (segment (start 141.9785 109.5968) (end 141.9606 109.5966) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D8050)) - (segment (start 141.9606 109.5966) (end 139.4206 109.5966) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D7E70)) - (segment (start 155.1686 108.8981) (end 153.9748 108.2631) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D7FB0)) - (segment (start 157.5181 108.8981) (end 155.1686 108.8981) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D7DD0)) - (segment (start 151.1681 105.8882) (end 154.0891 103.6911) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D8550)) - (segment (start 154.0891 103.6911) (end 157.7255 103.687) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D8690)) - (segment (start 157.7255 103.687) (end 159.2072 104.9061) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D84B0)) - (segment (start 148.5861 105.9136) (end 151.1681 105.8882) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D85F0)) - (segment (start 141.9861 111.7136) (end 142.0241 113.7241) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D8410)) - (segment (start 141.9606 111.6881) (end 141.9861 111.7136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0850)) - (segment (start 141.986 110.7904) (end 141.9606 111.6881) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0990)) - (segment (start 142.0241 113.7241) (end 142.0241 114.9941) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D07B0)) - (segment (start 142.7861 100.1136) (end 142.7861 97.0236) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D08F0)) - (segment (start 142.7861 101.0241) (end 142.7861 100.1136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0710)) - (segment (start 142.6591 105.9136) (end 143.4211 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D0210)) - (segment (start 143.4211 105.9136) (end 148.5861 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 109D0350)) - (segment (start 153.9748 108.2631) (end 153.6954 108.1615) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D0170)) - (segment (start 153.9748 108.2631) (end 153.3906 108.2377) (width 0.4064) (layer Bottom) (net 1) (tstamp 109D02B0)) - (segment (start 136.9861 105.9136) (end 137.8712 105.9136) (width 0.381) (layer Bottom) (net 1) (tstamp 109D00D0)) - (segment (start 162.1536 100.8336) (end 164.3761 94.4836) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C80B0)) - (segment (start 135.0391 105.9136) (end 136.9861 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8010)) - (segment (start 132.7531 103.9451) (end 132.9436 103.9451) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8150)) - (segment (start 132.9436 103.9451) (end 133.7691 104.7706) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C7F70)) - (segment (start 133.7691 104.7706) (end 133.7691 105.2786) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C99B0)) - (segment (start 133.7691 105.2786) (end 134.4041 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9910)) - (segment (start 134.4041 105.9136) (end 135.0391 105.9136) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9A50)) - (segment (start 134.3406 110.9936) (end 134.3406 110.5491) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9870)) - (segment (start 134.3406 110.5491) (end 134.1501 110.4094) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C85B0)) - (segment (start 168.1861 108.4536) (end 171.6151 108.4536) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8510)) - (segment (start 174.5361 124.9636) (end 174.5361 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8650)) - (segment (start 174.5361 119.8836) (end 174.5361 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8470)) - (segment (start 174.5361 117.3436) (end 174.5361 119.8836) (width 1.27) (layer Bottom) (net 1) (tstamp 109C8FB0)) - (segment (start 162.1536 108.4536) (end 162.1536 100.8336) (width 0.4064) (layer Top) (net 1) (tstamp 109C8F10)) - (segment (start 125.0061 109.7236) (end 122.4661 108.4536) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C9050)) - (segment (start 122.4661 108.4536) (end 122.4661 104.6436) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C8E70)) - (segment (start 122.4661 104.6436) (end 123.7361 103.3736) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C8AB0)) - (segment (start 123.7361 103.3736) (end 127.5461 103.3736) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8A10)) - (segment (start 127.5461 103.3736) (end 128.1557 103.018) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8B50)) - (segment (start 128.1557 103.018) (end 129.5527 103.018) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C8970)) - (segment (start 129.5527 103.018) (end 130.1369 103.4244) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C94B0)) - (segment (start 130.1369 103.4244) (end 131.9149 103.4498) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9410)) - (segment (start 131.9149 103.4498) (end 132.7531 103.9451) (width 0.4064) (layer Bottom) (net 1) (tstamp 109C9550)) - (segment (start 125.0061 109.7236) (end 128.8161 109.7236) (width 0.6096) (layer Bottom) (net 1) (tstamp 109C9370)) - (segment (start 158.6611 107.8186) (end 157.5181 108.8981) (width 0.6096) (layer Bottom) (net 1) (tstamp 106017A0)) - (segment (start 159.2498 107.1848) (end 158.6611 107.8186) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601700)) - (segment (start 158.6611 107.8186) (end 160.1343 108.8981) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601660)) - (segment (start 159.2072 104.9061) (end 159.2498 104.9061) (width 0.6096) (layer Bottom) (net 1) (tstamp 106015C0)) - (segment (start 159.2498 104.9061) (end 159.2498 105.7866) (width 0.6096) (layer Bottom) (net 1) (tstamp 106012A0)) - (segment (start 159.2498 105.7866) (end 159.2498 105.9136) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601200)) - (segment (start 159.2498 105.9136) (end 159.2498 107.1848) (width 0.6096) (layer Bottom) (net 1) (tstamp 10601160)) - (segment (start 159.2498 105.7866) (end 160.2359 105.7866) (width 0.8128) (layer Bottom) (net 1) (tstamp 106010C0)) - (segment (start 159.2498 105.7866) (end 159.2498 105.9136) (width 0.8128) (layer Bottom) (net 1) (tstamp 10601CA0)) - (segment (start 122.4661 108.4536) (end 122.4661 92.0736) (width 0.4064) (layer Top) (net 1) (tstamp 10601B60)) - (segment (start 122.4661 92.0736) (end 123.104 91.4386) (width 0.4064) (layer Top) (net 1) (tstamp 10601AC0)) - (segment (start 122.4661 108.4536) (end 125.0061 109.7236) (width 0.4064) (layer Top) (net 1) (tstamp 10602100)) - (segment (start 171.6151 108.4536) (end 170.7261 108.4536) (width 0.8128) (layer Top) (net 1) (tstamp 10601FC0)) - (segment (start 171.9961 124.9636) (end 174.5361 124.9636) (width 1.27) (layer Bottom) (net 1) (tstamp 10609FE0)) - (segment (start 171.9961 119.8836) (end 171.9961 117.3436) (width 1.27) (layer Bottom) (net 1) (tstamp 10609F40)) - (segment (start 171.9961 121.1536) (end 171.9961 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 10609EA0)) - (segment (start 171.9961 121.1536) (end 171.9961 119.8836) (width 1.27) (layer Bottom) (net 1) (tstamp 10609E00)) - (segment (start 171.9961 122.4236) (end 171.9961 124.9636) (width 1.27) (layer Bottom) (net 1) (tstamp 10609AE0)) - (segment (start 171.9961 117.3436) (end 174.5361 117.3436) (width 1.27) (layer Bottom) (net 1) (tstamp 10609A40)) - (segment (start 168.1461 122.4236) (end 167.6861 124.9636) (width 1.27) (layer Bottom) (net 1) (tstamp 106099A0)) - (segment (start 168.1461 122.4236) (end 171.9961 121.1536) (width 1.4224) (layer Bottom) (net 1) (tstamp 10609900)) - (segment (start 168.1861 108.4536) (end 165.6461 109.4696) (width 1.27) (layer Bottom) (net 1) (tstamp 106095E0)) - (segment (start 165.6461 109.4696) (end 165.6461 119.8836) (width 1.27) (layer Bottom) (net 1) (tstamp 10609540)) - (segment (start 165.6461 119.8836) (end 168.1461 122.4236) (width 1.27) (layer Bottom) (net 1) (tstamp 106094A0)) - (segment (start 165.6461 108.4536) (end 168.1861 108.4536) (width 1.27) (layer Bottom) (net 1) (tstamp 10609400)) - (segment (start 164.8587 107.7678) (end 165.3316 108.1797) (width 1.27) (layer Bottom) (net 1) (tstamp 106090E0)) - (segment (start 165.3316 108.1797) (end 165.6461 108.4536) (width 1.27) (layer Bottom) (net 1) (tstamp 10609040)) - (segment (start 164.3761 107.1836) (end 165.1381 107.3868) (width 1.27) (layer Bottom) (net 1) (tstamp 10608FA0)) - (segment (start 165.1381 107.3868) (end 164.8587 107.7678) (width 1.27) (layer Bottom) (net 1) (tstamp 10608F00)) - (segment (start 161.9377 105.7866) (end 164.3761 107.1836) (width 1.016) (layer Bottom) (net 1) (tstamp 10608BE0)) - (segment (start 150.4061 114.1686) (end 150.4061 114.9306) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608B40)) - (segment (start 148.5011 112.2636) (end 150.4061 114.1686) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608AA0)) - (segment (start 148.5011 111.6286) (end 148.5011 112.2636) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608A00)) - (segment (start 143.4211 106.5486) (end 148.5011 111.6286) (width 0.4064) (layer Bottom) (net 1) (tstamp 106086E0)) - (segment (start 143.4211 105.9136) (end 143.4211 106.5486) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608640)) - (segment (start 158.3055 115.1592) (end 158.3055 121.179) (width 0.4064) (layer Bottom) (net 1) (tstamp 106085A0)) - (segment (start 165.0111 108.4536) (end 164.8523 108.6124) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608500)) - (segment (start 164.8523 108.6124) (end 158.3055 115.1592) (width 0.4064) (layer Bottom) (net 1) (tstamp 106081E0)) - (segment (start 165.0577 108.4536) (end 165.0111 108.4536) (width 0.4064) (layer Bottom) (net 1) (tstamp 10608140)) - (segment (start 165.3316 108.1797) (end 165.0577 108.4536) (width 0.4064) (layer Bottom) (net 1) (tstamp 106080A0)) - (segment (start 170.7261 108.4536) (end 168.8211 107.1836) (width 1.016) (layer Top) (net 1) (tstamp 10608000)) - (segment (start 168.8211 107.1836) (end 168.8211 104.0086) (width 1.016) (layer Top) (net 1) (tstamp 10607CE0)) - (segment (start 168.8211 104.0086) (end 169.4561 103.3736) (width 1.016) (layer Top) (net 1) (tstamp 10607C40)) - (segment (start 169.4561 103.3736) (end 169.4561 99.5636) (width 1.016) (layer Top) (net 1) (tstamp 10607BA0)) - (segment (start 169.4561 99.5636) (end 169.4561 97.0236) (width 1.016) (layer Top) (net 1) (tstamp 10607B00)) - (segment (start 169.4561 97.0236) (end 169.4561 94.4836) (width 1.016) (layer Top) (net 1) (tstamp 106077E0)) - (segment (start 169.4561 94.4836) (end 169.4561 91.9436) (width 1.016) (layer Top) (net 1) (tstamp 10607740)) - (segment (start 160.2359 105.7866) (end 161.9377 105.7866) (width 0.8128) (layer Bottom) (net 1) (tstamp 106076A0)) - (segment (start 164.0967 108.479) (end 162.1536 108.4536) (width 0.8128) (layer Bottom) (net 1) (tstamp 10607600)) - (segment (start 164.8523 108.6124) (end 164.0967 108.479) (width 0.8128) (layer Bottom) (net 1) (tstamp 106072E0)) - (segment (start 171.6151 108.4536) (end 173.0883 108.4536) (width 0.8128) (layer Bottom) (net 1) (tstamp 10607240)) - (segment (start 173.0883 108.4536) (end 174.5361 108.4536) (width 0.8128) (layer Bottom) (net 1) (tstamp 106071A0)) - (segment (start 128.8161 109.7262) (end 130.4925 109.7008) (width 0.6096) (layer Top) (net 1) (tstamp 10607100)) - (segment (start 128.8161 109.7236) (end 128.8161 109.7262) (width 0.6096) (layer Top) (net 1) (tstamp 10606DE0)) - (via (at 174.5361 119.8836) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606D40)) - (via (at 174.5361 122.4236) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606CA0)) - (via (at 174.5361 124.9636) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606C00)) - (via (at 174.5361 117.3436) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 106068E0)) - (via (at 162.1536 108.4536) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 1) (tstamp 10606840)) - (via (at 162.1536 100.8336) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 1) (tstamp 106067A0)) - (via (at 171.9961 124.9636) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606700)) - (via (at 171.9961 122.4236) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 106063E0)) - (via (at 171.9961 119.8836) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 10606340)) - (via (at 171.9961 117.3436) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 1) (tstamp 106062A0)) - (segment (start 135.7761 90.0436) (end 129.4761 90.0436) (width 0.4064) (layer Top) (net 1)) - (segment (start 127.710506 91.459194) (end 127.5461 91.459194) (width 0.4064) (layer Top) (net 1)) - (segment (start 129.1261 90.0436) (end 127.710506 91.459194) (width 0.4064) (layer Top) (net 1)) - (segment (start 129.4761 90.0436) (end 129.1261 90.0436) (width 0.4064) (layer Top) (net 1)) - (segment (start 123.104 91.4386) (end 127.5461 91.459194) (width 0.4064) (layer Top) (net 1)) - (segment (start 142.7861 113.5971) (end 142.7861 111.7136) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060FA80)) - (segment (start 141.3891 96.2108) (end 141.3891 97.0998) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060FC60)) - (segment (start 141.3891 97.0998) (end 141.9861 98.3316) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F620)) - (segment (start 141.9861 98.3316) (end 141.9861 100.1136) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F6C0)) - (segment (start 142.0241 117.2801) (end 142.9131 117.1531) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F580)) - (segment (start 142.9131 117.1531) (end 143.2624 116.8038) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F760)) - (segment (start 143.2624 116.8038) (end 143.3195 116.6451) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F120)) - (segment (start 143.3195 116.6451) (end 143.3195 114.1686) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F1C0)) - (segment (start 143.3195 114.1686) (end 143.3322 114.1432) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F080)) - (segment (start 143.3322 114.1432) (end 142.7861 113.5971) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060F260)) - (segment (start 141.8971 94.7376) (end 141.3891 96.2108) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060EC20)) - (segment (start 142.7861 94.7376) (end 141.8971 94.7376) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060ECC0)) - (segment (start 142.7861 93.2136) (end 142.7861 94.7376) (width 0.8128) (layer Bottom) (net 2) (tstamp 1060EB80)) - (segment (start 141.5161 119.2486) (end 142.0241 117.2801) (width 0.8128) (layer Bottom) (net 2) (tstamp 1060ED60)) - (segment (start 142.7861 93.2136) (end 142.9766 93.1501) (width 0.381) (layer Bottom) (net 2) (tstamp 1060E720)) - (segment (start 143.2624 116.8038) (end 143.2941 116.8356) (width 0.381) (layer Bottom) (net 2) (tstamp 1060E7C0)) - (segment (start 131.1021 104.7946) (end 131.8881 105.0486) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060E680)) - (segment (start 131.8881 105.0486) (end 132.7531 105.9136) (width 0.4064) (layer Bottom) (net 2) (tstamp 1060E860)) - (segment (start 166.9161 102.9926) (end 166.8653 102.9164) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E220)) - (segment (start 166.8653 102.9164) (end 171.6151 105.9136) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E2C0)) - (segment (start 166.9161 98.2936) (end 166.9161 95.7536) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E180)) - (segment (start 166.9161 98.2936) (end 166.9161 100.8336) (width 1.27) (layer Bottom) (net 2) (tstamp 1060E360)) - (segment (start 166.9161 100.8336) (end 166.9161 102.1036) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DD20)) - (segment (start 166.9161 102.1036) (end 166.9161 102.9926) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DDC0)) - (segment (start 174.5361 94.4836) (end 174.5361 91.9436) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DC80)) - (segment (start 174.5361 97.0236) (end 174.5361 94.4836) (width 1.27) (layer Bottom) (net 2) (tstamp 1060DE60)) - (segment (start 174.5361 102.3576) (end 174.5361 99.5636) (width 1.27) (layer Bottom) (net 2) (tstamp 1060D320)) - (segment (start 171.6151 105.9136) (end 174.5361 102.3576) (width 1.27) (layer Bottom) (net 2) (tstamp 1060D3C0)) - (segment (start 174.5361 99.5636) (end 174.5361 97.0236) (width 1.27) (layer Bottom) (net 2) (tstamp 1060D280)) - (segment (start 128.8161 104.6436) (end 131.1021 104.7946) (width 0.6096) (layer Bottom) (net 2) (tstamp 1060D460)) - (segment (start 125.0061 104.6436) (end 128.8161 104.6436) (width 0.6096) (layer Bottom) (net 2) (tstamp 1060CE20)) - (segment (start 166.9161 95.7536) (end 166.9161 91.9436) (width 0.6096) (layer Top) (net 2) (tstamp 1060CEC0)) - (segment (start 165.6461 87.4986) (end 165.7304 87.4986) (width 0.6096) (layer Top) (net 2) (tstamp 1060D820)) - (segment (start 128.8161 104.6436) (end 134.5311 97.6586) (width 0.6096) (layer Top) (net 2) (tstamp 10601840)) - (segment (start 166.9161 100.8336) (end 166.9161 102.1036) (width 0.6096) (layer Top) (net 2) (tstamp 10601A20)) - (segment (start 166.9161 102.1036) (end 166.9161 102.7386) (width 0.6096) (layer Top) (net 2) (tstamp 106013E0)) - (segment (start 166.9161 102.7386) (end 166.9161 107.1836) (width 0.6096) (layer Top) (net 2) (tstamp 10601480)) - (segment (start 166.9161 107.1836) (end 164.3761 110.3586) (width 0.6096) (layer Top) (net 2) (tstamp 10601340)) - (segment (start 164.3761 110.3586) (end 162.4711 110.3586) (width 0.6096) (layer Top) (net 2) (tstamp 10601520)) - (segment (start 162.4711 110.3586) (end 157.3911 113.5336) (width 0.6096) (layer Top) (net 2) (tstamp 10601DE0)) - (segment (start 157.3911 113.5336) (end 151.6761 113.5336) (width 0.6096) (layer Top) (net 2) (tstamp 10601E80)) - (segment (start 151.6761 113.5336) (end 145.9611 113.5336) (width 0.6096) (layer Top) (net 2) (tstamp 10601D40)) - (segment (start 145.9611 113.5336) (end 141.5161 119.2486) (width 0.6096) (layer Top) (net 2) (tstamp 10601F20)) - (segment (start 159.2915 101.9766) (end 159.2961 101.9766) (width 0.4064) (layer Bottom) (net 2) (tstamp 106022E0)) - (segment (start 159.2153 102.4945) (end 159.2915 101.9766) (width 0.4064) (layer Bottom) (net 2) (tstamp 10602380)) - (segment (start 166.9161 93.2136) (end 164.3761 89.4036) (width 0.4064) (layer Bottom) (net 2) (tstamp 10602240)) - (segment (start 166.9161 95.7536) (end 166.9161 93.2136) (width 0.4064) (layer Bottom) (net 2) (tstamp 10602420)) - (segment (start 151.6761 113.5336) (end 151.6761 117.4706) (width 0.4064) (layer Top) (net 2) (tstamp F950850)) - (segment (start 157.3911 113.5336) (end 157.3911 117.4706) (width 0.4064) (layer Top) (net 2) (tstamp F9508F0)) - (segment (start 134.5311 97.6586) (end 133.8961 98.2936) (width 0.4064) (layer Top) (net 2) (tstamp F950990)) - (segment (start 133.8961 98.2936) (end 132.4991 98.2936) (width 0.4064) (layer Top) (net 2) (tstamp F950A30)) - (segment (start 166.9161 102.1036) (end 164.8587 101.4178) (width 1.016) (layer Bottom) (net 2) (tstamp F950AD0)) - (segment (start 174.5361 91.9436) (end 171.9961 91.9436) (width 1.016) (layer Bottom) (net 2) (tstamp F950B70)) - (segment (start 171.9961 94.4836) (end 171.9961 91.9436) (width 1.016) (layer Bottom) (net 2) (tstamp F950C10)) - (segment (start 171.9961 97.0236) (end 171.9961 94.4836) (width 1.016) (layer Bottom) (net 2) (tstamp F950CB0)) - (segment (start 174.5361 94.4836) (end 171.9961 94.4836) (width 1.016) (layer Bottom) (net 2) (tstamp F950D50)) - (segment (start 174.5361 97.0236) (end 171.9961 97.0236) (width 1.016) (layer Bottom) (net 2) (tstamp F950DF0)) - (segment (start 166.9161 91.9436) (end 166.9161 88.7686) (width 0.6096) (layer Top) (net 2) (tstamp F950E90)) - (segment (start 166.9161 88.7686) (end 165.6461 87.4986) (width 0.6096) (layer Top) (net 2) (tstamp F950F30)) - (segment (start 171.9961 99.5636) (end 171.9961 97.0236) (width 1.016) (layer Bottom) (net 2) (tstamp F950FD0)) - (segment (start 174.5361 99.5636) (end 171.9961 99.5636) (width 1.016) (layer Bottom) (net 2) (tstamp F951070)) - (segment (start 160.2359 103.5006) (end 159.2153 102.4945) (width 0.8128) (layer Bottom) (net 2) (tstamp F951110)) - (segment (start 164.8587 101.4178) (end 161.9377 103.5006) (width 1.016) (layer Bottom) (net 2) (tstamp F9511B0)) - (segment (start 161.9377 103.5006) (end 160.2359 103.5006) (width 0.8128) (layer Bottom) (net 2) (tstamp F951250)) - (via (at 142.7861 93.2136) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F9512F0)) - (via (at 141.5161 119.2486) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951390)) - (via (at 128.8161 104.6436) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951430)) - (via (at 166.9161 100.8336) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F9514D0)) - (via (at 166.9161 98.2936) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951570)) - (via (at 166.9161 95.7536) (size 1.9304) (drill 0.7) (layers Top Bottom) (net 2) (tstamp F951610)) - (via (at 174.5361 94.4836) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F9516B0)) - (via (at 174.5361 97.0236) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F951750)) - (via (at 174.5361 99.5636) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F9517F0)) - (via (at 174.5361 91.9436) (size 1.9304) (drill 0.9) (layers Top Bottom) (net 2) (tstamp F951890)) - (segment (start 142.7861 90.0386) (end 142.7861 93.2136) (width 0.6096) (layer Top) (net 2)) - (segment (start 143.5481 89.1496) (end 142.7861 90.0386) (width 0.6096) (layer Top) (net 2)) - (segment (start 150.9141 89.1496) (end 143.5481 89.1496) (width 0.6096) (layer Top) (net 2)) - (segment (start 165.6461 87.4986) (end 153.5811 87.4986) (width 0.6096) (layer Top) (net 2)) - (segment (start 153.5811 87.4986) (end 150.9141 89.1496) (width 0.6096) (layer Top) (net 2)) - (segment (start 165.6461 98.2936) (end 166.9161 98.2936) (width 0.6096) (layer Top) (net 2)) - (segment (start 165.0111 97.6586) (end 165.6461 98.2936) (width 0.6096) (layer Top) (net 2)) - (segment (start 159.2961 97.6586) (end 165.0111 97.6586) (width 0.6096) (layer Top) (net 2)) - (segment (start 158.5341 96.8966) (end 159.2961 97.6586) (width 0.6096) (layer Top) (net 2)) - (segment (start 158.5341 92.9596) (end 158.5341 96.8966) (width 0.6096) (layer Top) (net 2)) - (segment (start 156.5021 90.1656) (end 158.5341 92.9596) (width 0.6096) (layer Top) (net 2)) - (segment (start 134.5311 97.6586) (end 141.5161 97.6586) (width 0.6096) (layer Top) (net 2)) - (segment (start 141.5161 97.5316) (end 148.8821 90.1656) (width 0.6096) (layer Top) (net 2)) - (segment (start 141.5161 97.6586) (end 141.5161 97.5316) (width 0.6096) (layer Top) (net 2)) - (segment (start 148.8821 90.1656) (end 156.5021 90.1656) (width 0.6096) (layer Top) (net 2)) - (segment (start 149.1361 105.1516) (end 148.5861 105.1136) (width 0.4064) (layer Bottom) (net 2)) - (segment (start 150.876 105.1262) (end 149.1361 105.1516) (width 0.4064) (layer Bottom) (net 2)) - (segment (start 159.2153 102.4945) (end 153.7081 102.4846) (width 0.4064) (layer Bottom) (net 2)) - (segment (start 153.7081 102.4846) (end 150.876 105.1262) (width 0.4064) (layer Bottom) (net 2)) - (via (at 125.0061 86.3302) (size 7.62) (drill 3.2) (layers Top Bottom) (net 3) (tstamp 142C2950)) - (via (at 125.0061 123.6936) (size 7.62) (drill 3.2) (layers Top Bottom) (net 4) (tstamp 142C2A90)) - (via (at 171.9707 86.3302) (size 7.62) (drill 3.2) (layers Top Bottom) (net 5) (tstamp 142C2BD0)) - (segment (start 148.5011 90.6736) (end 150.4061 86.8636) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 147.8661 97.6586) (end 148.5011 90.6736) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 146.7861 100.1136) (end 146.8115 98.9672) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 146.8115 98.9672) (end 147.8661 97.6586) (width 0.4064) (layer Bottom) (net 6)) - (segment (start 147.2311 90.6736) (end 147.8661 86.8636) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 146.9009 97.6078) (end 147.2311 90.6736) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 145.9861 100.1136) (end 145.9865 98.8016) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 145.9865 98.8016) (end 146.9009 97.6078) (width 0.4064) (layer Bottom) (net 7)) - (segment (start 145.3261 89.4036) (end 145.3261 86.8636) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 146.0373 91.3848) (end 145.3261 89.4036) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 146.0373 91.3594) (end 146.0373 91.3848) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 146.0119 97.6332) (end 146.0373 91.3594) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 145.1861 100.1136) (end 145.1483 98.7) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 145.1483 98.7) (end 146.0119 97.6332) (width 0.4064) (layer Bottom) (net 8)) - (segment (start 142.7607 87.9558) (end 142.7861 86.8636) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 145.2245 92.2992) (end 142.7607 87.9558) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 145.2245 97.43) (end 145.2245 92.2992) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 144.3861 100.1136) (end 144.3609 98.5476) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 144.3609 98.5476) (end 145.2245 97.43) (width 0.4064) (layer Bottom) (net 9)) - (segment (start 140.2461 88.1336) (end 140.2461 86.8636) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 144.4117 92.477) (end 140.2461 88.1336) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 144.4117 97.2522) (end 144.4117 92.477) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 143.5861 100.1136) (end 143.5735 98.446) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 143.5735 98.446) (end 144.4117 97.2522) (width 0.4064) (layer Bottom) (net 10)) - (segment (start 137.7061 90.6736) (end 137.7061 86.8636) (width 0.4064) (layer Bottom) (net 11)) - (segment (start 140.2461 97.0236) (end 137.7061 90.6736) (width 0.4064) (layer Bottom) (net 11)) - (segment (start 141.1861 100.1136) (end 141.1605 98.6238) (width 0.4064) (layer Bottom) (net 11)) - (segment (start 141.1605 98.6238) (end 140.2461 97.0236) (width 0.4064) (layer Bottom) (net 11)) - (segment (start 135.1661 89.4036) (end 135.1661 86.8636) (width 0.4064) (layer Bottom) (net 12)) - (segment (start 140.3861 100.1136) (end 140.3985 98.7762) (width 0.4064) (layer Bottom) (net 12)) - (segment (start 140.3985 98.7762) (end 135.1661 89.4036) (width 0.4064) (layer Bottom) (net 12)) - (segment (start 132.6261 89.4036) (end 132.6261 86.8636) (width 0.4064) (layer Bottom) (net 13)) - (segment (start 139.5861 100.1136) (end 139.5857 98.9286) (width 0.4064) (layer Bottom) (net 13)) - (segment (start 139.5857 98.9286) (end 132.6261 89.4036) (width 0.4064) (layer Bottom) (net 13)) - (segment (start 130.0861 89.4036) (end 130.0861 86.8636) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 138.7861 100.1136) (end 138.7729 99.3096) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 138.7729 99.3096) (end 130.0861 89.4036) (width 0.4064) (layer Bottom) (net 14)) - (segment (start 127.5461 99.5636) (end 134.0231 99.5636) (width 0.4064) (layer Bottom) (net 15) (tstamp 10605760)) - (segment (start 134.0231 99.5636) (end 136.0551 101.8496) (width 0.4064) (layer Bottom) (net 15) (tstamp 10605120)) - (segment (start 136.0551 101.8496) (end 136.9861 101.9136) (width 0.4064) (layer Bottom) (net 15) (tstamp 106051C0)) - (segment (start 125.0061 99.5636) (end 127.5461 99.5636) (width 0.4064) (layer Bottom) (net 15) (tstamp 10605080)) - (segment (start 132.2705 102.0782) (end 133.2611 101.2146) (width 0.4064) (layer Bottom) (net 16) (tstamp 142C2E50)) - (segment (start 133.2611 101.2146) (end 134.4041 101.2146) (width 0.4064) (layer Bottom) (net 16) (tstamp 142C2EF0)) - (segment (start 134.4041 101.2146) (end 135.8011 102.7386) (width 0.4064) (layer Bottom) (net 16) (tstamp 142C2F90)) - (segment (start 135.8011 102.7386) (end 136.9861 102.7136) (width 0.4064) (layer Bottom) (net 16) (tstamp 142C3030)) - (segment (start 125.0061 102.1036) (end 132.2705 102.0782) (width 0.4064) (layer Bottom) (net 16) (tstamp 142C30D0)) - (segment (start 138.2586 103.545) (end 136.9861 103.5136) (width 0.4064) (layer Bottom) (net 17) (tstamp 10606160)) - (segment (start 138.5189 103.2911) (end 138.2586 103.545) (width 0.4064) (layer Bottom) (net 17) (tstamp 10605B20)) - (segment (start 138.5189 101.7988) (end 138.5189 103.2911) (width 0.4064) (layer Bottom) (net 17) (tstamp 10605BC0)) - (segment (start 133.8961 97.0236) (end 138.5189 101.7988) (width 0.4064) (layer Bottom) (net 17) (tstamp 10605A80)) - (segment (start 125.0061 97.0236) (end 133.8961 97.0236) (width 0.4064) (layer Bottom) (net 17) (tstamp 10605C60)) - (segment (start 139.4333 104.3388) (end 136.9861 104.3136) (width 0.4064) (layer Bottom) (net 18) (tstamp 142C44D0)) - (segment (start 125.0061 112.2636) (end 127.5715 114.575) (width 0.4064) (layer Top) (net 18) (tstamp 142C4570)) - (segment (start 127.5715 114.575) (end 131.3815 114.575) (width 0.4064) (layer Top) (net 18) (tstamp 142C4610)) - (segment (start 131.3815 114.575) (end 139.4333 104.3388) (width 0.4064) (layer Top) (net 18) (tstamp 142C46B0)) - (via (at 139.4333 104.3388) (size 1.27) (drill 0.6) (layers Top Bottom) (net 18) (tstamp 142C4750)) - (segment (start 136.1441 105.1136) (end 136.9861 105.1136) (width 0.4064) (layer Bottom) (net 19) (tstamp 1060DAA0)) - (segment (start 135.2931 104.5166) (end 136.1441 105.1136) (width 0.4064) (layer Bottom) (net 19) (tstamp 1060DA00)) - (segment (start 135.1661 104.0721) (end 135.2931 104.5166) (width 0.4064) (layer Bottom) (net 19) (tstamp 1060D1E0)) - (segment (start 135.0391 103.9451) (end 135.1661 104.0721) (width 0.4064) (layer Bottom) (net 19) (tstamp 1060D140)) - (segment (start 133.8961 102.4846) (end 135.0391 103.9451) (width 0.4064) (layer Bottom) (net 19) (tstamp 1060D0A0)) - (segment (start 125.0061 107.1836) (end 127.0381 108.4536) (width 0.4064) (layer Top) (net 19) (tstamp 1060D000)) - (segment (start 127.0381 108.4536) (end 130.7211 108.4536) (width 0.4064) (layer Top) (net 19) (tstamp 1060CCE0)) - (segment (start 130.7211 108.4536) (end 133.8961 102.4846) (width 0.4064) (layer Top) (net 19) (tstamp 1060CC40)) - (via (at 133.8961 102.4846) (size 1.27) (drill 0.6) (layers Top Bottom) (net 19) (tstamp 1060CBA0)) - (segment (start 131.1021 107.7946) (end 134.1261 108.0486) (width 0.4064) (layer Bottom) (net 20) (tstamp 1060D500)) - (segment (start 134.1261 108.0486) (end 134.1501 108.1234) (width 0.4064) (layer Bottom) (net 20) (tstamp 10602BA0)) - (segment (start 134.1501 108.1234) (end 134.6581 108.0726) (width 0.4064) (layer Bottom) (net 20) (tstamp 10602B00)) - (segment (start 134.6581 108.0726) (end 136.0551 106.6756) (width 0.4064) (layer Bottom) (net 20) (tstamp 10602A60)) - (segment (start 136.0551 106.6756) (end 136.9481 106.6756) (width 0.4064) (layer Bottom) (net 20) (tstamp 106029C0)) - (segment (start 136.9481 106.6756) (end 136.9861 106.7136) (width 0.4064) (layer Bottom) (net 20) (tstamp 10602920)) - (segment (start 139.4841 107.0566) (end 138.3157 107.5138) (width 0.4064) (layer Bottom) (net 21) (tstamp 142C49D0)) - (segment (start 138.3157 107.5138) (end 136.9861 107.5136) (width 0.4064) (layer Bottom) (net 21) (tstamp 142C4A70)) - (segment (start 132.5753 114.6258) (end 139.4841 107.0566) (width 0.4064) (layer Top) (net 21) (tstamp 142C4B10)) - (segment (start 126.2507 115.8958) (end 125.0061 114.8036) (width 0.4064) (layer Top) (net 21) (tstamp 142C4BB0)) - (segment (start 126.2507 115.8958) (end 131.3307 115.8958) (width 0.4064) (layer Top) (net 21) (tstamp 142C4C50)) - (segment (start 131.3307 115.8958) (end 132.5753 114.6258) (width 0.4064) (layer Top) (net 21) (tstamp 142C4CF0)) - (via (at 139.4841 107.0566) (size 1.27) (drill 0.6) (layers Top Bottom) (net 21) (tstamp 142C4D90)) - (segment (start 140.6271 108.2758) (end 138.4427 108.2758) (width 0.4064) (layer Bottom) (net 22) (tstamp 142C5010)) - (segment (start 138.4427 108.2758) (end 136.9861 108.3136) (width 0.4064) (layer Bottom) (net 22) (tstamp 142C50B0)) - (segment (start 125.0061 117.3436) (end 127.5461 119.8836) (width 0.4064) (layer Top) (net 22) (tstamp 142C5150)) - (segment (start 127.5461 119.8836) (end 130.0861 119.8836) (width 0.4064) (layer Top) (net 22) (tstamp 142C51F0)) - (segment (start 130.0861 119.8836) (end 131.3561 119.8836) (width 0.4064) (layer Top) (net 22) (tstamp 142C5290)) - (segment (start 131.3561 119.8836) (end 140.6271 108.2758) (width 0.4064) (layer Top) (net 22) (tstamp 142C5330)) - (via (at 140.6271 108.2758) (size 1.27) (drill 0.6) (layers Top Bottom) (net 22) (tstamp 142C53D0)) - (segment (start 128.1811 100.8336) (end 128.1811 100.0716) (width 0.4064) (layer Top) (net 23) (tstamp 10604680)) - (segment (start 128.1811 100.8336) (end 129.8956 100.8336) (width 0.4064) (layer Top) (net 23) (tstamp 10604860)) - (segment (start 129.8956 100.8336) (end 130.2131 100.5161) (width 0.4064) (layer Top) (net 23) (tstamp 10604220)) - (segment (start 130.2131 100.5161) (end 130.2131 98.2936) (width 0.4064) (layer Top) (net 23) (tstamp 106042C0)) - (segment (start 135.2169 108.9108) (end 136.9861 109.1136) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 132.4229 108.9108) (end 135.2169 108.9108) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 132.1181 109.2156) (end 132.4229 108.9108) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 130.3401 109.2156) (end 132.1181 109.2156) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 127.5461 107.1836) (end 128.8161 107.6916) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 128.8161 107.6916) (end 130.3401 109.2156) (width 0.4064) (layer Bottom) (net 23)) - (segment (start 127.2921 105.6596) (end 127.5461 107.1836) (width 0.4064) (layer Top) (net 23)) - (segment (start 128.1811 100.8336) (end 127.2921 101.7226) (width 0.4064) (layer Top) (net 23)) - (segment (start 127.2921 101.7226) (end 127.2921 105.6596) (width 0.4064) (layer Top) (net 23)) - (segment (start 131.4829 114.8419) (end 133.0579 109.622) (width 0.4064) (layer Bottom) (net 24) (tstamp 10603460)) - (segment (start 133.0579 109.622) (end 135.2931 109.622) (width 0.4064) (layer Bottom) (net 24) (tstamp 1060C920)) - (segment (start 135.2931 109.622) (end 136.9861 109.9136) (width 0.4064) (layer Bottom) (net 24) (tstamp 1060C9C0)) - (segment (start 131.4446 114.8036) (end 130.6449 114.8036) (width 0.4064) (layer Bottom) (net 24) (tstamp 1060C380)) - (segment (start 131.4829 114.8419) (end 131.4446 114.8036) (width 0.4064) (layer Bottom) (net 24) (tstamp 1060C560)) - (segment (start 128.8161 117.3436) (end 127.5461 117.3436) (width 0.4064) (layer Bottom) (net 24)) - (segment (start 130.0861 117.3436) (end 128.8161 117.3436) (width 0.4064) (layer Bottom) (net 24)) - (segment (start 131.2799 116.1498) (end 130.0861 117.3436) (width 0.4064) (layer Bottom) (net 24)) - (segment (start 131.4829 114.8419) (end 131.2799 115.5148) (width 0.4064) (layer Bottom) (net 24)) - (segment (start 131.2799 115.5148) (end 131.2799 116.1498) (width 0.4064) (layer Bottom) (net 24)) - (segment (start 130.0861 124.9636) (end 130.0861 123.6936) (width 0.4064) (layer Bottom) (net 25) (tstamp F951B10)) - (segment (start 130.0861 123.6936) (end 131.3561 121.1536) (width 0.4064) (layer Bottom) (net 25) (tstamp F951BB0)) - (segment (start 131.3561 121.1536) (end 131.3561 118.6136) (width 0.4064) (layer Bottom) (net 25) (tstamp F951C50)) - (segment (start 131.3561 118.6136) (end 138.7475 112.67) (width 0.4064) (layer Bottom) (net 25) (tstamp F951CF0)) - (segment (start 138.7475 112.67) (end 138.7861 111.7136) (width 0.4064) (layer Bottom) (net 25) (tstamp F951D90)) - (segment (start 132.6261 124.9636) (end 133.8961 121.1536) (width 0.4064) (layer Bottom) (net 26) (tstamp F952010)) - (segment (start 133.8961 121.1536) (end 133.8961 118.6136) (width 0.4064) (layer Bottom) (net 26) (tstamp F9520B0)) - (segment (start 133.8961 118.6136) (end 139.5603 113.2034) (width 0.4064) (layer Bottom) (net 26) (tstamp F952150)) - (segment (start 139.5603 113.2034) (end 139.5861 111.7136) (width 0.4064) (layer Bottom) (net 26) (tstamp F9521F0)) - (segment (start 135.1661 124.9636) (end 135.1661 122.4236) (width 0.4064) (layer Bottom) (net 27) (tstamp F952470)) - (segment (start 135.1661 122.4236) (end 140.2461 113.5336) (width 0.4064) (layer Bottom) (net 27) (tstamp F952510)) - (segment (start 140.2461 113.5336) (end 140.3861 111.7136) (width 0.4064) (layer Bottom) (net 27) (tstamp F9525B0)) - (segment (start 141.1097 113.5336) (end 141.1861 111.7136) (width 0.4064) (layer Bottom) (net 28) (tstamp F952830)) - (segment (start 137.7061 123.6936) (end 141.1097 113.5336) (width 0.4064) (layer Bottom) (net 28) (tstamp F9528D0)) - (segment (start 137.7061 124.9636) (end 137.7061 123.6936) (width 0.4064) (layer Bottom) (net 28) (tstamp F952970)) - (segment (start 140.2461 124.9636) (end 140.2461 122.4236) (width 0.4064) (layer Bottom) (net 29) (tstamp F952BF0)) - (segment (start 140.2461 122.4236) (end 141.5161 121.1536) (width 0.4064) (layer Bottom) (net 29) (tstamp F952C90)) - (segment (start 141.5161 121.1536) (end 142.7493 121.172) (width 0.4064) (layer Bottom) (net 29) (tstamp F952D30)) - (segment (start 142.7493 121.172) (end 143.0438 120.9843) (width 0.4064) (layer Bottom) (net 29) (tstamp F952DD0)) - (segment (start 143.0438 120.9843) (end 143.0701 120.9255) (width 0.4064) (layer Bottom) (net 29) (tstamp F952E70)) - (segment (start 143.0701 120.9255) (end 144.0561 117.3436) (width 0.4064) (layer Bottom) (net 29) (tstamp F952F10)) - (segment (start 144.0561 117.3436) (end 144.0561 114.0162) (width 0.4064) (layer Bottom) (net 29) (tstamp F952FB0)) - (segment (start 144.0561 114.0162) (end 143.5989 113.0256) (width 0.4064) (layer Bottom) (net 29) (tstamp F953050)) - (segment (start 143.5989 113.0256) (end 143.5861 111.7136) (width 0.4064) (layer Bottom) (net 29) (tstamp F9530F0)) - (segment (start 144.4117 112.9748) (end 144.3861 111.7136) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C1FF0)) - (segment (start 144.7419 113.5336) (end 144.4117 112.9748) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C2090)) - (segment (start 144.7419 117.9278) (end 144.7419 113.5336) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C2130)) - (segment (start 143.7259 122.2204) (end 144.7419 117.9278) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C21D0)) - (segment (start 142.8115 123.1602) (end 143.7259 122.2204) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C2270)) - (segment (start 142.7861 124.9636) (end 142.8115 123.1602) (width 0.4064) (layer Bottom) (net 30) (tstamp 142C2310)) - (segment (start 145.1991 112.7716) (end 145.1861 111.7136) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C1B90)) - (segment (start 145.4277 113.3304) (end 145.1991 112.7716) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C1C30)) - (segment (start 145.4277 118.385) (end 145.4277 113.3304) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C1CD0)) - (segment (start 145.3261 124.9636) (end 145.4277 118.385) (width 0.4064) (layer Bottom) (net 31) (tstamp 142C1D70)) - (segment (start 145.9865 112.7462) (end 145.9861 111.7136) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C1730)) - (segment (start 146.3929 114.194) (end 145.9865 112.7462) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C17D0)) - (segment (start 147.8661 124.9636) (end 147.8661 122.4236) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C1870)) - (segment (start 147.8661 122.4236) (end 146.3929 114.194) (width 0.4064) (layer Bottom) (net 32) (tstamp 142C1910)) - (segment (start 146.7739 112.6954) (end 146.7861 111.7136) (width 0.4064) (layer Bottom) (net 33) (tstamp 142C10F0)) - (segment (start 148.5011 117.3436) (end 146.7739 112.6954) (width 0.4064) (layer Bottom) (net 33) (tstamp 142C1190)) - (segment (start 149.1361 118.6136) (end 148.5011 117.3436) (width 0.4064) (layer Bottom) (net 33) (tstamp 142C1230)) - (segment (start 149.7711 119.2486) (end 149.1361 118.6136) (width 0.4064) (layer Bottom) (net 33) (tstamp 142C12D0)) - (segment (start 150.1911 119.2486) (end 149.7711 119.2486) (width 0.4064) (layer Bottom) (net 33) (tstamp 142C1370)) - (segment (start 150.4061 119.0336) (end 150.1911 119.2486) (width 0.4064) (layer Bottom) (net 33) (tstamp 142C1410)) - (segment (start 149.6441 110.2316) (end 148.5861 109.9136) (width 0.4064) (layer Bottom) (net 34) (tstamp 142C0970)) - (segment (start 152.9461 117.3436) (end 149.6441 110.2316) (width 0.4064) (layer Bottom) (net 34) (tstamp 142C0A10)) - (segment (start 152.9461 124.9636) (end 152.9461 122.4236) (width 0.4064) (layer Bottom) (net 34) (tstamp 142C0AB0)) - (segment (start 152.9461 122.4236) (end 152.9461 117.3436) (width 0.4064) (layer Bottom) (net 34) (tstamp 142C0B50)) - (segment (start 152.9461 124.9636) (end 152.9461 123.0586) (width 0.4064) (layer Top) (net 34) (tstamp 142C0BF0)) - (segment (start 152.9461 122.4236) (end 152.9461 123.0586) (width 0.4064) (layer Top) (net 34) (tstamp 142C0C90)) - (segment (start 152.9461 122.4236) (end 151.6761 121.1536) (width 0.4064) (layer Top) (net 34) (tstamp 142C0D30)) - (segment (start 151.6761 121.1536) (end 151.6761 119.7566) (width 0.4064) (layer Top) (net 34) (tstamp 142C0DD0)) - (segment (start 152.9461 124.9636) (end 152.9461 122.4236) (width 0.4064) (layer Bottom) (net 34) (tstamp 142C0E70)) - (segment (start 150.1267 109.2156) (end 148.5861 109.1136) (width 0.4064) (layer Bottom) (net 35) (tstamp 142C03D0)) - (segment (start 154.8511 117.4706) (end 150.1267 109.2156) (width 0.4064) (layer Bottom) (net 35) (tstamp 142C0470)) - (segment (start 154.8511 119.4654) (end 154.8511 117.4706) (width 0.4064) (layer Bottom) (net 35) (tstamp 142C0510)) - (segment (start 154.8003 119.5162) (end 154.8511 119.4654) (width 0.4064) (layer Bottom) (net 35) (tstamp 142C05B0)) - (segment (start 150.4061 108.4536) (end 148.5861 108.3136) (width 0.4064) (layer Bottom) (net 36) (tstamp 142BFD90)) - (segment (start 152.9461 110.9936) (end 150.4061 108.4536) (width 0.4064) (layer Bottom) (net 36) (tstamp 142BFE30)) - (segment (start 157.0101 118.7406) (end 152.9461 110.9936) (width 0.4064) (layer Bottom) (net 36) (tstamp 142BFED0)) - (segment (start 158.0261 124.9636) (end 157.0101 122.5506) (width 0.4064) (layer Bottom) (net 36) (tstamp 142BFF70)) - (segment (start 157.0101 122.5506) (end 157.0101 118.7406) (width 0.4064) (layer Bottom) (net 36) (tstamp 142C0010)) - (segment (start 158.0261 124.9636) (end 157.3911 122.4236) (width 0.4064) (layer Top) (net 36) (tstamp 142C00B0)) - (segment (start 157.3911 122.4236) (end 157.3911 119.7566) (width 0.4064) (layer Top) (net 36) (tstamp 142C0150)) - (segment (start 149.3266 107.5011) (end 150.7109 107.5392) (width 0.4064) (layer Bottom) (net 37) (tstamp 106049A0)) - (segment (start 150.7109 107.5392) (end 154.6479 110.9682) (width 0.4064) (layer Bottom) (net 37) (tstamp 10604900)) - (segment (start 148.5861 107.5136) (end 149.3266 107.5011) (width 0.4064) (layer Bottom) (net 37) (tstamp 106045E0)) - (segment (start 154.6479 110.9682) (end 156.7561 110.9936) (width 0.4064) (layer Bottom) (net 37) (tstamp 10604540)) - (segment (start 157.3911 111.1841) (end 160.1343 111.1841) (width 0.4064) (layer Bottom) (net 37) (tstamp 106044A0)) - (segment (start 156.7561 110.9936) (end 157.3911 111.1841) (width 0.4064) (layer Bottom) (net 37) (tstamp 10604400)) - (segment (start 149.3266 106.7391) (end 151.7396 106.7264) (width 0.4064) (layer Bottom) (net 38) (tstamp 10603BE0)) - (segment (start 148.5861 106.7136) (end 149.3266 106.7391) (width 0.4064) (layer Bottom) (net 38) (tstamp 10603B40)) - (segment (start 151.7396 106.7264) (end 153.3906 105.9517) (width 0.4064) (layer Bottom) (net 38) (tstamp 10603AA0)) - (segment (start 153.3906 105.9517) (end 156.7561 105.9136) (width 0.4064) (layer Bottom) (net 38) (tstamp 10603A00)) - (segment (start 148.6281 104.3261) (end 150.5966 104.3261) (width 0.381) (layer Bottom) (net 39) (tstamp 1060A8A0)) - (segment (start 148.5861 104.3136) (end 148.6281 104.3261) (width 0.381) (layer Bottom) (net 39) (tstamp 1060A800)) - (segment (start 159.2961 99.6906) (end 161.8361 94.4836) (width 0.4064) (layer Bottom) (net 39) (tstamp 1060FDA0)) - (segment (start 158.6611 99.5636) (end 159.2961 99.6906) (width 0.4064) (layer Bottom) (net 39)) - (segment (start 157.0101 101.7226) (end 158.6611 99.5636) (width 0.4064) (layer Bottom) (net 39)) - (segment (start 150.5966 104.3261) (end 153.3271 101.7226) (width 0.4064) (layer Bottom) (net 39)) - (segment (start 153.3271 101.7226) (end 157.0101 101.7226) (width 0.4064) (layer Bottom) (net 39)) - (segment (start 148.5861 103.5136) (end 148.6916 103.5641) (width 0.4064) (layer Bottom) (net 40) (tstamp 1060F440)) - (segment (start 148.8821 103.5006) (end 149.1996 103.5006) (width 0.381) (layer Bottom) (net 40) (tstamp 1060F3A0)) - (segment (start 148.5861 103.5136) (end 148.8821 103.5006) (width 0.381) (layer Bottom) (net 40) (tstamp 1060F300)) - (segment (start 156.7561 97.0236) (end 161.8361 91.9436) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 150.4061 97.0236) (end 152.9461 97.0236) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 152.9461 97.0236) (end 155.4861 97.0236) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 155.4861 97.0236) (end 156.7561 97.0236) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 152.9461 100.3256) (end 152.9461 97.0236) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 152.9461 101.0876) (end 152.9461 100.3256) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 150.3045 103.472324) (end 152.9461 101.0876) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 149.1996 103.5006) (end 150.3045 103.5006) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 150.3045 103.5006) (end 150.3045 103.472324) (width 0.4064) (layer Bottom) (net 40)) - (segment (start 156.7561 94.4836) (end 161.8361 89.4036) (width 0.4064) (layer Bottom) (net 41)) - (segment (start 153.846099 95.383599) (end 152.9461 94.4836) (width 0.4064) (layer Top) (net 41)) - (segment (start 154.230499 95.767999) (end 153.846099 95.383599) (width 0.4064) (layer Top) (net 41)) - (segment (start 154.230499 95.739201) (end 154.230499 95.767999) (width 0.4064) (layer Top) (net 41)) - (segment (start 155.4861 94.4836) (end 154.230499 95.739201) (width 0.4064) (layer Top) (net 41)) - (segment (start 156.7561 94.4836) (end 155.4861 94.4836) (width 0.4064) (layer Bottom) (net 41)) - (segment (start 155.4861 94.4836) (end 152.9461 94.4836) (width 0.4064) (layer Bottom) (net 41)) - (segment (start 152.9461 94.4836) (end 150.4061 94.4836) (width 0.4064) (layer Bottom) (net 41)) - (segment (start 149.5883 102.7331) (end 148.5861 102.7136) (width 0.4064) (layer Bottom) (net 41)) - (via (at 151.9301 100.5796) (size 1.27) (drill 0.6) (layers Top Bottom) (net 41)) - (segment (start 154.230499 98.279201) (end 151.9301 100.5796) (width 0.4064) (layer Top) (net 41)) - (segment (start 154.230499 95.767999) (end 154.230499 98.279201) (width 0.4064) (layer Top) (net 41)) - (segment (start 149.7766 102.7331) (end 151.9301 100.5796) (width 0.4064) (layer Bottom) (net 41)) - (segment (start 149.5883 102.7331) (end 149.7766 102.7331) (width 0.4064) (layer Bottom) (net 41)) - (segment (start 148.5861 101.9136) (end 148.6027 101.9385) (width 0.381) (layer Bottom) (net 42) (tstamp 10603000)) - (segment (start 154.2161 91.9436) (end 156.7561 91.9436) (width 0.4064) (layer Bottom) (net 42) (tstamp 1060C600)) - (segment (start 156.7561 91.9436) (end 160.2486 87.4986) (width 0.4064) (layer Bottom) (net 42) (tstamp 1060C2E0)) - (segment (start 160.2486 87.4986) (end 162.4711 87.4986) (width 0.4064) (layer Bottom) (net 42) (tstamp 5C8E5F91)) - (segment (start 162.4711 87.4986) (end 163.1061 88.1336) (width 0.4064) (layer Bottom) (net 42) (tstamp 1060C1A0)) - (segment (start 163.1061 88.1336) (end 163.1061 90.6736) (width 0.4064) (layer Bottom) (net 42) (tstamp 1060C100)) - (segment (start 163.1061 90.6736) (end 164.3761 91.9436) (width 0.4064) (layer Bottom) (net 42) (tstamp 1060BDE0)) - (segment (start 150.4061 91.9436) (end 154.2161 91.9436) (width 0.4064) (layer Bottom) (net 42)) - (segment (start 149.7425 101.9136) (end 150.5331 101.123) (width 0.4064) (layer Bottom) (net 42)) - (segment (start 148.5861 101.9136) (end 149.7425 101.9136) (width 0.4064) (layer Bottom) (net 42)) - (via (at 150.5331 99.6906) (size 1.27) (drill 0.6) (layers Top Bottom) (net 42)) - (segment (start 150.5331 101.123) (end 150.5331 99.6906) (width 0.4064) (layer Bottom) (net 42)) - (segment (start 152.046101 92.843599) (end 152.9461 91.9436) (width 0.4064) (layer Top) (net 42)) - (segment (start 151.661701 93.227999) (end 152.046101 92.843599) (width 0.4064) (layer Top) (net 42)) - (segment (start 151.661701 98.561999) (end 151.661701 93.227999) (width 0.4064) (layer Top) (net 42)) - (segment (start 150.5331 99.6906) (end 151.661701 98.561999) (width 0.4064) (layer Top) (net 42)) - (segment (start 151.306099 92.872397) (end 151.661701 93.227999) (width 0.4064) (layer Top) (net 42)) - (segment (start 151.306099 92.843599) (end 151.306099 92.872397) (width 0.4064) (layer Top) (net 42)) - (segment (start 150.4061 91.9436) (end 151.306099 92.843599) (width 0.4064) (layer Top) (net 42)) - (segment (start 171.6151 110.9936) (end 171.0121 111.0256) (width 0.8128) (layer Bottom) (net 43) (tstamp 142C35D0)) - (segment (start 171.6151 110.9936) (end 171.2849 110.9682) (width 0.8128) (layer Bottom) (net 43) (tstamp 142C3670)) - (segment (start 171.6151 110.9936) (end 170.7261 111.2476) (width 1.27) (layer Bottom) (net 43) (tstamp 142C3710)) - (segment (start 168.3131 111.2376) (end 169.3745 111.1592) (width 1.27) (layer Bottom) (net 43) (tstamp 142C37B0)) - (segment (start 169.3745 111.1592) (end 171.6151 110.9936) (width 1.27) (layer Bottom) (net 43) (tstamp 142C3850)) - (segment (start 171.9961 113.7808) (end 171.9961 114.1686) (width 1.27) (layer Bottom) (net 43) (tstamp 142C38F0)) - (segment (start 169.3745 111.1592) (end 171.9961 113.7808) (width 1.27) (layer Bottom) (net 43) (tstamp 142C3990)) - (segment (start 171.9961 114.1686) (end 174.5361 114.1686) (width 1.27) (layer Bottom) (net 43) (tstamp 142C3A30)) - (segment (start 171.6151 110.9936) (end 173.0883 110.7396) (width 0.8128) (layer Bottom) (net 43) (tstamp 142C3AD0)) - (segment (start 173.0883 110.7396) (end 174.5361 110.7396) (width 0.8128) (layer Bottom) (net 43) (tstamp 142C3B70)) - (segment (start 128.3589 114.8036) (end 128.8161 112.2636) (width 0.4064) (layer Bottom) (net 44) (tstamp 142C2630)) - (segment (start 130.2867 113.0992) (end 130.4925 113.2008) (width 0.6096) (layer Top) (net 44) (tstamp 142C26D0)) - (segment (start 129.4511 112.2636) (end 130.2867 113.0992) (width 0.6096) (layer Top) (net 44) (tstamp 142C2770)) - (segment (start 128.8161 112.2636) (end 129.4511 112.2636) (width 0.6096) (layer Top) (net 44) (tstamp 142C2810)) - (segment (start 150.4061 124.9636) (end 150.4061 122.4236) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C5790)) - (segment (start 150.4061 122.4236) (end 150.4061 120.7336) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C5830)) - (segment (start 151.5491 117.8516) (end 150.4061 117.2166) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C58D0)) - (segment (start 151.6761 117.9786) (end 151.5491 117.8516) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C5970)) - (segment (start 151.6761 120.2011) (end 151.6761 117.9786) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C5A10)) - (segment (start 151.3586 120.5186) (end 151.6761 120.2011) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C5AB0)) - (segment (start 150.6211 120.5186) (end 151.3586 120.5186) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C5B50)) - (segment (start 150.4061 120.7336) (end 150.6211 120.5186) (width 0.4064) (layer Bottom) (net 45) (tstamp 142C5BF0)) - (segment (start 154.8003 122.3728) (end 154.8003 121.2162) (width 0.4064) (layer Bottom) (net 46) (tstamp 142C6190)) - (segment (start 155.4861 123.0586) (end 154.8003 122.3728) (width 0.4064) (layer Bottom) (net 46) (tstamp 142C6230)) - (segment (start 155.4861 124.9636) (end 155.4861 123.0586) (width 0.4064) (layer Bottom) (net 46) (tstamp 142C62D0)) - (segment (start 154.8375 121.179) (end 156.0195 121.179) (width 0.4064) (layer Bottom) (net 46) (tstamp 142C6370)) - (segment (start 154.8003 121.2162) (end 154.8375 121.179) (width 0.4064) (layer Bottom) (net 46) (tstamp 142C6410)) - (segment (start 163.1461 122.4236) (end 163.6161 124.9636) (width 1.27) (layer Bottom) (net 47) (tstamp 1060E0E0)) - (segment (start 161.0741 123.7036) (end 163.1461 122.4236) (width 1.27) (layer Bottom) (net 47) (tstamp 1060E040)) - (segment (start 161.0741 118.6036) (end 163.2231 118.4866) (width 1.27) (layer Bottom) (net 48) (tstamp 142C5E70)) - (segment (start 168.3231 118.4866) (end 168.3131 116.3376) (width 1.27) (layer Bottom) (net 49) (tstamp 142C3DF0)) - (segment (start 128.1811 97.7856) (end 128.1811 97.0436) (width 0.4064) (layer Top) (net 50) (tstamp 142C4110)) - (segment (start 128.1811 97.0436) (end 129.4761 95.1136) (width 0.4064) (layer Top) (net 50) (tstamp 142C41B0)) - (segment (start 129.4761 95.1136) (end 129.4761 93.8436) (width 0.4064) (layer Top) (net 50)) - (segment (start 129.4761 93.8436) (end 135.7761 93.8436) (width 0.4064) (layer Top) (net 50)) - - (zone (net 1) (net_name GND) (layer Bottom) (tstamp 5C8E76A5) (hatch edge 0.508) - (priority 6) - (connect_pads (clearance 0.3048)) - (min_thickness 0.3048) - (fill yes (arc_segments 32) (thermal_gap 0.3548) (thermal_bridge_width 0.3548)) - (polygon - (pts - (xy 145.9611 109.7236) (xy 146.5961 109.0886) (xy 146.5961 102.7386) (xy 145.9611 101.9766) (xy 139.6111 101.9766) - (xy 139.6111 103.3736) (xy 138.9761 104.8976) (xy 138.9761 109.0886) (xy 139.6111 109.7236) - ) - ) - (filled_polygon - (pts - (xy 146.4437 102.793776) (xy 146.4437 109.025474) (xy 145.897974 109.5712) (xy 139.674226 109.5712) (xy 139.1285 109.025474) - (xy 139.1285 108.9362) (xy 139.754787 108.9362) (xy 139.778733 108.972037) (xy 139.930863 109.124167) (xy 140.109749 109.243695) - (xy 140.308517 109.326028) (xy 140.519528 109.368) (xy 140.734672 109.368) (xy 140.945683 109.326028) (xy 141.144451 109.243695) - (xy 141.323337 109.124167) (xy 141.475467 108.972037) (xy 141.594995 108.793151) (xy 141.677328 108.594383) (xy 141.7193 108.383372) - (xy 141.7193 108.168228) (xy 141.677328 107.957217) (xy 141.594995 107.758449) (xy 141.475467 107.579563) (xy 141.323337 107.427433) - (xy 141.144451 107.307905) (xy 140.945683 107.225572) (xy 140.734672 107.1836) (xy 140.572436 107.1836) (xy 140.5763 107.164172) - (xy 140.5763 106.949028) (xy 140.534328 106.738017) (xy 140.451995 106.539249) (xy 140.332467 106.360363) (xy 140.180337 106.208233) - (xy 140.001451 106.088705) (xy 139.802683 106.006372) (xy 139.591672 105.9644) (xy 139.376528 105.9644) (xy 139.165517 106.006372) - (xy 139.1285 106.021705) (xy 139.1285 105.39177) (xy 139.325728 105.431) (xy 139.540872 105.431) (xy 139.751883 105.389028) - (xy 139.950651 105.306695) (xy 140.129537 105.187167) (xy 140.281667 105.035037) (xy 140.401195 104.856151) (xy 140.483528 104.657383) - (xy 140.5255 104.446372) (xy 140.5255 104.231228) (xy 140.483528 104.020217) (xy 140.401195 103.821449) (xy 140.281667 103.642563) - (xy 140.129537 103.490433) (xy 139.950651 103.370905) (xy 139.7635 103.293384) (xy 139.7635 102.129) (xy 145.88972 102.129) - ) - ) - ) - (zone (net 1) (net_name GND) (layer Bottom) (tstamp 5C8E76A2) (hatch edge 0.508) - (priority 6) - (connect_pads (clearance 0.6096)) - (min_thickness 0.254) - (fill yes (arc_segments 32) (thermal_gap 0.304) (thermal_bridge_width 0.304)) - (polygon - (pts - (xy 121.8311 83.0536) (xy 175.1711 83.0536) (xy 175.1711 126.8686) (xy 121.8311 126.8686) - ) - ) - (filled_polygon - (pts - (xy 158.539278 103.433086) (xy 158.784536 103.67486) (xy 158.784536 103.8562) (xy 158.798758 104.000599) (xy 158.840878 104.139449) - (xy 158.909276 104.267413) (xy 159.001325 104.379575) (xy 159.113487 104.471624) (xy 159.241451 104.540022) (xy 159.380301 104.582142) - (xy 159.5247 104.596364) (xy 159.910639 104.596364) (xy 160.011833 104.627061) (xy 160.01594 104.627466) (xy 160.019897 104.628635) - (xy 160.127891 104.638492) (xy 160.179754 104.6436) (xy 160.183857 104.6436) (xy 160.244116 104.6491) (xy 160.296141 104.6436) - (xy 161.441152 104.6436) (xy 161.494423 104.670026) (xy 161.731084 104.734035) (xy 161.975685 104.750644) (xy 162.218827 104.719214) - (xy 162.451165 104.640954) (xy 162.528817 104.596364) (xy 162.6489 104.596364) (xy 162.793299 104.582142) (xy 162.932149 104.540022) - (xy 163.060113 104.471624) (xy 163.172275 104.379575) (xy 163.264324 104.267413) (xy 163.332722 104.139449) (xy 163.373352 104.005512) - (xy 164.176316 103.432964) (xy 165.588545 103.432964) (xy 165.591425 103.442495) (xy 165.60027 103.459085) (xy 165.606194 103.476921) - (xy 165.66375 103.578146) (xy 165.686686 103.621164) (xy 165.697045 103.636703) (xy 165.73974 103.711791) (xy 165.754218 103.728522) - (xy 165.770139 103.758307) (xy 165.855226 103.861985) (xy 165.940522 103.96614) (xy 165.941082 103.9666) (xy 165.941541 103.96716) - (xy 166.045354 104.052357) (xy 166.149195 104.137759) (xy 166.149834 104.138101) (xy 166.150394 104.138561) (xy 166.269068 104.201994) - (xy 166.387341 104.265371) (xy 166.388032 104.265581) (xy 166.388673 104.265924) (xy 166.475469 104.292253) (xy 169.367286 106.117037) - (xy 169.376184 106.207377) (xy 169.461875 106.489864) (xy 169.601031 106.750206) (xy 169.788303 106.978397) (xy 170.016494 107.165669) - (xy 170.276836 107.304825) (xy 170.416087 107.347066) (xy 170.373462 107.360978) (xy 170.169518 107.475545) (xy 169.991844 107.627698) - (xy 169.847267 107.81159) (xy 169.741344 108.020154) (xy 169.678957 108.242322) (xy 169.768138 108.4286) (xy 171.5901 108.4286) - (xy 171.5901 108.4086) (xy 171.6401 108.4086) (xy 171.6401 108.4286) (xy 174.5111 108.4286) (xy 174.5111 107.77475) - (xy 174.40335 107.667) (xy 173.269255 107.667) (xy 173.238356 107.627698) (xy 173.060682 107.475545) (xy 172.856738 107.360978) - (xy 172.814113 107.347066) (xy 172.953364 107.304825) (xy 173.213706 107.165669) (xy 173.441897 106.978397) (xy 173.629169 106.750206) - (xy 173.768325 106.489864) (xy 173.854016 106.207377) (xy 173.882951 105.9136) (xy 173.854016 105.619823) (xy 173.793986 105.421929) - (xy 175.0441 103.900052) (xy 175.0441 107.667) (xy 174.66885 107.667) (xy 174.5611 107.77475) (xy 174.5611 108.4286) - (xy 174.5811 108.4286) (xy 174.5811 108.4786) (xy 174.5611 108.4786) (xy 174.5611 109.13245) (xy 174.66885 109.2402) - (xy 175.0441 109.2402) (xy 175.0441 109.643836) (xy 174.861361 109.643836) (xy 174.760167 109.613139) (xy 174.592246 109.5966) - (xy 173.159122 109.5966) (xy 173.117715 109.591448) (xy 173.046833 109.5966) (xy 173.032154 109.5966) (xy 172.990814 109.600672) - (xy 172.955042 109.603272) (xy 172.953364 109.602375) (xy 172.814113 109.560134) (xy 172.856738 109.546222) (xy 173.060682 109.431655) - (xy 173.238356 109.279502) (xy 173.269255 109.2402) (xy 174.40335 109.2402) (xy 174.5111 109.13245) (xy 174.5111 108.4786) - (xy 171.6401 108.4786) (xy 171.6401 108.4986) (xy 171.5901 108.4986) (xy 171.5901 108.4786) (xy 169.768138 108.4786) - (xy 169.678957 108.664878) (xy 169.741344 108.887046) (xy 169.847267 109.09561) (xy 169.991844 109.279502) (xy 170.169518 109.431655) - (xy 170.373462 109.546222) (xy 170.416087 109.560134) (xy 170.276836 109.602375) (xy 170.027611 109.735589) (xy 169.856102 109.748265) - (xy 169.824313 109.722176) (xy 169.696349 109.653778) (xy 169.557499 109.611658) (xy 169.4131 109.597436) (xy 167.2131 109.597436) - (xy 167.068701 109.611658) (xy 166.929851 109.653778) (xy 166.801887 109.722176) (xy 166.689725 109.814225) (xy 166.597676 109.926387) - (xy 166.529278 110.054351) (xy 166.487158 110.193201) (xy 166.472936 110.3376) (xy 166.472936 112.1376) (xy 166.487158 112.281999) - (xy 166.529278 112.420849) (xy 166.597676 112.548813) (xy 166.689725 112.660975) (xy 166.801887 112.753024) (xy 166.929851 112.821422) - (xy 167.068701 112.863542) (xy 167.2131 112.877764) (xy 169.153329 112.877764) (xy 170.3595 114.083935) (xy 170.3595 114.329791) - (xy 170.422393 114.645979) (xy 170.545764 114.943821) (xy 170.72487 115.211872) (xy 170.952828 115.43983) (xy 171.220879 115.618936) - (xy 171.518721 115.742307) (xy 171.834909 115.8052) (xy 172.157291 115.8052) (xy 172.473479 115.742307) (xy 172.771321 115.618936) - (xy 172.889158 115.5402) (xy 173.643042 115.5402) (xy 173.760879 115.618936) (xy 174.058721 115.742307) (xy 174.374909 115.8052) - (xy 174.697291 115.8052) (xy 175.013479 115.742307) (xy 175.0441 115.729623) (xy 175.0441 116.171671) (xy 175.002847 116.150658) - (xy 174.761147 116.082522) (xy 174.5611 116.170593) (xy 174.5611 117.3186) (xy 174.5811 117.3186) (xy 174.5811 117.3686) - (xy 174.5611 117.3686) (xy 174.5611 118.516607) (xy 174.761147 118.604678) (xy 175.002847 118.536542) (xy 175.0441 118.515529) - (xy 175.0441 118.711671) (xy 175.002847 118.690658) (xy 174.761147 118.622522) (xy 174.5611 118.710593) (xy 174.5611 119.8586) - (xy 174.5811 119.8586) (xy 174.5811 119.9086) (xy 174.5611 119.9086) (xy 174.5611 121.056607) (xy 174.761147 121.144678) - (xy 175.002847 121.076542) (xy 175.0441 121.055529) (xy 175.0441 121.251671) (xy 175.002847 121.230658) (xy 174.761147 121.162522) - (xy 174.5611 121.250593) (xy 174.5611 122.3986) (xy 174.5811 122.3986) (xy 174.5811 122.4486) (xy 174.5611 122.4486) - (xy 174.5611 123.596607) (xy 174.761147 123.684678) (xy 175.002847 123.616542) (xy 175.0441 123.595529) (xy 175.0441 123.791671) - (xy 175.002847 123.770658) (xy 174.761147 123.702522) (xy 174.5611 123.790593) (xy 174.5611 124.9386) (xy 174.5811 124.9386) - (xy 174.5811 124.9886) (xy 174.5611 124.9886) (xy 174.5611 126.136607) (xy 174.761147 126.224678) (xy 175.002847 126.156542) - (xy 175.0441 126.135529) (xy 175.0441 126.692) (xy 164.855619 126.692) (xy 164.917313 126.659024) (xy 165.029475 126.566975) - (xy 165.121524 126.454813) (xy 165.189922 126.326849) (xy 165.232042 126.187999) (xy 165.246264 126.0436) (xy 165.246264 125.09635) - (xy 166.3651 125.09635) (xy 166.3651 126.08605) (xy 166.381663 126.169318) (xy 166.414153 126.247755) (xy 166.46132 126.318346) - (xy 166.521353 126.378379) (xy 166.591945 126.425547) (xy 166.670382 126.458037) (xy 166.75365 126.4746) (xy 167.55335 126.4746) - (xy 167.6611 126.36685) (xy 167.6611 124.9886) (xy 167.7111 124.9886) (xy 167.7111 126.36685) (xy 167.81885 126.4746) - (xy 168.61855 126.4746) (xy 168.701818 126.458037) (xy 168.780255 126.425547) (xy 168.850847 126.378379) (xy 168.91088 126.318346) - (xy 168.958047 126.247755) (xy 168.990537 126.169318) (xy 169.0071 126.08605) (xy 169.0071 125.188647) (xy 170.735023 125.188647) - (xy 170.744895 125.238277) (xy 170.822523 125.477097) (xy 170.945251 125.696184) (xy 171.108363 125.887118) (xy 171.30559 126.042562) - (xy 171.529353 126.156542) (xy 171.771053 126.224678) (xy 171.9711 126.136607) (xy 171.9711 124.9886) (xy 172.0211 124.9886) - (xy 172.0211 126.136607) (xy 172.221147 126.224678) (xy 172.462847 126.156542) (xy 172.68661 126.042562) (xy 172.883837 125.887118) - (xy 173.046949 125.696184) (xy 173.169677 125.477097) (xy 173.247305 125.238277) (xy 173.257177 125.188647) (xy 173.275023 125.188647) - (xy 173.284895 125.238277) (xy 173.362523 125.477097) (xy 173.485251 125.696184) (xy 173.648363 125.887118) (xy 173.84559 126.042562) - (xy 174.069353 126.156542) (xy 174.311053 126.224678) (xy 174.5111 126.136607) (xy 174.5111 124.9886) (xy 173.363116 124.9886) - (xy 173.275023 125.188647) (xy 173.257177 125.188647) (xy 173.169084 124.9886) (xy 172.0211 124.9886) (xy 171.9711 124.9886) - (xy 170.823116 124.9886) (xy 170.735023 125.188647) (xy 169.0071 125.188647) (xy 169.0071 125.09635) (xy 168.89935 124.9886) - (xy 167.7111 124.9886) (xy 167.6611 124.9886) (xy 166.47285 124.9886) (xy 166.3651 125.09635) (xy 165.246264 125.09635) - (xy 165.246264 123.8836) (xy 165.242084 123.84115) (xy 166.3651 123.84115) (xy 166.3651 124.83085) (xy 166.47285 124.9386) - (xy 167.6611 124.9386) (xy 167.6611 124.9186) (xy 167.7111 124.9186) (xy 167.7111 124.9386) (xy 168.89935 124.9386) - (xy 169.0071 124.83085) (xy 169.0071 124.738553) (xy 170.735023 124.738553) (xy 170.823116 124.9386) (xy 171.9711 124.9386) - (xy 171.9711 123.790593) (xy 172.0211 123.790593) (xy 172.0211 124.9386) (xy 173.169084 124.9386) (xy 173.257177 124.738553) - (xy 173.275023 124.738553) (xy 173.363116 124.9386) (xy 174.5111 124.9386) (xy 174.5111 123.790593) (xy 174.311053 123.702522) - (xy 174.069353 123.770658) (xy 173.84559 123.884638) (xy 173.648363 124.040082) (xy 173.485251 124.231016) (xy 173.362523 124.450103) - (xy 173.284895 124.688923) (xy 173.275023 124.738553) (xy 173.257177 124.738553) (xy 173.247305 124.688923) (xy 173.169677 124.450103) - (xy 173.046949 124.231016) (xy 172.883837 124.040082) (xy 172.68661 123.884638) (xy 172.462847 123.770658) (xy 172.221147 123.702522) - (xy 172.0211 123.790593) (xy 171.9711 123.790593) (xy 171.771053 123.702522) (xy 171.529353 123.770658) (xy 171.30559 123.884638) - (xy 171.108363 124.040082) (xy 170.945251 124.231016) (xy 170.822523 124.450103) (xy 170.744895 124.688923) (xy 170.735023 124.738553) - (xy 169.0071 124.738553) (xy 169.0071 124.321238) (xy 169.066293 124.274498) (xy 169.23503 124.076617) (xy 169.36192 123.849619) - (xy 169.442087 123.602228) (xy 169.47245 123.34395) (xy 169.47245 122.648647) (xy 170.735023 122.648647) (xy 170.744895 122.698277) - (xy 170.822523 122.937097) (xy 170.945251 123.156184) (xy 171.108363 123.347118) (xy 171.30559 123.502562) (xy 171.529353 123.616542) - (xy 171.771053 123.684678) (xy 171.9711 123.596607) (xy 171.9711 122.4486) (xy 172.0211 122.4486) (xy 172.0211 123.596607) - (xy 172.221147 123.684678) (xy 172.462847 123.616542) (xy 172.68661 123.502562) (xy 172.883837 123.347118) (xy 173.046949 123.156184) - (xy 173.169677 122.937097) (xy 173.247305 122.698277) (xy 173.257177 122.648647) (xy 173.275023 122.648647) (xy 173.284895 122.698277) - (xy 173.362523 122.937097) (xy 173.485251 123.156184) (xy 173.648363 123.347118) (xy 173.84559 123.502562) (xy 174.069353 123.616542) - (xy 174.311053 123.684678) (xy 174.5111 123.596607) (xy 174.5111 122.4486) (xy 173.363116 122.4486) (xy 173.275023 122.648647) - (xy 173.257177 122.648647) (xy 173.169084 122.4486) (xy 172.0211 122.4486) (xy 171.9711 122.4486) (xy 170.823116 122.4486) - (xy 170.735023 122.648647) (xy 169.47245 122.648647) (xy 169.47245 122.4486) (xy 168.1711 122.4486) (xy 168.1711 122.4686) - (xy 168.1211 122.4686) (xy 168.1211 122.4486) (xy 166.81975 122.4486) (xy 166.81975 123.34395) (xy 166.832523 123.4526) - (xy 166.75365 123.4526) (xy 166.670382 123.469163) (xy 166.591945 123.501653) (xy 166.521353 123.548821) (xy 166.46132 123.608854) - (xy 166.414153 123.679445) (xy 166.381663 123.757882) (xy 166.3651 123.84115) (xy 165.242084 123.84115) (xy 165.232042 123.739201) - (xy 165.189922 123.600351) (xy 165.121524 123.472387) (xy 165.029475 123.360225) (xy 164.917313 123.268176) (xy 164.789349 123.199778) - (xy 164.77805 123.19635) (xy 164.77805 121.44808) (xy 164.754437 121.208332) (xy 164.66112 120.900708) (xy 164.509582 120.6172) - (xy 164.305646 120.368704) (xy 164.240458 120.315205) (xy 164.267499 120.312542) (xy 164.406349 120.270422) (xy 164.534313 120.202024) - (xy 164.646475 120.109975) (xy 164.738524 119.997813) (xy 164.806922 119.869849) (xy 164.849042 119.730999) (xy 164.863264 119.5866) - (xy 164.863264 117.3866) (xy 164.849042 117.242201) (xy 164.806922 117.103351) (xy 164.738524 116.975387) (xy 164.646475 116.863225) - (xy 164.534313 116.771176) (xy 164.406349 116.702778) (xy 164.267499 116.660658) (xy 164.1231 116.646436) (xy 162.3231 116.646436) - (xy 162.178701 116.660658) (xy 162.039851 116.702778) (xy 161.911887 116.771176) (xy 161.799725 116.863225) (xy 161.717484 116.963436) - (xy 159.9741 116.963436) (xy 159.829701 116.977658) (xy 159.690851 117.019778) (xy 159.562887 117.088176) (xy 159.450725 117.180225) - (xy 159.358676 117.292387) (xy 159.290278 117.420351) (xy 159.248158 117.559201) (xy 159.233936 117.7036) (xy 159.233936 119.5036) - (xy 159.248158 119.647999) (xy 159.290278 119.786849) (xy 159.358676 119.914813) (xy 159.450725 120.026975) (xy 159.562887 120.119024) - (xy 159.690851 120.187422) (xy 159.829701 120.229542) (xy 159.9741 120.243764) (xy 161.989977 120.243764) (xy 162.039851 120.270422) - (xy 162.088375 120.285142) (xy 161.986555 120.368704) (xy 161.782619 120.6172) (xy 161.631081 120.900708) (xy 161.537764 121.208332) - (xy 161.51415 121.44808) (xy 161.51415 121.819539) (xy 161.119343 122.063436) (xy 159.9741 122.063436) (xy 159.829701 122.077658) - (xy 159.690851 122.119778) (xy 159.562887 122.188176) (xy 159.450725 122.280225) (xy 159.358676 122.392387) (xy 159.290278 122.520351) - (xy 159.248158 122.659201) (xy 159.233936 122.8036) (xy 159.233936 123.87249) (xy 159.06236 123.700914) (xy 158.796111 123.523012) - (xy 158.50027 123.40047) (xy 158.377354 123.376021) (xy 157.9499 122.360817) (xy 157.9499 122.3212) (xy 158.17275 122.3212) - (xy 158.2805 122.21345) (xy 158.2805 121.204) (xy 158.3305 121.204) (xy 158.3305 122.21345) (xy 158.43825 122.3212) - (xy 158.70355 122.3212) (xy 158.786818 122.304637) (xy 158.865255 122.272147) (xy 158.935846 122.22498) (xy 158.995879 122.164947) - (xy 159.043047 122.094355) (xy 159.075537 122.015918) (xy 159.0921 121.93265) (xy 159.0921 121.31175) (xy 158.98435 121.204) - (xy 158.3305 121.204) (xy 158.2805 121.204) (xy 158.2605 121.204) (xy 158.2605 121.154) (xy 158.2805 121.154) - (xy 158.2805 120.14455) (xy 158.3305 120.14455) (xy 158.3305 121.154) (xy 158.98435 121.154) (xy 159.0921 121.04625) - (xy 159.0921 120.42535) (xy 159.075537 120.342082) (xy 159.043047 120.263645) (xy 158.995879 120.193053) (xy 158.935846 120.13302) - (xy 158.865255 120.085853) (xy 158.786818 120.053363) (xy 158.70355 120.0368) (xy 158.43825 120.0368) (xy 158.3305 120.14455) - (xy 158.2805 120.14455) (xy 158.17275 120.0368) (xy 157.9499 120.0368) (xy 157.9499 118.744137) (xy 157.950588 118.655322) - (xy 157.941208 118.606177) (xy 157.936302 118.556367) (xy 157.923892 118.515458) (xy 157.91588 118.47348) (xy 157.897091 118.427105) - (xy 157.882563 118.379214) (xy 157.840664 118.300827) (xy 156.338644 115.4376) (xy 166.472936 115.4376) (xy 166.472936 117.2376) - (xy 166.487158 117.381999) (xy 166.529278 117.520849) (xy 166.597676 117.648813) (xy 166.682936 117.752703) (xy 166.682936 119.5866) - (xy 166.697158 119.730999) (xy 166.739278 119.869849) (xy 166.807676 119.997813) (xy 166.899725 120.109975) (xy 167.011887 120.202024) - (xy 167.139851 120.270422) (xy 167.278701 120.312542) (xy 167.4231 120.326764) (xy 167.596068 120.326764) (xy 167.430006 120.411542) - (xy 167.225907 120.572702) (xy 167.05717 120.770583) (xy 166.93028 120.997581) (xy 166.850113 121.244972) (xy 166.81975 121.50325) - (xy 166.81975 122.3986) (xy 168.1211 122.3986) (xy 168.1211 122.3786) (xy 168.1711 122.3786) (xy 168.1711 122.3986) - (xy 169.47245 122.3986) (xy 169.47245 122.198553) (xy 170.735023 122.198553) (xy 170.823116 122.3986) (xy 171.9711 122.3986) - (xy 171.9711 121.250593) (xy 172.0211 121.250593) (xy 172.0211 122.3986) (xy 173.169084 122.3986) (xy 173.257177 122.198553) - (xy 173.275023 122.198553) (xy 173.363116 122.3986) (xy 174.5111 122.3986) (xy 174.5111 121.250593) (xy 174.311053 121.162522) - (xy 174.069353 121.230658) (xy 173.84559 121.344638) (xy 173.648363 121.500082) (xy 173.485251 121.691016) (xy 173.362523 121.910103) - (xy 173.284895 122.148923) (xy 173.275023 122.198553) (xy 173.257177 122.198553) (xy 173.247305 122.148923) (xy 173.169677 121.910103) - (xy 173.046949 121.691016) (xy 172.883837 121.500082) (xy 172.68661 121.344638) (xy 172.462847 121.230658) (xy 172.221147 121.162522) - (xy 172.0211 121.250593) (xy 171.9711 121.250593) (xy 171.771053 121.162522) (xy 171.529353 121.230658) (xy 171.30559 121.344638) - (xy 171.108363 121.500082) (xy 170.945251 121.691016) (xy 170.822523 121.910103) (xy 170.744895 122.148923) (xy 170.735023 122.198553) - (xy 169.47245 122.198553) (xy 169.47245 121.50325) (xy 169.442087 121.244972) (xy 169.36192 120.997581) (xy 169.23503 120.770583) - (xy 169.066293 120.572702) (xy 168.862194 120.411542) (xy 168.696132 120.326764) (xy 169.2231 120.326764) (xy 169.367499 120.312542) - (xy 169.506349 120.270422) (xy 169.634313 120.202024) (xy 169.746475 120.109975) (xy 169.747564 120.108647) (xy 170.735023 120.108647) - (xy 170.744895 120.158277) (xy 170.822523 120.397097) (xy 170.945251 120.616184) (xy 171.108363 120.807118) (xy 171.30559 120.962562) - (xy 171.529353 121.076542) (xy 171.771053 121.144678) (xy 171.9711 121.056607) (xy 171.9711 119.9086) (xy 172.0211 119.9086) - (xy 172.0211 121.056607) (xy 172.221147 121.144678) (xy 172.462847 121.076542) (xy 172.68661 120.962562) (xy 172.883837 120.807118) - (xy 173.046949 120.616184) (xy 173.169677 120.397097) (xy 173.247305 120.158277) (xy 173.257177 120.108647) (xy 173.275023 120.108647) - (xy 173.284895 120.158277) (xy 173.362523 120.397097) (xy 173.485251 120.616184) (xy 173.648363 120.807118) (xy 173.84559 120.962562) - (xy 174.069353 121.076542) (xy 174.311053 121.144678) (xy 174.5111 121.056607) (xy 174.5111 119.9086) (xy 173.363116 119.9086) - (xy 173.275023 120.108647) (xy 173.257177 120.108647) (xy 173.169084 119.9086) (xy 172.0211 119.9086) (xy 171.9711 119.9086) - (xy 170.823116 119.9086) (xy 170.735023 120.108647) (xy 169.747564 120.108647) (xy 169.838524 119.997813) (xy 169.906922 119.869849) - (xy 169.949042 119.730999) (xy 169.963264 119.5866) (xy 169.963264 117.728333) (xy 170.028524 117.648813) (xy 170.096922 117.520849) - (xy 170.11042 117.47635) (xy 170.7151 117.47635) (xy 170.7151 118.23605) (xy 170.731663 118.319318) (xy 170.764153 118.397755) - (xy 170.81132 118.468346) (xy 170.871353 118.528379) (xy 170.941945 118.575547) (xy 171.020382 118.608037) (xy 171.10365 118.6246) - (xy 171.763682 118.6246) (xy 171.529353 118.690658) (xy 171.30559 118.804638) (xy 171.108363 118.960082) (xy 170.945251 119.151016) - (xy 170.822523 119.370103) (xy 170.744895 119.608923) (xy 170.735023 119.658553) (xy 170.823116 119.8586) (xy 171.9711 119.8586) - (xy 171.9711 118.710593) (xy 171.775773 118.6246) (xy 171.86335 118.6246) (xy 171.9711 118.51685) (xy 171.9711 117.3686) - (xy 172.0211 117.3686) (xy 172.0211 118.51685) (xy 172.12885 118.6246) (xy 172.216427 118.6246) (xy 172.0211 118.710593) - (xy 172.0211 119.8586) (xy 173.169084 119.8586) (xy 173.257177 119.658553) (xy 173.275023 119.658553) (xy 173.363116 119.8586) - (xy 174.5111 119.8586) (xy 174.5111 118.710593) (xy 174.311053 118.622522) (xy 174.069353 118.690658) (xy 173.84559 118.804638) - (xy 173.648363 118.960082) (xy 173.485251 119.151016) (xy 173.362523 119.370103) (xy 173.284895 119.608923) (xy 173.275023 119.658553) - (xy 173.257177 119.658553) (xy 173.247305 119.608923) (xy 173.169677 119.370103) (xy 173.046949 119.151016) (xy 172.883837 118.960082) - (xy 172.68661 118.804638) (xy 172.462847 118.690658) (xy 172.228518 118.6246) (xy 172.88855 118.6246) (xy 172.971818 118.608037) - (xy 173.050255 118.575547) (xy 173.120847 118.528379) (xy 173.18088 118.468346) (xy 173.228047 118.397755) (xy 173.260537 118.319318) - (xy 173.2771 118.23605) (xy 173.2771 117.579089) (xy 173.284895 117.618277) (xy 173.362523 117.857097) (xy 173.485251 118.076184) - (xy 173.648363 118.267118) (xy 173.84559 118.422562) (xy 174.069353 118.536542) (xy 174.311053 118.604678) (xy 174.5111 118.516607) - (xy 174.5111 117.3686) (xy 173.363116 117.3686) (xy 173.2771 117.56393) (xy 173.2771 117.47635) (xy 173.16935 117.3686) - (xy 172.0211 117.3686) (xy 171.9711 117.3686) (xy 170.82285 117.3686) (xy 170.7151 117.47635) (xy 170.11042 117.47635) - (xy 170.139042 117.381999) (xy 170.153264 117.2376) (xy 170.153264 116.45115) (xy 170.7151 116.45115) (xy 170.7151 117.21085) - (xy 170.82285 117.3186) (xy 171.9711 117.3186) (xy 171.9711 116.17035) (xy 172.0211 116.17035) (xy 172.0211 117.3186) - (xy 173.16935 117.3186) (xy 173.2771 117.21085) (xy 173.2771 117.12327) (xy 173.363116 117.3186) (xy 174.5111 117.3186) - (xy 174.5111 116.170593) (xy 174.311053 116.082522) (xy 174.069353 116.150658) (xy 173.84559 116.264638) (xy 173.648363 116.420082) - (xy 173.485251 116.611016) (xy 173.362523 116.830103) (xy 173.284895 117.068923) (xy 173.2771 117.108111) (xy 173.2771 116.45115) - (xy 173.260537 116.367882) (xy 173.228047 116.289445) (xy 173.18088 116.218854) (xy 173.120847 116.158821) (xy 173.050255 116.111653) - (xy 172.971818 116.079163) (xy 172.88855 116.0626) (xy 172.12885 116.0626) (xy 172.0211 116.17035) (xy 171.9711 116.17035) - (xy 171.86335 116.0626) (xy 171.10365 116.0626) (xy 171.020382 116.079163) (xy 170.941945 116.111653) (xy 170.871353 116.158821) - (xy 170.81132 116.218854) (xy 170.764153 116.289445) (xy 170.731663 116.367882) (xy 170.7151 116.45115) (xy 170.153264 116.45115) - (xy 170.153264 115.4376) (xy 170.139042 115.293201) (xy 170.096922 115.154351) (xy 170.028524 115.026387) (xy 169.936475 114.914225) - (xy 169.824313 114.822176) (xy 169.696349 114.753778) (xy 169.557499 114.711658) (xy 169.4131 114.697436) (xy 167.2131 114.697436) - (xy 167.068701 114.711658) (xy 166.929851 114.753778) (xy 166.801887 114.822176) (xy 166.689725 114.914225) (xy 166.597676 115.026387) - (xy 166.529278 115.154351) (xy 166.487158 115.293201) (xy 166.472936 115.4376) (xy 156.338644 115.4376) (xy 154.480331 111.895192) - (xy 154.490544 111.896323) (xy 154.527827 111.904882) (xy 154.582329 111.90648) (xy 154.590415 111.907375) (xy 154.628492 111.907834) - (xy 154.712872 111.910308) (xy 154.720941 111.908948) (xy 154.92519 111.911408) (xy 155.016198 112.022302) (xy 155.236654 112.203226) - (xy 155.48817 112.337665) (xy 155.761082 112.420451) (xy 155.973778 112.4414) (xy 157.538422 112.4414) (xy 157.751118 112.420451) - (xy 158.02403 112.337665) (xy 158.275546 112.203226) (xy 158.372205 112.1239) (xy 158.97384 112.1239) (xy 159.011887 112.155124) - (xy 159.139851 112.223522) (xy 159.278701 112.265642) (xy 159.4231 112.279864) (xy 160.8455 112.279864) (xy 160.989899 112.265642) - (xy 161.128749 112.223522) (xy 161.256713 112.155124) (xy 161.368875 112.063075) (xy 161.460924 111.950913) (xy 161.529322 111.822949) - (xy 161.571442 111.684099) (xy 161.585664 111.5397) (xy 161.585664 110.8285) (xy 161.571442 110.684101) (xy 161.529322 110.545251) - (xy 161.460924 110.417287) (xy 161.368875 110.305125) (xy 161.256713 110.213076) (xy 161.128749 110.144678) (xy 160.989899 110.102558) - (xy 160.8455 110.088336) (xy 159.4231 110.088336) (xy 159.278701 110.102558) (xy 159.139851 110.144678) (xy 159.011887 110.213076) - (xy 158.97384 110.2443) (xy 158.708434 110.2443) (xy 158.676926 110.185354) (xy 158.496002 109.964898) (xy 158.275546 109.783974) - (xy 158.02403 109.649535) (xy 157.751118 109.566749) (xy 157.538422 109.5458) (xy 155.973778 109.5458) (xy 155.761082 109.566749) - (xy 155.48817 109.649535) (xy 155.236654 109.783974) (xy 155.016198 109.964898) (xy 154.978967 110.010265) (xy 153.854454 109.03085) - (xy 158.9921 109.03085) (xy 158.9921 109.29615) (xy 159.008663 109.379418) (xy 159.041153 109.457855) (xy 159.08832 109.528446) - (xy 159.148353 109.588479) (xy 159.218945 109.635647) (xy 159.297382 109.668137) (xy 159.38065 109.6847) (xy 160.00155 109.6847) - (xy 160.1093 109.57695) (xy 160.1093 108.9231) (xy 160.1593 108.9231) (xy 160.1593 109.57695) (xy 160.26705 109.6847) - (xy 160.88795 109.6847) (xy 160.971218 109.668137) (xy 161.049655 109.635647) (xy 161.120247 109.588479) (xy 161.18028 109.528446) - (xy 161.227447 109.457855) (xy 161.259937 109.379418) (xy 161.2765 109.29615) (xy 161.2765 109.03085) (xy 161.16875 108.9231) - (xy 160.1593 108.9231) (xy 160.1093 108.9231) (xy 159.09985 108.9231) (xy 158.9921 109.03085) (xy 153.854454 109.03085) - (xy 153.846933 109.0243) (xy 154.14425 109.0243) (xy 154.227518 109.007737) (xy 154.305955 108.975247) (xy 154.376547 108.928079) - (xy 154.43658 108.868046) (xy 154.483747 108.797455) (xy 154.516237 108.719018) (xy 154.5328 108.63575) (xy 154.5328 108.50005) - (xy 158.9921 108.50005) (xy 158.9921 108.76535) (xy 159.09985 108.8731) (xy 160.1093 108.8731) (xy 160.1093 108.21925) - (xy 160.1593 108.21925) (xy 160.1593 108.8731) (xy 161.16875 108.8731) (xy 161.2765 108.76535) (xy 161.2765 108.50005) - (xy 161.259937 108.416782) (xy 161.227447 108.338345) (xy 161.18028 108.267754) (xy 161.120247 108.207721) (xy 161.049655 108.160553) - (xy 160.971218 108.128063) (xy 160.88795 108.1115) (xy 160.26705 108.1115) (xy 160.1593 108.21925) (xy 160.1093 108.21925) - (xy 160.00155 108.1115) (xy 159.38065 108.1115) (xy 159.297382 108.128063) (xy 159.218945 108.160553) (xy 159.148353 108.207721) - (xy 159.08832 108.267754) (xy 159.041153 108.338345) (xy 159.008663 108.416782) (xy 158.9921 108.50005) (xy 154.5328 108.50005) - (xy 154.5328 108.37045) (xy 154.42505 108.2627) (xy 153.4156 108.2627) (xy 153.4156 108.2827) (xy 153.3656 108.2827) - (xy 153.3656 108.2627) (xy 153.3456 108.2627) (xy 153.3456 108.2127) (xy 153.3656 108.2127) (xy 153.3656 107.55885) - (xy 153.4156 107.55885) (xy 153.4156 108.2127) (xy 154.42505 108.2127) (xy 154.5328 108.10495) (xy 154.5328 107.90055) - (xy 163.0777 107.90055) (xy 163.0777 109.08525) (xy 163.094263 109.168518) (xy 163.126753 109.246955) (xy 163.173921 109.317547) - (xy 163.233954 109.37758) (xy 163.304545 109.424747) (xy 163.382982 109.457237) (xy 163.46625 109.4738) (xy 164.72595 109.4738) - (xy 164.8337 109.36605) (xy 164.8337 107.7928) (xy 164.8837 107.7928) (xy 164.8837 109.36605) (xy 164.99145 109.4738) - (xy 166.25115 109.4738) (xy 166.334418 109.457237) (xy 166.412855 109.424747) (xy 166.483446 109.37758) (xy 166.543479 109.317547) - (xy 166.590647 109.246955) (xy 166.623137 109.168518) (xy 166.6397 109.08525) (xy 166.6397 107.90055) (xy 166.53195 107.7928) - (xy 164.8837 107.7928) (xy 164.8337 107.7928) (xy 163.18545 107.7928) (xy 163.0777 107.90055) (xy 154.5328 107.90055) - (xy 154.5328 107.83965) (xy 154.516237 107.756382) (xy 154.483747 107.677945) (xy 154.43658 107.607354) (xy 154.376547 107.547321) - (xy 154.305955 107.500153) (xy 154.227518 107.467663) (xy 154.14425 107.4511) (xy 153.52335 107.4511) (xy 153.4156 107.55885) - (xy 153.3656 107.55885) (xy 153.25785 107.4511) (xy 152.63695 107.4511) (xy 152.553682 107.467663) (xy 152.475245 107.500153) - (xy 152.404653 107.547321) (xy 152.34462 107.607354) (xy 152.298801 107.675927) (xy 152.169116 107.562976) (xy 153.267748 107.047464) - (xy 154.1018 107.047464) (xy 154.246199 107.033242) (xy 154.385049 106.991122) (xy 154.513013 106.922724) (xy 154.567217 106.87824) - (xy 154.959974 106.873793) (xy 155.016198 106.942302) (xy 155.236654 107.123226) (xy 155.48817 107.257665) (xy 155.761082 107.340451) - (xy 155.973778 107.3614) (xy 157.538422 107.3614) (xy 157.751118 107.340451) (xy 158.02403 107.257665) (xy 158.275546 107.123226) - (xy 158.496002 106.942302) (xy 158.676926 106.721846) (xy 158.811365 106.47033) (xy 158.894151 106.197418) (xy 158.921538 105.91935) - (xy 159.0937 105.91935) (xy 159.0937 106.18465) (xy 159.110263 106.267918) (xy 159.142753 106.346355) (xy 159.18992 106.416946) - (xy 159.249953 106.476979) (xy 159.320545 106.524147) (xy 159.398982 106.556637) (xy 159.48225 106.5732) (xy 160.10315 106.5732) - (xy 160.2109 106.46545) (xy 160.2109 105.8116) (xy 160.2609 105.8116) (xy 160.2609 106.46545) (xy 160.36865 106.5732) - (xy 160.98955 106.5732) (xy 161.072818 106.556637) (xy 161.0868 106.550845) (xy 161.100782 106.556637) (xy 161.18405 106.5732) - (xy 161.80495 106.5732) (xy 161.9127 106.46545) (xy 161.9127 105.8116) (xy 161.9627 105.8116) (xy 161.9627 106.46545) - (xy 162.07045 106.5732) (xy 162.69135 106.5732) (xy 162.774618 106.556637) (xy 162.853055 106.524147) (xy 162.923647 106.476979) - (xy 162.950276 106.45035) (xy 163.0777 106.45035) (xy 163.0777 107.63505) (xy 163.18545 107.7428) (xy 164.8337 107.7428) - (xy 164.8337 106.16955) (xy 164.8837 106.16955) (xy 164.8837 107.7428) (xy 166.53195 107.7428) (xy 166.6397 107.63505) - (xy 166.6397 106.45035) (xy 166.623137 106.367082) (xy 166.590647 106.288645) (xy 166.543479 106.218053) (xy 166.483446 106.15802) - (xy 166.412855 106.110853) (xy 166.334418 106.078363) (xy 166.25115 106.0618) (xy 164.99145 106.0618) (xy 164.8837 106.16955) - (xy 164.8337 106.16955) (xy 164.72595 106.0618) (xy 163.46625 106.0618) (xy 163.382982 106.078363) (xy 163.304545 106.110853) - (xy 163.233954 106.15802) (xy 163.173921 106.218053) (xy 163.126753 106.288645) (xy 163.094263 106.367082) (xy 163.0777 106.45035) - (xy 162.950276 106.45035) (xy 162.98368 106.416946) (xy 163.030847 106.346355) (xy 163.063337 106.267918) (xy 163.0799 106.18465) - (xy 163.0799 105.91935) (xy 162.97215 105.8116) (xy 161.9627 105.8116) (xy 161.9127 105.8116) (xy 160.2609 105.8116) - (xy 160.2109 105.8116) (xy 159.20145 105.8116) (xy 159.0937 105.91935) (xy 158.921538 105.91935) (xy 158.922105 105.9136) - (xy 158.894151 105.629782) (xy 158.820975 105.38855) (xy 159.0937 105.38855) (xy 159.0937 105.65385) (xy 159.20145 105.7616) - (xy 160.2109 105.7616) (xy 160.2109 105.10775) (xy 160.2609 105.10775) (xy 160.2609 105.7616) (xy 161.9127 105.7616) - (xy 161.9127 105.10775) (xy 161.9627 105.10775) (xy 161.9627 105.7616) (xy 162.97215 105.7616) (xy 163.0799 105.65385) - (xy 163.0799 105.38855) (xy 163.063337 105.305282) (xy 163.030847 105.226845) (xy 162.98368 105.156254) (xy 162.923647 105.096221) - (xy 162.853055 105.049053) (xy 162.774618 105.016563) (xy 162.69135 105) (xy 162.07045 105) (xy 161.9627 105.10775) - (xy 161.9127 105.10775) (xy 161.80495 105) (xy 161.18405 105) (xy 161.100782 105.016563) (xy 161.0868 105.022355) - (xy 161.072818 105.016563) (xy 160.98955 105) (xy 160.36865 105) (xy 160.2609 105.10775) (xy 160.2109 105.10775) - (xy 160.10315 105) (xy 159.48225 105) (xy 159.398982 105.016563) (xy 159.320545 105.049053) (xy 159.249953 105.096221) - (xy 159.18992 105.156254) (xy 159.142753 105.226845) (xy 159.110263 105.305282) (xy 159.0937 105.38855) (xy 158.820975 105.38855) - (xy 158.811365 105.35687) (xy 158.676926 105.105354) (xy 158.496002 104.884898) (xy 158.275546 104.703974) (xy 158.02403 104.569535) - (xy 157.751118 104.486749) (xy 157.538422 104.4658) (xy 155.973778 104.4658) (xy 155.761082 104.486749) (xy 155.48817 104.569535) - (xy 155.236654 104.703974) (xy 155.016198 104.884898) (xy 154.926287 104.994455) (xy 154.535197 104.998882) (xy 154.513013 104.980676) - (xy 154.385049 104.912278) (xy 154.246199 104.870158) (xy 154.1018 104.855936) (xy 152.6794 104.855936) (xy 152.535001 104.870158) - (xy 152.525131 104.873152) (xy 154.077647 103.425065) - ) - ) - (filled_polygon - (pts - (xy 129.1463 89.326536) (xy 129.143778 89.341809) (xy 129.1463 89.418926) (xy 129.1463 89.449766) (xy 129.14781 89.465098) - (xy 129.149829 89.526833) (xy 129.156861 89.556995) (xy 129.159898 89.587832) (xy 129.177837 89.646967) (xy 129.191861 89.707123) - (xy 129.204643 89.735337) (xy 129.213637 89.764985) (xy 129.242761 89.819472) (xy 129.268257 89.875749) (xy 129.286301 89.90093) - (xy 129.300904 89.928251) (xy 129.340106 89.976019) (xy 129.349064 89.98852) (xy 129.36936 90.011664) (xy 129.418346 90.071354) - (xy 129.430321 90.081182) (xy 137.795936 99.62092) (xy 137.795936 99.700839) (xy 134.59813 96.397611) (xy 134.563854 96.355846) - (xy 134.498178 96.301947) (xy 134.433413 96.247014) (xy 134.426694 96.243281) (xy 134.420751 96.238404) (xy 134.345805 96.198344) - (xy 134.271584 96.157112) (xy 134.26427 96.154763) (xy 134.257486 96.151137) (xy 134.176141 96.126461) (xy 134.095326 96.100508) - (xy 134.087695 96.099631) (xy 134.080333 96.097398) (xy 133.995737 96.089066) (xy 133.911411 96.079378) (xy 133.857576 96.0838) - (xy 126.333239 96.0838) (xy 126.268786 95.98734) (xy 126.04236 95.760914) (xy 125.776111 95.583012) (xy 125.48027 95.46047) - (xy 125.166208 95.398) (xy 124.845992 95.398) (xy 124.53193 95.46047) (xy 124.236089 95.583012) (xy 123.96984 95.760914) - (xy 123.743414 95.98734) (xy 123.565512 96.253589) (xy 123.44297 96.54943) (xy 123.3805 96.863492) (xy 123.3805 97.183708) - (xy 123.44297 97.49777) (xy 123.565512 97.793611) (xy 123.743414 98.05986) (xy 123.96984 98.286286) (xy 123.980786 98.2936) - (xy 123.96984 98.300914) (xy 123.743414 98.52734) (xy 123.565512 98.793589) (xy 123.44297 99.08943) (xy 123.3805 99.403492) - (xy 123.3805 99.723708) (xy 123.44297 100.03777) (xy 123.565512 100.333611) (xy 123.743414 100.59986) (xy 123.96984 100.826286) - (xy 123.980786 100.8336) (xy 123.96984 100.840914) (xy 123.743414 101.06734) (xy 123.565512 101.333589) (xy 123.44297 101.62943) - (xy 123.3805 101.943492) (xy 123.3805 102.263708) (xy 123.44297 102.57777) (xy 123.565512 102.873611) (xy 123.743414 103.13986) - (xy 123.96984 103.366286) (xy 123.980786 103.3736) (xy 123.96984 103.380914) (xy 123.743414 103.60734) (xy 123.565512 103.873589) - (xy 123.44297 104.16943) (xy 123.3805 104.483492) (xy 123.3805 104.803708) (xy 123.44297 105.11777) (xy 123.565512 105.413611) - (xy 123.743414 105.67986) (xy 123.96984 105.906286) (xy 123.980786 105.9136) (xy 123.96984 105.920914) (xy 123.743414 106.14734) - (xy 123.565512 106.413589) (xy 123.44297 106.70943) (xy 123.3805 107.023492) (xy 123.3805 107.343708) (xy 123.44297 107.65777) - (xy 123.565512 107.953611) (xy 123.743414 108.21986) (xy 123.96984 108.446286) (xy 124.236089 108.624188) (xy 124.253659 108.631466) - (xy 124.246833 108.636027) (xy 124.162252 108.844397) (xy 125.0061 109.688245) (xy 125.849948 108.844397) (xy 125.765367 108.636027) - (xy 125.757791 108.631776) (xy 125.776111 108.624188) (xy 126.04236 108.446286) (xy 126.268786 108.21986) (xy 126.269485 108.218813) - (xy 126.27487 108.226872) (xy 126.502828 108.45483) (xy 126.770879 108.633936) (xy 127.068721 108.757307) (xy 127.384909 108.8202) - (xy 127.707291 108.8202) (xy 128.023479 108.757307) (xy 128.062132 108.741296) (xy 128.008356 108.8805) (xy 128.8161 109.688245) - (xy 128.830243 109.674103) (xy 128.865598 109.709458) (xy 128.851455 109.7236) (xy 129.6592 110.531344) (xy 129.862369 110.452858) - (xy 129.984537 110.234729) (xy 130.027398 110.102831) (xy 130.155867 110.141802) (xy 130.293933 110.1554) (xy 130.293942 110.1554) - (xy 130.340099 110.159946) (xy 130.386256 110.1554) (xy 131.915309 110.1554) (xy 130.950728 113.352236) (xy 130.2893 113.352236) - (xy 130.144901 113.366458) (xy 130.006051 113.408578) (xy 129.878087 113.476976) (xy 129.765925 113.569025) (xy 129.673876 113.681187) - (xy 129.605478 113.809151) (xy 129.563358 113.948001) (xy 129.549136 114.0924) (xy 129.549136 115.5148) (xy 129.563358 115.659199) - (xy 129.605478 115.798049) (xy 129.673876 115.926013) (xy 129.765925 116.038175) (xy 129.878087 116.130224) (xy 129.938244 116.162379) - (xy 129.696824 116.4038) (xy 128.886468 116.4038) (xy 128.81733 116.300328) (xy 128.766814 116.249812) (xy 128.858899 116.240742) - (xy 128.997749 116.198622) (xy 129.125713 116.130224) (xy 129.237875 116.038175) (xy 129.329924 115.926013) (xy 129.398322 115.798049) - (xy 129.440442 115.659199) (xy 129.454664 115.5148) (xy 129.454664 114.0924) (xy 129.450121 114.046276) (xy 129.516397 113.678079) - (xy 129.562048 113.65917) (xy 129.819977 113.486827) (xy 130.039327 113.267477) (xy 130.21167 113.009548) (xy 130.330382 112.722952) - (xy 130.3909 112.418704) (xy 130.3909 112.108496) (xy 130.330382 111.804248) (xy 130.21167 111.517652) (xy 130.039327 111.259723) - (xy 129.819977 111.040373) (xy 129.562048 110.86803) (xy 129.453738 110.823167) (xy 129.503652 110.797736) (xy 129.545358 110.769869) - (xy 129.623844 110.5667) (xy 128.8161 109.758955) (xy 128.008356 110.5667) (xy 128.086842 110.769869) (xy 128.180498 110.822323) - (xy 128.070152 110.86803) (xy 127.812223 111.040373) (xy 127.592873 111.259723) (xy 127.42053 111.517652) (xy 127.301818 111.804248) - (xy 127.2413 112.108496) (xy 127.2413 112.418704) (xy 127.301818 112.722952) (xy 127.42053 113.009548) (xy 127.592873 113.267477) - (xy 127.667133 113.341737) (xy 127.648187 113.44699) (xy 127.592087 113.476976) (xy 127.479925 113.569025) (xy 127.387876 113.681187) - (xy 127.319478 113.809151) (xy 127.277358 113.948001) (xy 127.263136 114.0924) (xy 127.263136 115.5148) (xy 127.277358 115.659199) - (xy 127.297153 115.724455) (xy 127.068721 115.769893) (xy 126.770879 115.893264) (xy 126.502828 116.07237) (xy 126.27487 116.300328) - (xy 126.269485 116.308387) (xy 126.268786 116.30734) (xy 126.04236 116.080914) (xy 126.031414 116.0736) (xy 126.04236 116.066286) - (xy 126.268786 115.83986) (xy 126.446688 115.573611) (xy 126.56923 115.27777) (xy 126.6317 114.963708) (xy 126.6317 114.643492) - (xy 126.56923 114.32943) (xy 126.446688 114.033589) (xy 126.268786 113.76734) (xy 126.04236 113.540914) (xy 126.031414 113.5336) - (xy 126.04236 113.526286) (xy 126.268786 113.29986) (xy 126.446688 113.033611) (xy 126.56923 112.73777) (xy 126.6317 112.423708) - (xy 126.6317 112.103492) (xy 126.56923 111.78943) (xy 126.446688 111.493589) (xy 126.268786 111.22734) (xy 126.04236 111.000914) - (xy 125.776111 110.823012) (xy 125.758541 110.815734) (xy 125.765367 110.811173) (xy 125.849948 110.602803) (xy 125.0061 109.758955) - (xy 124.162252 110.602803) (xy 124.246833 110.811173) (xy 124.254409 110.815424) (xy 124.236089 110.823012) (xy 123.96984 111.000914) - (xy 123.743414 111.22734) (xy 123.565512 111.493589) (xy 123.44297 111.78943) (xy 123.3805 112.103492) (xy 123.3805 112.423708) - (xy 123.44297 112.73777) (xy 123.565512 113.033611) (xy 123.743414 113.29986) (xy 123.96984 113.526286) (xy 123.980786 113.5336) - (xy 123.96984 113.540914) (xy 123.743414 113.76734) (xy 123.565512 114.033589) (xy 123.44297 114.32943) (xy 123.3805 114.643492) - (xy 123.3805 114.963708) (xy 123.44297 115.27777) (xy 123.565512 115.573611) (xy 123.743414 115.83986) (xy 123.96984 116.066286) - (xy 123.980786 116.0736) (xy 123.96984 116.080914) (xy 123.743414 116.30734) (xy 123.565512 116.573589) (xy 123.44297 116.86943) - (xy 123.3805 117.183492) (xy 123.3805 117.503708) (xy 123.44297 117.81777) (xy 123.565512 118.113611) (xy 123.743414 118.37986) - (xy 123.96984 118.606286) (xy 124.236089 118.784188) (xy 124.53193 118.90673) (xy 124.845992 118.9692) (xy 125.166208 118.9692) - (xy 125.48027 118.90673) (xy 125.776111 118.784188) (xy 126.04236 118.606286) (xy 126.268786 118.37986) (xy 126.269485 118.378813) - (xy 126.27487 118.386872) (xy 126.502828 118.61483) (xy 126.770879 118.793936) (xy 127.068721 118.917307) (xy 127.384909 118.9802) - (xy 127.707291 118.9802) (xy 128.023479 118.917307) (xy 128.321321 118.793936) (xy 128.589372 118.61483) (xy 128.81733 118.386872) - (xy 128.886468 118.2834) (xy 130.039943 118.2834) (xy 130.0861 118.287946) (xy 130.132257 118.2834) (xy 130.132267 118.2834) - (xy 130.270333 118.269802) (xy 130.447486 118.216063) (xy 130.520567 118.177001) (xy 130.507722 118.207155) (xy 130.483638 118.252214) - (xy 130.471534 118.292114) (xy 130.455196 118.330472) (xy 130.44473 118.380475) (xy 130.429899 118.429367) (xy 130.425812 118.470862) - (xy 130.417271 118.51167) (xy 130.416761 118.56276) (xy 130.416301 118.567433) (xy 130.416301 118.60889) (xy 130.415424 118.696785) - (xy 130.416301 118.701436) (xy 130.4163 120.931742) (xy 129.46919 122.825964) (xy 129.377977 122.367406) (xy 129.035245 121.539977) - (xy 128.537675 120.795311) (xy 127.904389 120.162025) (xy 127.159723 119.664455) (xy 126.332294 119.321723) (xy 125.453901 119.147) - (xy 124.558299 119.147) (xy 123.679906 119.321723) (xy 122.852477 119.664455) (xy 122.107811 120.162025) (xy 122.0077 120.262136) - (xy 122.0077 109.696516) (xy 123.679991 109.696516) (xy 123.700188 109.955748) (xy 123.77057 110.206058) (xy 123.888434 110.437828) - (xy 123.918527 110.482867) (xy 124.126897 110.567448) (xy 124.970745 109.7236) (xy 125.041455 109.7236) (xy 125.885303 110.567448) - (xy 126.093673 110.482867) (xy 126.220901 110.256102) (xy 126.301445 110.008874) (xy 126.332209 109.750684) (xy 126.328145 109.69852) - (xy 127.541004 109.69852) (xy 127.560612 109.947761) (xy 127.628468 110.188388) (xy 127.741964 110.411152) (xy 127.769831 110.452858) - (xy 127.973 110.531344) (xy 128.780745 109.7236) (xy 127.973 108.915856) (xy 127.769831 108.994342) (xy 127.647663 109.212471) - (xy 127.570398 109.450243) (xy 127.541004 109.69852) (xy 126.328145 109.69852) (xy 126.312012 109.491452) (xy 126.24163 109.241142) - (xy 126.123766 109.009372) (xy 126.093673 108.964333) (xy 125.885303 108.879752) (xy 125.041455 109.7236) (xy 124.970745 109.7236) - (xy 124.126897 108.879752) (xy 123.918527 108.964333) (xy 123.791299 109.191098) (xy 123.710755 109.438326) (xy 123.679991 109.696516) - (xy 122.0077 109.696516) (xy 122.0077 89.761664) (xy 122.107811 89.861775) (xy 122.852477 90.359345) (xy 123.679906 90.702077) - (xy 124.558299 90.8768) (xy 125.453901 90.8768) (xy 126.332294 90.702077) (xy 127.159723 90.359345) (xy 127.904389 89.861775) - (xy 128.537675 89.228489) (xy 129.035245 88.483823) (xy 129.1463 88.215711) - ) - ) - (filled_polygon - (pts - (xy 134.1751 111.08825) (xy 134.28285 111.196) (xy 134.90375 111.196) (xy 134.987018 111.179437) (xy 135.065455 111.146947) - (xy 135.136047 111.099779) (xy 135.19608 111.039746) (xy 135.243247 110.969155) (xy 135.275737 110.890718) (xy 135.2923 110.80745) - (xy 135.2923 110.5755) (xy 135.675391 110.641483) (xy 135.712725 110.686975) (xy 135.824887 110.779024) (xy 135.952851 110.847422) - (xy 136.091701 110.889542) (xy 136.2361 110.903764) (xy 137.7361 110.903764) (xy 137.802473 110.897227) (xy 137.795936 110.9636) - (xy 137.795936 112.229219) (xy 131.330737 117.42804) (xy 131.911795 116.846982) (xy 131.947654 116.817554) (xy 131.991915 116.763622) - (xy 132.065096 116.674452) (xy 132.142803 116.529071) (xy 132.152363 116.511186) (xy 132.206102 116.334033) (xy 132.2197 116.195967) - (xy 132.2197 116.195958) (xy 132.224246 116.149801) (xy 132.2197 116.103644) (xy 132.2197 115.653471) (xy 132.382633 115.113383) - (xy 132.409101 115.026132) (xy 132.40917 115.025436) (xy 133.564625 111.196) (xy 134.01735 111.196) (xy 134.1251 111.08825) - (xy 134.1251 110.5618) (xy 134.1751 110.5618) - ) - ) - (filled_polygon - (pts - (xy 147.8361 110.903764) (xy 148.615482 110.903764) (xy 148.969415 111.010145) (xy 150.460702 114.222148) (xy 150.4311 114.25175) - (xy 150.4311 114.9056) (xy 150.4511 114.9056) (xy 150.4511 114.9556) (xy 150.4311 114.9556) (xy 150.4311 115.60945) - (xy 150.53885 115.7172) (xy 151.154833 115.7172) (xy 151.363123 116.165825) (xy 151.261699 116.135058) (xy 151.1173 116.120836) - (xy 149.6949 116.120836) (xy 149.550501 116.135058) (xy 149.411651 116.177178) (xy 149.283687 116.245576) (xy 149.171525 116.337625) - (xy 149.142859 116.372555) (xy 148.656379 115.06335) (xy 149.2639 115.06335) (xy 149.2639 115.32865) (xy 149.280463 115.411918) - (xy 149.312953 115.490355) (xy 149.36012 115.560946) (xy 149.420153 115.620979) (xy 149.490745 115.668147) (xy 149.569182 115.700637) - (xy 149.65245 115.7172) (xy 150.27335 115.7172) (xy 150.3811 115.60945) (xy 150.3811 114.9556) (xy 149.37165 114.9556) - (xy 149.2639 115.06335) (xy 148.656379 115.06335) (xy 148.459142 114.53255) (xy 149.2639 114.53255) (xy 149.2639 114.79785) - (xy 149.37165 114.9056) (xy 150.3811 114.9056) (xy 150.3811 114.25175) (xy 150.27335 114.144) (xy 149.65245 114.144) - (xy 149.569182 114.160563) (xy 149.490745 114.193053) (xy 149.420153 114.240221) (xy 149.36012 114.300254) (xy 149.312953 114.370845) - (xy 149.280463 114.449282) (xy 149.2639 114.53255) (xy 148.459142 114.53255) (xy 147.753936 112.634721) (xy 147.762042 112.607999) - (xy 147.776264 112.4636) (xy 147.776264 110.9636) (xy 147.769727 110.897227) - ) - ) - (filled_polygon - (pts - (xy 142.000904 114.121751) (xy 142.109849 114.254501) (xy 142.0491 114.31525) (xy 142.0491 114.9691) (xy 142.0691 114.9691) - (xy 142.0691 115.0191) (xy 142.0491 115.0191) (xy 142.0491 115.67295) (xy 142.15685 115.7807) (xy 142.3797 115.7807) - (xy 142.3797 116.184336) (xy 142.35573 116.184336) (xy 142.311092 116.168005) (xy 142.088618 116.133384) (xy 141.863666 116.142831) - (xy 141.692817 116.184336) (xy 141.3129 116.184336) (xy 141.209421 116.194528) (xy 141.348054 115.7807) (xy 141.89135 115.7807) - (xy 141.9991 115.67295) (xy 141.9991 115.0191) (xy 141.9791 115.0191) (xy 141.9791 114.9691) (xy 141.9991 114.9691) - (xy 141.9991 114.31525) (xy 141.89135 114.2075) (xy 141.875075 114.2075) (xy 141.941213 114.010076) - ) - ) - (filled_polygon - (pts - (xy 142.812725 101.386975) (xy 142.924887 101.479024) (xy 143.052851 101.547422) (xy 143.191701 101.589542) (xy 143.3361 101.603764) - (xy 143.8361 101.603764) (xy 143.980499 101.589542) (xy 143.9861 101.587843) (xy 143.991701 101.589542) (xy 144.1361 101.603764) - (xy 144.6361 101.603764) (xy 144.780499 101.589542) (xy 144.7861 101.587843) (xy 144.791701 101.589542) (xy 144.9361 101.603764) - (xy 145.4361 101.603764) (xy 145.580499 101.589542) (xy 145.5861 101.587843) (xy 145.591701 101.589542) (xy 145.7361 101.603764) - (xy 146.2361 101.603764) (xy 146.380499 101.589542) (xy 146.3861 101.587843) (xy 146.391701 101.589542) (xy 146.5361 101.603764) - (xy 147.0361 101.603764) (xy 147.102473 101.597227) (xy 147.095936 101.6636) (xy 147.095936 102.1636) (xy 147.110158 102.307999) - (xy 147.111857 102.3136) (xy 147.110158 102.319201) (xy 147.095936 102.4636) (xy 147.095936 102.9636) (xy 147.110158 103.107999) - (xy 147.111857 103.1136) (xy 147.110158 103.119201) (xy 147.095936 103.2636) (xy 147.095936 103.7636) (xy 147.110158 103.907999) - (xy 147.111857 103.9136) (xy 147.110158 103.919201) (xy 147.095936 104.0636) (xy 147.095936 104.5636) (xy 147.110158 104.707999) - (xy 147.111857 104.7136) (xy 147.110158 104.719201) (xy 147.095936 104.8636) (xy 147.095936 105.3636) (xy 147.110158 105.507999) - (xy 147.152278 105.646849) (xy 147.220676 105.774813) (xy 147.312725 105.886975) (xy 147.345168 105.9136) (xy 147.312725 105.940225) - (xy 147.220676 106.052387) (xy 147.152278 106.180351) (xy 147.110158 106.319201) (xy 147.095936 106.4636) (xy 147.095936 106.9636) - (xy 147.110158 107.107999) (xy 147.111857 107.1136) (xy 147.110158 107.119201) (xy 147.095936 107.2636) (xy 147.095936 107.7636) - (xy 147.110158 107.907999) (xy 147.111857 107.9136) (xy 147.110158 107.919201) (xy 147.095936 108.0636) (xy 147.095936 108.5636) - (xy 147.110158 108.707999) (xy 147.111857 108.7136) (xy 147.110158 108.719201) (xy 147.095936 108.8636) (xy 147.095936 109.3636) - (xy 147.110158 109.507999) (xy 147.111857 109.5136) (xy 147.110158 109.519201) (xy 147.095936 109.6636) (xy 147.095936 110.1636) - (xy 147.102473 110.229973) (xy 147.0361 110.223436) (xy 146.5361 110.223436) (xy 146.391701 110.237658) (xy 146.3861 110.239357) - (xy 146.380499 110.237658) (xy 146.2361 110.223436) (xy 145.7361 110.223436) (xy 145.591701 110.237658) (xy 145.5861 110.239357) - (xy 145.580499 110.237658) (xy 145.4361 110.223436) (xy 144.9361 110.223436) (xy 144.791701 110.237658) (xy 144.7861 110.239357) - (xy 144.780499 110.237658) (xy 144.6361 110.223436) (xy 144.1361 110.223436) (xy 143.991701 110.237658) (xy 143.9861 110.239357) - (xy 143.980499 110.237658) (xy 143.8361 110.223436) (xy 143.3361 110.223436) (xy 143.191701 110.237658) (xy 143.1861 110.239357) - (xy 143.180499 110.237658) (xy 143.0361 110.223436) (xy 142.5361 110.223436) (xy 142.391701 110.237658) (xy 142.252851 110.279778) - (xy 142.124887 110.348176) (xy 142.012725 110.440225) (xy 141.9861 110.472668) (xy 141.959475 110.440225) (xy 141.847313 110.348176) - (xy 141.719349 110.279778) (xy 141.580499 110.237658) (xy 141.4361 110.223436) (xy 140.9361 110.223436) (xy 140.791701 110.237658) - (xy 140.7861 110.239357) (xy 140.780499 110.237658) (xy 140.6361 110.223436) (xy 140.1361 110.223436) (xy 139.991701 110.237658) - (xy 139.9861 110.239357) (xy 139.980499 110.237658) (xy 139.8361 110.223436) (xy 139.3361 110.223436) (xy 139.191701 110.237658) - (xy 139.1861 110.239357) (xy 139.180499 110.237658) (xy 139.0361 110.223436) (xy 138.5361 110.223436) (xy 138.469727 110.229973) - (xy 138.476264 110.1636) (xy 138.476264 109.6636) (xy 138.462042 109.519201) (xy 138.460343 109.5136) (xy 138.462042 109.507999) - (xy 138.476264 109.3636) (xy 138.476264 109.2156) (xy 139.627164 109.2156) (xy 139.752756 109.341192) (xy 139.977404 109.491297) - (xy 140.227019 109.594691) (xy 140.492009 109.6474) (xy 140.762191 109.6474) (xy 141.027181 109.594691) (xy 141.276796 109.491297) - (xy 141.501444 109.341192) (xy 141.692492 109.150144) (xy 141.842597 108.925496) (xy 141.945991 108.675881) (xy 141.9987 108.410891) - (xy 141.9987 108.140709) (xy 141.945991 107.875719) (xy 141.842597 107.626104) (xy 141.692492 107.401456) (xy 141.501444 107.210408) - (xy 141.276796 107.060303) (xy 141.027181 106.956909) (xy 140.8557 106.9228) (xy 140.8557 106.921509) (xy 140.802991 106.656519) - (xy 140.699597 106.406904) (xy 140.549492 106.182256) (xy 140.358444 105.991208) (xy 140.133796 105.841103) (xy 139.884181 105.737709) - (xy 139.657639 105.692648) (xy 139.833381 105.657691) (xy 140.082996 105.554297) (xy 140.307644 105.404192) (xy 140.498692 105.213144) - (xy 140.648797 104.988496) (xy 140.752191 104.738881) (xy 140.8049 104.473891) (xy 140.8049 104.203709) (xy 140.752191 103.938719) - (xy 140.648797 103.689104) (xy 140.498692 103.464456) (xy 140.307644 103.273408) (xy 140.082996 103.123303) (xy 139.833381 103.019909) - (xy 139.568391 102.9672) (xy 139.4587 102.9672) (xy 139.4587 101.8526) (xy 139.463122 101.814111) (xy 139.4587 101.760279) - (xy 139.4587 101.752633) (xy 139.454915 101.714203) (xy 139.447966 101.629608) (xy 139.445856 101.622224) (xy 139.445102 101.614567) - (xy 139.441825 101.603764) (xy 139.8361 101.603764) (xy 139.980499 101.589542) (xy 139.9861 101.587843) (xy 139.991701 101.589542) - (xy 140.1361 101.603764) (xy 140.6361 101.603764) (xy 140.780499 101.589542) (xy 140.7861 101.587843) (xy 140.791701 101.589542) - (xy 140.9361 101.603764) (xy 141.4361 101.603764) (xy 141.580499 101.589542) (xy 141.5861 101.587843) (xy 141.591701 101.589542) - (xy 141.7361 101.603764) (xy 142.2361 101.603764) (xy 142.380499 101.589542) (xy 142.519349 101.547422) (xy 142.647313 101.479024) - (xy 142.759475 101.386975) (xy 142.7861 101.354532) - ) - ) - (filled_polygon - (pts - (xy 133.761009 103.8562) (xy 133.776137 103.8562) (xy 133.943336 104.069843) (xy 133.943336 104.6563) (xy 133.957558 104.800699) - (xy 133.999678 104.939549) (xy 134.068076 105.067513) (xy 134.160125 105.179675) (xy 134.2525 105.255485) (xy 134.2525 105.78085) - (xy 134.36025 105.8886) (xy 135.0141 105.8886) (xy 135.0141 105.8686) (xy 135.0641 105.8686) (xy 135.0641 105.8886) - (xy 135.0841 105.8886) (xy 135.0841 105.9386) (xy 135.0641 105.9386) (xy 135.0641 105.9586) (xy 135.0141 105.9586) - (xy 135.0141 105.9386) (xy 134.36025 105.9386) (xy 134.2525 106.04635) (xy 134.2525 106.66725) (xy 134.269063 106.750518) - (xy 134.301553 106.828955) (xy 134.348721 106.899547) (xy 134.408754 106.95958) (xy 134.42871 106.972914) (xy 134.373987 107.027636) - (xy 133.728602 107.027636) (xy 133.792522 106.908049) (xy 133.834642 106.769199) (xy 133.848864 106.6248) (xy 133.848864 105.2024) - (xy 133.834642 105.058001) (xy 133.792522 104.919151) (xy 133.724124 104.791187) (xy 133.632075 104.679025) (xy 133.5397 104.603215) - (xy 133.5397 104.07785) (xy 133.43195 103.9701) (xy 132.7781 103.9701) (xy 132.7781 103.9901) (xy 132.7281 103.9901) - (xy 132.7281 103.9701) (xy 132.7081 103.9701) (xy 132.7081 103.9201) (xy 132.7281 103.9201) (xy 132.7281 103.9001) - (xy 132.7781 103.9001) (xy 132.7781 103.9201) (xy 133.43195 103.9201) (xy 133.5397 103.81235) (xy 133.5397 103.81218) - ) - ) - (filled_polygon - (pts - (xy 138.558956 105.404192) (xy 138.783604 105.554297) (xy 139.033219 105.657691) (xy 139.259761 105.702752) (xy 139.084019 105.737709) - (xy 138.834404 105.841103) (xy 138.609756 105.991208) (xy 138.420083 106.180881) (xy 138.419922 106.180351) (xy 138.351524 106.052387) - (xy 138.259475 105.940225) (xy 138.227032 105.9136) (xy 138.259475 105.886975) (xy 138.351524 105.774813) (xy 138.419922 105.646849) - (xy 138.462042 105.507999) (xy 138.476264 105.3636) (xy 138.476264 105.3215) - ) - ) - (filled_polygon - (pts - (xy 168.439125 83.431911) (xy 167.941555 84.176577) (xy 167.598823 85.004006) (xy 167.4241 85.882399) (xy 167.4241 86.778001) - (xy 167.598823 87.656394) (xy 167.941555 88.483823) (xy 168.439125 89.228489) (xy 169.072411 89.861775) (xy 169.817077 90.359345) - (xy 170.644506 90.702077) (xy 170.876896 90.748302) (xy 170.72487 90.900328) (xy 170.545764 91.168379) (xy 170.543411 91.17406) - (xy 170.34312 91.091935) (xy 169.491455 91.9436) (xy 170.34312 92.795265) (xy 170.543411 92.71314) (xy 170.545764 92.718821) - (xy 170.72487 92.986872) (xy 170.751501 93.013503) (xy 170.7515 93.413698) (xy 170.72487 93.440328) (xy 170.545764 93.708379) - (xy 170.543411 93.71406) (xy 170.34312 93.631935) (xy 169.491455 94.4836) (xy 170.34312 95.335265) (xy 170.543411 95.25314) - (xy 170.545764 95.258821) (xy 170.72487 95.526872) (xy 170.751501 95.553503) (xy 170.7515 95.953698) (xy 170.72487 95.980328) - (xy 170.545764 96.248379) (xy 170.543411 96.25406) (xy 170.34312 96.171935) (xy 169.491455 97.0236) (xy 170.34312 97.875265) - (xy 170.543411 97.79314) (xy 170.545764 97.798821) (xy 170.72487 98.066872) (xy 170.751501 98.093503) (xy 170.7515 98.493698) - (xy 170.72487 98.520328) (xy 170.545764 98.788379) (xy 170.543411 98.79406) (xy 170.34312 98.711935) (xy 169.491455 99.5636) - (xy 170.34312 100.415265) (xy 170.543411 100.33314) (xy 170.545764 100.338821) (xy 170.72487 100.606872) (xy 170.952828 100.83483) - (xy 171.220879 101.013936) (xy 171.518721 101.137307) (xy 171.834909 101.2002) (xy 172.157291 101.2002) (xy 172.473479 101.137307) - (xy 172.771321 101.013936) (xy 173.039372 100.83483) (xy 173.066002 100.8082) (xy 173.164501 100.8082) (xy 173.1645 101.866486) - (xy 171.323476 104.107735) (xy 168.2877 102.192113) (xy 168.2877 101.844014) (xy 168.424215 101.639704) (xy 168.552501 101.329997) - (xy 168.6179 101.001213) (xy 168.6179 100.665987) (xy 168.579935 100.475123) (xy 168.604436 100.450622) (xy 168.690335 100.660117) - (xy 168.918969 100.78844) (xy 169.168245 100.869695) (xy 169.428582 100.900756) (xy 169.689977 100.880431) (xy 169.942384 100.809501) - (xy 170.176104 100.690692) (xy 170.221865 100.660117) (xy 170.307765 100.45062) (xy 169.4561 99.598955) (xy 169.441958 99.613098) - (xy 169.406603 99.577743) (xy 169.420745 99.5636) (xy 169.406603 99.549458) (xy 169.441958 99.514103) (xy 169.4561 99.528245) - (xy 170.307765 98.67658) (xy 170.221865 98.467083) (xy 169.993231 98.33876) (xy 169.855586 98.293893) (xy 169.942384 98.269501) - (xy 170.176104 98.150692) (xy 170.221865 98.120117) (xy 170.307765 97.91062) (xy 169.4561 97.058955) (xy 169.441958 97.073098) - (xy 169.406603 97.037743) (xy 169.420745 97.0236) (xy 169.406603 97.009458) (xy 169.441958 96.974103) (xy 169.4561 96.988245) - (xy 170.307765 96.13658) (xy 170.221865 95.927083) (xy 169.993231 95.79876) (xy 169.855586 95.753893) (xy 169.942384 95.729501) - (xy 170.176104 95.610692) (xy 170.221865 95.580117) (xy 170.307765 95.37062) (xy 169.4561 94.518955) (xy 169.441958 94.533098) - (xy 169.406603 94.497743) (xy 169.420745 94.4836) (xy 168.56908 93.631935) (xy 168.359583 93.717835) (xy 168.23126 93.946469) - (xy 168.150005 94.195745) (xy 168.118944 94.456082) (xy 168.12684 94.557632) (xy 168.000934 94.431726) (xy 167.8559 94.334818) - (xy 167.8559 93.260254) (xy 167.860446 93.214587) (xy 167.8559 93.167931) (xy 167.8559 93.167433) (xy 167.851354 93.121276) - (xy 167.842493 93.030335) (xy 167.842351 93.029865) (xy 167.842302 93.029367) (xy 167.815414 92.940729) (xy 167.78894 92.853126) - (xy 167.788707 92.852689) (xy 167.788563 92.852214) (xy 167.777021 92.83062) (xy 168.604435 92.83062) (xy 168.690335 93.040117) - (xy 168.918969 93.16844) (xy 169.056614 93.213307) (xy 168.969816 93.237699) (xy 168.736096 93.356508) (xy 168.690335 93.387083) - (xy 168.604435 93.59658) (xy 169.4561 94.448245) (xy 170.307765 93.59658) (xy 170.221865 93.387083) (xy 169.993231 93.25876) - (xy 169.855586 93.213893) (xy 169.942384 93.189501) (xy 170.176104 93.070692) (xy 170.221865 93.040117) (xy 170.307765 92.83062) - (xy 169.4561 91.978955) (xy 168.604435 92.83062) (xy 167.777021 92.83062) (xy 167.745083 92.77087) (xy 167.723669 92.730705) - (xy 167.723397 92.730297) (xy 167.701296 92.688949) (xy 167.672179 92.65347) (xy 167.180587 91.916082) (xy 168.118944 91.916082) - (xy 168.139269 92.177477) (xy 168.210199 92.429884) (xy 168.329008 92.663604) (xy 168.359583 92.709365) (xy 168.56908 92.795265) - (xy 169.420745 91.9436) (xy 168.56908 91.091935) (xy 168.359583 91.177835) (xy 168.23126 91.406469) (xy 168.150005 91.655745) - (xy 168.118944 91.916082) (xy 167.180587 91.916082) (xy 166.607586 91.05658) (xy 168.604435 91.05658) (xy 169.4561 91.908245) - (xy 170.307765 91.05658) (xy 170.221865 90.847083) (xy 169.993231 90.71876) (xy 169.743955 90.637505) (xy 169.483618 90.606444) - (xy 169.222223 90.626769) (xy 168.969816 90.697699) (xy 168.736096 90.816508) (xy 168.690335 90.847083) (xy 168.604435 91.05658) - (xy 166.607586 91.05658) (xy 165.860281 89.935623) (xy 165.890382 89.862952) (xy 165.9509 89.558704) (xy 165.9509 89.248496) - (xy 165.890382 88.944248) (xy 165.77167 88.657652) (xy 165.599327 88.399723) (xy 165.379977 88.180373) (xy 165.122048 88.00803) - (xy 164.835452 87.889318) (xy 164.531204 87.8288) (xy 164.220996 87.8288) (xy 164.008547 87.871058) (xy 163.978563 87.772214) - (xy 163.916656 87.656394) (xy 163.891296 87.608948) (xy 163.803284 87.501706) (xy 163.803282 87.501704) (xy 163.773854 87.465846) - (xy 163.737995 87.436417) (xy 163.16829 86.866714) (xy 163.138854 86.830846) (xy 162.995751 86.713404) (xy 162.832486 86.626137) - (xy 162.655333 86.572398) (xy 162.517267 86.5588) (xy 162.517257 86.5588) (xy 162.4711 86.554254) (xy 162.424943 86.5588) - (xy 160.331083 86.5588) (xy 160.321168 86.557046) (xy 160.238648 86.5588) (xy 160.202433 86.5588) (xy 160.192466 86.559782) - (xy 160.136085 86.56098) (xy 160.100572 86.568832) (xy 160.064367 86.572398) (xy 160.010388 86.588772) (xy 159.955326 86.600947) - (xy 159.922026 86.615577) (xy 159.887214 86.626137) (xy 159.837475 86.652723) (xy 159.785838 86.675409) (xy 159.756027 86.696258) - (xy 159.723949 86.713404) (xy 159.680356 86.74918) (xy 159.634133 86.781507) (xy 159.608962 86.807772) (xy 159.580846 86.830846) - (xy 159.545065 86.874445) (xy 159.538141 86.88167) (xy 159.515791 86.910116) (xy 159.463404 86.973949) (xy 159.458655 86.982835) - (xy 156.546375 90.689373) (xy 156.529372 90.67237) (xy 156.261321 90.493264) (xy 155.963479 90.369893) (xy 155.647291 90.307) - (xy 155.324909 90.307) (xy 155.008721 90.369893) (xy 154.710879 90.493264) (xy 154.442828 90.67237) (xy 154.2161 90.899098) - (xy 153.989372 90.67237) (xy 153.721321 90.493264) (xy 153.423479 90.369893) (xy 153.107291 90.307) (xy 152.784909 90.307) - (xy 152.468721 90.369893) (xy 152.170879 90.493264) (xy 151.902828 90.67237) (xy 151.6761 90.899098) (xy 151.449372 90.67237) - (xy 151.181321 90.493264) (xy 150.883479 90.369893) (xy 150.567291 90.307) (xy 150.244909 90.307) (xy 149.928721 90.369893) - (xy 149.6449 90.487456) (xy 150.652622 88.472011) (xy 150.88027 88.42673) (xy 151.176111 88.304188) (xy 151.44236 88.126286) - (xy 151.668786 87.89986) (xy 151.846688 87.633611) (xy 151.96923 87.33777) (xy 152.0317 87.023708) (xy 152.0317 86.703492) - (xy 151.96923 86.38943) (xy 151.846688 86.093589) (xy 151.668786 85.82734) (xy 151.44236 85.600914) (xy 151.176111 85.423012) - (xy 150.88027 85.30047) (xy 150.566208 85.238) (xy 150.245992 85.238) (xy 149.93193 85.30047) (xy 149.636089 85.423012) - (xy 149.36984 85.600914) (xy 149.143414 85.82734) (xy 149.1361 85.838286) (xy 149.128786 85.82734) (xy 148.90236 85.600914) - (xy 148.636111 85.423012) (xy 148.34027 85.30047) (xy 148.026208 85.238) (xy 147.705992 85.238) (xy 147.39193 85.30047) - (xy 147.096089 85.423012) (xy 146.82984 85.600914) (xy 146.603414 85.82734) (xy 146.5961 85.838286) (xy 146.588786 85.82734) - (xy 146.36236 85.600914) (xy 146.096111 85.423012) (xy 145.80027 85.30047) (xy 145.486208 85.238) (xy 145.165992 85.238) - (xy 144.85193 85.30047) (xy 144.556089 85.423012) (xy 144.28984 85.600914) (xy 144.063414 85.82734) (xy 144.0561 85.838286) - (xy 144.048786 85.82734) (xy 143.82236 85.600914) (xy 143.556111 85.423012) (xy 143.26027 85.30047) (xy 142.946208 85.238) - (xy 142.625992 85.238) (xy 142.31193 85.30047) (xy 142.016089 85.423012) (xy 141.74984 85.600914) (xy 141.523414 85.82734) - (xy 141.5161 85.838286) (xy 141.508786 85.82734) (xy 141.28236 85.600914) (xy 141.016111 85.423012) (xy 140.72027 85.30047) - (xy 140.406208 85.238) (xy 140.085992 85.238) (xy 139.77193 85.30047) (xy 139.476089 85.423012) (xy 139.20984 85.600914) - (xy 138.983414 85.82734) (xy 138.9761 85.838286) (xy 138.968786 85.82734) (xy 138.74236 85.600914) (xy 138.476111 85.423012) - (xy 138.18027 85.30047) (xy 137.866208 85.238) (xy 137.545992 85.238) (xy 137.23193 85.30047) (xy 136.936089 85.423012) - (xy 136.66984 85.600914) (xy 136.443414 85.82734) (xy 136.4361 85.838286) (xy 136.428786 85.82734) (xy 136.20236 85.600914) - (xy 135.936111 85.423012) (xy 135.64027 85.30047) (xy 135.326208 85.238) (xy 135.005992 85.238) (xy 134.69193 85.30047) - (xy 134.396089 85.423012) (xy 134.12984 85.600914) (xy 133.903414 85.82734) (xy 133.8961 85.838286) (xy 133.888786 85.82734) - (xy 133.66236 85.600914) (xy 133.396111 85.423012) (xy 133.10027 85.30047) (xy 132.786208 85.238) (xy 132.465992 85.238) - (xy 132.15193 85.30047) (xy 131.856089 85.423012) (xy 131.58984 85.600914) (xy 131.363414 85.82734) (xy 131.3561 85.838286) - (xy 131.348786 85.82734) (xy 131.12236 85.600914) (xy 130.856111 85.423012) (xy 130.56027 85.30047) (xy 130.246208 85.238) - (xy 129.925992 85.238) (xy 129.61193 85.30047) (xy 129.450267 85.367433) (xy 129.377977 85.004006) (xy 129.035245 84.176577) - (xy 128.537675 83.431911) (xy 128.420964 83.3152) (xy 168.555836 83.3152) - ) - ) - (filled_polygon - (pts - (xy 128.009996 103.135485) (xy 127.731266 103.321726) (xy 127.494226 103.558766) (xy 127.465204 103.6022) (xy 126.263646 103.6022) - (xy 126.04236 103.380914) (xy 126.031414 103.3736) (xy 126.04236 103.366286) (xy 126.268786 103.13986) (xy 126.336343 103.038754) - (xy 128.25976 103.032029) - ) - ) - (filled_polygon - (pts - (xy 132.015553 103.029745) (xy 131.983063 103.108182) (xy 131.9665 103.19145) (xy 131.9665 103.460779) (xy 131.9021 103.454436) - (xy 130.3021 103.454436) (xy 130.157701 103.468658) (xy 130.07343 103.494222) (xy 129.900934 103.321726) (xy 129.622204 103.135485) - (xy 129.363127 103.028171) (xy 132.022819 103.018871) - ) - ) - (filled_polygon - (pts - (xy 163.152873 92.947477) (xy 163.372223 93.166827) (xy 163.630152 93.33917) (xy 163.738462 93.384033) (xy 163.688548 93.409464) - (xy 163.646842 93.437331) (xy 163.568356 93.6405) (xy 164.3761 94.448245) (xy 165.183844 93.6405) (xy 165.105358 93.437331) - (xy 165.011702 93.384877) (xy 165.122048 93.33917) (xy 165.379977 93.166827) (xy 165.599327 92.947477) (xy 165.604262 92.940092) - (xy 165.976301 93.498151) (xy 165.976301 94.334817) (xy 165.831266 94.431726) (xy 165.637348 94.625644) (xy 165.651196 94.50868) - (xy 165.631588 94.259439) (xy 165.563732 94.018812) (xy 165.450236 93.796048) (xy 165.422369 93.754342) (xy 165.2192 93.675856) - (xy 164.411455 94.4836) (xy 164.425598 94.497742) (xy 164.390242 94.533098) (xy 164.3761 94.518955) (xy 163.568356 95.3267) - (xy 163.646842 95.529869) (xy 163.864971 95.652037) (xy 164.102743 95.729302) (xy 164.35102 95.758696) (xy 164.600261 95.739088) - (xy 164.840888 95.671232) (xy 165.063652 95.557736) (xy 165.105358 95.529869) (xy 165.183843 95.326701) (xy 165.252265 95.395123) - (xy 165.2143 95.585987) (xy 165.2143 95.921213) (xy 165.279699 96.249997) (xy 165.407985 96.559704) (xy 165.544501 96.764015) - (xy 165.5445 97.283186) (xy 165.407985 97.487496) (xy 165.279699 97.797203) (xy 165.2143 98.125987) (xy 165.2143 98.461213) - (xy 165.279699 98.789997) (xy 165.407985 99.099704) (xy 165.5445 99.304014) (xy 165.5445 99.402636) (xy 163.5087 99.402636) - (xy 163.364301 99.416858) (xy 163.225451 99.458978) (xy 163.097487 99.527376) (xy 162.985325 99.619425) (xy 162.893276 99.731587) - (xy 162.824878 99.859551) (xy 162.782758 99.998401) (xy 162.768536 100.1428) (xy 162.768536 101.379583) (xy 161.396927 102.3576) - (xy 160.744962 102.3576) (xy 160.747464 102.3322) (xy 160.747464 101.621) (xy 160.733242 101.476601) (xy 160.691122 101.337751) - (xy 160.622724 101.209787) (xy 160.530675 101.097625) (xy 160.418513 101.005576) (xy 160.290549 100.937178) (xy 160.151699 100.895058) - (xy 160.0073 100.880836) (xy 158.836895 100.880836) (xy 158.909139 100.786364) (xy 160.0073 100.786364) (xy 160.151699 100.772142) - (xy 160.290549 100.730022) (xy 160.418513 100.661624) (xy 160.530675 100.569575) (xy 160.622724 100.457413) (xy 160.691122 100.329449) - (xy 160.733242 100.190599) (xy 160.747464 100.0462) (xy 160.747464 99.335) (xy 160.733242 99.190601) (xy 160.691122 99.051751) - (xy 160.671392 99.014838) (xy 162.126705 96.031447) (xy 162.295452 95.997882) (xy 162.582048 95.87917) (xy 162.839977 95.706827) - (xy 163.059327 95.487477) (xy 163.23167 95.229548) (xy 163.276533 95.121238) (xy 163.301964 95.171152) (xy 163.329831 95.212858) - (xy 163.533 95.291344) (xy 164.340745 94.4836) (xy 163.533 93.675856) (xy 163.329831 93.754342) (xy 163.277377 93.847998) - (xy 163.23167 93.737652) (xy 163.059327 93.479723) (xy 162.839977 93.260373) (xy 162.769976 93.2136) (xy 162.839977 93.166827) - (xy 163.059327 92.947477) (xy 163.1061 92.877476) - ) - ) - (filled_polygon - (pts - (xy 143.4719 96.237) (xy 142.91885 96.237) (xy 142.8111 96.34475) (xy 142.8111 96.9986) (xy 142.8311 96.9986) - (xy 142.8311 97.0486) (xy 142.8111 97.0486) (xy 142.8111 97.70245) (xy 142.891087 97.782437) (xy 142.822593 97.879989) - (xy 142.81571 97.888506) (xy 142.737146 97.726404) (xy 142.7611 97.70245) (xy 142.7611 97.0486) (xy 142.7411 97.0486) - (xy 142.7411 96.9986) (xy 142.7611 96.9986) (xy 142.7611 96.34475) (xy 142.65335 96.237) (xy 142.37417 96.237) - (xy 142.508382 95.847786) (xy 142.562034 95.864061) (xy 142.7861 95.88613) (xy 143.010167 95.864061) (xy 143.111361 95.833364) - (xy 143.4719 95.833364) - ) - ) - ) -) diff --git a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_pinmap.pro b/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_pinmap.pro deleted file mode 100644 index 152769c..0000000 --- a/KiCad_M644_breakout_v1.2d/M644_breakout_v1.2d_pinmap.pro +++ /dev/null @@ -1,33 +0,0 @@ -update=22/05/2015 07:44:53 -version=1 -last_client=kicad -[general] -version=1 -RootSch= -BoardNm= -[pcbnew] -version=1 -LastNetListRead= -UseCmpFile=1 -PadDrill=0.600000000000 -PadDrillOvalY=0.600000000000 -PadSizeH=1.500000000000 -PadSizeV=1.500000000000 -PcbTextSizeV=1.500000000000 -PcbTextSizeH=1.500000000000 -PcbTextThickness=0.300000000000 -ModuleTextSizeV=1.000000000000 -ModuleTextSizeH=1.000000000000 -ModuleTextSizeThickness=0.150000000000 -SolderMaskClearance=0.000000000000 -SolderMaskMinWidth=0.000000000000 -DrawSegmentWidth=0.200000000000 -BoardOutlineThickness=0.100000000000 -ModuleOutlineThickness=0.150000000000 -[cvpcb] -version=1 -NetIExt=net -[eeschema] -version=1 -LibDir= -[eeschema/libraries] diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_bottom.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_bottom.png deleted file mode 100644 index cd4614c..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_bottom.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_bottom_tiny.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_bottom_tiny.png deleted file mode 100644 index 5983eb0..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_bottom_tiny.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_top.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_top.png deleted file mode 100644 index 984a203..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_top.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_top_tiny.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_top_tiny.png deleted file mode 100644 index 9cc1eeb..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d-a_top_tiny.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_bottom.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_bottom.png deleted file mode 100644 index db13c37..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_bottom.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap.png deleted file mode 100644 index 3c6a0a4..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap_tiny.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap_tiny.png deleted file mode 100644 index 782e7c9..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap_tiny.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_schematic.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_schematic.png deleted file mode 100644 index a3f6892..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_schematic.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_top.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_top.png deleted file mode 100644 index 5054320..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_top.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/M644_connection_schematic.png b/KiCad_M644_breakout_v1.2d/Pictures/M644_connection_schematic.png deleted file mode 100644 index 51cfdfc..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/M644_connection_schematic.png and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/Pictures/tested_system_photo_01.jpg b/KiCad_M644_breakout_v1.2d/Pictures/tested_system_photo_01.jpg deleted file mode 100644 index 7a011d2..0000000 Binary files a/KiCad_M644_breakout_v1.2d/Pictures/tested_system_photo_01.jpg and /dev/null differ diff --git a/KiCad_M644_breakout_v1.2d/README.md b/KiCad_M644_breakout_v1.2d/README.md deleted file mode 100644 index c70f8f8..0000000 --- a/KiCad_M644_breakout_v1.2d/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# AtMega 8535/16/32/324/644/1284 generic board - -### Briefly about the features of the scheme: -* Nearly all GPIO pins connected to PLS terminals. -* Two GPIOs are connected: button (SW1 / PC5) and the LED (LED1 / PC4). -* External pull-up on UART RX0 / RX1. -* R-dividers for 3.3V-TTL on UART TX0 / TX1. -* SPI pins for 3 devices connected to (for example): -Ethernet (Wiz5500 / ENC28J60), Sd-Card, CAN MCP2515 and so on ... -* Compatible with **Arduino Sanguino/Mightycore** - -#### Schematic: - -m1284p schematic - -#### This is my own custom board looks like: - -m1284p 3D top - -#### Pinmap board (Sanguino notation): - -m1284p pinmap - -## Author -* **Ibragimov Maksim aka maxxir** -08/04/2019 diff --git a/KiCad_M644_breakout_v1.2d/fp-lib-table b/KiCad_M644_breakout_v1.2d/fp-lib-table deleted file mode 100644 index 755c337..0000000 --- a/KiCad_M644_breakout_v1.2d/fp-lib-table +++ /dev/null @@ -1,3 +0,0 @@ -(fp_lib_table - (lib (name M644_breakout_v1.2d)(type KiCad)(uri "$(KIPRJMOD)/M644_breakout_v1.2d.pretty")(options "")(descr "")) -) diff --git a/KiCad_M644_breakout_v1.2d/sym-lib-table b/KiCad_M644_breakout_v1.2d/sym-lib-table deleted file mode 100644 index bd73bd3..0000000 --- a/KiCad_M644_breakout_v1.2d/sym-lib-table +++ /dev/null @@ -1,3 +0,0 @@ -(sym_lib_table - (lib (name M644_breakout_v1.2d-eagle-import)(type Legacy)(uri ${KIPRJMOD}/M644_breakout_v1.2d-eagle-import.lib)(options "")(descr "")) -) diff --git a/README.md b/README.md deleted file mode 100644 index 1033978..0000000 --- a/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# m1284p_wiz5500 - -*Read this in other languages: [English](README.md), [Русский](README.ru.md).* - -Lots of projects using ATMEGA 1284p(644p partially) and Ethernet NIC Wiznet 5500. - -Based on W5500 EVB examples, but heavily modified. - -Building in Eclipse Kepler with AVR-Eclipse plugin and avr-gcc 4.9.2 toolchain. - -## Hardware part of the projects - -* [Kicad open hardware](../master/KiCad_M644_breakout_v1.2d/) - -#### This is my own m644p/m1284p custom board looks like: - -m1284p Board 3D Top - -#### Tested system photo: - -m1284p System photo - - -## Software part. What done ( In order of increasing complexity and date of creation ) - -1. [Wiznet Loopback TCP/UDP Static IP](../master/03_m1284p_WIZNET_loopback_STATIC_IP/) -2. [Wiznet Loopback TCP/UDP DHCP IP](../master/04_m1284p_WIZNET_loopback_DHCP/) -3. [DNS example](../master/05_m1284p_WIZNET_DNS_client/) -4. [SNTP + DNS example](../master/06_m1284p_WIZNET_DNS_SNTP_client/) -5. [Telnet server example](../master/07_m1284p_WIZNET_telnets_basic/) -6. [ICMP aka ping example](../master/08_m1284p_WIZNET_ICMP_aka_ping/) -7. [Simple Web Server (one page with HTTP POST/GET queries)](../master/09_m1284p_WIZNET_simple_webserver/) -8. [HTTPD Web Server with all contents in AVR FLASH (with AJAX queries)](../master/11_m1284p_WIZNET_HTTPServer_FLASH_pages/) -9. [HTTPD Web Server with all content on SD card (Chang FAT FS lib using) (with AJAX queries)](../master/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/) -10. [FTPC example (only active mode sorry) with store content on SD card (console dialog from serial terminal like putty..)](../master/14_m1284p_WIZNET_FTPC_FATFS/) -11. [FTPD example (both active-passive modes working) with store content on SD card, checked on FTP clients: Windows 7 cmd, FAR, Total commander, WinSCP.](../master/15_m1284p_WIZNET_FTPD_FATFS/) -12. [Combined HTTPD + FTPD for dynamic upload WEB server pages, with all content on SD card (Chang FAT FS lib using) (with AJAX queries)](../master/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/) -13. ZEVERO SD PetitFS Bootloader for both [M1284p](../master/bootloader_zevero_sd_m1284p_make/)/[M644p](../master/bootloader_zevero_sd_m644p_make/) -14. Bootloaded code: Combined Wiznet Loopback TCP/UDP Static IP + FTPD server (for bootloading via FTP client) + SD-bootloader ZEVERO, working on [M644p](../master/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/)/[M1284p](../master/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/) -15. [Bootloaded code: Combined HTTPD server (with AJAX) + FTPD server (for bootloading via FTP client and upload WEB server contents) + SD-bootloader ZEVERO, working on M1284p only](../master/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/) -16. [IOT Blynk client Example with Blynk smartphone application (checked only Android side) - NO Arduino CODE, used Wiznet Sockets](../master/19_m1284p_WIZNET_blynk/) -17. [Bootloaded code: IOT BLYNK client combined with FTPD server (for bootloading via FTP client)+ SD-bootloader ZEVERO, working on M1284p only](../master/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/) -18. [TFTP client](../master/21_m1284p_WIZNET_TFTP_client_FATFS/) -19. [MQTT client](../master/22_m1284p_WIZNET_MQTT/) - -#### Blynk application screenshot: - -Blynk application - -[//]: # (TODO: Add all other links here) - -## What TODO: - -All done. - -## Remarks: -* [m1284P schematic](../master/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_schematic.png/) -* [m1284P typical connection diagram](../master/KiCad_M644_breakout_v1.2d/Pictures/M644_connection_schematic.png/) -* [m1284P Board pinmap](../master/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap.png/) -* [Blynk IOT Application QR-code](../master/19_m1284p_WIZNET_blynk/Blynk_application/app2_m1284p_and_W5500_QR.png/) - -[>>Hardware and Software parts (no Blynk) discussion your are welcome here..](https://www.avrfreaks.net/forum/need-w5500-example-c-tcp) - -[>>Blynk part discussion your are welcome here..](https://community.blynk.cc/t/port-from-w5500-evb-to-atmega1284p-w5500-wiznet-sockets-library-without-arduino/35235) - - -## Author porting to AVR m1284p/m644p -* **Ibragimov Maksim aka maxxir** diff --git a/README.ru.md b/README.ru.md deleted file mode 100644 index 1aba456..0000000 --- a/README.ru.md +++ /dev/null @@ -1,69 +0,0 @@ -# m1284p_wiz5500 - -*На других языках: [English](README.md), [Русский](README.ru.md).* - -Множество проектов использующих ATMEGA 1284p/644p и Ethernet контроллер Wiznet 5500 (см. Примечания). - -Основано на примерах для W5500 EVB (LCP13xx + W5500) , но довольно серьезно модифицировано (по причинам различий в архитектуре микропроцессоров ARM и AtMEGA, a также немалого количества багов в коде приложений для W5500 EVB). - -Собиралось при помощи Eclipse Kepler с плагином AVR-Eclipse и тулчейном avr-gcc 4.9.2. - -## Железо проекта - -* [Kicad open hardware](../master/KiCad_M644_breakout_v1.2d/) - -#### Моя плата на m644p/m1284p (KiCad 3D render): - -m1284p Board 3D Top - -#### Фото тестовой системы: - -m1284p System photo - - -## Софт. Что сделано ( В порядке усложнения и времени создания) - -1. [Wiznet Loopback TCP/UDP Static IP](../master/03_m1284p_WIZNET_loopback_STATIC_IP/) -2. [Wiznet Loopback TCP/UDP DHCP IP](../master/04_m1284p_WIZNET_loopback_DHCP/) -3. [DNS пример](../master/05_m1284p_WIZNET_DNS_client/) -4. [SNTP + DNS пример](../master/06_m1284p_WIZNET_DNS_SNTP_client/) -5. [Telnet server пример](../master/07_m1284p_WIZNET_telnets_basic/) -6. [ICMP(ping) пример](../master/08_m1284p_WIZNET_ICMP_aka_ping/) -7. [Простой Веб-сервер (одна страница HTTP POST/GET запросы)](../master/09_m1284p_WIZNET_simple_webserver/) -8. [HTTPD Веб-сервер со всем содержимым в AVR FLASH-памяти (используются AJAX запросы)](../master/11_m1284p_WIZNET_HTTPServer_FLASH_pages/) -9. [HTTPD Веб-сервер со всем содержимым на SD-карте (Chang FAT FS библиотека) (AJAX запросы)](../master/12_m1284p_WIZNET_HTTPServer_SDCARD_pages/) -10. [FTP-клиент (работает только в активном режиме) c сохранением контента на SD-карте ( диалог FTPC посредством последовательно терминала например: Terminal v1.9b by Bray, putty и тд.)](../master/14_m1284p_WIZNET_FTPC_FATFS/) -11. [FTP-сервер (работает в обоих режимах активный/пассивный) c сохранением контента на SD-карте, проверена работа с FTP клиентами: Windows 7 cmd - т.е ftp, FAR, Total Сommander (в нем надо добавить небольшой паттерн на выборку), WinSCP.](../master/15_m1284p_WIZNET_FTPD_FATFS/) -12. [HTTPD + FTPD для динамической загрузки страниц Веб-сервера, весь контент на SD-карте (Chang FAT FS библиотека) (AJAX запросы)](../master/16_m1284p_WIZNET_HTTPD_FTPD_FATFS_SDCARD/) -13. ZEVERO SD PetitFS бутлоадер (для двух процессоров): [M1284p](../master/bootloader_zevero_sd_m1284p_make/)/[M644p](../master/bootloader_zevero_sd_m644p_make/) -14. C обновлением через бутлоадер: Wiznet Loopback TCP/UDP Static IP + FTP-сервер (для обновления программы через FTP-клиент) + SD-бутлоадер ZEVERO, (для двух процессоров): [M644p](../master/18_m644p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/)/[M1284p](../master/18_m1284p_BTLD_WIZNET_LOOPBACK_FTPD_FATFS_SDCARD/) -15. [C обновлением через бутлоадер: Веб-сервер (с AJAX) + FTP-сервер (для обновления программы через FTP-клиент и загрузки контента Веб-сервера) + SD-бутлоадер ZEVERO, только для M1284p](../master/17_m1284p_BTLD_WIZNET_HTTPD_FTPD_FATFS_SDCARD/) -16. [IOT(Интернет вещей) Blynk-клиент пример с Blynk-приложением для смартфона (проверен только на Android (должен работать и в IOS)) - КОД НЕ АРДУИНО, использована библиотека Wiznet-сокетов](../master/19_m1284p_WIZNET_blynk/) -17. [C обновлением через бутлоадер: IOT(Интернет вещей) Blynk-клиент + FTP-сервер (для обновления программы через FTP-клиент)+ SD-бутлоадер ZEVERO, только для M1284p](../master/20_m1284p_BTLD_WIZNET_BLYNK_FTPD_FATFS_SDCARD/) -18. [TFTP клиент](../master/21_m1284p_WIZNET_TFTP_client_FATFS/) -19. [MQTT клиент](../master/22_m1284p_WIZNET_MQTT/) - -#### Скриншот приложения Blynk: - -Blynk application - -[//]: # (TODO: Add all other links here) - -## Софт. Что хочу добавить : - -Все что хотел, опубликовано. - -## Примечания: -* На AtMega644p работают не все примеры т.к недостаточно RAM (4kb). -* [m1284P схема](../master/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_schematic.png/) -* [m1284P диаграмма соединения](../master/KiCad_M644_breakout_v1.2d/Pictures/M644_connection_schematic.png/) -* [m1284P пинмап платы](../master/KiCad_M644_breakout_v1.2d/Pictures/M644_breakout_v1.2d_pinmap.png/) -* [Blynk IOT приложение QR-code](../master/19_m1284p_WIZNET_blynk/Blynk_application/app2_m1284p_and_W5500_QR.png/) - -[>>Обсужение проекта (исключая Blynk) здесь..](https://www.avrfreaks.net/forum/need-w5500-example-c-tcp) - -[>>Обсужение Blynk части проекта здесь..](https://community.blynk.cc/t/port-from-w5500-evb-to-atmega1284p-w5500-wiznet-sockets-library-without-arduino/35235) - - -## Автор порта на AVR m1284p/m644p -* **Ибрагимов Максим aka maxxir** diff --git a/bootloader_zevero_sd_m1284p_make/.cproject b/bootloader_zevero_sd_m1284p_make/.cproject deleted file mode 100644 index d50f016..0000000 --- a/bootloader_zevero_sd_m1284p_make/.cproject +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - - program - true - true - true - - - - - - - - - - diff --git a/bootloader_zevero_sd_m1284p_make/.gitignore b/bootloader_zevero_sd_m1284p_make/.gitignore deleted file mode 100644 index 3c2fcf6..0000000 --- a/bootloader_zevero_sd_m1284p_make/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -*.o -*.eps -*.bak -*.a -*.bin -*.elf -*.hex -*.lst -*.map -/nbproject \ No newline at end of file diff --git a/bootloader_zevero_sd_m1284p_make/.project b/bootloader_zevero_sd_m1284p_make/.project deleted file mode 100644 index 7e47f47..0000000 --- a/bootloader_zevero_sd_m1284p_make/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - bootloader_zevero_sd_m1284p_make - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/bootloader_zevero_sd_m1284p_make/LICENSE b/bootloader_zevero_sd_m1284p_make/LICENSE deleted file mode 100644 index 0c0bbe3..0000000 --- a/bootloader_zevero_sd_m1284p_make/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2015, zevero -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* 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. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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. - diff --git a/bootloader_zevero_sd_m1284p_make/Makefile b/bootloader_zevero_sd_m1284p_make/Makefile deleted file mode 100644 index 4b51a6a..0000000 --- a/bootloader_zevero_sd_m1284p_make/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -#------------------------------------------------------------------ -# Makefile for stand-alone MMC boot strap loader -#------------------------------------------------------------------ -# Change these defs for the target device - -MCU_TARGET = atmega1284p # Target device to be used (32K or larger) -BOOT_ADR = 0x1F000 # Boot loader start address [byte] NOT [word] as in http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega1284p -F_CPU = 16000000 # CPU clock frequency [Hz] NOT critical: it just should be higher than the actual Hz -SD_CS_PORT = PORTB # Data Register of the SD CS pin -SD_CS_DDR = DDRB # Data Direction Register of the SD CS pin -SD_CS_BIT = 0 # Bit of the SD CS pin -USE_LED = 1 # Debug with two (defined in asmfunc.S) -USE_UART = 0 # Debug on Serial. 0 ... deactivate or divider of http://wormfood.net/avrbaudcalc.php for baud rate! -#------------------------------------------------------------------ -ifeq ($(strip $(USE_UART)),0) -CSRC = main.c pff/src/pff.c diskio.c -else -CSRC = main.c pff/src/pff.c diskio.c uart/uart.c -endif - -TARGET = bootloader_zevero_sd_m1284p -ASRC = asmfunc.S -OPTIMIZE = -Os -mcall-prologues -ffunction-sections -fdata-sections -DEFS = -DBOOT_ADR=$(BOOT_ADR) -DF_CPU=$(F_CPU) -DUSE_LED=$(USE_LED) -DUSE_UART=$(USE_UART) -DSD_CS_PORT=$(SD_CS_PORT) -DSD_CS_DDR=$(SD_CS_DDR) -DSD_CS_BIT=$(SD_CS_BIT) -LIBS = -DEBUG = dwarf-2 - -ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs $(DEFS) -ALL_ASFLAGS = -mmcu=$(MCU_TARGET) -I. -x assembler-with-cpp $(ASFLAGS) -CFLAGS = -g$(DEBUG) -Wall $(OPTIMIZE) $(ADDED_CFLAGS) -mmcu=$(MCU_TARGET) -std=c99 $(DEFS) -LDFLAGS = -Wl,-Map,$(TARGET).map -Wl,--gc-sections -Wl,--section-start,.text=$(BOOT_ADR) -OBJ = $(CSRC:.c=.o) $(ASRC:.S=.o) - -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size - - -all: clean $(TARGET).elf lst text bin size - -$(TARGET).elf: $(OBJ) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) - -clean: - rm -rf *.o $(TARGET).elf *.eps *.bak *.a *.bin - rm -rf pff/src/*.o uart/*.o - rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) - rm -rf $(TARGET).hex - -size: $(TARGET).elf - $(SIZE) -C --mcu=$(MCU_TARGET) $(TARGET).elf - -lst: $(TARGET).lst -%.lst: %.elf - $(OBJDUMP) -h -S $< > $@ - -%.o : %.S - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - -text: $(TARGET).hex -%.hex: %.elf - $(OBJCOPY) -j .text -j .data -j .fuse -O ihex $< $@ -# --- make bin just to check size :) -bin: $(TARGET).bin -%.bin: %.hex - $(OBJCOPY) -I ihex -O binary $< $@ - -print-% : ; @echo $* = $($*) #test any var with make print-XXX - diff --git a/bootloader_zevero_sd_m1284p_make/README.md b/bootloader_zevero_sd_m1284p_make/README.md deleted file mode 100644 index dd2b29a..0000000 --- a/bootloader_zevero_sd_m1284p_make/README.md +++ /dev/null @@ -1,86 +0,0 @@ -avr_boot -======== - -SD card bootloader for atmega processors - -As easy as it can get! I spent days with this. Hopefully you wont! - -- for any ATMega with 4096kb Bootloader -- uses Petit FatFs R0.03 for FAT12, FAT16, FAT32 -- looks for FIRMWARE.BIN and flashes it nearly instantly -- without any interference to your application -- no CRC Check and no version bytes in EEPROM (see KISS) - -### Boards Manager installation - -avr_boot is integrated in Arduino IDE version 1.6.4 or greater!!! [See here for instructions.](https://github.com/zevero/avr_boot/tree/gh-pages) - -### Manual installation - -This is with avr-gcc and avrdude under linux with an Atmega1284p and AVRISP mkII! Adaption to your case (WinAvr, another Atmega, another flash-tool) will not be complicated... - -- adapt Makefile - - MCU_TARGET: Your atmegaXXX - - BOOT_ADR: in bytes not words! - - F_CPU: CPU Frequency (not critical. A higher value will work as well) - - SD_CS_PORT: Data Register of the SD CS pin(see the datasheet for your microcontroller) - - SD_CS_DDR: Data Direction Register of the SD CS pin - - SD_CS_BIT: Bit of the SD CS pin - - USE_LED: For debugging 0...deactivate or 1...active - - USE_UART: For debugging 0...deactivate or divider (UBRR) for baudate see http://wormfood.net/avrbaudcalc.php -- update spi_pins.h with the SPI pins of your microcontroller if not already defined -- if using USE_LED adapt LED-pins in asmfunc.S -- if you want to add FAT12 adapt pff/src/pffconfh.h (default ist FAT16 + FAT32) -- if you want to support lower case filenames adapt pff/src/pffconfh.h (default is uppercase) -- if you prefer another filename instead of FIRMWARE.BIN adapt main.c -- make (you may need to do "sudo apt-get install avr-libc gcc-avr") -- set fuses: avrdude -c avrispmkII -p m1284p -U hfuse:w:0xda:m - - find high fuse in http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega1284p -- flash: avrdude -c avrispmkII -p m1284p -Uflash:w:./avr_boot.hex:i -Ulock:w:0x3F:m - -### Put your sketch on SD card - -- in Arduino IDE go to File > Preferences and check "Show verbose output during compiliation" -- compile sketch and find the location of your /tmp/buildxxx/sketch.cpp.hex -- make bin file: avr-objcopy -I ihex -O binary sketch.cpp.hex FIRMWARE.BIN -- copy the file into the root of an SD (FAT16/FAT32) -- put it into the SD slot of your ATmega -- reset it -- it might already have happend! - -### Bootloader sizes -Compiled under linux for atmega328p / atmega1284p - - 3674 / 3724 bytes - - 3984 / 4034 bytes debugging with USE_LED - - 3992 / 4052 bytes debugging with USE_UART - -### Tested successfully on - - ATmega168 - - ATmega328P - - ATmega32u4 - - ATmega1284P - - ATmega2560 (see issue #2) - -### Serial support - Help wanted -it should not be impossible to fit a normal serial bootloader (with automatic baudrate detection?) into the remaining bytes ... help is appreciated! - -### KISS -If you wish you *can* add CRC Check or versioning with EEPROM *but* I prefere to keep things simple. avr_boot will reflash your FIRMWARE.BIN as long as it is present. -Is this a problem? No! It happens nearly instantly and only differing bytes are flashed really. -You may consider putting your logic into your application and perform a CRC Check after the fact to inform the user and delete or rename FIRMWARE.BIN - -### Thanks to -- https://github.com/per1234 - Boards Manager Installation and help with differenct MCUs -- http://elm-chan.org/fsw/ff/00index_p.html -- Wilfried Klaas for the MCSDepthLogger https://github.com/willie68/OpenSeaMapLogger -- https://github.com/mharizanov/avr_boot -- https://github.com/osbock/avr_boot -- and others??? - -### Alternatives - -- https://spaces.atmel.com/gf/project/sdbootloader/ -- https://github.com/thseiler/embedded/tree/master/avr/2boots -- http://www.mikrocontroller.net/articles/MMC/SD_Bootloader_f%C3%BCr_AT_Mega - -... call me stupid, but I passed several days debugging those - without success ... diff --git a/bootloader_zevero_sd_m1284p_make/asmfunc.S b/bootloader_zevero_sd_m1284p_make/asmfunc.S deleted file mode 100644 index 099a8d1..0000000 --- a/bootloader_zevero_sd_m1284p_make/asmfunc.S +++ /dev/null @@ -1,271 +0,0 @@ -;---------------------------------------------------------------------------; -; MMC hardware controls and Flash controls (C)ChaN, 2010 -;---------------------------------------------------------------------------; -; Hardware dependent macros to be modified //do this in Makefile -#include "spi_pins.h" - -; ALL Pins given as Port (A,B,C,...) plus number - -; LED Pins -;#define DDR_SS _SFR_IO_ADDR(DDRD), 5 // SS pin (PIN, PORT) -;#define PORT_SS _SFR_IO_ADDR(PORTD), 5 -#define DDR_SS _SFR_IO_ADDR(DDRC), 3 // SS pin (PIN, PORT) -#define PORT_SS _SFR_IO_ADDR(PORTC), 3 - -;#define DDR_PW _SFR_IO_ADDR(DDRD), 6 // Power pin (PIN, PORT) -;#define PORT_PW _SFR_IO_ADDR(PORTD), 6 - -;SD CARD PINS -#define DDR_CS _SFR_IO_ADDR(SD_CS_DDR), SD_CS_BIT -#define PORT_CS _SFR_IO_ADDR(SD_CS_PORT), SD_CS_BIT - -;---------------------------------------------------------------------------; -.nolist -#include -.list -.text - -.global init_leds -.func init_leds -init_leds: - sbi DDR_SS -; sbi DDR_PW - ret -.endfunc - - -.global led_write_on -.func led_write_on -led_write_on: - sbi PORT_SS - ret -.endfunc - -.global led_write_off -.func led_write_off -led_write_off: - cbi PORT_SS - ret -.endfunc - -;.global led_power_on -;.func led_power_on -;led_power_on: -; sbi PORT_PW -; ret -;.endfunc - -;.;global led_power_off -;.;func led_power_off -;led_power_off: -; cbi PORT_PW -; ret -;.endfunc - -;.;global led_power_toggle -;.func led_power_toggle -;led_power_toggle: -; sbis PORT_PW -; jmp led_power_on -; jmp led_power_off -;.endfunc - -.global led_write_toggle -.func led_write_toggle -led_write_toggle: - sbis PORT_SS - jmp led_write_on - jmp led_write_off -.endfunc - -;---------------------------------------------------------------------------; -; Initialize MMC port -; -; void init_spi (void); - -.global init_spi -.func init_spi -init_spi: - sbi DDR_CS ; CS: output - sbi DDR_DI ; DI: output - sbi DDR_CK ; SCLK: output - sbi PORT_DO ; DO: pull-up - ret -.endfunc - - - -;---------------------------------------------------------------------------; -; Delay 100 microseconds -; -; void dly_us (UINT n); - -.global dly_100us -.func dly_100us -dly_100us: - ldi r24, lo8(F_CPU / 100000) /* Loop counter */ -1: sbiw r30, 1 /* 10 clocks per loop */ - sbiw r30, 1 - sbiw r30, 1 - nop - dec r24 - brne 1b - ret -.endfunc - - - -;---------------------------------------------------------------------------; -; Select MMC -; -; void select (void); - -.global select -.func select -select: - rcall deselect - cbi PORT_CS - rjmp rcv_spi -.endfunc - - - -;---------------------------------------------------------------------------; -; Deselect MMC -; -; void deselect (void); - -.global deselect -.func deselect -deselect: - sbi PORT_CS - ; Goto next function -.endfunc - - - -;---------------------------------------------------------------------------; -; Receive a byte -; -; BYTE rcv_spi (void); - -.global rcv_spi -.func rcv_spi -rcv_spi: - ldi r24, 0xFF ; Send 0xFF to receive data - ; Goto next function -.endfunc - - - -;---------------------------------------------------------------------------; -; Transmit a byte -; -; void xmit_spi (BYTE); - -.global xmit_spi -.func xmit_spi -xmit_spi: - ldi r25, 8 -1: sbrc r24, 7 ; DI = Bit to sent - sbi PORT_DI ; - sbrs r24, 7 ; - cbi PORT_DI ; / - lsl r24 ; Get DO from MMC - sbic PIN_DO ; - inc r24 ; / - sbi PORT_CK ; A positive pulse to SCLK - cbi PORT_CK ; / - dec r25 ; Repeat 8 times - brne 1b ; / - ret -.endfunc - - - -;--------------------------------------------------------------------------- -; Erase a flash page -; -; void flash_erase (DWORD flash_addr); - -#ifndef SPMCSR -#define SPMCSR SPMCR -#endif - -.global flash_erase -.func flash_erase -flash_erase: - - movw ZL, r22 -#if FLASHEND >= 0x10000 - out _SFR_IO_ADDR(RAMPZ), r24 -#endif - - ; Initiate erase operation - ldi r24, 0b00000011 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - - ; Wait for end of erase operation -1: lds r24, _SFR_MEM_ADDR(SPMCSR) - sbrc r24, 0 - rjmp 1b - - ; Re-enable read access to the flash - ldi r24, 0b00010001 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - -9: ret -.endfunc - - - -;--------------------------------------------------------------------------- -; Write a flash page -; -; void flash_write (DWORD flash_addr, const BYTE* data); - -.global flash_write -.func flash_write -flash_write: - push r0 - push r1 - -#if FLASHEND >= 0x10000 - out _SFR_IO_ADDR(RAMPZ), r24 -#endif - - ; Fill page buffer - movw ZL, r22 - movw XL, r20 - ldi r25, lo8(SPM_PAGESIZE/2) -1: ld r0, X+ - ld r1, X+ - ldi r24, 0b00000001 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - adiw ZL, 2 - dec r25 - brne 1b - - ; Initiate write operation - movw ZL, r22 - ldi r24, 0b00000101 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - - ; Wait for end of write operation -2: lds r24, _SFR_MEM_ADDR(SPMCSR) - sbrc r24, 0 - rjmp 2b - - ; Re-enable read access to the flash - ldi r24, 0b00010001 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - -9: pop r1 - pop r0 - ret -.endfunc diff --git a/bootloader_zevero_sd_m1284p_make/bootloader_zevero_sd_m1284p.hex.bootloader b/bootloader_zevero_sd_m1284p_make/bootloader_zevero_sd_m1284p.hex.bootloader deleted file mode 100644 index d50c467..0000000 --- a/bootloader_zevero_sd_m1284p_make/bootloader_zevero_sd_m1284p.hex.bootloader +++ /dev/null @@ -1,247 +0,0 @@ -:020000021000EC -:10F000000C9446F80C9472F80C9472F80C9472F804 -:10F010000C9472F80C9472F80C9472F80C9472F8C8 -:10F020000C9472F80C9472F80C9472F80C9472F8B8 -:10F030000C9472F80C9472F80C9472F80C9472F8A8 -:10F040000C9472F80C9472F80C9472F80C9472F898 -:10F050000C9472F80C9472F80C9472F80C9472F888 -:10F060000C9472F80C9472F80C9472F80C9472F878 -:10F070000C9472F80C9472F80C9472F80C9472F868 -:10F080000C9472F80C9472F80C9472F811241FBE50 -:10F09000CFEFD0E4DEBFCDBF87EF84BF0FB6F894CB -:10F0A000A895809160008861809360001092600054 -:10F0B0000FBE11E0A0E0B1E0E0E3FFEF01E00BBF25 -:10F0C00002C007900D92AE30B107D9F722E0AEE052 -:10F0D000B1E001C01D92AB33B207E1F70E9458F9CD -:10F0E0000C9496FF0C9400F83B9A0895439A089567 -:10F0F00043980895439B0C9476F80C9478F8209AE2 -:10F10000259A279A2E9A089580EA31973197319758 -:10F1100000008A95D1F7089502D0289801C0289A56 -:10F120008FEF98E087FD2D9A87FF2D98880F1E9905 -:10F1300083952F9A2F989A95A9F70895FB018BBF75 -:10F1400083E080935700E8958091570080FDFCCFC5 -:10F1500081E180935700E89508950F921F928BBF2D -:10F16000FB01DA0190E80D901D9081E0809357003B -:10F17000E89532969A95B9F7FB0185E080935700A0 -:10F18000E8958091570080FDFCCF81E18093570086 -:10F19000E8951F900F900895CF92DF92EF92FF9223 -:10F1A0001F93CF93DF9300D0CDB7DEB712E30E9459 -:10F1B0007AF82FEF81EE94E0215080409040E1F703 -:10F1C00000C00000115099F7C12CD12C760140E00D -:10F1D00051E06FEF70E08BE391E00E948FFFAE0192 -:10F1E0004F5F5F4F60E071E08BE391E00E9437FD7D -:10F1F000ABE3B1E0B701A6016BBFFA0197918D9126 -:10F2000098131FC04F5F5F4F6F4F7F4F22E0AB33AC -:10F21000B20791F70E9476F88FEFD81AE80AF80A39 -:10F22000C11490EFD90691E0E906F10481F60F9040 -:10F230000F90DF91CF911F91FF90EF90DF90CF90D3 -:10F2400008950E9478F8C701B6010E949EF84BE32A -:10F2500051E0C701B6010E94ADF8DECFCF9381E146 -:10F2600091E00E94B2FA811121C080E091E00E94F9 -:10F270009FFB81111BC00E94CCF80E9478F82FEFF1 -:10F2800087EA91E6215080409040E1F700C00000FD -:10F29000C8E20E947AF82FEF80E792E02150804088 -:10F2A0009040E1F700C00000C15099F7CF91089558 -:10F2B0000E9474F800E010E00E9476F82FEF83ECD3 -:10F2C00099E0215080409040E1F700C000000E948A -:10F2D00078F80E942EF9F80185919491019611F029 -:10F2E000F8010995CAE00E947AF8FFEF23EC89E063 -:10F2F000F15020408040E1F700C00000C15099F774 -:10F300009FEFE3E2F4EF9150E040F040E1F700C0FE -:10F310000000D2CF0F931F93E0910E01F0910F01E7 -:10F320009B01AC0122503109410951098681978125 -:10F33000A085B1850297A109B109281739074A07A5 -:10F340005B0768F4A281B0E00E943EFF0289138946 -:10F3500024893589600F711F821F931F03C060E0ED -:10F3600070E0CB011F910F9108950F931F93CF93DE -:10F37000DF93DC01E0910E01F0910F0111961C92D8 -:10F380001E9214966D917D918D919C91179761308D -:10F3900071058105910569F1068117812085318507 -:10F3A000601771078207930720F5611571058105C4 -:10F3B000910539F42081233021F466857785808991 -:10F3C0009189ED01688779878A879B876115710527 -:10F3D0008105910519F00E948AF904C06685778538 -:10F3E000808991896C877D878E879F8780E090E0F8 -:10F3F00002C081E090E0DF91CF911F910F910895BD -:10F40000A4E0B0E0E6E0FAEF0C9453FFE0910E01C7 -:10F41000F0910F01623071058105910508F459C022 -:10F42000C680D780E084F1846C157D058E059F052C -:10F4300008F04FC02081223019F0233001F149C07B -:10F440009B013327220F331FBB27A92F982F872F0C -:10F45000C284D384E484F584AC01BD014C0D5D1DF0 -:10F460006E1D7F1D02E010E0CE0101960E94CDFED0 -:10F47000892B79F569817A8180E090E02EC09B012B -:10F480002F773327220F331F220F331FDC01CB01CD -:10F4900057E0B695A795979587955A95D1F7C28469 -:10F4A000D384E484F584AC01BD014C0D5D1D6E1D5B -:10F4B0007F1D04E010E0CE0101960E94CDFE892B55 -:10F4C00041F489819A81AB81BC81BC01CD019F70DF -:10F4D00004C061E070E080E090E02496E8E00C94E5 -:10F4E0006FFFA0E0B0E0E7E7FAEF0C9453FFEC0108 -:10F4F0006A017B0102E010E02EEF31E00E94CDFEB8 -:10F50000892B31F58881998185359A4A19F526E349 -:10F5100030E0B701A601CE010E94CDFE892B39F45F -:10F52000888199818634914411F480E016C002E00C -:10F5300010E022E530E0B701A601CE010E94CDFE29 -:10F54000892B51F4888199818634914429F4EDCF37 -:10F5500083E003C082E001C081E0CDB7DEB7E8E020 -:10F560000C946FFFA4E2B0E0E8EBFAEF0C9449FFD3 -:10F570001C0110920F0110920E010E9432FE80FDBC -:10F58000A0C040E050E0BA01CE0101960E9471FA9D -:10F59000813009F500E110E02EEB31E040E050E071 -:10F5A000BA01CE0101960E94CDFE892B19F081E0AF -:10F5B00090E0C1C08D81811103C086E090E0BBC0A6 -:10F5C00049845A846B847C84B301A201CE010196E4 -:10F5D0000E9471FA03C0412C512C3201833039F35F -:10F5E0008111EBCF04E210E02DE030E0B301A20185 -:10F5F000CE0101960E94CDFE892BC9F62A853B8556 -:10F6000040E050E0211531054105510521F4288DD8 -:10F61000398D4A8D5B8DAC81B0E00E943EFF4B017D -:10F620005C010A811B8120E030E0400E511E621E09 -:10F63000731EF10142865386648675864981428332 -:10F64000CD80DE80D582C4828F819885A0E0B0E035 -:10F650000097A105B10521F48C899D89AE89BF89E8 -:10F6600054E0D694C7945A95E1F7E12CF12C801B15 -:10F67000910BA20BB30B88199909AA09BB09BC010C -:10F68000CD016C197D098E099F09242F30E040E0DF -:10F6900050E00E941CFFDA01C9010296A11DB11DB4 -:10F6A000F10186839783A087B187BA01A901465FDC -:10F6B0005F40610971094F3F5F4E61057105A0F11F -:10F6C00003C082E090E037C0873F9F4FA105B1059E -:10F6D00008F473CF83E0F1018083833029F488A19B -:10F6E00099A1AAA1BBA107C0D501C401840D951D94 -:10F6F000A61DB71DF10186879787A08BB18BC40C1F -:10F70000D51CE61CF71CC80CD91CEA1CFB1CF1011B -:10F71000C28AD38AE48AF58A118230920F0120923C -:10F720000E0180E090E007C0873F9F4FA105B10523 -:10F7300088F682E0D0CFA496E2E10C9465FF4F9268 -:10F740005F926F927F929F92AF92BF92CF92DF9221 -:10F75000EF92FF920F931F93CF93DF93CDB7DEB756 -:10F76000EC970FB6F894DEBF0FBECDBFC0900E0170 -:10F77000D0900F01C114D10409F452C1D6011196E1 -:10F780001C929E012F5C3F4F3CA32BA3FC012E2F0C -:10F790009F2F81918032D9F3E22EF92E8F3219F406 -:10F7A000BFEFEB1AFB0A1DA21EA21FA218A6F701AB -:10F7B0008081803238F0A0E29A2E5E01FCE0AF0E2C -:10F7C000B11C6AC0CE0181960E94B5F919820097DA -:10F7D00009F4F1C036C180E090E028E031E0390F53 -:10F7E000D701A90FB11D9C91913208F060C0E30EC2 -:10F7F000F11C81E0913208F080E08387CE01819690 -:10F800000E94B5F9009709F01CC129A13AA12F70F7 -:10F810003327F5E0220F331FFA95E1F74DA55EA5DA -:10F820006FA578A900E210E0CE0101960E94CDFEFE -:10F83000892B09F0FAC08981882309F4F9C04C8525 -:10F8400043FD53C06BA17CA1FE0131969B01EA15DB -:10F85000FB05E9F5DB011B968C918111ACC044FFDF -:10F86000E7C0E0910E01F0910F018081833009F033 -:10F870009EC08D899E89A0E0B0E0DC019927882791 -:10F880004B8D5C8D60E070E0842B952BA62BB72B05 -:10F890008DA39EA3AFA3B8A7EBA1FCA1DF01CF016D -:10F8A0000B96A817B90709F496CF9D92FACF9F320D -:10F8B00009F49DCF9E3209F4BEC0821708F097CF9D -:10F8C000DF01A80FB11D9C938F5F932F87CF81918C -:10F8D000D9015D919D01082E000C990B851B9109A2 -:10F8E00057FD9395892B09F4B2CF60900E0170906B -:10F8F0000F0109A11AA10F5F1F4F09F499C08DA52F -:10F900009EA5AFA5B8A90097A105B10509F490C0BF -:10F9100098012F703327232B09F046C00196A11DB3 -:10F92000B11D8DA79EA7AFA7B8AB69A57AA58BA57A -:10F930009CA5611571058105910541F4F301848150 -:10F9400095810817190708F073C02EC0D3011296CD -:10F950002C9130E0A901415051099801E4E036951D -:10F960002795EA95E1F724233523232BE9F40E9418 -:10F9700000FA623071058105910508F456C0F30163 -:10F9800046805780608471846415750586059705E7 -:10F9900008F04EC069A77AA78BA79CA70E948AF996 -:10F9A0006DA77EA78FA798AB1AA309A32ECF80E0DF -:10F9B00090E0DC0165CF89818823A1F18C8584FDED -:10F9C00031C0E0910E01F0910F018081833041F44C -:10F9D0008D899E89A0E0B0E0DC019927882703C0CB -:10F9E00080E090E0DC014B8D5C8D60E070E0842B6A -:10F9F000952BA62BB72BF601868F978FA0A3B1A3CB -:10FA00008D8D9E8DAF8DB8A1828F938FA48FB58F72 -:10FA1000168A178A108E118E81E0818380E003C0E0 -:10FA200085E001C083E090E00CC081E090E009C077 -:10FA300083E090E006C0283009F0D9CE88E02BE0C2 -:10FA400044CFEC960FB6F894DEBF0FBECDBFDF916A -:10FA5000CF911F910F91FF90EF90DF90CF90BF90CB -:10FA6000AF909F907F906F905F904F900895A0E02F -:10FA7000B0E0EDE3FDEF0C944BFF4C016B015A013C -:10FA8000C0910E01D0910F01FA01118210822097CE -:10FA900009F4A1C0898180FFA1C08A8D9B8DAC8DA6 -:10FAA000BD8D4E895F89688D798D841B950BA60B62 -:10FAB000B70BA60160E070E084179507A607B707AB -:10FAC00008F46C013401412C32E0532EC114D104EE -:10FAD00009F47EC08E899F89A88DB98DAC01BD01C6 -:10FAE000517066277727452B462B472BD1F5FA8097 -:10FAF000FA94AC01BD0129E0769567955795479535 -:10FB00002A95D1F7F422C1F4892B8A2B8B2B29F467 -:10FB10006E8D7F8D88A199A106C06AA17BA18CA161 -:10FB20009DA10E9400FA6230710581059105A0F146 -:10FB30006AA37BA38CA39DA36AA17BA18CA19DA199 -:10FB40000E948AF9611571058105910529F1DC0191 -:10FB5000CB018F0D911DA11DB11D8EA39FA3A8A741 -:10FB6000B9A72E893F893170C201821B930B7601A0 -:10FB70008C159D0508F47C014EA15FA168A579A5AF -:10FB80008114910411F0C30102C080E090E087016C -:10FB90000E94CDFE892B21F0198281E090E020C0E7 -:10FBA0008E899F89A88DB98D8E0D9F1DA11DB11DB8 -:10FBB0008E8B9F8BA88FB98F6E0C7F1CCE18DF08A1 -:10FBC000F50180819181E80EF91EF182E0827ECFFD -:10FBD00080E090E005C085E090E002C084E090E025 -:10FBE000CDB7DEB7E0E10C9467FFFF920F931F9350 -:10FBF000CF93DF93C82FD42F152F062FF72E87FF13 -:10FC000009C040E050E0BA0187E70E94F5FD82306C -:10FC100020F5CF770E948CF88C2F0E9491F88F2DC1 -:10FC20000E9491F8802F0E9491F8812F0E9491F8F4 -:10FC30008D2F0E9491F8C03421F0C83421F487E858 -:10FC400003C085E901C081E00E9491F8CAE00E94EA -:10FC500090F887FF02C0C150D1F7CDB7DEB7E5E01D -:10FC60000C9472FFA4E0B0E0E8E3FEEF0C9454FFC4 -:10FC70000E947FF814E60E9484F81150E1F71AE020 -:10FC80000E948FF81150E1F740E050E0BA0180E4A3 -:10FC90000E94F5FD813009F07AC04AEA51E060E047 -:10FCA00070E088E40E94F5FD813051F58E010F5F10 -:10FCB0001F4F780124E0D22ED00E0E9490F8F70159 -:10FCC00081937F01DE12F9CF8B81813009F05FC013 -:10FCD0008C818A3A09F05BC090E1E92E97E2F92E17 -:10FCE00040E050E060E070E489EE0E94F5FD88237A -:10FCF00039F10E9484F8F1E0EF1AF10889F747C062 -:10FD000040E050E0BA0189EE0E94F5FD823018F023 -:10FD100011E001E402C012E009EE80E1E82E87E282 -:10FD2000F82E40E050E0BA01802F0E94F5FD8823B4 -:10FD300029F10E9484F8F1E0EF1AF10891F727C049 -:10FD400040E050E0BA018AE70E94F5FD81111FC032 -:10FD50000E9490F8F80181938F01DE12F9CF89811A -:10FD600086FD02C014E001C01CE0109310010E9447 -:10FD70008FF881E0112369F080E00BC040E052E091 -:10FD800060E070E080E50E94F5FD882371F310E0EB -:10FD9000ECCF2496E7E00C9470FFA0E0B0E0E3ED38 -:10FDA000FEEF0C9453FFD82EC92E790180911001DB -:10FDB00083FD07C089E0440F551F661F771F8A9592 -:10FDC000D1F781E50E94F5FD882319F0C1E0D0E06C -:10FDD0002BC0C0E4DCE90E9490F88F3F19F4219712 -:10FDE000D1F7F4CF8E3F91F7C2E0D2E0C01BD10B28 -:10FDF000CE19DF09E114F10419F4ED2CFC2C06C036 -:10FE00000E9490F881E0E81AF108F4CF0E9490F87F -:10FE1000F70181937F0101501109C1F70E9490F809 -:10FE20002197E1F7C0E0D0E00E948FF8CE01CDB776 -:10FE3000DEB7E8E00C946FFFA1E21A2EAA1BBB1BF1 -:10FE4000FD010DC0AA1FBB1FEE1FFF1FA217B307A6 -:10FE5000E407F50720F0A21BB30BE40BF50B661FBC -:10FE6000771F881F991F1A9469F760957095809580 -:10FE700090959B01AC01BD01CF0108950E9480FFC8 -:10FE8000A59F900DB49F900DA49F800D911D1124EE -:10FE900008952F923F924F925F926F927F928F922E -:10FEA0009F92AF92BF92CF92DF92EF92FF920F9309 -:10FEB0001F93CF93DF93CDB7DEB7CA1BDB0B0FB613 -:10FEC000F894DEBF0FBECDBF09942A8839884888D0 -:10FED0005F846E847D848C849B84AA84B984C88466 -:10FEE000DF80EE80FD800C811B81AA81B981CE0F5D -:10FEF000D11D0FB6F894DEBF0FBECDBFED01089542 -:10FF0000A29FB001B39FC001A39F700D811D11245A -:10FF1000911DB29F700D811D1124911D0895DC016A -:10FF200001C06D9341505040E0F70895F894FFCF21 -:0EFF300031323834424F4F542E42494E0000B9 -:040000031000F000F9 -:00000001FF diff --git a/bootloader_zevero_sd_m1284p_make/diskio.c b/bootloader_zevero_sd_m1284p_make/diskio.c deleted file mode 100644 index 4608c5e..0000000 --- a/bootloader_zevero_sd_m1284p_make/diskio.c +++ /dev/null @@ -1,226 +0,0 @@ -/*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014 */ -/*-----------------------------------------------------------------------*/ - -#include "pff/src/pff.h" -#include "pff/src/diskio.h" - -void init_spi (void); /* Initialize SPI port (asmfunc.S) */ -void deselect (void); /* Select MMC (asmfunc.S) */ -void select (void); /* Deselect MMC (asmfunc.S) */ -void xmit_spi (BYTE d); /* Send a byte to the MMC (asmfunc.S) */ -BYTE rcv_spi (void); /* Send a 0xFF to the MMC and get the received byte (asmfunc.S) */ -void dly_100us (void); /* Delay 100 microseconds (asmfunc.S) */ - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - -/* Definitions for MMC/SDC command */ -#define CMD0 (0x40+0) /* GO_IDLE_STATE */ -#define CMD1 (0x40+1) /* SEND_OP_COND (MMC) */ -#define ACMD41 (0xC0+41) /* SEND_OP_COND (SDC) */ -#define CMD8 (0x40+8) /* SEND_IF_COND */ -#define CMD16 (0x40+16) /* SET_BLOCKLEN */ -#define CMD17 (0x40+17) /* READ_SINGLE_BLOCK */ -#define CMD24 (0x40+24) /* WRITE_BLOCK */ -#define CMD55 (0x40+55) /* APP_CMD */ -#define CMD58 (0x40+58) /* READ_OCR */ - - -/* Card type flags (CardType) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -static -BYTE CardType; - - -/*-----------------------------------------------------------------------*/ -/* Send a command packet to MMC */ -/*-----------------------------------------------------------------------*/ - -static -BYTE send_cmd ( - BYTE cmd, /* 1st byte (Start + Index) */ - DWORD arg /* Argument (32 bits) */ -) -{ - BYTE n, res; - - - if (cmd & 0x80) { /* ACMD is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card */ - select(); - - /* Send a command packet */ - xmit_spi(cmd); /* Start + Command index */ - xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xmit_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xmit_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xmit_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */ - xmit_spi(n); - - /* Receive a command response */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do { - res = rcv_spi(); - } while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - DSTATUS stat; - - BYTE n, cmd, ty, ocr[4]; - UINT tmr; - - - init_spi(); /* Initialize ports to control MMC */ - for (n = 100; n; n--) dly_100us(); /* 10ms delay */ - for (n = 10; n; n--) deselect(); /* 80 Dummy clocks with CS=H */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2 */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - for (tmr = 10000; tmr && send_cmd(ACMD41, 1UL << 30); tmr--) dly_100us(); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (tmr && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 (HC or SC) */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - for (tmr = 10000; tmr && send_cmd(cmd, 0); tmr--) dly_100us(); /* Wait for leaving idle state */ - if (!tmr || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - stat = ty ? 0 : STA_NOINIT; - - return stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE* buff, /* Pointer to the destination object */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Offset in the sector */ - UINT count /* Byte count (bit15:destination) */ -) -{ - DRESULT res; - BYTE rc; - WORD bc; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - res = RES_ERROR; - if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */ - - bc = 40000; - do { /* Wait for data packet */ - rc = rcv_spi(); - } while (rc == 0xFF && --bc); - - if (rc == 0xFE) { /* A data packet arrived */ - bc = 514 - offset - count; - - /* Skip leading bytes */ - if (offset) { - do rcv_spi(); while (--offset); - } - - /* Receive a part of the sector */ - do { - *buff++ = rcv_spi(); - } while (--count); - - /* Skip trailing bytes and CRC */ - do rcv_spi(); while (--bc); - - res = RES_OK; - } - } - - deselect(); - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Partial Sector */ -/*-----------------------------------------------------------------------*/ -/* -DRESULT disk_writep ( - const BYTE* buff, // Pointer to the data to be written, NULL:Initiate/Finalize write operation - DWORD sc // Sector number (LBA) or Number of bytes to send -) -{ - DRESULT res; - - - if (!buff) { - if (sc) { - - // Initiate write process - - } else { - - // Finalize write process - - } - } else { - - // Send data to the disk - - } - - return res; -} -*/ diff --git a/bootloader_zevero_sd_m1284p_make/m1284p_zevero_sd_m1284p_fuses.txt b/bootloader_zevero_sd_m1284p_make/m1284p_zevero_sd_m1284p_fuses.txt deleted file mode 100644 index e50695a..0000000 --- a/bootloader_zevero_sd_m1284p_make/m1284p_zevero_sd_m1284p_fuses.txt +++ /dev/null @@ -1,29 +0,0 @@ -3) Working FUSE for M1284 (with bootloader Zevero-SD) -I.e - Arduino Bootloader to Flash from SD Card: https://github.com/zevero/avr_boot - -PS. SET FUSES: -============== - LOW = 0xFF - HIGH = 0xDA - EXTD = 0xFD -======================================== -It means: -Ext. XTAL High FREQ START-UP 16K CK + 65ms -JTAG DISABLED -BROWN-OUT 2.7V ON -BOOT-LOADER ENABLED -BOOT Flash Section Size = 2048 words; Boot Start address = 0xF800 -========================================= - -AVRDUDE arguments: --U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0xfd:m - -Full commands to write from console: -avrdude -Pusb -cavrispmkii -patmega1284p -B5 -U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0xfd:m - - -Detection avrdude CPU: B5 (5us bit clock period for programmer SPI) - VERY IMPORTANT (1Mhz CPU M1284p FREQ DEFAULT) -avrdude -Pusb -cavrispmkii -patmega1284p -B5 - -Check m1284p fuse here: -http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega1284p diff --git a/bootloader_zevero_sd_m1284p_make/main.c b/bootloader_zevero_sd_m1284p_make/main.c deleted file mode 100644 index 32a560d..0000000 --- a/bootloader_zevero_sd_m1284p_make/main.c +++ /dev/null @@ -1,259 +0,0 @@ -/*-------------------------------------------------------------------------/ -/ Stand-alone MMC boot loader R0.01 -/--------------------------------------------------------------------------/ -/ -/ Copyright (C) 2010, ChaN, all right reserved. -/ -/ * This software 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. -/ -/--------------------------------------------------------------------------/ -/ Dec 6, 2010 R0.01 First release -/--------------------------------------------------------------------------/ -/ This is a stand-alone MMC/SD boot loader for megaAVRs. It requires a 4KB -/ boot section for code, four GPIO pins for MMC/SD as shown in sch.jpg and -/ nothing else. To port the boot loader into your project, follow the -/ instruction described below. -/ -/ 1. Setup the hardware. Attach a memory card socket to the any GPIO port -/ where you like. Select boot size at least 4KB for the boot loader with -/ BOOTSZ fuses and enable boot loader with BOOTRST fuse. -/ -/ 2. Setup the software. Change the four port definitions in the asmfunc.S. -/ Change MCU_TARGET, BOOT_ADR and MCU_FREQ in the Makefile. The BOOT_ADR -/ is a BYTE address of boot section in the flash. Build the boot loader -/ and write it to the device with a programmer. -/ -/ 3. Build the application program and output it in binary form instead of -/ hex format. Rename the file "app.bin" and put it into the memory card. -/ -/ 4. Insert the card and turn the target power on. When the boot loader found -/ the application file, the file is written into the flash memory prior to -/ start the application program. On-board LED lights (if exist) during -/ the flash programming operation. -/ -/-------------------------------------------------------------------------*/ - -const char filename[13] ="1284BOOT.BIN\0"; // EDIT FILENAME HERE -#include -#include -#include -#include -#include -#include "pff/src/pff.h" -#include //Watchdog -// The following code is recommended in http://avr-libc.nongnu.org/user-manual/group__avr__watchdog.html but is disabled for now because avr_boot doesn't currently do anything with mcusr_mirror so for now we will only reset MCUSR and disable WDT. -//uint8_t mcusr_mirror __attribute__ ((section (".noinit")));void get_mcusr(void) __attribute__((naked)) __attribute__((section(".init3")));void get_mcusr(void){mcusr_mirror = MCUSR;MCUSR = 0;wdt_disable();} -void disable_watchdog(void) __attribute__((naked)) __attribute__((section(".init3"))); -void disable_watchdog(void) -{ -#if defined(MCUCSR) - MCUCSR = ~(_BV(WDRF)); //Some MCUs require the watchdog reset flag to be cleared before WDT can be disabled. & operation is skipped to spare few bytes as bits in MCUSR can only be cleared. -#else - MCUSR = ~(_BV(WDRF)); //Some MCUs require the watchdog reset flag to be cleared before WDT can be disabled. & operation is skipped to spare few bytes as bits in MCUSR can only be cleared. -#endif - wdt_disable(); //immediately disable watchdog in case it was running in the application to avoid perpetual reset loop -} - -#if BOOT_ADR > 0xFFFF - #define PGM_READ_BYTE(x) pgm_read_byte_far(x) -#else - #define PGM_READ_BYTE(x) pgm_read_byte(x) -#endif - -#if USE_UART - #include "uart/uart.h" -#endif - -#if USE_LED -void init_leds(); -void led_power_on(); -void led_power_off(); -void led_power_toggle(); -void led_write_on(); -void led_write_off(); -void led_write_toggle(); -#endif -void flash_erase (DWORD); /* Erase a flash page (asmfunc.S) */ -void flash_write (DWORD, const BYTE*); /* Program a flash page (asmfunc.S) */ - - -FATFS Fatfs; // Petit-FatFs work area -BYTE Buff[SPM_PAGESIZE]; // Page data buffer - - - -static uint8_t pagecmp(const DWORD fa, uint8_t buff[SPM_PAGESIZE]) -{ - UINT i; - uint8_t b_flash,b_buff; - for (i = 0; i < SPM_PAGESIZE; i++) { - b_flash = PGM_READ_BYTE(fa+i); - b_buff = buff[i]; - if ( b_flash != b_buff) { - #if USE_UART //output first difference - UART_puthex32(fa);UART_puts(PSTR(":")); - UART_puthex(b_flash);UART_puts(PSTR(" ")); - UART_puthex(b_buff); UART_newline(); - #endif - return 1; - } - } - #if USE_UART //output first difference - UART_puthex32(fa);UART_puts(PSTR(":")); - UART_puts(PSTR("="));UART_newline(); - #endif - return 0; -} - -void doFlash() { - DWORD fa; /* Flash address */ - UINT br; /* Bytes read */ - #if USE_LED - uint8_t i; - for(i=0;i<50;i++) { led_write_toggle();_delay_ms(100);} //Start Programming: Flash WRITE Wildly for 5 secs - #endif - - - for (fa = 0; fa < BOOT_ADR; fa += SPM_PAGESIZE) { /* Update all application pages */ - - memset(Buff, 0xFF, SPM_PAGESIZE); /* Clear buffer */ - pf_read(Buff, SPM_PAGESIZE, &br); /* Load a page data */ - - if (pagecmp(fa, Buff)) { /* Only flash if page is changed */ - #if USE_LED - led_write_off(); - //led_power_on(); - #endif - flash_erase(fa); /* Erase a page */ - flash_write(fa, Buff); /* Write it if the data is available */ - - } else { - - #if USE_LED - //led_power_off(); - led_write_on(); - #endif - } - } -} - -void checkFile() { - uint8_t fresult; - - fresult = pf_mount(&Fatfs); /* Initialize file system */ - - if (fresult != FR_OK) { /* File System could not be mounted */ - #if USE_UART - UART_puts(PSTR("File not mounted")); - UART_newline(); - #endif - - #if USE_LED - //uint8_t i; - //led_write_on(); - //for(i=0;i<2*fresult;i++) { led_power_toggle();_delay_ms(500);}//Give error number while Write led is on - //led_write_off(); - #endif - return; - } -/* - - WORD flashver = eeprom_read_word((const uint16_t *)E2END - 1); - if (flashver > 999) { - flashver = 0; - } - BYTE y, tmp; - WORD x; - BYTE found = 0; - - for (x = flashver+10; x > flashver; x--) { - y = x / 100; - filename[5] = y + 0x30; - tmp = x % 100; - - y = tmp / 10; - filename[6] = y + 0x30; - tmp = x % 10; - - filename[7] = tmp + 0x30; - - if (pf_open(filename) == FR_OK) { // File opens normally - found = 1; - doProgram(); - } - led_power_toggle(); - } - - if (found == 0) {*/ - - fresult = pf_open(filename); - - if (fresult != FR_OK) { /* File could not be opened */ - - #if USE_UART - UART_puts(PSTR("File not open")); - UART_newline(); - #endif - #if USE_LED - //uint8_t i; - //led_power_on(); - //for(i=0;i<2*fresult;i++) { led_write_toggle();_delay_ms(500);}//Give error number while Power led is on - //led_power_off(); - #endif - return; - } - - doFlash(); - - #if USE_LED - led_write_off(); - //led_power_off(); - _delay_ms(2000); - uint8_t i; - //for(i=0;i<40;i++) { led_power_toggle();_delay_ms(50);}//SUCCESS FLASH WILDLY for 2 secs - for(i=0;i<40;i++) { led_write_toggle();_delay_ms(50);}//SUCCESS FLASH WILDLY for 2 secs - #endif - -} - - - - - - -int main (void) -{ - #if USE_LED - init_leds(); - uint8_t i=0; - #endif - - #if USE_UART - UART_init(); - UART_puts(PSTR("AVR_BOOT")); - UART_newline(); - #endif - while (1) { - #if USE_LED - //led_power_on();_delay_ms(200);led_power_off(); //Test Power Led - led_write_on();_delay_ms(200);led_write_off(); //Test Write Led - #endif - - checkFile(); - - if (pgm_read_word(0) != 0xFFFF) ((void(*)(void))0)(); //EXIT BOOTLOADER - - #if USE_UART - UART_puts(PSTR("retry")); - UART_newline(); - #endif - #if USE_LED - //for(i=0;i<10;i++) { led_power_toggle();_delay_ms(200);} //SOMETHING WENT WRONG: Flash Power LED - for(i=0;i<10;i++) { led_write_toggle();_delay_ms(200);} //SOMETHING WENT WRONG: Flash Write LED - #endif - _delay_ms(5000); // Retry - } -} diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/00index_p.html b/bootloader_zevero_sd_m1284p_make/pff/doc/00index_p.html deleted file mode 100644 index 46847cd..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/00index_p.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - -Petit FAT File System Module - - - -

Petit FAT File System Module

-
- -
-layer -

Petit FatFs is a sub-set of FatFs module for tiny 8-bit microcontrollers. It is written in compliance with ANSI C and completely separated from the disk I/O layer. It can be incorporated into the tiny microcontrollers with limited memory even if the RAM size is less than sector size. Also full featured FAT file system module is available here↗.

- -

Features

-
    -
  • Very small RAM consumption (44 bytes work area + certain stack).
  • -
  • Very small code size (2K-4K bytes).
  • -
  • FAT12, FAT16 and FAT32.
  • -
  • Single volume and Single file.
  • -
  • File write function with some restrictions.
  • -
-
- - -
-

Application Interface

-

Petit FatFs module provides following functions.

- -
- - -
-

Disk I/O Interface

-

Since the Petit FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read data from storage device. The low level disk I/O module is not a part of Petit FatFs module and it must be provided by user. The sample drivers are also available in the resources.

- -
- - -
-

Resources

-

The Petit FatFs module is a free software and is opened for education, research and development. You can use, modify and/or redistribute it for personal, non-profit or commercial use without any restriction under your responsibility. For further information, refer to the application note.

- -
- - -
-

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/css_e.css b/bootloader_zevero_sd_m1284p_make/pff/doc/css_e.css deleted file mode 100644 index 2fa0cc1..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/css_e.css +++ /dev/null @@ -1,65 +0,0 @@ -* {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;} diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/css_p.css b/bootloader_zevero_sd_m1284p_make/pff/doc/css_p.css deleted file mode 100644 index f8589aa..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/css_p.css +++ /dev/null @@ -1 +0,0 @@ -body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/img/layers3.png b/bootloader_zevero_sd_m1284p_make/pff/doc/img/layers3.png deleted file mode 100644 index ac439b0..0000000 Binary files a/bootloader_zevero_sd_m1284p_make/pff/doc/img/layers3.png and /dev/null differ diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/img/rwtest3.png b/bootloader_zevero_sd_m1284p_make/pff/doc/img/rwtest3.png deleted file mode 100644 index cbaa3d1..0000000 Binary files a/bootloader_zevero_sd_m1284p_make/pff/doc/img/rwtest3.png and /dev/null differ diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/appnote.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/appnote.html deleted file mode 100644 index 3b6d6dc..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/appnote.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - -FatFs Module Application Note - - - -

Petit FatFs Module Application Note

-
- -

Basic Considerations

-

The FatFs module is assuming following conditions on portability.

-
    -
  • ANSI C
    -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.
  • -
  • Size of integer types
    -The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.
  • -
- - -
-

Memory Usage (R0.03)

- - - - - - - - - - - -
AVRx86
Compilergcc(WinAVR)VC6
_WORD_ACCESS11
Code (default)21001720
Code (!_USE_READ)-444-246
Code (_USE_DIR)+1002+420
Code (_USE_LSEEK)+490+228
Code (_USE_WRITE)+518+351
RAM (bss)24
RAM (work)4244
-

This is the size of the Petit FatFs module itself. In addition to this, a low level disk I/O module will be required for a complete function. The size of MMC/SDC module on AVR becomes approximate 620 bytes without write function and 840 bytes with write function.

-
- -
-

Module Size Reduction

-

Follwing table shows which function is removed by configuration options for the module size reduction.

- - - - - - - - - - -
Function_USE_READ_USE_DIR_USE_LSEEK_USE_WRITE
0000
pf_mount
pf_open
pf_readx
pf_lseekx
pf_opendirx
pf_readdirx
pf_writex
-
- -
-

Performance effective file access

-

For good performance on reading a file on the small embedded system, application programmer should consider what process is done in the file system module.

-

The Petit FatFs reads the disk sectors without a sector buffer. This means the file system reads a part of the sector contains the required data every reference point even if they are in the same sector. However the generic storage device are not byte addressable so that the disk I/O layer will read the entire sector and pick up the data bytes from the read data steram.

-

When read 512 byte data from a file at a time, the data sector will be read only a time. When read that data in byte-by-byte, the data sector will be read 512 times. Therefore the byte-by-byte read request will drastically decrease the read performance. To avoid this stupid read controls, the file data should be read in long block as possible. Sector alignment access is not impotant on the Petit FatFs.

-

The tiny microcontrollers targeted by Petit FatFs has a limited size of RAM. It may not able to allocate a certain size of read buffer and most type of text processing will require byte-by-byte read operation. The Petit FatFs supports data forwarding feature for such purpose.

- -
- -
-

About FatFs License

-

Petit 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 license document that included in the source files.

-
/*----------------------------------------------------------------------------/
-/  Petit FatFs - FAT file system module  R0.03                  (C)ChaN, 2014
-/-----------------------------------------------------------------------------/
-/ Petit FatFs module is a generic FAT file system module for small embedded
-/ systems. This is a free software that opened for education, research and
-/ commercial developments under license policy of following trems.
-/
-/  Copyright (C) 2014, ChaN, all right reserved.
-/
-/ * The Petit FatFs module is a free software and there is NO WARRANTY.
-/ * No restriction on use. You can use, modify and redistribute it for
-/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
-/ * Redistributions of source code must retain the above copyright notice.
-/
-/-----------------------------------------------------------------------------/
-

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 and any form without source code, are not specified in order to extend usability to commercial use. The documentation of the distributions need not include about Petit FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course Petit FatFs is compatible with the projects under GNU GPL. When redistribute the Petit FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dinit.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dinit.html deleted file mode 100644 index 6c38a23..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dinit.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - -Petit FatFs - disk_initialize - - - - -
-

disk_initialize

-

The disk_initialize function initializes the disk drive.

-
-DSTATUS disk_initialize (void)
-
-
- -
-

Return Values

-

The disk status is returned in combination of following flags.

-
-
STA_NOINIT
-
Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.
-
STA_NODISK
-
Indicates that no medium in the drive. This is always cleared on fixed disk drive. This flag is not referred by Petit FatFs.
-
-
- -
-

Description

-

The disk_initialize function initializes the storage device. If the function succeeded, STA_NOINIT flag in the return value is cleared.

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dreadp.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dreadp.html deleted file mode 100644 index 41309a4..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dreadp.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - -Petit FatFs - disk_readp - - - - -
-

disk_readp

-

The disk_readp function reads a partial sector of the device.

-
-DRESULT disk_readp (
-  BYTE* buff,    /* [OUT] Pointer to the read buffer */
-  DWORD sector,  /* [IN]  Sector number */
-  UINT offset,   /* [IN]  Byte offset in the sector to start to read */
-  UINT count     /* [IN]  Number of bytes to read */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the read buffer to store the read data. If a NULL is given, read bytes will be forwarded to the outgoing stream instead of the memory.
-
sector
-
Specifies the sector number to be read in logical block address (LBA).
-
offset
-
Specifies the byte offset in the sector to start to read. The value can be 0 to 511.
-
count
-
Specifies number of bytes to read. The value can be 0 to 512 and offset + count must not exceed 512.
-
-
- - -
-

Return Value

-
-
RES_OK (0)
-
The function succeeded.
-
RES_ERROR
-
Any hard error occured during the disk read operation and could not recover it.
-
RES_PARERR
-
Invalid parameter.
-
RES_NOTRDY
-
The device has not been initialized.
-
-
- - -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dwritep.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dwritep.html deleted file mode 100644 index 5361a5f..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/dwritep.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - -Petit FatFs - disk_writep - - - - -
-

disk_writep

-

The disk_writep function writes data to the sector.

-
-DRESULT disk_writep (
-  BYTE* buff,  /* [IN] Pointer to the data to be written */
-  DWORD sc,    /* [IN] Sector number or Number of bytes to wtite */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the data to be written to the sector. If a NULL is given, the function initiate/finalize a write transaction to the sector.
-
sc
-
Specifies nubmer of bytes to write if buff is not a NULL. If buff is a NULL and sc is not a zero, the function initiates a write transactin to the sector. If buff and sc are zero, the function finalize the current sector write transactin.
-
-
- - -
-

Return Value

-
-
RES_OK (0)
-
The function succeeded.
-
RES_ERROR
-
Any hard error occured during the write operation and could not recover it or the medium is write protected.
-
RES_PARERR
-
Invalid parameter.
-
RES_NOTRDY
-
The device has not been initialized.
-
-
- - -
-

Description

-

A sector write operation is done in following sequence.

-
    -
  1. disk_writep(0, sector_number); Initiate a sector write transaction.
  2. -
  3. disk_writep(data, byte_to_write); Start to write data to the sector.
  4. -
  5. disk_writep(data, byte_to_write); And data can be written upto 512 bytes with one or more calls.
  6. -
  7. disk_writep(data, byte_to_write); ...
  8. -
  9. disk_writep(0, 0); Finalize the write transaction. If number of bytes sent is less than 512, left bytes in the sector is filled by zero.
  10. -
-

If a write transaction is in progress, disk_readp() function will fail and disk_initialize() function finalize the current write transaction.

-
- - -
-

Remarks

-

This funciton is needed when _USE_WRITE == 1.

-
- - -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/filename.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/filename.html deleted file mode 100644 index b751cda..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/filename.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - -Petit FatFs - Path Names - - - - -
-

Format of the path names

-

The path name format on the Petit FatFs module is similer to MS-DOS as follows.

-
"[/]directory/file"
-

The Petit FatFs module supports only 8.3 format file name. The sub-directories are separated with a /. The path name is terminated with a nul character, control character or white space. Heading spaces are ignored and skipped. When _USE_LCC == 1, lower case characters are allowed for the path name.

-

The Petit FatFs module does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name following from the root directory. Heading separator is ignored and it can be exist or omitted.

-
- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/lseek.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/lseek.html deleted file mode 100644 index 2b65826..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/lseek.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - -Petit FatFs - pf_lseek - - - - -
-

pf_lseek

-

The pf_lseek function moves the file read/write pointer of the open file.

- -
-FRESULT pf_lseek (
-  DWORD ofs       /* [IN] File offset in unit of byte */
-);
-
-
- -
-

Parameters

-
-
ofs
-
Number of bytes where from start of the file
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to an error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The file has not been opened.
-
-
- - -
-

Description

-

The pf_lseek() function moves the file read/write pointer of the open file. The offset can be specified in only origin from top of the file.

-
- - -
-

Example

-
-    /* Move to offset of 5000 from top of the file */
-    res = pf_lseek(5000);
-
-    /* Forward 3000 bytes */
-    res = pf_lseek(fs.fptr + 3000);
-
-    /* Rewind 2000 bytes (take care on wraparound) */
-    res = pf_lseek(fs.fptr - 2000);
-
-
- -
-

QuickInfo

-

Available when _USE_LSEEK == 1.

-
- -
-

References

-

pf_open, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/mount.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/mount.html deleted file mode 100644 index f787cca..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/mount.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - -Petit FatFs - pf_mount - - - - -
-

pf_mount

-

The pf_mount fucntion mounts a volume.

-
-FRESULT pf_mount (
-  FATFS*  fs  /* [IN] Pointer to the work area */
-);
-
-
- -
-

Parameters

-
-
fs
-
Pointer to the work area (file system object) to be registered.
-
-
- -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_NOT_READY
-
The drive could not be initialized due to a disk error or no medium.
-
FR_DISK_ERR
-
An error occured in the disk function.
-
FR_NO_FILESYSTEM
-
There is no valid FAT partition on the disk.
-
-
- - -
-

Description

-

The pf_mount() function registers a work area to the Petit FatFs module. The volume is mounted on registration. The volume must be mounted with this function prior to any other file function and after every media changes.

-
- - -
-

QuickInfo

-

Always available.

-
- -
-

References

-

FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/open.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/open.html deleted file mode 100644 index 8deb830..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/open.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - -Petit FatFs - pf_open - - - - -
-

pf_open

-

The pf_open function opens an existing file.

-
-FRESULT pf_open (
-  const char* path  /* [IN] Pointer to the file neme */
-);
-
-
- -
-

Parameters

-
-
path
-
Pointer to a null-terminated string that specifies the file name to open.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_NO_FILE
-
Could not find the file or path.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_ENABLED
-
The volume has not been mounted.
-
-
- - -
-

Description

-

The file must be opend prior to use pf_read() and pf_lseek() function. The open file is valid until next open.

-
- - -
-

Example

-
-int main (void)
-{
-    FATFS fs;          /* Work area (file system object) for the volume */
-    BYTE buff[16];     /* File read buffer */
-    UINT br;           /* File read count */
-    FRESULT res;       /* Petit FatFs function common result code */
-
-
-    /* Mount the volume */
-    pf_mount(&fs);
-    if (res) die(res);
-
-    /* Open a file */
-    res = pf_open("srcfile.dat");
-    if (res) die(res);
-
-    /* Read data to the memory */
-    res = pf_read(buff, 16, &br);    /* Read data to the buff[] */
-    if (res) die(res);               /* Check error */
-    if (br != 16) die(255);          /* Check EOF */
-
-    ....
-
-    /* Forward data to the outgoing stream */
-    do
-        res = pf_read(0, 512, &br);  /* Send data to the stream */
-    while (res || br != 512);        /* Break on error or eof */
-
-    ....
-
-}
-
-
- -
-

QuickInfo

-

Always available.

-
- -
-

References

-

pf_read, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/opendir.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/opendir.html deleted file mode 100644 index adf7a96..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/opendir.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - -Petit FatFs - pf_opendir - - - - -
-

pf_opendir

-

The pf_opendir function opens a directory.

-
-FRESULT pf_opendir (
-  DIR* dp,          /* [OUT] Pointer to the blank directory object structure */
-  const char* path  /* [IN]  Pointer to the directory name */
-);
-
-
- -
-

Parameters

-
-
dp
-
Pointer to the blank directory object to be created.
-
path
-
Pinter to the null-terminated string that specifies the directory name to be opened.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded and the directory object is created. It is used for subsequent calls to read the directory entries.
-
FR_NO_FILE
-
Could not find the path.
-
FR_NOT_READY
-
The disk drive cannot work due to no medium in the drive or any other reason.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_ENABLED
-
The volume has no work area.
-
-
- - -
-

Description

-

The pf_opendir() function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.

-
- - -
-

QuickInfo

-

Available when _USE_DIR == 1.

-
- - -
-

References

-

f_readdir, DIR

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/read.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/read.html deleted file mode 100644 index 7118841..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/read.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - -Petit FatFs - pf_read - - - - -
-

pf_read

-

The pf_read function reads data from the file.

-
-FRESULT pf_read (
-  void* buff,  /* [OUT] Pointer to the read buffer */
-  UINT btr,    /* [IN]  Number of bytes to read */
-  UINT* br     /* [OUT] Number of bytes read */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the buffer to store the read data. A NULL specifies the destination is an outgoing stream.
-
btr
-
Number of bytes to read.
-
br
-
Pointer to the variable to return number of bytes read.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The file has not been opened.
-
FR_NOT_ENABLED
-
The volume has not been mounted.
-
-
- - -
-

Description

-

The file read/write pointer in the file system object advances in number of bytes read. After the function succeeded, *br should be checked to detect end of file. In case of *br < btr, it means the read pointer reached end of file during read operation.

-

If a NULL is given to the buff, the read bytes will be forwarded to the outgoing stream instead of the memory. The streaming function will be typically built-in the disk_readp() function.

-
- -
-

QuickInfo

-

Available when _USE_READ == 1.

-
- - -
-

References

-

pf_open, pf_write, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/readdir.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/readdir.html deleted file mode 100644 index 4ac4997..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/readdir.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - -Petit FatFs - pf_readdir - - - - -
-

pf_readdir

-

The pf_readdir function reads directory entries.

-
-FRESULT pf_readdir (
-  DIR* dp,      /* [IN]  Pointer to the open directory object */
-  FILINFO* fno  /* [OUT] Pointer to the file information structure */
-);
-
-
- -
-

Parameters

-
-
dp
-
Pointer to the open directory object.
-
fno
-
Pointer to the file information structure to store the read item.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to an error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The directory object has not been opened.
-
-
- - -
-

Description

-

The pf_readdir() function reads directory entries in sequence. All items in the directory can be read by calling this function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into member f_name[] in the file information structure without error. When a null pointer is given to the fno, the read index of the directory object will be rewinded.

-
- - -
-

Sample Code

-
-FRESULT scan_files (char* path)
-{
-    FRESULT res;
-    FILINFO fno;
-    DIR dir;
-    int i;
-
-
-    res = pf_opendir(&dir, path);
-    if (res == FR_OK) {
-        i = strlen(path);
-        for (;;) {
-            res = pf_readdir(&dir, &fno);
-            if (res != FR_OK || fno.fname[0] == 0) break;
-            if (fno.fattrib & AM_DIR) {
-                sprintf(&path[i], "/%s", fno.fname);
-                res = scan_files(path);
-                if (res != FR_OK) break;
-                path[i] = 0;
-            } else {
-                printf("%s/%s\n", path, fno.fname);
-            }
-        }
-    }
-
-    return res;
-}
-
-
- -
-

QuickInfo

-

Available when _USE_DIR == 1.

-
- -
-

References

-

pf_opendir, FILINFO, DIR

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sdir.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sdir.html deleted file mode 100644 index ee1bfbb..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sdir.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - -Petit FatFs - DIR - - - - -
-

DIR

-

The DIR structure is used for the work area to read a directory by pf_oepndir, pf_readdir function.

-
-typedef struct {
-    WORD    index;     /* Current read/write index number */
-    BYTE*   fn;        /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
-    CLUST   sclust;    /* Table start cluster (0:Static table) */
-    CLUST   clust;     /* Current cluster */
-    DWORD   sect;      /* Current sector */
-} DIR;
-
-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sfatfs.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sfatfs.html deleted file mode 100644 index f0776dc..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sfatfs.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - -Petit FatFs - FATFS - - - - -
-

FATFS

-

The FATFS structure holds dynamic work area of the logical drive and a file. It is given by application program and registerd/unregisterd to the Petit FatFs module with pf_mount function. There is no member that can be changed by application programs.

-
-typedef struct {
-    BYTE    fs_type;     /* FAT sub type */
-    BYTE    csize;       /* Number of sectors per cluster */
-    BYTE    flag;        /* File status flags */
-    BYTE    pad1;
-    WORD    n_rootdir;   /* Number of root directory entries (0 on FAT32) */
-    CLUST   n_fatent;    /* Number of FAT entries (= number of clusters + 2) */
-    DWORD   fatbase;     /* FAT start sector */
-    DWORD   dirbase;     /* Root directory start sector (Cluster# on FAT32) */
-    DWORD   database;    /* Data start sector */
-    DWORD   fptr;        /* File read/write pointer */
-    DWORD   fsize;       /* File size */
-    CLUST   org_clust;   /* File start cluster */
-    CLUST   curr_clust;  /* File current cluster */
-    DWORD   dsect;       /* File current data sector */
-} FATFS;
-
-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sfileinfo.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sfileinfo.html deleted file mode 100644 index a16ce16..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/sfileinfo.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - -Petit FatFs - FILINFO - - - - -
-

FILINFO

-

The FILINFO structure holds a file information returned by pf_readdir function.

-
-typedef struct {
-    DWORD   fsize;        /* File size */
-    WORD    fdate;        /* Last modified date */
-    WORD    ftime;        /* Last modified time */
-    BYTE    fattrib;      /* Attribute */
-    char    fname[13];    /* File name */
-} FILINFO;
-
-
- -

Members

-
-
fsize
-
Indicates size of the file in unit of byte. This is always zero when it is a directory.
-
fdate
-
Indicates the date that the file was modified or the directory was created.
-
-
bit15:9
-
Year origin from 1980 (0..127)
-
bit8:5
-
Month (1..12)
-
bit4:0
-
Day (1..31)
-
-
-
ftime
-
Indicates the time that the file was modified or the directory was created.
-
-
bit15:11
-
Hour (0..23)
-
bit10:5
-
Minute (0..59)
-
bit4:0
-
Second / 2 (0..29)
-
-
-
fattrib
-
Indicates the file/directory attribute in combination of AM_DIR, AM_RDO, AM_HID, AM_SYS and AM_ARC.
-
fname[]
-
Indicates the file/directory name in 8.3 format null-terminated string.
-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/write.html b/bootloader_zevero_sd_m1284p_make/pff/doc/pf/write.html deleted file mode 100644 index 81f3f56..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/doc/pf/write.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - -Petit FatFs - pf_write - - - - -
-

pf_write

-

The pf_write function writes data to the file.

-
-FRESULT pf_write (
-  const void* buff, /* [IN]  Pointer to the data to be written */
-  UINT btw,         /* [IN]  Number of bytes to write */
-  UINT* bw          /* [OUT] Pointer to the variable to return number of bytes written */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the data to be wtitten. A NULL specifies to finalize the current write operation.
-
btw
-
Number of bytes to write.
-
bw
-
Pointer to the variable to return number of bytes read.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, write protected, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The file has not been opened.
-
FR_NOT_ENABLED
-
The volume has not been mounted.
-
-
- - -
-

Description

-

The write function has some restrictions listed below:

-
    -
  • Cannot create file. Only existing file can be written.
  • -
  • Cannot expand file size.
  • -
  • Cannot update time stamp of the file.
  • -
  • Write operation can start/stop on the sector boundary.
  • -
  • Read-only attribute of the file cannot block write operation.
  • -
-

File write operation must be done in following sequence.

-
    -
  1. pf_lseek(ofs); read/write pointer must be moved to sector bundary prior to initiate write operation or it will be rounded-down to the sector boundary.
  2. -
  3. pf_write(buff, btw, &bw); Initiate write operation. Write first data to the file.
  4. -
  5. pf_write(buff, btw, &bw); Write next data. Any other file function cannot be used while a write operation is in progress.
  6. -
  7. pf_write(0, 0, &bw); Finalize the write operation. If read/write pointer is not on the sector boundary, left bytes in the sector will be filled with zero.
  8. -
-

The read/write pointer in the file system object advances in number of bytes written. After the function succeeded, *bw should be checked to detect end of file. In case of *bw < btw, it means the read/write pointer reached end of file during the write operation. Once a write operation is initiated, it must be finalized or the written data can be lost.

-
- -
-

QuickInfo

-

Available when _USE_WRITE == 1.

-
- -
-

References

-

pf_open, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m1284p_make/pff/src/00readme.txt b/bootloader_zevero_sd_m1284p_make/pff/src/00readme.txt deleted file mode 100644 index 974a17b..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/src/00readme.txt +++ /dev/null @@ -1,46 +0,0 @@ -Petit FatFs Module Source Files R0.03 (C)ChaN, 2014 - - -FILES - - pff.h Common include file for Petit FatFs and application module. - pff.c Petit FatFs module. - diskio.h Common include file for Petit FatFs and disk I/O module. - diskio.c Skeleton of low level disk I/O module. - integer.h Alternative type definitions for integer variables. - - Low level disk I/O module is not included in this archive because the Petit - FatFs module is only a generic file system layer and not depend on any - specific storage device. You have to provide a low level disk I/O module that - written to control your storage device. - - - -AGREEMENTS - - Petit FatFs module is an open source software to implement FAT file system to - small embedded systems. This is a free software and is opened for education, - research and commercial developments under license policy of following trems. - - Copyright (C) 2014, ChaN, all right reserved. - - * The Petit FatFs module is a free software and there is NO WARRANTY. - * No restriction on use. You can use, modify and redistribute it for - personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. - * Redistributions of source code must retain the above copyright notice. - - - -REVISION HISTORY - - Jun 15, 2009 R0.01a First release (Branched from FatFs R0.07b) - - Dec 14, 2009 R0.02 Added multiple code page support. - Added write funciton. - Changed stream read mode interface. - Dec 07,'2010 R0.02a Added some configuration options. - Fixed fails to open objects with DBCS character. - - Jun 10, 2014 R0.03 Separated out configuration options to pffconf.h. - Added _USE_LCC option. - Added _FS_FAT16 option. diff --git a/bootloader_zevero_sd_m1284p_make/pff/src/diskio.c b/bootloader_zevero_sd_m1284p_make/pff/src/diskio.c deleted file mode 100644 index 5b303b8..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/src/diskio.c +++ /dev/null @@ -1,73 +0,0 @@ -/*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014 */ -/*-----------------------------------------------------------------------*/ - -#include "diskio.h" - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - DSTATUS stat; - - // Put your code here - - return stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE* buff, /* Pointer to the destination object */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Offset in the sector */ - UINT count /* Byte count (bit15:destination) */ -) -{ - DRESULT res; - - // Put your code here - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_writep ( - BYTE* buff, /* Pointer to the data to be written, NULL:Initiate/Finalize write operation */ - DWORD sc /* Sector number (LBA) or Number of bytes to send */ -) -{ - DRESULT res; - - - if (!buff) { - if (sc) { - - // Initiate write process - - } else { - - // Finalize write process - - } - } else { - - // Send data to the disk - - } - - return res; -} - diff --git a/bootloader_zevero_sd_m1284p_make/pff/src/diskio.h b/bootloader_zevero_sd_m1284p_make/pff/src/diskio.h deleted file mode 100644 index bb75d3e..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/src/diskio.h +++ /dev/null @@ -1,42 +0,0 @@ -/*----------------------------------------------------------------------- -/ PFF - Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Function succeeded */ - RES_ERROR, /* 1: Disk error */ - RES_NOTRDY, /* 2: Not ready */ - RES_PARERR /* 3: Invalid parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - -DSTATUS disk_initialize (void); -DRESULT disk_readp (BYTE* buff, DWORD sector, UINT offser, UINT count); -DRESULT disk_writep (const BYTE* buff, DWORD sc); - -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DISKIO_DEFINED */ diff --git a/bootloader_zevero_sd_m1284p_make/pff/src/integer.h b/bootloader_zevero_sd_m1284p_make/pff/src/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/src/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/bootloader_zevero_sd_m1284p_make/pff/src/pff.c b/bootloader_zevero_sd_m1284p_make/pff/src/pff.c deleted file mode 100644 index f8f6329..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/src/pff.c +++ /dev/null @@ -1,1108 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03 (C)ChaN, 2014 -/-----------------------------------------------------------------------------/ -/ Petit FatFs module is a generic FAT file system module for small embedded -/ systems. This is a free software that opened for education, research and -/ commercial developments under license policy of following trems. -/ -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/----------------------------------------------------------------------------*/ - -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "diskio.h" /* Declarations of low level disk I/O functions */ - - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - - -#if _PFATFS != 4004 /* Revision ID */ -#error Wrong include file (pff.h). -#endif - -#if _FS_FAT32 -#if !_FS_FAT16 && !_FS_FAT12 -#define _FS_32ONLY 1 -#else -#define _FS_32ONLY 0 -#endif -#else -#if !_FS_FAT16 && !_FS_FAT12 -#error Wrong _FS_FATxx setting. -#endif -#define _FS_32ONLY 0 -#endif - -#define ABORT(err) {fs->flag = 0; return err;} - - - -/*--------------------------------------------------------*/ -/* DBCS code ranges and SBCS extend char conversion table */ -/*--------------------------------------------------------*/ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#else -#error Unknown code page. - -#endif - - - -/* Character code support macros */ - -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) - -#ifndef _EXCVT /* DBCS configuration */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* SBCS configuration */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _EXCVT */ - - -/* FatFs refers the members in the FAT structures with byte offset instead -/ of structure member because there are incompatibility of the packing option -/ between various compilers. */ - -#define BS_jmpBoot 0 -#define BS_OEMName 3 -#define BPB_BytsPerSec 11 -#define BPB_SecPerClus 13 -#define BPB_RsvdSecCnt 14 -#define BPB_NumFATs 16 -#define BPB_RootEntCnt 17 -#define BPB_TotSec16 19 -#define BPB_Media 21 -#define BPB_FATSz16 22 -#define BPB_SecPerTrk 24 -#define BPB_NumHeads 26 -#define BPB_HiddSec 28 -#define BPB_TotSec32 32 -#define BS_55AA 510 - -#define BS_DrvNum 36 -#define BS_BootSig 38 -#define BS_VolID 39 -#define BS_VolLab 43 -#define BS_FilSysType 54 - -#define BPB_FATSz32 36 -#define BPB_ExtFlags 40 -#define BPB_FSVer 42 -#define BPB_RootClus 44 -#define BPB_FSInfo 48 -#define BPB_BkBootSec 50 -#define BS_DrvNum32 64 -#define BS_BootSig32 66 -#define BS_VolID32 67 -#define BS_VolLab32 71 -#define BS_FilSysType32 82 - -#define MBR_Table 446 - -#define DIR_Name 0 -#define DIR_Attr 11 -#define DIR_NTres 12 -#define DIR_CrtTime 14 -#define DIR_CrtDate 16 -#define DIR_FstClusHI 20 -#define DIR_WrtTime 22 -#define DIR_WrtDate 24 -#define DIR_FstClusLO 26 -#define DIR_FileSize 28 - - - -/*-------------------------------------------------------------------------- - - Private Functions - ----------------------------------------------------------------------------*/ - - -static -FATFS *FatFs; /* Pointer to the file system object (logical drive) */ - - -/* Fill memory */ -static -void mem_set (void* dst, int val, int cnt) { - char *d = (char*)dst; - while (cnt--) *d++ = (char)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, int cnt) { - const char *d = (const char *)dst, *s = (const char *)src; - int r = 0; - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - -static -CLUST get_fat ( /* 1:IO error, Else:Cluster status */ - CLUST clst /* Cluster# to get the link information */ -) -{ - BYTE buf[4]; - FATFS *fs = FatFs; - - if (clst < 2 || clst >= fs->n_fatent) /* Range check */ - return 1; - - switch (fs->fs_type) { -#if _FS_FAT12 - case FS_FAT12 : { - UINT wc, bc, ofs; - - bc = (UINT)clst; bc += bc / 2; - ofs = bc % 512; bc /= 512; - if (ofs != 511) { - if (disk_readp(buf, fs->fatbase + bc, ofs, 2)) break; - } else { - if (disk_readp(buf, fs->fatbase + bc, 511, 1)) break; - if (disk_readp(buf+1, fs->fatbase + bc + 1, 0, 1)) break; - } - wc = LD_WORD(buf); - return (clst & 1) ? (wc >> 4) : (wc & 0xFFF); - } -#endif -#if _FS_FAT16 - case FS_FAT16 : - if (disk_readp(buf, fs->fatbase + clst / 256, ((UINT)clst % 256) * 2, 2)) break; - return LD_WORD(buf); -#endif -#if _FS_FAT32 - case FS_FAT32 : - if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; - return LD_DWORD(buf) & 0x0FFFFFFF; -#endif - } - - return 1; /* An error occured at the disk I/O layer */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# / Get cluster field from directory entry */ -/*-----------------------------------------------------------------------*/ - -static -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - CLUST clst /* Cluster# to be converted */ -) -{ - FATFS *fs = FatFs; - - - clst -= 2; - if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ - return (DWORD)clst * fs->csize + fs->database; -} - - -static -CLUST get_clust ( - BYTE* dir /* Pointer to directory entry */ -) -{ - FATFS *fs = FatFs; - CLUST clst = 0; - - - if (_FS_32ONLY || (_FS_FAT32 && fs->fs_type == FS_FAT32)) { - clst = LD_WORD(dir+DIR_FstClusHI); - clst <<= 16; - } - clst |= LD_WORD(dir+DIR_FstClusLO); - - return clst; -} - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Rewind directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_rewind ( - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - FATFS *fs = FatFs; - - - dj->index = 0; - clst = dj->sclust; - if (clst == 1 || clst >= fs->n_fatent) /* Check start cluster range */ - return FR_DISK_ERR; - if (_FS_FAT32 && !clst && (_FS_32ONLY || fs->fs_type == FS_FAT32)) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = (CLUST)fs->dirbase; - dj->clust = clst; /* Current cluster */ - dj->sect = (_FS_32ONLY || clst) ? clust2sect(clst) : fs->dirbase; /* Current sector */ - - return FR_OK; /* Seek succeeded */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - WORD i; - FATFS *fs = FatFs; - - - i = dj->index + 1; - if (!i || !dj->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % 16)) { /* Sector changed? */ - dj->sect++; /* Next sector */ - - if (dj->clust == 0) { /* Static table */ - if (i >= fs->n_rootdir) /* Report EOT when end of table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dj->clust); /* Get next cluster */ - if (clst <= 1) return FR_DISK_ERR; - if (clst >= fs->n_fatent) /* When it reached end of dynamic table */ - return FR_NO_FILE; /* Report EOT */ - dj->clust = clst; /* Initialize data for new cluster */ - dj->sect = clust2sect(clst); - } - } - } - - dj->index = i; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR *dj, /* Pointer to the directory object linked to the file name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE c; - - - res = dir_rewind(dj); /* Rewind directory object */ - if (res != FR_OK) return res; - - do { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; /* First character */ - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) /* Is it a valid entry? */ - break; - res = dir_next(dj); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR -static -FRESULT dir_read ( - DIR *dj, /* Pointer to the directory object to store read object name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE a, c; - - - res = FR_NO_FILE; - while (dj->sect) { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; - if (c != 0xE5 && c != '.' && !(a & AM_VOL)) /* Is it a valid entry? */ - break; - res = dir_next(dj); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dj->sect = 0; - - return res; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - - -static -FRESULT create_name ( - DIR *dj, /* Pointer to the directory object */ - const char **path /* Pointer to pointer to the segment in the path string */ -) -{ - BYTE c, ni, si, i, *sfn; - const char *p; -#if _USE_LCC -#ifdef _EXCVT - static const BYTE cvt[] = _EXCVT; -#endif -#endif - - /* Create file name in directory form */ - sfn = dj->fn; - mem_set(sfn, ' ', 11); - si = i = 0; ni = 8; - p = *path; - for (;;) { - c = p[si++]; - if (c <= ' ' || c == '/') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') break; - i = 8; ni = 11; - continue; - } -#if _USE_LCC -#ifdef _EXCVT - if (c >= 0x80) /* To upper extended char (SBCS) */ - c = cvt[c - 0x80]; -#endif - if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ - BYTE d = p[si++]; /* Get 2nd byte */ - sfn[i++] = c; - sfn[i++] = d; - } else -#endif - { /* Single byte code */ - if (_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ - sfn[i++] = c; - } - } - *path = &p[si]; /* Rerurn pointer to the next segment */ - - sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR -static -void get_fileinfo ( /* No return code */ - DIR *dj, /* Pointer to the directory object */ - BYTE *dir, /* 32-byte working buffer */ - FILINFO *fno /* Pointer to store the file information */ -) -{ - BYTE i, c; - char *p; - - - p = fno->fname; - if (dj->sect) { - for (i = 0; i < 8; i++) { /* Copy file name body */ - c = dir[i]; - if (c == ' ') break; - if (c == 0x05) c = 0xE5; - *p++ = c; - } - if (dir[8] != ' ') { /* Copy file name extension */ - *p++ = '.'; - for (i = 8; i < 11; i++) { - c = dir[i]; - if (c == ' ') break; - *p++ = c; - } - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir+DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir+DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir+DIR_WrtTime); /* Time */ - } - *p = 0; -} -#endif /* _USE_DIR */ - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR *dj, /* Directory object to return last directory and found object */ - BYTE *dir, /* 32-byte working buffer */ - const char *path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - - - while (*path == ' ') path++; /* Strip leading spaces */ - if (*path == '/') path++; /* Strip heading separator if exist */ - dj->sclust = 0; /* Set start directory (always root dir) */ - - if ((BYTE)*path < ' ') { /* Null path means the root directory */ - res = dir_rewind(dj); - dir[0] = 0; - - } else { /* Follow path */ - for (;;) { - res = create_name(dj, &path); /* Get a segment */ - if (res != FR_OK) break; - res = dir_find(dj, dir); /* Find it */ - if (res != FR_OK) break; /* Could not find the object */ - if (dj->fn[11]) break; /* Last segment match. Function completed. */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ - res = FR_NO_FILE; break; - } - dj->sclust = get_clust(dir); /* Follow next */ - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check a sector if it is an FAT boot record */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ - BYTE *buf, /* Working buffer */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - if (disk_readp(buf, sect, 510, 2)) /* Read the boot record */ - return 3; - if (LD_WORD(buf) != 0xAA55) /* Check record signature */ - return 2; - - if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && LD_WORD(buf) == 0x4146) /* Check FAT12/16 */ - return 0; - if (_FS_FAT32 && !disk_readp(buf, sect, BS_FilSysType32, 2) && LD_WORD(buf) == 0x4146) /* Check FAT32 */ - return 0; - return 1; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Locical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_mount ( - FATFS *fs /* Pointer to new file system object */ -) -{ - BYTE fmt, buf[36]; - DWORD bsect, fsize, tsect, mclst; - - - FatFs = 0; - - if (disk_initialize() & STA_NOINIT) /* Check if the drive is ready or not */ - return FR_NOT_READY; - - /* Search FAT partition on the drive */ - bsect = 0; - fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ - if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ - /* Check a partition listed in top of the partition table */ - if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ - fmt = 3; - } else { - if (buf[4]) { /* Is the partition existing? */ - bsect = LD_DWORD(&buf[8]); /* Partition offset in LBA */ - fmt = check_fs(buf, bsect); /* Check the partition */ - } - } - } - if (fmt == 3) return FR_DISK_ERR; - if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ - - /* Initialize the file system object */ - if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; - - fsize = LD_WORD(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ - if (!fsize) fsize = LD_DWORD(buf+BPB_FATSz32-13); - - fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ - fs->fatbase = bsect + LD_WORD(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ - fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ - fs->n_rootdir = LD_WORD(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ - tsect = LD_WORD(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ - if (!tsect) tsect = LD_DWORD(buf+BPB_TotSec32-13); - mclst = (tsect /* Last cluster# + 1 */ - - LD_WORD(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 - ) / fs->csize + 2; - fs->n_fatent = (CLUST)mclst; - - fmt = 0; /* Determine the FAT sub type */ - if (_FS_FAT12 && mclst < 0xFF7) - fmt = FS_FAT12; - if (_FS_FAT16 && mclst >= 0xFF8 && mclst < 0xFFF7) - fmt = FS_FAT16; - if (_FS_FAT32 && mclst >= 0xFFF7) - fmt = FS_FAT32; - if (!fmt) return FR_NO_FILESYSTEM; - fs->fs_type = fmt; - - if (_FS_32ONLY || (_FS_FAT32 && fmt == FS_FAT32)) - fs->dirbase = LD_DWORD(buf+(BPB_RootClus-13)); /* Root directory start cluster */ - else - fs->dirbase = fs->fatbase + fsize; /* Root directory start sector (lba) */ - fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ - - fs->flag = 0; - FatFs = fs; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_open ( - const char *path /* Pointer to the file name */ -) -{ - FRESULT res; - DIR dj; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - - fs->flag = 0; - dj.fn = sp; - res = follow_path(&dj, dir, path); /* Follow the file path */ - if (res != FR_OK) return res; /* Follow failed */ - if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) /* It is a directory */ - return FR_NO_FILE; - - fs->org_clust = get_clust(dir); /* File start cluster */ - fs->fsize = LD_DWORD(dir+DIR_FileSize); /* File size */ - fs->fptr = 0; /* File pointer */ - fs->flag = FA_OPENED; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ -#if _USE_READ - -FRESULT pf_read ( - void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - DRESULT dr; - CLUST clst; - DWORD sect, remain; - UINT rcnt; - BYTE cs, *rbuff = buff; - FATFS *fs = FatFs; - - - *br = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - remain = fs->fsize - fs->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - while (btr) { /* Repeat until all data transferred */ - if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) /* On the top of the file? */ - clst = fs->org_clust; - else - clst = get_fat(fs->curr_clust); - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - } - rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; - dr = disk_readp(!buff ? 0 : rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); - if (dr) ABORT(FR_DISK_ERR); - fs->fptr += rcnt; rbuff += rcnt; /* Update pointers and counters */ - btr -= rcnt; *br += rcnt; - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ -#if _USE_WRITE - -FRESULT pf_write ( - const void* buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write (0:Finalize the current write operation) */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - CLUST clst; - DWORD sect, remain; - const BYTE *p = buff; - BYTE cs; - UINT wcnt; - FATFS *fs = FatFs; - - - *bw = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - if (!btw) { /* Finalize request */ - if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); - fs->flag &= ~FA__WIP; - return FR_OK; - } else { /* Write data request */ - if (!(fs->flag & FA__WIP)) /* Round-down fptr to the sector boundary */ - fs->fptr &= 0xFFFFFE00; - } - remain = fs->fsize - fs->fptr; - if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ - - while (btw) { /* Repeat until all data transferred */ - if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) /* On the top of the file? */ - clst = fs->org_clust; - else - clst = get_fat(fs->curr_clust); - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ - fs->flag |= FA__WIP; - } - wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ - if (wcnt > btw) wcnt = btw; - if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ - fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ - btw -= wcnt; *bw += wcnt; - if ((UINT)fs->fptr % 512 == 0) { - if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ - fs->flag &= ~FA__WIP; - } - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ -#if _USE_LSEEK - -FRESULT pf_lseek ( - DWORD ofs /* File pointer from top of file */ -) -{ - CLUST clst; - DWORD bcs, sect, ifptr; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ - ifptr = fs->fptr; - fs->fptr = 0; - if (ofs > 0) { - bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fs->fptr; - clst = fs->curr_clust; - } else { /* When seek to back cluster, */ - clst = fs->org_clust; /* start from the first cluster */ - fs->curr_clust = clst; - } - while (ofs > bcs) { /* Cluster following loop */ - clst = get_fat(clst); /* Follow cluster chain */ - if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; - fs->fptr += bcs; - ofs -= bcs; - } - fs->fptr += ofs; - sect = clust2sect(clst); /* Current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directroy Object */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR - -FRESULT pf_opendir ( - DIR *dj, /* Pointer to directory object to create */ - const char *path /* Pointer to the directory path */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - res = follow_path(dj, dir, path); /* Follow the path to the directory */ - if (res == FR_OK) { /* Follow completed */ - if (dir[0]) { /* It is not the root dir */ - if (dir[DIR_Attr] & AM_DIR) /* The object is a directory */ - dj->sclust = get_clust(dir); - else /* The object is not a directory */ - res = FR_NO_FILE; - } - if (res == FR_OK) - res = dir_rewind(dj); /* Rewind dir */ - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entry in Sequense */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_readdir ( - DIR *dj, /* Pointer to the open directory object */ - FILINFO *fno /* Pointer to file information to return */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - if (!fno) { - res = dir_rewind(dj); - } else { - res = dir_read(dj, dir); /* Get current directory item */ - if (res == FR_NO_FILE) res = FR_OK; - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dj, dir, fno); /* Get the object information */ - res = dir_next(dj); /* Increment read index for next */ - if (res == FR_NO_FILE) res = FR_OK; - } - } - } - - return res; -} - -#endif /* _USE_DIR */ - diff --git a/bootloader_zevero_sd_m1284p_make/pff/src/pff.h b/bootloader_zevero_sd_m1284p_make/pff/src/pff.h deleted file mode 100644 index 76157d0..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/src/pff.h +++ /dev/null @@ -1,159 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module include file R0.03 (C)ChaN, 2014 -/----------------------------------------------------------------------------/ -/ Petit FatFs module is an open source software to implement FAT file system to -/ small embedded systems. This is a free software and is opened for education, -/ research and commercial developments under license policy of following trems. -/ -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/----------------------------------------------------------------------------*/ - -#ifndef _PFATFS -#define _PFATFS 4004 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" -#include "pffconf.h" - -#if _PFATFS != _PFFCONF -#error Wrong configuration file (pffconf.h). -#endif - -#if _FS_FAT32 -#define CLUST DWORD -#else -#define CLUST WORD -#endif - - -/* File system object structure */ - -typedef struct { - BYTE fs_type; /* FAT sub type */ - BYTE flag; /* File status flags */ - BYTE csize; /* Number of sectors per cluster */ - BYTE pad1; - WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */ - CLUST n_fatent; /* Number of FAT entries (= number of clusters + 2) */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */ - DWORD database; /* Data start sector */ - DWORD fptr; /* File R/W pointer */ - DWORD fsize; /* File size */ - CLUST org_clust; /* File start cluster */ - CLUST curr_clust; /* File current cluster */ - DWORD dsect; /* File current data sector */ -} FATFS; - - - -/* Directory object structure */ - -typedef struct { - WORD index; /* Current read/write index number */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ - CLUST sclust; /* Table start cluster (0:Static table) */ - CLUST clust; /* Current cluster */ - DWORD sect; /* Current sector */ -} DIR; - - - -/* File status structure */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - char fname[13]; /* File name */ -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* 0 */ - FR_DISK_ERR, /* 1 */ - FR_NOT_READY, /* 2 */ - FR_NO_FILE, /* 3 */ - FR_NOT_OPENED, /* 4 */ - FR_NOT_ENABLED, /* 5 */ - FR_NO_FILESYSTEM /* 6 */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* Petit FatFs module application interface */ - -FRESULT pf_mount (FATFS* fs); /* Mount/Unmount a logical drive */ -FRESULT pf_open (const char* path); /* Open a file */ -FRESULT pf_read (void* buff, UINT btr, UINT* br); /* Read data from the open file */ -FRESULT pf_write (const void* buff, UINT btw, UINT* bw); /* Write data to the open file */ -FRESULT pf_lseek (DWORD ofs); /* Move file pointer of the open file */ -FRESULT pf_opendir (DIR* dj, const char* path); /* Open a directory */ -FRESULT pf_readdir (DIR* dj, FILINFO* fno); /* Read a directory item from the open directory */ - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - -/* File status flag (FATFS.flag) */ - -#define FA_OPENED 0x01 -#define FA_WPRT 0x02 -#define FA__WIP 0x40 - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* _PFATFS */ diff --git a/bootloader_zevero_sd_m1284p_make/pff/src/pffconf.h b/bootloader_zevero_sd_m1284p_make/pff/src/pffconf.h deleted file mode 100644 index d6b984e..0000000 --- a/bootloader_zevero_sd_m1284p_make/pff/src/pffconf.h +++ /dev/null @@ -1,89 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - Configuration file R0.03 (C)ChaN, 2014 -/---------------------------------------------------------------------------*/ - -#ifndef _PFFCONF -#define _PFFCONF 4004 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Function Configurations -/---------------------------------------------------------------------------*/ - -#define _USE_READ 1 /* Enable pf_read() function */ -#define _USE_DIR 0 /* Enable pf_opendir() and pf_readdir() function */ -#define _USE_LSEEK 0 /* Enable pf_lseek() function */ -#define _USE_WRITE 0 /* Enable pf_write() function */ - -#define _FS_FAT12 0 /* Enable FAT12 */ -#define _FS_FAT16 1 /* Enable FAT16 */ -#define _FS_FAT32 1 /* Enable FAT32 */ - - -/*---------------------------------------------------------------------------/ -/ Locale and Namespace Configurations -/---------------------------------------------------------------------------*/ - -#define _USE_LCC 0 /* Allow lower case characters for path name */ - -#define _CODE_PAGE 437 -/* The _CODE_PAGE specifies the code page to be used on the target system. -/ SBCS code pages with _USE_LCC == 1 requiers a 128 byte of case conversion -/ table. This might occupy RAM on some platforms, e.g. avr-gcc. -/ When _USE_LCC == 0, _CODE_PAGE has no effect. -/ -/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows) -/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows) -/ 949 - Korean (DBCS, OEM, Windows) -/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows) -/ 1250 - Central Europe (Windows) -/ 1251 - Cyrillic (Windows) -/ 1252 - Latin 1 (Windows) -/ 1253 - Greek (Windows) -/ 1254 - Turkish (Windows) -/ 1255 - Hebrew (Windows) -/ 1256 - Arabic (Windows) -/ 1257 - Baltic (Windows) -/ 1258 - Vietnam (OEM, Windows) -/ 437 - U.S. (OEM) -/ 720 - Arabic (OEM) -/ 737 - Greek (OEM) -/ 775 - Baltic (OEM) -/ 850 - Multilingual Latin 1 (OEM) -/ 858 - Multilingual Latin 1 + Euro (OEM) -/ 852 - Latin 2 (OEM) -/ 855 - Cyrillic (OEM) -/ 866 - Russian (OEM) -/ 857 - Turkish (OEM) -/ 862 - Hebrew (OEM) -/ 874 - Thai (OEM, Windows) -*/ - - -/*---------------------------------------------------------------------------/ -/ System Configurations -/---------------------------------------------------------------------------*/ - -#define _WORD_ACCESS 1 -/* The _WORD_ACCESS option is an only platform dependent option. It defines -/ which access method is used to the word data on the FAT volume. -/ -/ 0: Byte-by-byte access. Always compatible with all platforms. -/ 1: Word access. Do not choose this unless under both the following conditions. -/ -/ * Address misaligned memory access is always allowed for ALL instructions. -/ * Byte order on the memory is little-endian. -/ -/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and -/ reduce code size. Following table shows an example of some processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 RX600(LE) 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(BE) 0 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 x86 0/1 -*/ - -#endif /* _PFFCONF */ diff --git a/bootloader_zevero_sd_m1284p_make/spi_pins.h b/bootloader_zevero_sd_m1284p_make/spi_pins.h deleted file mode 100644 index bda946b..0000000 --- a/bootloader_zevero_sd_m1284p_make/spi_pins.h +++ /dev/null @@ -1,76 +0,0 @@ -// MOSI, MISO, and SCK pin definitions for all standard ATmega microcontrollers -#ifndef SPI_PINS_H -#define SPI_PINS_H - -#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega64A__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega128A__) || \ -defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \ -defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) || \ -defined(__AVR_ATmega165__) || defined(__AVR_ATmega165A__) || defined(__AVR_ATmega165P__) || defined(__AVR_ATmega165PA__) || defined(__AVR_ATmega325__) ||defined(__AVR_ATmega325A__) || defined(__AVR_ATmega325P__) || defined(__AVR_ATmega325PA__) || defined(__AVR_ATmega645__) || defined(__AVR_ATmega645A__) || defined(__AVR_ATmega645P__) || \ -defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3250A__) || defined(__AVR_ATmega3250P__) || defined(__AVR_ATmega3250PA__) || defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6450A__) || defined(__AVR_ATmega6450P__) || \ -defined(__AVR_ATmega169__) || defined(__AVR_ATmega169A__) || defined(__AVR_ATmega169P__) || defined(__AVR_ATmega169PA__) || defined(__AVR_ATmega329__) || defined(__AVR_ATmega329A__) || defined(__AVR_ATmega329P__) || defined(__AVR_ATmega329PA__) || defined(__AVR_ATmega3290__) || defined(__AVR_ATmega3290A__) || defined(__AVR_ATmega3290P__) || defined(__AVR_ATmega3290PA__) || defined(__AVR_ATmega649__) || defined(__AVR_ATmega649A__) || defined(__AVR_ATmega649P__) || defined(__AVR_ATmega6490__) || defined(__AVR_ATmega6490A__) || defined(__AVR_ATmega6490P__) || \ -defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U6__) || \ -defined(__AVR_AT90CAN32__ ) || defined(__AVR_AT90CAN64__ ) || defined(__AVR_AT90CAN128__ ) || \ -defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 2 //MMC DI MOSI pin (DDR, PORT) -#define PORT_DI _SFR_IO_ADDR(PORTB), 2 - -#define PIN_DO _SFR_IO_ADDR(PINB), 3 //MMC DO MISO pin (PIN, PORT) -#define PORT_DO _SFR_IO_ADDR(PORTB), 3 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 1 //MMC SCK pin (DDR, PORT) -#define PORT_CK _SFR_IO_ADDR(PORTB), 1 - - -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega8A__) || defined(__AVR_ATmega48__) || defined(__AVR_ATmega48A__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega48PA__) || defined(__AVR_ATmega48PB__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega88A__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega88PA__) || defined(__AVR_ATmega88PB__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168A__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega168PA__) || defined(__AVR_ATmega168PB__) ||defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328PB__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 3 -#define PORT_DI _SFR_IO_ADDR(PORTB), 3 - -#define PIN_DO _SFR_IO_ADDR(PINB), 4 -#define PORT_DO _SFR_IO_ADDR(PORTB), 4 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 5 -#define PORT_CK _SFR_IO_ADDR(PORTB), 5 - - -#elif defined(__AVR_ATmega16__) || defined(__AVR_ATmega16A__) || defined(__AVR_ATmega32__) || defined(__AVR_ATmega32A__) || \ -defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__) || defined(__AVR_ATmega163__) || \ -defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__) || defined(__AVR_ATmega164PA__) || defined(__AVR_ATmega323__) || defined(__AVR_ATmega324A__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega324PB__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || \ -defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 5 -#define PORT_DI _SFR_IO_ADDR(PORTB), 5 - -#define PIN_DO _SFR_IO_ADDR(PINB), 6 -#define PORT_DO _SFR_IO_ADDR(PORTB), 6 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 7 -#define PORT_CK _SFR_IO_ADDR(PORTB), 7 - - -#elif defined(__AVR_ATmega16M1__) || defined(__AVR_ATmega32M1__) || defined(__AVR_ATmega64M1__) || defined(__AVR_ATmega32C1__) || defined(__AVR_ATmega64C1__) || \ -defined(__AVR_AT90PWM1__) || defined(__AVR_AT90PWM2__) || defined(__AVR_AT90PWM2B__) || defined(__AVR_AT90PWM3__) || defined(__AVR_AT90PWM3B__) || defined(__AVR_AT90PWM216__) || defined(__AVR_AT90PWM316__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 1 -#define PORT_DI _SFR_IO_ADDR(PORTB), 1 - -#define PIN_DO _SFR_IO_ADDR(PINB), 0 -#define PORT_DO _SFR_IO_ADDR(PORTB), 0 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 7 -#define PORT_CK _SFR_IO_ADDR(PORTB), 7 - - -#elif defined(__AVR_AT90PWM81__) || defined(__AVR_AT90PWM161__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 4 -#define PORT_DI _SFR_IO_ADDR(PORTB), 4 - -#define PIN_DO _SFR_IO_ADDR(PINB), 6 -#define PORT_DO _SFR_IO_ADDR(PORTB), 6 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 5 -#define PORT_CK _SFR_IO_ADDR(PORTB), 5 - - -#else -#error SPI pins not defined for your processor. You must modify spi_pins.h -#endif - -#endif //SPI_PINS_H diff --git a/bootloader_zevero_sd_m1284p_make/uart/uart.c b/bootloader_zevero_sd_m1284p_make/uart/uart.c deleted file mode 100644 index 12f9956..0000000 --- a/bootloader_zevero_sd_m1284p_make/uart/uart.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -** This is a simple set of UART routines for debug purposes -** It's Tx only and the baud rate is fixed (see UART_init) -*/ - -#include "uart.h" -#define UCSRA UCSR0A -#define UCSRB UCSR0B -#define UCSRC UCSR0C -#define UBRRH UBRR0H -#define UBRRL UBRR0L -#define UDRE UDRE0 -#define UDR UDR0 -#define RXC RXC0 - -#if BOOT_ADR > 0xFFFF - #define PGM_READ_BYTE(x) pgm_read_byte_far(x) -#else - #define PGM_READ_BYTE(x) pgm_read_byte(x) -#endif - -// Just enable the UART Tx and set baud rate for 38400 on 3.6864MHz (STK500) - -void UART_init(void) { - UCSRB = (1 << TXEN0); - UBRRL = USE_UART; // SEE HERE: http://wormfood.net/avrbaudcalc.php -} - -// The classic Tx one character routine -void UART_put(uint8_t c) { - while (!(UCSRA & (1 << UDRE))); - UDR = c; -} - -// classic Tx a C-string routine -// As there is no .data (in the bootloader) it only makes sense for theis to use PSTR() -void UART_puts(const char * str) { - char c; - do { - c = PGM_READ_BYTE(str++); - if (c) { - UART_put(c); - } - } while (c != 0); -} - -// Just outputs "\r\n" -void UART_newline(void){ - UART_put('\r'); - UART_put('\n'); -} - -// used in printing a 2 digit hex number, outputs one of the two nibbles -// the parameter is expected to be 0..F -void UART_putnibble(uint8_t c) { - if (c < 10) { - UART_put('0' + c); - } - else { - UART_put('A' + c - 10); - } -} - -// print both nibbles of an 8 bit hex number -void UART_puthex(uint8_t c) { - UART_putnibble(c >> 4); - UART_putnibble(c & 0x0F); -} - -// print both bytes of a 16 bit hex number -void UART_puthex16(uint16_t n) { - UART_puthex(n >> 8); - UART_puthex(n & 0xFF); -} -// print both bytes of a 32 bit hex number -void UART_puthex32(uint32_t n) { - UART_puthex(n >> 24); - UART_puthex(n >> 16 & 0xFF); - UART_puthex(n >> 8 & 0xFF); - UART_puthex(n & 0xFF); -} - -// this expect the first parameter to be a string in dlash (that is PSTR()) -// and then the second to be a value to print out in hex. typically used in -// the form UART_putsP(PSTR("SecPerClus = "), SecPerClus) -void UART_putsP(const char * str, uint16_t n) { - UART_puts(str); - UART_puthex16(n); - UART_newline(); -} - -// dump the 512 bytes at the given address in the form: -// CD BF 10 E0 A0 E6 B0 E0 E4 E5 F0 E0 02 C0 05 90 Ϳ ������� � � -void UART_dumpsector(uint8_t * Buff) { - for (uint16_t i=0; i<512; i++) { - if ((i % 16) == 0) { - UART_put(' '); - for(uint16_t j=(i -16); j<=i; j++) { - UART_put(((Buff[j]>=(uint8_t)32) && (Buff[j]<(uint8_t)127)) ? Buff[j] : '.'); - } - UART_newline(); - } - UART_puthex(Buff[i]); - UART_put(' '); - } - UART_newline(); -} diff --git a/bootloader_zevero_sd_m1284p_make/uart/uart.h b/bootloader_zevero_sd_m1284p_make/uart/uart.h deleted file mode 100644 index 015783e..0000000 --- a/bootloader_zevero_sd_m1284p_make/uart/uart.h +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -/* -** This is a simple set of UART routines for debug purposes -** It's Tx only and the baud rate is fixed (see UART_init) -*/ - -// Just enable the UART Tx and set baud rate for 38400 on 3.6864MHz (STK500) -void UART_init(void); -// The classic Tx one character routine -void UART_put(uint8_t c); -// classic Tx a C-string routine (string in PROGMEM) -void UART_puts(const char * str); -// this expect the first parameter to be a string in dlash (that is PSTR()) -// and then the second to be a value to print out in hex. typically used in -// the form UART_putsP(PSTR("SecPerClus = "), SecPerClus) -void UART_putsP(const char * str, uint16_t n); -// Just outputs "\r\n" -void UART_newline(void); -// used in printing a 2 digit hex number, outputs one of the two nibbles -// the parameter is expected to be 0..F -void UART_putnibble(uint8_t c); -// print both nibbles of an 8 bit hex number -void UART_puthex(uint8_t c); -// print both bytes of a 16 bit hex number -void UART_puthex16(uint16_t n); -// print both bytes of a 32 bit hex number -void UART_puthex32(uint32_t n); -// dump the 512 bytes at the given address in the form: -// CD BF 10 E0 A0 E6 B0 E0 E4 E5 F0 E0 02 C0 05 90 Ϳ ������� � � -void UART_dumpsector(uint8_t * Buff); diff --git a/bootloader_zevero_sd_m644p_make/.cproject b/bootloader_zevero_sd_m644p_make/.cproject deleted file mode 100644 index d50f016..0000000 --- a/bootloader_zevero_sd_m644p_make/.cproject +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - - program - true - true - true - - - - - - - - - - diff --git a/bootloader_zevero_sd_m644p_make/.gitignore b/bootloader_zevero_sd_m644p_make/.gitignore deleted file mode 100644 index 3c2fcf6..0000000 --- a/bootloader_zevero_sd_m644p_make/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -*.o -*.eps -*.bak -*.a -*.bin -*.elf -*.hex -*.lst -*.map -/nbproject \ No newline at end of file diff --git a/bootloader_zevero_sd_m644p_make/.project b/bootloader_zevero_sd_m644p_make/.project deleted file mode 100644 index faafa10..0000000 --- a/bootloader_zevero_sd_m644p_make/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - bootloader_zevero_sd_m644p_make - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - diff --git a/bootloader_zevero_sd_m644p_make/LICENSE b/bootloader_zevero_sd_m644p_make/LICENSE deleted file mode 100644 index 0c0bbe3..0000000 --- a/bootloader_zevero_sd_m644p_make/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2015, zevero -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* 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. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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. - diff --git a/bootloader_zevero_sd_m644p_make/Makefile b/bootloader_zevero_sd_m644p_make/Makefile deleted file mode 100644 index a87bb6c..0000000 --- a/bootloader_zevero_sd_m644p_make/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -#------------------------------------------------------------------ -# Makefile for stand-alone MMC boot strap loader -#------------------------------------------------------------------ -# Change these defs for the target device - -MCU_TARGET = atmega644p # Target device to be used (32K or larger) -BOOT_ADR = 0xF000 # Boot loader start address [byte] NOT [word] as in http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega644p -F_CPU = 16000000 # CPU clock frequency [Hz] NOT critical: it just should be higher than the actual Hz -SD_CS_PORT = PORTB # Data Register of the SD CS pin -SD_CS_DDR = DDRB # Data Direction Register of the SD CS pin -SD_CS_BIT = 0 # Bit of the SD CS pin -USE_LED = 1 # Debug with two (defined in asmfunc.S) -USE_UART = 0 # Debug on Serial. 0 ... deactivate or divider of http://wormfood.net/avrbaudcalc.php for baud rate! -#------------------------------------------------------------------ -ifeq ($(strip $(USE_UART)),0) -CSRC = main.c pff/src/pff.c diskio.c -else -CSRC = main.c pff/src/pff.c diskio.c uart/uart.c -endif - -TARGET = bootloader_zevero_sd_m644p -ASRC = asmfunc.S -OPTIMIZE = -Os -mcall-prologues -ffunction-sections -fdata-sections -DEFS = -DBOOT_ADR=$(BOOT_ADR) -DF_CPU=$(F_CPU) -DUSE_LED=$(USE_LED) -DUSE_UART=$(USE_UART) -DSD_CS_PORT=$(SD_CS_PORT) -DSD_CS_DDR=$(SD_CS_DDR) -DSD_CS_BIT=$(SD_CS_BIT) -LIBS = -DEBUG = dwarf-2 - -ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs $(DEFS) -ALL_ASFLAGS = -mmcu=$(MCU_TARGET) -I. -x assembler-with-cpp $(ASFLAGS) -CFLAGS = -g$(DEBUG) -Wall $(OPTIMIZE) $(ADDED_CFLAGS) -mmcu=$(MCU_TARGET) -std=c99 $(DEFS) -LDFLAGS = -Wl,-Map,$(TARGET).map -Wl,--gc-sections -Wl,--section-start,.text=$(BOOT_ADR) -OBJ = $(CSRC:.c=.o) $(ASRC:.S=.o) - -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size - - -all: clean $(TARGET).elf lst text bin size - -$(TARGET).elf: $(OBJ) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) - -clean: - rm -rf *.o $(TARGET).elf *.eps *.bak *.a *.bin - rm -rf pff/src/*.o uart/*.o - rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) - rm -rf $(TARGET).hex - -size: $(TARGET).elf - $(SIZE) -C --mcu=$(MCU_TARGET) $(TARGET).elf - -lst: $(TARGET).lst -%.lst: %.elf - $(OBJDUMP) -h -S $< > $@ - -%.o : %.S - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - -text: $(TARGET).hex -%.hex: %.elf - $(OBJCOPY) -j .text -j .data -j .fuse -O ihex $< $@ -# --- make bin just to check size :) -bin: $(TARGET).bin -%.bin: %.hex - $(OBJCOPY) -I ihex -O binary $< $@ - -print-% : ; @echo $* = $($*) #test any var with make print-XXX - diff --git a/bootloader_zevero_sd_m644p_make/README.md b/bootloader_zevero_sd_m644p_make/README.md deleted file mode 100644 index dd2b29a..0000000 --- a/bootloader_zevero_sd_m644p_make/README.md +++ /dev/null @@ -1,86 +0,0 @@ -avr_boot -======== - -SD card bootloader for atmega processors - -As easy as it can get! I spent days with this. Hopefully you wont! - -- for any ATMega with 4096kb Bootloader -- uses Petit FatFs R0.03 for FAT12, FAT16, FAT32 -- looks for FIRMWARE.BIN and flashes it nearly instantly -- without any interference to your application -- no CRC Check and no version bytes in EEPROM (see KISS) - -### Boards Manager installation - -avr_boot is integrated in Arduino IDE version 1.6.4 or greater!!! [See here for instructions.](https://github.com/zevero/avr_boot/tree/gh-pages) - -### Manual installation - -This is with avr-gcc and avrdude under linux with an Atmega1284p and AVRISP mkII! Adaption to your case (WinAvr, another Atmega, another flash-tool) will not be complicated... - -- adapt Makefile - - MCU_TARGET: Your atmegaXXX - - BOOT_ADR: in bytes not words! - - F_CPU: CPU Frequency (not critical. A higher value will work as well) - - SD_CS_PORT: Data Register of the SD CS pin(see the datasheet for your microcontroller) - - SD_CS_DDR: Data Direction Register of the SD CS pin - - SD_CS_BIT: Bit of the SD CS pin - - USE_LED: For debugging 0...deactivate or 1...active - - USE_UART: For debugging 0...deactivate or divider (UBRR) for baudate see http://wormfood.net/avrbaudcalc.php -- update spi_pins.h with the SPI pins of your microcontroller if not already defined -- if using USE_LED adapt LED-pins in asmfunc.S -- if you want to add FAT12 adapt pff/src/pffconfh.h (default ist FAT16 + FAT32) -- if you want to support lower case filenames adapt pff/src/pffconfh.h (default is uppercase) -- if you prefer another filename instead of FIRMWARE.BIN adapt main.c -- make (you may need to do "sudo apt-get install avr-libc gcc-avr") -- set fuses: avrdude -c avrispmkII -p m1284p -U hfuse:w:0xda:m - - find high fuse in http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega1284p -- flash: avrdude -c avrispmkII -p m1284p -Uflash:w:./avr_boot.hex:i -Ulock:w:0x3F:m - -### Put your sketch on SD card - -- in Arduino IDE go to File > Preferences and check "Show verbose output during compiliation" -- compile sketch and find the location of your /tmp/buildxxx/sketch.cpp.hex -- make bin file: avr-objcopy -I ihex -O binary sketch.cpp.hex FIRMWARE.BIN -- copy the file into the root of an SD (FAT16/FAT32) -- put it into the SD slot of your ATmega -- reset it -- it might already have happend! - -### Bootloader sizes -Compiled under linux for atmega328p / atmega1284p - - 3674 / 3724 bytes - - 3984 / 4034 bytes debugging with USE_LED - - 3992 / 4052 bytes debugging with USE_UART - -### Tested successfully on - - ATmega168 - - ATmega328P - - ATmega32u4 - - ATmega1284P - - ATmega2560 (see issue #2) - -### Serial support - Help wanted -it should not be impossible to fit a normal serial bootloader (with automatic baudrate detection?) into the remaining bytes ... help is appreciated! - -### KISS -If you wish you *can* add CRC Check or versioning with EEPROM *but* I prefere to keep things simple. avr_boot will reflash your FIRMWARE.BIN as long as it is present. -Is this a problem? No! It happens nearly instantly and only differing bytes are flashed really. -You may consider putting your logic into your application and perform a CRC Check after the fact to inform the user and delete or rename FIRMWARE.BIN - -### Thanks to -- https://github.com/per1234 - Boards Manager Installation and help with differenct MCUs -- http://elm-chan.org/fsw/ff/00index_p.html -- Wilfried Klaas for the MCSDepthLogger https://github.com/willie68/OpenSeaMapLogger -- https://github.com/mharizanov/avr_boot -- https://github.com/osbock/avr_boot -- and others??? - -### Alternatives - -- https://spaces.atmel.com/gf/project/sdbootloader/ -- https://github.com/thseiler/embedded/tree/master/avr/2boots -- http://www.mikrocontroller.net/articles/MMC/SD_Bootloader_f%C3%BCr_AT_Mega - -... call me stupid, but I passed several days debugging those - without success ... diff --git a/bootloader_zevero_sd_m644p_make/asmfunc.S b/bootloader_zevero_sd_m644p_make/asmfunc.S deleted file mode 100644 index 099a8d1..0000000 --- a/bootloader_zevero_sd_m644p_make/asmfunc.S +++ /dev/null @@ -1,271 +0,0 @@ -;---------------------------------------------------------------------------; -; MMC hardware controls and Flash controls (C)ChaN, 2010 -;---------------------------------------------------------------------------; -; Hardware dependent macros to be modified //do this in Makefile -#include "spi_pins.h" - -; ALL Pins given as Port (A,B,C,...) plus number - -; LED Pins -;#define DDR_SS _SFR_IO_ADDR(DDRD), 5 // SS pin (PIN, PORT) -;#define PORT_SS _SFR_IO_ADDR(PORTD), 5 -#define DDR_SS _SFR_IO_ADDR(DDRC), 3 // SS pin (PIN, PORT) -#define PORT_SS _SFR_IO_ADDR(PORTC), 3 - -;#define DDR_PW _SFR_IO_ADDR(DDRD), 6 // Power pin (PIN, PORT) -;#define PORT_PW _SFR_IO_ADDR(PORTD), 6 - -;SD CARD PINS -#define DDR_CS _SFR_IO_ADDR(SD_CS_DDR), SD_CS_BIT -#define PORT_CS _SFR_IO_ADDR(SD_CS_PORT), SD_CS_BIT - -;---------------------------------------------------------------------------; -.nolist -#include -.list -.text - -.global init_leds -.func init_leds -init_leds: - sbi DDR_SS -; sbi DDR_PW - ret -.endfunc - - -.global led_write_on -.func led_write_on -led_write_on: - sbi PORT_SS - ret -.endfunc - -.global led_write_off -.func led_write_off -led_write_off: - cbi PORT_SS - ret -.endfunc - -;.global led_power_on -;.func led_power_on -;led_power_on: -; sbi PORT_PW -; ret -;.endfunc - -;.;global led_power_off -;.;func led_power_off -;led_power_off: -; cbi PORT_PW -; ret -;.endfunc - -;.;global led_power_toggle -;.func led_power_toggle -;led_power_toggle: -; sbis PORT_PW -; jmp led_power_on -; jmp led_power_off -;.endfunc - -.global led_write_toggle -.func led_write_toggle -led_write_toggle: - sbis PORT_SS - jmp led_write_on - jmp led_write_off -.endfunc - -;---------------------------------------------------------------------------; -; Initialize MMC port -; -; void init_spi (void); - -.global init_spi -.func init_spi -init_spi: - sbi DDR_CS ; CS: output - sbi DDR_DI ; DI: output - sbi DDR_CK ; SCLK: output - sbi PORT_DO ; DO: pull-up - ret -.endfunc - - - -;---------------------------------------------------------------------------; -; Delay 100 microseconds -; -; void dly_us (UINT n); - -.global dly_100us -.func dly_100us -dly_100us: - ldi r24, lo8(F_CPU / 100000) /* Loop counter */ -1: sbiw r30, 1 /* 10 clocks per loop */ - sbiw r30, 1 - sbiw r30, 1 - nop - dec r24 - brne 1b - ret -.endfunc - - - -;---------------------------------------------------------------------------; -; Select MMC -; -; void select (void); - -.global select -.func select -select: - rcall deselect - cbi PORT_CS - rjmp rcv_spi -.endfunc - - - -;---------------------------------------------------------------------------; -; Deselect MMC -; -; void deselect (void); - -.global deselect -.func deselect -deselect: - sbi PORT_CS - ; Goto next function -.endfunc - - - -;---------------------------------------------------------------------------; -; Receive a byte -; -; BYTE rcv_spi (void); - -.global rcv_spi -.func rcv_spi -rcv_spi: - ldi r24, 0xFF ; Send 0xFF to receive data - ; Goto next function -.endfunc - - - -;---------------------------------------------------------------------------; -; Transmit a byte -; -; void xmit_spi (BYTE); - -.global xmit_spi -.func xmit_spi -xmit_spi: - ldi r25, 8 -1: sbrc r24, 7 ; DI = Bit to sent - sbi PORT_DI ; - sbrs r24, 7 ; - cbi PORT_DI ; / - lsl r24 ; Get DO from MMC - sbic PIN_DO ; - inc r24 ; / - sbi PORT_CK ; A positive pulse to SCLK - cbi PORT_CK ; / - dec r25 ; Repeat 8 times - brne 1b ; / - ret -.endfunc - - - -;--------------------------------------------------------------------------- -; Erase a flash page -; -; void flash_erase (DWORD flash_addr); - -#ifndef SPMCSR -#define SPMCSR SPMCR -#endif - -.global flash_erase -.func flash_erase -flash_erase: - - movw ZL, r22 -#if FLASHEND >= 0x10000 - out _SFR_IO_ADDR(RAMPZ), r24 -#endif - - ; Initiate erase operation - ldi r24, 0b00000011 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - - ; Wait for end of erase operation -1: lds r24, _SFR_MEM_ADDR(SPMCSR) - sbrc r24, 0 - rjmp 1b - - ; Re-enable read access to the flash - ldi r24, 0b00010001 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - -9: ret -.endfunc - - - -;--------------------------------------------------------------------------- -; Write a flash page -; -; void flash_write (DWORD flash_addr, const BYTE* data); - -.global flash_write -.func flash_write -flash_write: - push r0 - push r1 - -#if FLASHEND >= 0x10000 - out _SFR_IO_ADDR(RAMPZ), r24 -#endif - - ; Fill page buffer - movw ZL, r22 - movw XL, r20 - ldi r25, lo8(SPM_PAGESIZE/2) -1: ld r0, X+ - ld r1, X+ - ldi r24, 0b00000001 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - adiw ZL, 2 - dec r25 - brne 1b - - ; Initiate write operation - movw ZL, r22 - ldi r24, 0b00000101 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - - ; Wait for end of write operation -2: lds r24, _SFR_MEM_ADDR(SPMCSR) - sbrc r24, 0 - rjmp 2b - - ; Re-enable read access to the flash - ldi r24, 0b00010001 - sts _SFR_MEM_ADDR(SPMCSR), r24 - spm - -9: pop r1 - pop r0 - ret -.endfunc diff --git a/bootloader_zevero_sd_m644p_make/bootloader_zevero_sd_m644p.hex.bootloader b/bootloader_zevero_sd_m644p_make/bootloader_zevero_sd_m644p.hex.bootloader deleted file mode 100644 index efd7b70..0000000 --- a/bootloader_zevero_sd_m644p_make/bootloader_zevero_sd_m644p.hex.bootloader +++ /dev/null @@ -1,245 +0,0 @@ -:10F000000C943E780C9468780C9468780C9468782A -:10F010000C9468780C9468780C9468780C946878F0 -:10F020000C9468780C9468780C9468780C946878E0 -:10F030000C9468780C9468780C9468780C946878D0 -:10F040000C9468780C9468780C9468780C946878C0 -:10F050000C9468780C9468780C9468780C946878B0 -:10F060000C9468780C9468780C9468780C946878A0 -:10F070000C9468780C9468780C94687811241FBEFE -:10F08000CFEFD0E1DEBFCDBF87EF84BF0FB6F894DE -:10F09000A895809160008861809360001092600064 -:10F0A0000FBE11E0A0E0B1E0E2E1FFEF02C0059089 -:10F0B0000D92AE30B107D9F722E0AEE0B1E001C069 -:10F0C0001D92AB33B207E1F70E9449790C94877F18 -:10F0D0000C9400783B9A0895439A089543980895B4 -:10F0E000439B0C946C780C946E78209A259A279AFE -:10F0F0002E9A089580EA31973197319700008A95CA -:10F10000D1F7089502D0289801C0289A8FEF98E08F -:10F1100087FD2D9A87FF2D98880F1E9983952F9A2A -:10F120002F989A95A9F70895FB0183E080935700E3 -:10F13000E8958091570080FDFCCF81E180935700D6 -:10F14000E89508950F921F92FB01DA0190E80D9067 -:10F150001D9081E080935700E89532969A95B9F713 -:10F16000FB0185E080935700E8958091570080FD72 -:10F17000FCCF81E180935700E8951F900F90089590 -:10F18000CF92DF92EF92FF921F93CF93DF9300D045 -:10F19000CDB7DEB712E30E9470782FEF81EE94E0D6 -:10F1A000215080409040E1F700C00000115099F7D5 -:10F1B000C12CD12C760140E051E06FEF70E08BE381 -:10F1C00091E00E94807FAE014F5F5F4F60E071E091 -:10F1D0008BE391E00E94287DABE3B1E0C6018B5345 -:10F1E0009140FC01EA0FFB1FE4912D91E2131AC03C -:10F1F00022E0AB33B207A9F70E946C788FEFD81AE0 -:10F20000E80AF80AC11490EFD906E104F10499F66E -:10F210000F900F90DF91CF911F91FF90EF90DF90B3 -:10F22000CF9008950E946E78C701B6010E9494782D -:10F230004BE351E0C701B6010E94A278DFCFCF9324 -:10F2400081E191E00E94A37A811121C080E091E0E8 -:10F250000E94907B81111BC00E94C0780E946E7832 -:10F260002FEF87EA91E6215080409040E1F700C0FF -:10F270000000C8E20E9470782FEF80E792E02150F2 -:10F2800080409040E1F700C00000C15099F7CF9155 -:10F2900008950E946A7800E010E00E946C782FEFD9 -:10F2A00083EC99E0215080409040E1F700C00000DD -:10F2B0000E946E780E941F79F801859194910196C1 -:10F2C00011F0F8010995CAE00E947078FFEF23EC75 -:10F2D00089E0F15020408040E1F700C00000C150BB -:10F2E00099F79FEFE3E2F4EF9150E040F040E1F74F -:10F2F00000C00000D2CF0F931F93E0910E01F09158 -:10F300000F019B01AC01225031094109510986814D -:10F310009781A085B1850297A109B10928173907FE -:10F320004A075B0768F4A281B0E00E942F7F028940 -:10F33000138924893589600F711F821F931F03C0B1 -:10F3400060E070E0CB011F910F9108950F931F9320 -:10F35000CF93DF93DC01E0910E01F0910F01119644 -:10F360001C921E9214966D917D918D919C91179790 -:10F37000613071058105910569F10681178120854C -:10F380003185601771078207930720F561157105B4 -:10F390008105910539F42081233021F46685778534 -:10F3A00080899189ED01688779878A879B876115B4 -:10F3B00071058105910519F00E947B7904C066856D -:10F3C0007785808991896C877D878E879F8780E08C -:10F3D00090E002C081E090E0DF91CF911F910F910A -:10F3E0000895A4E0B0E0E7EFF9E70C94447FE091E2 -:10F3F0000E01F0910F01623071058105910508F44D -:10F4000059C0C680D780E084F1846C157D058E05D7 -:10F410009F0508F04FC02081223019F0233001F100 -:10F4200049C09B013327220F331FBB27A92F982FD9 -:10F43000872FC284D384E484F584AC01BD014C0DD4 -:10F440005D1D6E1D7F1D02E010E0CE0101960E9441 -:10F45000BE7E892B79F569817A8180E090E02EC0AB -:10F460009B012F773327220F331F220F331FDC011D -:10F47000CB0157E0B695A795979587955A95D1F703 -:10F48000C284D384E484F584AC01BD014C0D5D1DC0 -:10F490006E1D7F1D04E010E0CE0101960E94BE7E2D -:10F4A000892B41F489819A81AB81BC81BC01CD015A -:10F4B0009F7004C061E070E080E090E02496E8E096 -:10F4C0000C94607FA0E0B0E0E8E6FAE70C94447F9B -:10F4D000EC016A017B0102E010E02EEF31E00E94B6 -:10F4E000BE7E892B31F58881998185359A4A19F537 -:10F4F00026E330E0B701A601CE010E94BE7E892B33 -:10F5000039F4888199818634914411F480E016C0E1 -:10F5100002E010E022E530E0B701A601CE010E9432 -:10F52000BE7E892B51F4888199818634914429F4D7 -:10F53000EDCF83E003C082E001C081E0CDB7DEB74C -:10F54000E8E00C94607FA4E2B0E0E9EAFAE70C940A -:10F550003A7F1C0110920F0110920E010E94237E2F -:10F5600080FDA0C040E050E0BA01CE0101960E94AB -:10F57000627A813009F500E110E02EEB31E040E0E5 -:10F5800050E0BA01CE0101960E94BE7E892B19F08F -:10F5900081E090E0C1C08D81811103C086E090E0E0 -:10F5A000BBC049845A846B847C84B301A201CE0120 -:10F5B00001960E94627A03C0412C512C32018330A3 -:10F5C00039F38111EBCF04E210E02DE030E0B3011C -:10F5D000A201CE0101960E94BE7E892BC9F62A8522 -:10F5E0003B8540E050E0211531054105510521F4EE -:10F5F000288D398D4A8D5B8DAC81B0E00E942F7FC4 -:10F600004B015C010A811B8120E030E0400E511E5D -:10F61000621E731EF1014286538664867586498197 -:10F620004283CD80DE80D582C4828F819885A0E020 -:10F63000B0E00097A105B10521F48C899D89AE89C0 -:10F64000BF8954E0D694C7945A95E1F7E12CF12C88 -:10F65000801B910BA20BB30B88199909AA09BB094E -:10F66000BC01CD016C197D098E099F09242F30E062 -:10F6700040E050E00E940D7FDA01C9010296A11D11 -:10F68000B11DF10186839783A087B187BA01A901D3 -:10F69000465F5F40610971094F3F5F4E610571052B -:10F6A000A0F103C082E090E037C0873F9F4FA105E3 -:10F6B000B10508F473CF83E0F1018083833029F42E -:10F6C00088A199A1AAA1BBA107C0D501C401840D3D -:10F6D000951DA61DB71DF10186879787A08BB18B5D -:10F6E000C40CD51CE61CF71CC80CD91CEA1CFB1C5E -:10F6F000F101C28AD38AE48AF58A118230920F011D -:10F7000020920E0180E090E007C0873F9F4FA10547 -:10F71000B10588F682E0D0CFA496E2E10C94567F42 -:10F720004F925F926F927F929F92AF92BF92CF92D1 -:10F73000DF92EF92FF920F931F93CF93DF93CDB79A -:10F74000DEB7EC970FB6F894DEBF0FBECDBFC0900A -:10F750000E01D0900F01C114D10409F452C1D60199 -:10F7600011961C929E012F5C3F4F3CA32BA3FC01E2 -:10F770002E2F9F2F81918032D9F3E22EF92E8F32D6 -:10F7800019F4BFEFEB1AFB0A1DA21EA21FA218A6B6 -:10F79000F7018081803238F0A0E29A2E5E01FCE011 -:10F7A000AF0EB11C6AC0CE0181960E94A679198263 -:10F7B000009709F4F1C036C180E090E028E031E024 -:10F7C000390FD701A90FB11D9C91913208F060C08B -:10F7D000E30EF11C81E0913208F080E08387CE01D6 -:10F7E00081960E94A679009709F01CC129A13AA12F -:10F7F0002F703327F5E0220F331FFA95E1F74DA55F -:10F800005EA56FA578A900E210E0CE0101960E94E6 -:10F81000BE7E892B09F0FAC08981882309F4F9C0DA -:10F820004C8543FD53C06BA17CA1FE0131969B0129 -:10F83000EA15FB05E9F5DB011B968C918111ACC043 -:10F8400044FFE7C0E0910E01F0910F018081833009 -:10F8500009F09EC08D899E89A0E0B0E0DC01992767 -:10F8600088274B8D5C8D60E070E0842B952BA62B58 -:10F87000B72B8DA39EA3AFA3B8A7EBA1FCA1DF017B -:10F88000CF010B96A817B90709F496CF9D92FACF2E -:10F890009F3209F49DCF9E3209F4BEC0821708F052 -:10F8A00097CFDF01A80FB11D9C938F5F932F87CF58 -:10F8B0008191D9015D919D01082E000C990B851B4A -:10F8C000910957FD9395892B09F4B2CF60900E01F1 -:10F8D00070900F0109A11AA10F5F1F4F09F499C081 -:10F8E0008DA59EA5AFA5B8A90097A105B10509F4FE -:10F8F00090C098012F703327232B09F046C0019642 -:10F90000A11DB11D8DA79EA7AFA7B8AB69A57AA50C -:10F910008BA59CA5611571058105910541F4F30145 -:10F92000848195810817190708F073C02EC0D30190 -:10F9300012962C9130E0A901415051099801E4E060 -:10F9400036952795EA95E1F724233523232BE9F40F -:10F950000E94F179623071058105910508F456C065 -:10F96000F3014680578060847184641575058605AF -:10F97000970508F04EC069A77AA78BA79CA70E949D -:10F980007B796DA77EA78FA798AB1AA309A32ECF6B -:10F9900080E090E0DC0165CF89818823A1F18C852E -:10F9A00084FD31C0E0910E01F0910F018081833020 -:10F9B00041F48D899E89A0E0B0E0DC019927882779 -:10F9C00003C080E090E0DC014B8D5C8D60E070E076 -:10F9D000842B952BA62BB72BF601868F978FA0A390 -:10F9E000B1A38D8D9E8DAF8DB8A1828F938FA48F83 -:10F9F000B58F168A178A108E118E81E0818380E080 -:10FA000003C085E001C083E090E00CC081E090E09D -:10FA100009C083E090E006C0283009F0D9CE88E024 -:10FA20002BE044CFEC960FB6F894DEBF0FBECDBFEF -:10FA3000DF91CF911F910F91FF90EF90DF90CF90CA -:10FA4000BF90AF909F907F906F905F904F90089580 -:10FA5000A0E0B0E0EEE2FDE70C943C7F4C016B01CE -:10FA60005A01C0910E01D0910F01FA01118210824A -:10FA7000209709F4A1C0898180FFA1C08A8D9B8D48 -:10FA8000AC8DBD8D4E895F89688D798D841B950BFA -:10FA9000A60BB70BA60160E070E084179507A607D8 -:10FAA000B70708F46C013401412C32E0532EC11425 -:10FAB000D10409F47EC08E899F89A88DB98DAC01CF -:10FAC000BD01517066277727452B462B472BD1F573 -:10FAD000FA80FA94AC01BD0129E0769567955795B7 -:10FAE00047952A95D1F7F422C1F4892B8A2B8B2BC9 -:10FAF00029F46E8D7F8D88A199A106C06AA17BA192 -:10FB00008CA19DA10E94F17962307105810591055A -:10FB1000A0F16AA37BA38CA39DA36AA17BA18CA166 -:10FB20009DA10E947B79611571058105910529F1DF -:10FB3000DC01CB018F0D911DA11DB11D8EA39FA3D3 -:10FB4000A8A7B9A72E893F893170C201821B930BE8 -:10FB500076018C159D0508F47C014EA15FA168A576 -:10FB600079A58114910411F0C30102C080E090E0F6 -:10FB700087010E94BE7E892B21F0198281E090E0EE -:10FB800020C08E899F89A88DB98D8E0D9F1DA11DC6 -:10FB9000B11D8E8B9F8BA88FB98F6E0C7F1CCE18DA -:10FBA000DF08F50180819181E80EF91EF182E08283 -:10FBB0007ECF80E090E005C085E090E002C084E068 -:10FBC00090E0CDB7DEB7E0E10C94587FFF920F9341 -:10FBD0001F93CF93DF93C82FD42F152F062FF72E07 -:10FBE00087FF09C040E050E0BA0187E70E94E67D48 -:10FBF000823020F5CF770E9482788C2F0E94877800 -:10FC00008F2D0E948778802F0E948778812F0E94F5 -:10FC100087788D2F0E948778C03421F0C83421F472 -:10FC200087E803C085E901C081E00E948778CAE0C7 -:10FC30000E94867887FF02C0C150D1F7CDB7DEB7EA -:10FC4000E5E00C94637FA4E0B0E0E9E2FEE70C9409 -:10FC5000457F0E94757814E60E947A781150E1F78A -:10FC60001AE00E9485781150E1F740E050E0BA01B7 -:10FC700080E40E94E67D813009F07AC04AEA51E0D2 -:10FC800060E070E088E40E94E67D813051F58E01ED -:10FC90000F5F1F4F780124E0D22ED00E0E9486788D -:10FCA000F70181937F01DE12F9CF8B81813009F05A -:10FCB0005FC08C818A3A09F05BC090E1E92E97E23F -:10FCC000F92E40E050E060E070E489EE0E94E67DAD -:10FCD000882339F10E947A78F1E0EF1AF10889F768 -:10FCE00047C040E050E0BA0189EE0E94E67D8230D4 -:10FCF00018F011E001E402C012E009EE80E1E82E04 -:10FD000087E2F82E40E050E0BA01802F0E94E67DA5 -:10FD1000882329F10E947A78F1E0EF1AF10891F72F -:10FD200027C040E050E0BA018AE70E94E67D8111D9 -:10FD30001FC00E948678F80181938F01DE12F9CFEF -:10FD4000898186FD02C014E001C01CE010931001FF -:10FD50000E94857881E0112369F080E00BC040E0CB -:10FD600052E060E070E080E50E94E67D882371F358 -:10FD700010E0ECCF2496E7E00C94617FA0E0B0E0C7 -:10FD8000E4ECFEE70C94447FD82EC92E79018091D3 -:10FD9000100183FD07C089E0440F551F661F771FC0 -:10FDA0008A95D1F781E50E94E67D882319F0C1E0AC -:10FDB000D0E02BC0C0E4DCE90E9486788F3F19F4C4 -:10FDC0002197D1F7F4CF8E3F91F7C2E0D2E0C01B6C -:10FDD000D10BCE19DF09E114F10419F4ED2CFC2C40 -:10FDE00006C00E94867881E0E81AF108F4CF0E94EC -:10FDF0008678F70181937F0101501109C1F70E94B4 -:10FE000086782197E1F7C0E0D0E00E948578CE01A6 -:10FE1000CDB7DEB7E8E00C94607FA1E21A2EAA1BF2 -:10FE2000BB1BFD010DC0AA1FBB1FEE1FFF1FA217AA -:10FE3000B307E407F50720F0A21BB30BE40BF50BA7 -:10FE4000661F771F881F991F1A9469F76095709530 -:10FE5000809590959B01AC01BD01CF0108950E9452 -:10FE6000717FA59F900DB49F900DA49F800D911D53 -:10FE7000112408952F923F924F925F926F927F923A -:10FE80008F929F92AF92BF92CF92DF92EF92FF92AA -:10FE90000F931F93CF93DF93CDB7DEB7CA1BDB0B56 -:10FEA0000FB6F894DEBF0FBECDBF09942A883988FB -:10FEB00048885F846E847D848C849B84AA84B98402 -:10FEC000C884DF80EE80FD800C811B81AA81B9810E -:10FED000CE0FD11D0FB6F894DEBF0FBECDBFED0122 -:10FEE0000895A29FB001B39FC001A39F700D811D13 -:10FEF0001124911DB29F700D811D1124911D089533 -:10FF0000DC0101C06D9341505040E0F70895F89432 -:02FF1000FFCF21 -:0EFF1200363434424F4F542E42494E00000008 -:040000030000F00009 -:00000001FF diff --git a/bootloader_zevero_sd_m644p_make/diskio.c b/bootloader_zevero_sd_m644p_make/diskio.c deleted file mode 100644 index 4608c5e..0000000 --- a/bootloader_zevero_sd_m644p_make/diskio.c +++ /dev/null @@ -1,226 +0,0 @@ -/*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014 */ -/*-----------------------------------------------------------------------*/ - -#include "pff/src/pff.h" -#include "pff/src/diskio.h" - -void init_spi (void); /* Initialize SPI port (asmfunc.S) */ -void deselect (void); /* Select MMC (asmfunc.S) */ -void select (void); /* Deselect MMC (asmfunc.S) */ -void xmit_spi (BYTE d); /* Send a byte to the MMC (asmfunc.S) */ -BYTE rcv_spi (void); /* Send a 0xFF to the MMC and get the received byte (asmfunc.S) */ -void dly_100us (void); /* Delay 100 microseconds (asmfunc.S) */ - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - -/* Definitions for MMC/SDC command */ -#define CMD0 (0x40+0) /* GO_IDLE_STATE */ -#define CMD1 (0x40+1) /* SEND_OP_COND (MMC) */ -#define ACMD41 (0xC0+41) /* SEND_OP_COND (SDC) */ -#define CMD8 (0x40+8) /* SEND_IF_COND */ -#define CMD16 (0x40+16) /* SET_BLOCKLEN */ -#define CMD17 (0x40+17) /* READ_SINGLE_BLOCK */ -#define CMD24 (0x40+24) /* WRITE_BLOCK */ -#define CMD55 (0x40+55) /* APP_CMD */ -#define CMD58 (0x40+58) /* READ_OCR */ - - -/* Card type flags (CardType) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -static -BYTE CardType; - - -/*-----------------------------------------------------------------------*/ -/* Send a command packet to MMC */ -/*-----------------------------------------------------------------------*/ - -static -BYTE send_cmd ( - BYTE cmd, /* 1st byte (Start + Index) */ - DWORD arg /* Argument (32 bits) */ -) -{ - BYTE n, res; - - - if (cmd & 0x80) { /* ACMD is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card */ - select(); - - /* Send a command packet */ - xmit_spi(cmd); /* Start + Command index */ - xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xmit_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xmit_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xmit_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */ - xmit_spi(n); - - /* Receive a command response */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do { - res = rcv_spi(); - } while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - DSTATUS stat; - - BYTE n, cmd, ty, ocr[4]; - UINT tmr; - - - init_spi(); /* Initialize ports to control MMC */ - for (n = 100; n; n--) dly_100us(); /* 10ms delay */ - for (n = 10; n; n--) deselect(); /* 80 Dummy clocks with CS=H */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2 */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - for (tmr = 10000; tmr && send_cmd(ACMD41, 1UL << 30); tmr--) dly_100us(); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (tmr && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 (HC or SC) */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - for (tmr = 10000; tmr && send_cmd(cmd, 0); tmr--) dly_100us(); /* Wait for leaving idle state */ - if (!tmr || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - deselect(); - - stat = ty ? 0 : STA_NOINIT; - - return stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE* buff, /* Pointer to the destination object */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Offset in the sector */ - UINT count /* Byte count (bit15:destination) */ -) -{ - DRESULT res; - BYTE rc; - WORD bc; - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - res = RES_ERROR; - if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */ - - bc = 40000; - do { /* Wait for data packet */ - rc = rcv_spi(); - } while (rc == 0xFF && --bc); - - if (rc == 0xFE) { /* A data packet arrived */ - bc = 514 - offset - count; - - /* Skip leading bytes */ - if (offset) { - do rcv_spi(); while (--offset); - } - - /* Receive a part of the sector */ - do { - *buff++ = rcv_spi(); - } while (--count); - - /* Skip trailing bytes and CRC */ - do rcv_spi(); while (--bc); - - res = RES_OK; - } - } - - deselect(); - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Partial Sector */ -/*-----------------------------------------------------------------------*/ -/* -DRESULT disk_writep ( - const BYTE* buff, // Pointer to the data to be written, NULL:Initiate/Finalize write operation - DWORD sc // Sector number (LBA) or Number of bytes to send -) -{ - DRESULT res; - - - if (!buff) { - if (sc) { - - // Initiate write process - - } else { - - // Finalize write process - - } - } else { - - // Send data to the disk - - } - - return res; -} -*/ diff --git a/bootloader_zevero_sd_m644p_make/m644p_zevero_sd_m644p_fuses.txt b/bootloader_zevero_sd_m644p_make/m644p_zevero_sd_m644p_fuses.txt deleted file mode 100644 index 5409b45..0000000 --- a/bootloader_zevero_sd_m644p_make/m644p_zevero_sd_m644p_fuses.txt +++ /dev/null @@ -1,29 +0,0 @@ -3) Working FUSE for M644p (with bootloader Zevero-SD) -I.e - Arduino Bootloader to Flash from SD Card: https://github.com/zevero/avr_boot - -PS. SET FUSES: -============== - LOW = 0xFF - HIGH = 0xDA - EXTD = 0xFD -======================================== -It means: -Ext. XTAL High FREQ START-UP 16K CK + 65ms -JTAG DISABLED -BROWN-OUT 2.7V ON -BOOT-LOADER ENABLED -BOOT Flash Section Size = 2048 words (4096 bytes); Boot Start address = 0x7800 words (0xF000 bytes) -========================================= - -AVRDUDE arguments: --U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0xfd:m - -Full commands to write from console: -avrdude -Pusb -cavrispmkii -patmega644p -B5 -U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0xfd:m - - -Detection avrdude CPU: B5 (5us bit clock period for programmer SPI) - VERY IMPORTANT (1Mhz CPU M1284p/M644p FREQ DEFAULT) -avrdude -Pusb -cavrispmkii -patmega644p -B5 - -Check m644p fuse here: -http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega644p diff --git a/bootloader_zevero_sd_m644p_make/main.c b/bootloader_zevero_sd_m644p_make/main.c deleted file mode 100644 index 1d51476..0000000 --- a/bootloader_zevero_sd_m644p_make/main.c +++ /dev/null @@ -1,259 +0,0 @@ -/*-------------------------------------------------------------------------/ -/ Stand-alone MMC boot loader R0.01 -/--------------------------------------------------------------------------/ -/ -/ Copyright (C) 2010, ChaN, all right reserved. -/ -/ * This software 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. -/ -/--------------------------------------------------------------------------/ -/ Dec 6, 2010 R0.01 First release -/--------------------------------------------------------------------------/ -/ This is a stand-alone MMC/SD boot loader for megaAVRs. It requires a 4KB -/ boot section for code, four GPIO pins for MMC/SD as shown in sch.jpg and -/ nothing else. To port the boot loader into your project, follow the -/ instruction described below. -/ -/ 1. Setup the hardware. Attach a memory card socket to the any GPIO port -/ where you like. Select boot size at least 4KB for the boot loader with -/ BOOTSZ fuses and enable boot loader with BOOTRST fuse. -/ -/ 2. Setup the software. Change the four port definitions in the asmfunc.S. -/ Change MCU_TARGET, BOOT_ADR and MCU_FREQ in the Makefile. The BOOT_ADR -/ is a BYTE address of boot section in the flash. Build the boot loader -/ and write it to the device with a programmer. -/ -/ 3. Build the application program and output it in binary form instead of -/ hex format. Rename the file "app.bin" and put it into the memory card. -/ -/ 4. Insert the card and turn the target power on. When the boot loader found -/ the application file, the file is written into the flash memory prior to -/ start the application program. On-board LED lights (if exist) during -/ the flash programming operation. -/ -/-------------------------------------------------------------------------*/ - -const char filename[13] ="644BOOT.BIN\0"; // EDIT FILENAME HERE -#include -#include -#include -#include -#include -#include "pff/src/pff.h" -#include //Watchdog -// The following code is recommended in http://avr-libc.nongnu.org/user-manual/group__avr__watchdog.html but is disabled for now because avr_boot doesn't currently do anything with mcusr_mirror so for now we will only reset MCUSR and disable WDT. -//uint8_t mcusr_mirror __attribute__ ((section (".noinit")));void get_mcusr(void) __attribute__((naked)) __attribute__((section(".init3")));void get_mcusr(void){mcusr_mirror = MCUSR;MCUSR = 0;wdt_disable();} -void disable_watchdog(void) __attribute__((naked)) __attribute__((section(".init3"))); -void disable_watchdog(void) -{ -#if defined(MCUCSR) - MCUCSR = ~(_BV(WDRF)); //Some MCUs require the watchdog reset flag to be cleared before WDT can be disabled. & operation is skipped to spare few bytes as bits in MCUSR can only be cleared. -#else - MCUSR = ~(_BV(WDRF)); //Some MCUs require the watchdog reset flag to be cleared before WDT can be disabled. & operation is skipped to spare few bytes as bits in MCUSR can only be cleared. -#endif - wdt_disable(); //immediately disable watchdog in case it was running in the application to avoid perpetual reset loop -} - -#if BOOT_ADR > 0xFFFF - #define PGM_READ_BYTE(x) pgm_read_byte_far(x) -#else - #define PGM_READ_BYTE(x) pgm_read_byte(x) -#endif - -#if USE_UART - #include "uart/uart.h" -#endif - -#if USE_LED -void init_leds(); -void led_power_on(); -void led_power_off(); -void led_power_toggle(); -void led_write_on(); -void led_write_off(); -void led_write_toggle(); -#endif -void flash_erase (DWORD); /* Erase a flash page (asmfunc.S) */ -void flash_write (DWORD, const BYTE*); /* Program a flash page (asmfunc.S) */ - - -FATFS Fatfs; // Petit-FatFs work area -BYTE Buff[SPM_PAGESIZE]; // Page data buffer - - - -static uint8_t pagecmp(const DWORD fa, uint8_t buff[SPM_PAGESIZE]) -{ - UINT i; - uint8_t b_flash,b_buff; - for (i = 0; i < SPM_PAGESIZE; i++) { - b_flash = PGM_READ_BYTE(fa+i); - b_buff = buff[i]; - if ( b_flash != b_buff) { - #if USE_UART //output first difference - UART_puthex32(fa);UART_puts(PSTR(":")); - UART_puthex(b_flash);UART_puts(PSTR(" ")); - UART_puthex(b_buff); UART_newline(); - #endif - return 1; - } - } - #if USE_UART //output first difference - UART_puthex32(fa);UART_puts(PSTR(":")); - UART_puts(PSTR("="));UART_newline(); - #endif - return 0; -} - -void doFlash() { - DWORD fa; /* Flash address */ - UINT br; /* Bytes read */ - #if USE_LED - uint8_t i; - for(i=0;i<50;i++) { led_write_toggle();_delay_ms(100);} //Start Programming: Flash WRITE Wildly for 5 secs - #endif - - - for (fa = 0; fa < BOOT_ADR; fa += SPM_PAGESIZE) { /* Update all application pages */ - - memset(Buff, 0xFF, SPM_PAGESIZE); /* Clear buffer */ - pf_read(Buff, SPM_PAGESIZE, &br); /* Load a page data */ - - if (pagecmp(fa, Buff)) { /* Only flash if page is changed */ - #if USE_LED - led_write_off(); - //led_power_on(); - #endif - flash_erase(fa); /* Erase a page */ - flash_write(fa, Buff); /* Write it if the data is available */ - - } else { - - #if USE_LED - //led_power_off(); - led_write_on(); - #endif - } - } -} - -void checkFile() { - uint8_t fresult; - - fresult = pf_mount(&Fatfs); /* Initialize file system */ - - if (fresult != FR_OK) { /* File System could not be mounted */ - #if USE_UART - UART_puts(PSTR("File not mounted")); - UART_newline(); - #endif - - #if USE_LED - //uint8_t i; - //led_write_on(); - //for(i=0;i<2*fresult;i++) { led_power_toggle();_delay_ms(500);}//Give error number while Write led is on - //led_write_off(); - #endif - return; - } -/* - - WORD flashver = eeprom_read_word((const uint16_t *)E2END - 1); - if (flashver > 999) { - flashver = 0; - } - BYTE y, tmp; - WORD x; - BYTE found = 0; - - for (x = flashver+10; x > flashver; x--) { - y = x / 100; - filename[5] = y + 0x30; - tmp = x % 100; - - y = tmp / 10; - filename[6] = y + 0x30; - tmp = x % 10; - - filename[7] = tmp + 0x30; - - if (pf_open(filename) == FR_OK) { // File opens normally - found = 1; - doProgram(); - } - led_power_toggle(); - } - - if (found == 0) {*/ - - fresult = pf_open(filename); - - if (fresult != FR_OK) { /* File could not be opened */ - - #if USE_UART - UART_puts(PSTR("File not open")); - UART_newline(); - #endif - #if USE_LED - //uint8_t i; - //led_power_on(); - //for(i=0;i<2*fresult;i++) { led_write_toggle();_delay_ms(500);}//Give error number while Power led is on - //led_power_off(); - #endif - return; - } - - doFlash(); - - #if USE_LED - led_write_off(); - //led_power_off(); - _delay_ms(2000); - uint8_t i; - //for(i=0;i<40;i++) { led_power_toggle();_delay_ms(50);}//SUCCESS FLASH WILDLY for 2 secs - for(i=0;i<40;i++) { led_write_toggle();_delay_ms(50);}//SUCCESS FLASH WILDLY for 2 secs - #endif - -} - - - - - - -int main (void) -{ - #if USE_LED - init_leds(); - uint8_t i=0; - #endif - - #if USE_UART - UART_init(); - UART_puts(PSTR("AVR_BOOT")); - UART_newline(); - #endif - while (1) { - #if USE_LED - //led_power_on();_delay_ms(200);led_power_off(); //Test Power Led - led_write_on();_delay_ms(200);led_write_off(); //Test Write Led - #endif - - checkFile(); - - if (pgm_read_word(0) != 0xFFFF) ((void(*)(void))0)(); //EXIT BOOTLOADER - - #if USE_UART - UART_puts(PSTR("retry")); - UART_newline(); - #endif - #if USE_LED - //for(i=0;i<10;i++) { led_power_toggle();_delay_ms(200);} //SOMETHING WENT WRONG: Flash Power LED - for(i=0;i<10;i++) { led_write_toggle();_delay_ms(200);} //SOMETHING WENT WRONG: Flash Write LED - #endif - _delay_ms(5000); // Retry - } -} diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/00index_p.html b/bootloader_zevero_sd_m644p_make/pff/doc/00index_p.html deleted file mode 100644 index 46847cd..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/00index_p.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - -Petit FAT File System Module - - - -

Petit FAT File System Module

-
- -
-layer -

Petit FatFs is a sub-set of FatFs module for tiny 8-bit microcontrollers. It is written in compliance with ANSI C and completely separated from the disk I/O layer. It can be incorporated into the tiny microcontrollers with limited memory even if the RAM size is less than sector size. Also full featured FAT file system module is available here↗.

- -

Features

-
    -
  • Very small RAM consumption (44 bytes work area + certain stack).
  • -
  • Very small code size (2K-4K bytes).
  • -
  • FAT12, FAT16 and FAT32.
  • -
  • Single volume and Single file.
  • -
  • File write function with some restrictions.
  • -
-
- - -
-

Application Interface

-

Petit FatFs module provides following functions.

- -
- - -
-

Disk I/O Interface

-

Since the Petit FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read data from storage device. The low level disk I/O module is not a part of Petit FatFs module and it must be provided by user. The sample drivers are also available in the resources.

- -
- - -
-

Resources

-

The Petit FatFs module is a free software and is opened for education, research and development. You can use, modify and/or redistribute it for personal, non-profit or commercial use without any restriction under your responsibility. For further information, refer to the application note.

- -
- - -
-

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/css_e.css b/bootloader_zevero_sd_m644p_make/pff/doc/css_e.css deleted file mode 100644 index 2fa0cc1..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/css_e.css +++ /dev/null @@ -1,65 +0,0 @@ -* {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;} diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/css_p.css b/bootloader_zevero_sd_m644p_make/pff/doc/css_p.css deleted file mode 100644 index f8589aa..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/css_p.css +++ /dev/null @@ -1 +0,0 @@ -body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/img/layers3.png b/bootloader_zevero_sd_m644p_make/pff/doc/img/layers3.png deleted file mode 100644 index ac439b0..0000000 Binary files a/bootloader_zevero_sd_m644p_make/pff/doc/img/layers3.png and /dev/null differ diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/img/rwtest3.png b/bootloader_zevero_sd_m644p_make/pff/doc/img/rwtest3.png deleted file mode 100644 index cbaa3d1..0000000 Binary files a/bootloader_zevero_sd_m644p_make/pff/doc/img/rwtest3.png and /dev/null differ diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/appnote.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/appnote.html deleted file mode 100644 index 3b6d6dc..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/appnote.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - -FatFs Module Application Note - - - -

Petit FatFs Module Application Note

-
- -

Basic Considerations

-

The FatFs module is assuming following conditions on portability.

-
    -
  • ANSI C
    -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.
  • -
  • Size of integer types
    -The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.
  • -
- - -
-

Memory Usage (R0.03)

- - - - - - - - - - - -
AVRx86
Compilergcc(WinAVR)VC6
_WORD_ACCESS11
Code (default)21001720
Code (!_USE_READ)-444-246
Code (_USE_DIR)+1002+420
Code (_USE_LSEEK)+490+228
Code (_USE_WRITE)+518+351
RAM (bss)24
RAM (work)4244
-

This is the size of the Petit FatFs module itself. In addition to this, a low level disk I/O module will be required for a complete function. The size of MMC/SDC module on AVR becomes approximate 620 bytes without write function and 840 bytes with write function.

-
- -
-

Module Size Reduction

-

Follwing table shows which function is removed by configuration options for the module size reduction.

- - - - - - - - - - -
Function_USE_READ_USE_DIR_USE_LSEEK_USE_WRITE
0000
pf_mount
pf_open
pf_readx
pf_lseekx
pf_opendirx
pf_readdirx
pf_writex
-
- -
-

Performance effective file access

-

For good performance on reading a file on the small embedded system, application programmer should consider what process is done in the file system module.

-

The Petit FatFs reads the disk sectors without a sector buffer. This means the file system reads a part of the sector contains the required data every reference point even if they are in the same sector. However the generic storage device are not byte addressable so that the disk I/O layer will read the entire sector and pick up the data bytes from the read data steram.

-

When read 512 byte data from a file at a time, the data sector will be read only a time. When read that data in byte-by-byte, the data sector will be read 512 times. Therefore the byte-by-byte read request will drastically decrease the read performance. To avoid this stupid read controls, the file data should be read in long block as possible. Sector alignment access is not impotant on the Petit FatFs.

-

The tiny microcontrollers targeted by Petit FatFs has a limited size of RAM. It may not able to allocate a certain size of read buffer and most type of text processing will require byte-by-byte read operation. The Petit FatFs supports data forwarding feature for such purpose.

- -
- -
-

About FatFs License

-

Petit 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 license document that included in the source files.

-
/*----------------------------------------------------------------------------/
-/  Petit FatFs - FAT file system module  R0.03                  (C)ChaN, 2014
-/-----------------------------------------------------------------------------/
-/ Petit FatFs module is a generic FAT file system module for small embedded
-/ systems. This is a free software that opened for education, research and
-/ commercial developments under license policy of following trems.
-/
-/  Copyright (C) 2014, ChaN, all right reserved.
-/
-/ * The Petit FatFs module is a free software and there is NO WARRANTY.
-/ * No restriction on use. You can use, modify and redistribute it for
-/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
-/ * Redistributions of source code must retain the above copyright notice.
-/
-/-----------------------------------------------------------------------------/
-

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 and any form without source code, are not specified in order to extend usability to commercial use. The documentation of the distributions need not include about Petit FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course Petit FatFs is compatible with the projects under GNU GPL. When redistribute the Petit FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/dinit.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/dinit.html deleted file mode 100644 index 6c38a23..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/dinit.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - -Petit FatFs - disk_initialize - - - - -
-

disk_initialize

-

The disk_initialize function initializes the disk drive.

-
-DSTATUS disk_initialize (void)
-
-
- -
-

Return Values

-

The disk status is returned in combination of following flags.

-
-
STA_NOINIT
-
Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.
-
STA_NODISK
-
Indicates that no medium in the drive. This is always cleared on fixed disk drive. This flag is not referred by Petit FatFs.
-
-
- -
-

Description

-

The disk_initialize function initializes the storage device. If the function succeeded, STA_NOINIT flag in the return value is cleared.

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/dreadp.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/dreadp.html deleted file mode 100644 index 41309a4..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/dreadp.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - -Petit FatFs - disk_readp - - - - -
-

disk_readp

-

The disk_readp function reads a partial sector of the device.

-
-DRESULT disk_readp (
-  BYTE* buff,    /* [OUT] Pointer to the read buffer */
-  DWORD sector,  /* [IN]  Sector number */
-  UINT offset,   /* [IN]  Byte offset in the sector to start to read */
-  UINT count     /* [IN]  Number of bytes to read */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the read buffer to store the read data. If a NULL is given, read bytes will be forwarded to the outgoing stream instead of the memory.
-
sector
-
Specifies the sector number to be read in logical block address (LBA).
-
offset
-
Specifies the byte offset in the sector to start to read. The value can be 0 to 511.
-
count
-
Specifies number of bytes to read. The value can be 0 to 512 and offset + count must not exceed 512.
-
-
- - -
-

Return Value

-
-
RES_OK (0)
-
The function succeeded.
-
RES_ERROR
-
Any hard error occured during the disk read operation and could not recover it.
-
RES_PARERR
-
Invalid parameter.
-
RES_NOTRDY
-
The device has not been initialized.
-
-
- - -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/dwritep.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/dwritep.html deleted file mode 100644 index 5361a5f..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/dwritep.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - -Petit FatFs - disk_writep - - - - -
-

disk_writep

-

The disk_writep function writes data to the sector.

-
-DRESULT disk_writep (
-  BYTE* buff,  /* [IN] Pointer to the data to be written */
-  DWORD sc,    /* [IN] Sector number or Number of bytes to wtite */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the data to be written to the sector. If a NULL is given, the function initiate/finalize a write transaction to the sector.
-
sc
-
Specifies nubmer of bytes to write if buff is not a NULL. If buff is a NULL and sc is not a zero, the function initiates a write transactin to the sector. If buff and sc are zero, the function finalize the current sector write transactin.
-
-
- - -
-

Return Value

-
-
RES_OK (0)
-
The function succeeded.
-
RES_ERROR
-
Any hard error occured during the write operation and could not recover it or the medium is write protected.
-
RES_PARERR
-
Invalid parameter.
-
RES_NOTRDY
-
The device has not been initialized.
-
-
- - -
-

Description

-

A sector write operation is done in following sequence.

-
    -
  1. disk_writep(0, sector_number); Initiate a sector write transaction.
  2. -
  3. disk_writep(data, byte_to_write); Start to write data to the sector.
  4. -
  5. disk_writep(data, byte_to_write); And data can be written upto 512 bytes with one or more calls.
  6. -
  7. disk_writep(data, byte_to_write); ...
  8. -
  9. disk_writep(0, 0); Finalize the write transaction. If number of bytes sent is less than 512, left bytes in the sector is filled by zero.
  10. -
-

If a write transaction is in progress, disk_readp() function will fail and disk_initialize() function finalize the current write transaction.

-
- - -
-

Remarks

-

This funciton is needed when _USE_WRITE == 1.

-
- - -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/filename.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/filename.html deleted file mode 100644 index b751cda..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/filename.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - -Petit FatFs - Path Names - - - - -
-

Format of the path names

-

The path name format on the Petit FatFs module is similer to MS-DOS as follows.

-
"[/]directory/file"
-

The Petit FatFs module supports only 8.3 format file name. The sub-directories are separated with a /. The path name is terminated with a nul character, control character or white space. Heading spaces are ignored and skipped. When _USE_LCC == 1, lower case characters are allowed for the path name.

-

The Petit FatFs module does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name following from the root directory. Heading separator is ignored and it can be exist or omitted.

-
- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/lseek.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/lseek.html deleted file mode 100644 index 2b65826..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/lseek.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - -Petit FatFs - pf_lseek - - - - -
-

pf_lseek

-

The pf_lseek function moves the file read/write pointer of the open file.

- -
-FRESULT pf_lseek (
-  DWORD ofs       /* [IN] File offset in unit of byte */
-);
-
-
- -
-

Parameters

-
-
ofs
-
Number of bytes where from start of the file
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to an error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The file has not been opened.
-
-
- - -
-

Description

-

The pf_lseek() function moves the file read/write pointer of the open file. The offset can be specified in only origin from top of the file.

-
- - -
-

Example

-
-    /* Move to offset of 5000 from top of the file */
-    res = pf_lseek(5000);
-
-    /* Forward 3000 bytes */
-    res = pf_lseek(fs.fptr + 3000);
-
-    /* Rewind 2000 bytes (take care on wraparound) */
-    res = pf_lseek(fs.fptr - 2000);
-
-
- -
-

QuickInfo

-

Available when _USE_LSEEK == 1.

-
- -
-

References

-

pf_open, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/mount.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/mount.html deleted file mode 100644 index f787cca..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/mount.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - -Petit FatFs - pf_mount - - - - -
-

pf_mount

-

The pf_mount fucntion mounts a volume.

-
-FRESULT pf_mount (
-  FATFS*  fs  /* [IN] Pointer to the work area */
-);
-
-
- -
-

Parameters

-
-
fs
-
Pointer to the work area (file system object) to be registered.
-
-
- -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_NOT_READY
-
The drive could not be initialized due to a disk error or no medium.
-
FR_DISK_ERR
-
An error occured in the disk function.
-
FR_NO_FILESYSTEM
-
There is no valid FAT partition on the disk.
-
-
- - -
-

Description

-

The pf_mount() function registers a work area to the Petit FatFs module. The volume is mounted on registration. The volume must be mounted with this function prior to any other file function and after every media changes.

-
- - -
-

QuickInfo

-

Always available.

-
- -
-

References

-

FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/open.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/open.html deleted file mode 100644 index 8deb830..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/open.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - -Petit FatFs - pf_open - - - - -
-

pf_open

-

The pf_open function opens an existing file.

-
-FRESULT pf_open (
-  const char* path  /* [IN] Pointer to the file neme */
-);
-
-
- -
-

Parameters

-
-
path
-
Pointer to a null-terminated string that specifies the file name to open.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_NO_FILE
-
Could not find the file or path.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_ENABLED
-
The volume has not been mounted.
-
-
- - -
-

Description

-

The file must be opend prior to use pf_read() and pf_lseek() function. The open file is valid until next open.

-
- - -
-

Example

-
-int main (void)
-{
-    FATFS fs;          /* Work area (file system object) for the volume */
-    BYTE buff[16];     /* File read buffer */
-    UINT br;           /* File read count */
-    FRESULT res;       /* Petit FatFs function common result code */
-
-
-    /* Mount the volume */
-    pf_mount(&fs);
-    if (res) die(res);
-
-    /* Open a file */
-    res = pf_open("srcfile.dat");
-    if (res) die(res);
-
-    /* Read data to the memory */
-    res = pf_read(buff, 16, &br);    /* Read data to the buff[] */
-    if (res) die(res);               /* Check error */
-    if (br != 16) die(255);          /* Check EOF */
-
-    ....
-
-    /* Forward data to the outgoing stream */
-    do
-        res = pf_read(0, 512, &br);  /* Send data to the stream */
-    while (res || br != 512);        /* Break on error or eof */
-
-    ....
-
-}
-
-
- -
-

QuickInfo

-

Always available.

-
- -
-

References

-

pf_read, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/opendir.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/opendir.html deleted file mode 100644 index adf7a96..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/opendir.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - -Petit FatFs - pf_opendir - - - - -
-

pf_opendir

-

The pf_opendir function opens a directory.

-
-FRESULT pf_opendir (
-  DIR* dp,          /* [OUT] Pointer to the blank directory object structure */
-  const char* path  /* [IN]  Pointer to the directory name */
-);
-
-
- -
-

Parameters

-
-
dp
-
Pointer to the blank directory object to be created.
-
path
-
Pinter to the null-terminated string that specifies the directory name to be opened.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded and the directory object is created. It is used for subsequent calls to read the directory entries.
-
FR_NO_FILE
-
Could not find the path.
-
FR_NOT_READY
-
The disk drive cannot work due to no medium in the drive or any other reason.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_ENABLED
-
The volume has no work area.
-
-
- - -
-

Description

-

The pf_opendir() function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.

-
- - -
-

QuickInfo

-

Available when _USE_DIR == 1.

-
- - -
-

References

-

f_readdir, DIR

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/read.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/read.html deleted file mode 100644 index 7118841..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/read.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - -Petit FatFs - pf_read - - - - -
-

pf_read

-

The pf_read function reads data from the file.

-
-FRESULT pf_read (
-  void* buff,  /* [OUT] Pointer to the read buffer */
-  UINT btr,    /* [IN]  Number of bytes to read */
-  UINT* br     /* [OUT] Number of bytes read */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the buffer to store the read data. A NULL specifies the destination is an outgoing stream.
-
btr
-
Number of bytes to read.
-
br
-
Pointer to the variable to return number of bytes read.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The file has not been opened.
-
FR_NOT_ENABLED
-
The volume has not been mounted.
-
-
- - -
-

Description

-

The file read/write pointer in the file system object advances in number of bytes read. After the function succeeded, *br should be checked to detect end of file. In case of *br < btr, it means the read pointer reached end of file during read operation.

-

If a NULL is given to the buff, the read bytes will be forwarded to the outgoing stream instead of the memory. The streaming function will be typically built-in the disk_readp() function.

-
- -
-

QuickInfo

-

Available when _USE_READ == 1.

-
- - -
-

References

-

pf_open, pf_write, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/readdir.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/readdir.html deleted file mode 100644 index 4ac4997..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/readdir.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - -Petit FatFs - pf_readdir - - - - -
-

pf_readdir

-

The pf_readdir function reads directory entries.

-
-FRESULT pf_readdir (
-  DIR* dp,      /* [IN]  Pointer to the open directory object */
-  FILINFO* fno  /* [OUT] Pointer to the file information structure */
-);
-
-
- -
-

Parameters

-
-
dp
-
Pointer to the open directory object.
-
fno
-
Pointer to the file information structure to store the read item.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to an error in the disk function, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The directory object has not been opened.
-
-
- - -
-

Description

-

The pf_readdir() function reads directory entries in sequence. All items in the directory can be read by calling this function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into member f_name[] in the file information structure without error. When a null pointer is given to the fno, the read index of the directory object will be rewinded.

-
- - -
-

Sample Code

-
-FRESULT scan_files (char* path)
-{
-    FRESULT res;
-    FILINFO fno;
-    DIR dir;
-    int i;
-
-
-    res = pf_opendir(&dir, path);
-    if (res == FR_OK) {
-        i = strlen(path);
-        for (;;) {
-            res = pf_readdir(&dir, &fno);
-            if (res != FR_OK || fno.fname[0] == 0) break;
-            if (fno.fattrib & AM_DIR) {
-                sprintf(&path[i], "/%s", fno.fname);
-                res = scan_files(path);
-                if (res != FR_OK) break;
-                path[i] = 0;
-            } else {
-                printf("%s/%s\n", path, fno.fname);
-            }
-        }
-    }
-
-    return res;
-}
-
-
- -
-

QuickInfo

-

Available when _USE_DIR == 1.

-
- -
-

References

-

pf_opendir, FILINFO, DIR

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/sdir.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/sdir.html deleted file mode 100644 index ee1bfbb..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/sdir.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - -Petit FatFs - DIR - - - - -
-

DIR

-

The DIR structure is used for the work area to read a directory by pf_oepndir, pf_readdir function.

-
-typedef struct {
-    WORD    index;     /* Current read/write index number */
-    BYTE*   fn;        /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
-    CLUST   sclust;    /* Table start cluster (0:Static table) */
-    CLUST   clust;     /* Current cluster */
-    DWORD   sect;      /* Current sector */
-} DIR;
-
-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/sfatfs.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/sfatfs.html deleted file mode 100644 index f0776dc..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/sfatfs.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - -Petit FatFs - FATFS - - - - -
-

FATFS

-

The FATFS structure holds dynamic work area of the logical drive and a file. It is given by application program and registerd/unregisterd to the Petit FatFs module with pf_mount function. There is no member that can be changed by application programs.

-
-typedef struct {
-    BYTE    fs_type;     /* FAT sub type */
-    BYTE    csize;       /* Number of sectors per cluster */
-    BYTE    flag;        /* File status flags */
-    BYTE    pad1;
-    WORD    n_rootdir;   /* Number of root directory entries (0 on FAT32) */
-    CLUST   n_fatent;    /* Number of FAT entries (= number of clusters + 2) */
-    DWORD   fatbase;     /* FAT start sector */
-    DWORD   dirbase;     /* Root directory start sector (Cluster# on FAT32) */
-    DWORD   database;    /* Data start sector */
-    DWORD   fptr;        /* File read/write pointer */
-    DWORD   fsize;       /* File size */
-    CLUST   org_clust;   /* File start cluster */
-    CLUST   curr_clust;  /* File current cluster */
-    DWORD   dsect;       /* File current data sector */
-} FATFS;
-
-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/sfileinfo.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/sfileinfo.html deleted file mode 100644 index a16ce16..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/sfileinfo.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - -Petit FatFs - FILINFO - - - - -
-

FILINFO

-

The FILINFO structure holds a file information returned by pf_readdir function.

-
-typedef struct {
-    DWORD   fsize;        /* File size */
-    WORD    fdate;        /* Last modified date */
-    WORD    ftime;        /* Last modified time */
-    BYTE    fattrib;      /* Attribute */
-    char    fname[13];    /* File name */
-} FILINFO;
-
-
- -

Members

-
-
fsize
-
Indicates size of the file in unit of byte. This is always zero when it is a directory.
-
fdate
-
Indicates the date that the file was modified or the directory was created.
-
-
bit15:9
-
Year origin from 1980 (0..127)
-
bit8:5
-
Month (1..12)
-
bit4:0
-
Day (1..31)
-
-
-
ftime
-
Indicates the time that the file was modified or the directory was created.
-
-
bit15:11
-
Hour (0..23)
-
bit10:5
-
Minute (0..59)
-
bit4:0
-
Second / 2 (0..29)
-
-
-
fattrib
-
Indicates the file/directory attribute in combination of AM_DIR, AM_RDO, AM_HID, AM_SYS and AM_ARC.
-
fname[]
-
Indicates the file/directory name in 8.3 format null-terminated string.
-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/doc/pf/write.html b/bootloader_zevero_sd_m644p_make/pff/doc/pf/write.html deleted file mode 100644 index 81f3f56..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/doc/pf/write.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - -Petit FatFs - pf_write - - - - -
-

pf_write

-

The pf_write function writes data to the file.

-
-FRESULT pf_write (
-  const void* buff, /* [IN]  Pointer to the data to be written */
-  UINT btw,         /* [IN]  Number of bytes to write */
-  UINT* bw          /* [OUT] Pointer to the variable to return number of bytes written */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the data to be wtitten. A NULL specifies to finalize the current write operation.
-
btw
-
Number of bytes to write.
-
bw
-
Pointer to the variable to return number of bytes read.
-
-
- - -
-

Return Values

-
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
The function failed due to a hard error in the disk function, write protected, a wrong FAT structure or an internal error.
-
FR_NOT_OPENED
-
The file has not been opened.
-
FR_NOT_ENABLED
-
The volume has not been mounted.
-
-
- - -
-

Description

-

The write function has some restrictions listed below:

-
    -
  • Cannot create file. Only existing file can be written.
  • -
  • Cannot expand file size.
  • -
  • Cannot update time stamp of the file.
  • -
  • Write operation can start/stop on the sector boundary.
  • -
  • Read-only attribute of the file cannot block write operation.
  • -
-

File write operation must be done in following sequence.

-
    -
  1. pf_lseek(ofs); read/write pointer must be moved to sector bundary prior to initiate write operation or it will be rounded-down to the sector boundary.
  2. -
  3. pf_write(buff, btw, &bw); Initiate write operation. Write first data to the file.
  4. -
  5. pf_write(buff, btw, &bw); Write next data. Any other file function cannot be used while a write operation is in progress.
  6. -
  7. pf_write(0, 0, &bw); Finalize the write operation. If read/write pointer is not on the sector boundary, left bytes in the sector will be filled with zero.
  8. -
-

The read/write pointer in the file system object advances in number of bytes written. After the function succeeded, *bw should be checked to detect end of file. In case of *bw < btw, it means the read/write pointer reached end of file during the write operation. Once a write operation is initiated, it must be finalized or the written data can be lost.

-
- -
-

QuickInfo

-

Available when _USE_WRITE == 1.

-
- -
-

References

-

pf_open, FATFS

-
- -

Return

- - diff --git a/bootloader_zevero_sd_m644p_make/pff/src/00readme.txt b/bootloader_zevero_sd_m644p_make/pff/src/00readme.txt deleted file mode 100644 index 974a17b..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/src/00readme.txt +++ /dev/null @@ -1,46 +0,0 @@ -Petit FatFs Module Source Files R0.03 (C)ChaN, 2014 - - -FILES - - pff.h Common include file for Petit FatFs and application module. - pff.c Petit FatFs module. - diskio.h Common include file for Petit FatFs and disk I/O module. - diskio.c Skeleton of low level disk I/O module. - integer.h Alternative type definitions for integer variables. - - Low level disk I/O module is not included in this archive because the Petit - FatFs module is only a generic file system layer and not depend on any - specific storage device. You have to provide a low level disk I/O module that - written to control your storage device. - - - -AGREEMENTS - - Petit FatFs module is an open source software to implement FAT file system to - small embedded systems. This is a free software and is opened for education, - research and commercial developments under license policy of following trems. - - Copyright (C) 2014, ChaN, all right reserved. - - * The Petit FatFs module is a free software and there is NO WARRANTY. - * No restriction on use. You can use, modify and redistribute it for - personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. - * Redistributions of source code must retain the above copyright notice. - - - -REVISION HISTORY - - Jun 15, 2009 R0.01a First release (Branched from FatFs R0.07b) - - Dec 14, 2009 R0.02 Added multiple code page support. - Added write funciton. - Changed stream read mode interface. - Dec 07,'2010 R0.02a Added some configuration options. - Fixed fails to open objects with DBCS character. - - Jun 10, 2014 R0.03 Separated out configuration options to pffconf.h. - Added _USE_LCC option. - Added _FS_FAT16 option. diff --git a/bootloader_zevero_sd_m644p_make/pff/src/diskio.c b/bootloader_zevero_sd_m644p_make/pff/src/diskio.c deleted file mode 100644 index 5b303b8..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/src/diskio.c +++ /dev/null @@ -1,73 +0,0 @@ -/*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014 */ -/*-----------------------------------------------------------------------*/ - -#include "diskio.h" - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - DSTATUS stat; - - // Put your code here - - return stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE* buff, /* Pointer to the destination object */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Offset in the sector */ - UINT count /* Byte count (bit15:destination) */ -) -{ - DRESULT res; - - // Put your code here - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_writep ( - BYTE* buff, /* Pointer to the data to be written, NULL:Initiate/Finalize write operation */ - DWORD sc /* Sector number (LBA) or Number of bytes to send */ -) -{ - DRESULT res; - - - if (!buff) { - if (sc) { - - // Initiate write process - - } else { - - // Finalize write process - - } - } else { - - // Send data to the disk - - } - - return res; -} - diff --git a/bootloader_zevero_sd_m644p_make/pff/src/diskio.h b/bootloader_zevero_sd_m644p_make/pff/src/diskio.h deleted file mode 100644 index bb75d3e..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/src/diskio.h +++ /dev/null @@ -1,42 +0,0 @@ -/*----------------------------------------------------------------------- -/ PFF - Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Function succeeded */ - RES_ERROR, /* 1: Disk error */ - RES_NOTRDY, /* 2: Not ready */ - RES_PARERR /* 3: Invalid parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - -DSTATUS disk_initialize (void); -DRESULT disk_readp (BYTE* buff, DWORD sector, UINT offser, UINT count); -DRESULT disk_writep (const BYTE* buff, DWORD sc); - -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DISKIO_DEFINED */ diff --git a/bootloader_zevero_sd_m644p_make/pff/src/integer.h b/bootloader_zevero_sd_m644p_make/pff/src/integer.h deleted file mode 100644 index 074a46b..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/src/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/bootloader_zevero_sd_m644p_make/pff/src/pff.c b/bootloader_zevero_sd_m644p_make/pff/src/pff.c deleted file mode 100644 index f8f6329..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/src/pff.c +++ /dev/null @@ -1,1108 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03 (C)ChaN, 2014 -/-----------------------------------------------------------------------------/ -/ Petit FatFs module is a generic FAT file system module for small embedded -/ systems. This is a free software that opened for education, research and -/ commercial developments under license policy of following trems. -/ -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/----------------------------------------------------------------------------*/ - -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "diskio.h" /* Declarations of low level disk I/O functions */ - - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - - -#if _PFATFS != 4004 /* Revision ID */ -#error Wrong include file (pff.h). -#endif - -#if _FS_FAT32 -#if !_FS_FAT16 && !_FS_FAT12 -#define _FS_32ONLY 1 -#else -#define _FS_32ONLY 0 -#endif -#else -#if !_FS_FAT16 && !_FS_FAT12 -#error Wrong _FS_FATxx setting. -#endif -#define _FS_32ONLY 0 -#endif - -#define ABORT(err) {fs->flag = 0; return err;} - - - -/*--------------------------------------------------------*/ -/* DBCS code ranges and SBCS extend char conversion table */ -/*--------------------------------------------------------*/ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#else -#error Unknown code page. - -#endif - - - -/* Character code support macros */ - -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) - -#ifndef _EXCVT /* DBCS configuration */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* SBCS configuration */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _EXCVT */ - - -/* FatFs refers the members in the FAT structures with byte offset instead -/ of structure member because there are incompatibility of the packing option -/ between various compilers. */ - -#define BS_jmpBoot 0 -#define BS_OEMName 3 -#define BPB_BytsPerSec 11 -#define BPB_SecPerClus 13 -#define BPB_RsvdSecCnt 14 -#define BPB_NumFATs 16 -#define BPB_RootEntCnt 17 -#define BPB_TotSec16 19 -#define BPB_Media 21 -#define BPB_FATSz16 22 -#define BPB_SecPerTrk 24 -#define BPB_NumHeads 26 -#define BPB_HiddSec 28 -#define BPB_TotSec32 32 -#define BS_55AA 510 - -#define BS_DrvNum 36 -#define BS_BootSig 38 -#define BS_VolID 39 -#define BS_VolLab 43 -#define BS_FilSysType 54 - -#define BPB_FATSz32 36 -#define BPB_ExtFlags 40 -#define BPB_FSVer 42 -#define BPB_RootClus 44 -#define BPB_FSInfo 48 -#define BPB_BkBootSec 50 -#define BS_DrvNum32 64 -#define BS_BootSig32 66 -#define BS_VolID32 67 -#define BS_VolLab32 71 -#define BS_FilSysType32 82 - -#define MBR_Table 446 - -#define DIR_Name 0 -#define DIR_Attr 11 -#define DIR_NTres 12 -#define DIR_CrtTime 14 -#define DIR_CrtDate 16 -#define DIR_FstClusHI 20 -#define DIR_WrtTime 22 -#define DIR_WrtDate 24 -#define DIR_FstClusLO 26 -#define DIR_FileSize 28 - - - -/*-------------------------------------------------------------------------- - - Private Functions - ----------------------------------------------------------------------------*/ - - -static -FATFS *FatFs; /* Pointer to the file system object (logical drive) */ - - -/* Fill memory */ -static -void mem_set (void* dst, int val, int cnt) { - char *d = (char*)dst; - while (cnt--) *d++ = (char)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, int cnt) { - const char *d = (const char *)dst, *s = (const char *)src; - int r = 0; - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - -static -CLUST get_fat ( /* 1:IO error, Else:Cluster status */ - CLUST clst /* Cluster# to get the link information */ -) -{ - BYTE buf[4]; - FATFS *fs = FatFs; - - if (clst < 2 || clst >= fs->n_fatent) /* Range check */ - return 1; - - switch (fs->fs_type) { -#if _FS_FAT12 - case FS_FAT12 : { - UINT wc, bc, ofs; - - bc = (UINT)clst; bc += bc / 2; - ofs = bc % 512; bc /= 512; - if (ofs != 511) { - if (disk_readp(buf, fs->fatbase + bc, ofs, 2)) break; - } else { - if (disk_readp(buf, fs->fatbase + bc, 511, 1)) break; - if (disk_readp(buf+1, fs->fatbase + bc + 1, 0, 1)) break; - } - wc = LD_WORD(buf); - return (clst & 1) ? (wc >> 4) : (wc & 0xFFF); - } -#endif -#if _FS_FAT16 - case FS_FAT16 : - if (disk_readp(buf, fs->fatbase + clst / 256, ((UINT)clst % 256) * 2, 2)) break; - return LD_WORD(buf); -#endif -#if _FS_FAT32 - case FS_FAT32 : - if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; - return LD_DWORD(buf) & 0x0FFFFFFF; -#endif - } - - return 1; /* An error occured at the disk I/O layer */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# / Get cluster field from directory entry */ -/*-----------------------------------------------------------------------*/ - -static -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - CLUST clst /* Cluster# to be converted */ -) -{ - FATFS *fs = FatFs; - - - clst -= 2; - if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ - return (DWORD)clst * fs->csize + fs->database; -} - - -static -CLUST get_clust ( - BYTE* dir /* Pointer to directory entry */ -) -{ - FATFS *fs = FatFs; - CLUST clst = 0; - - - if (_FS_32ONLY || (_FS_FAT32 && fs->fs_type == FS_FAT32)) { - clst = LD_WORD(dir+DIR_FstClusHI); - clst <<= 16; - } - clst |= LD_WORD(dir+DIR_FstClusLO); - - return clst; -} - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Rewind directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_rewind ( - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - FATFS *fs = FatFs; - - - dj->index = 0; - clst = dj->sclust; - if (clst == 1 || clst >= fs->n_fatent) /* Check start cluster range */ - return FR_DISK_ERR; - if (_FS_FAT32 && !clst && (_FS_32ONLY || fs->fs_type == FS_FAT32)) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = (CLUST)fs->dirbase; - dj->clust = clst; /* Current cluster */ - dj->sect = (_FS_32ONLY || clst) ? clust2sect(clst) : fs->dirbase; /* Current sector */ - - return FR_OK; /* Seek succeeded */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - WORD i; - FATFS *fs = FatFs; - - - i = dj->index + 1; - if (!i || !dj->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % 16)) { /* Sector changed? */ - dj->sect++; /* Next sector */ - - if (dj->clust == 0) { /* Static table */ - if (i >= fs->n_rootdir) /* Report EOT when end of table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dj->clust); /* Get next cluster */ - if (clst <= 1) return FR_DISK_ERR; - if (clst >= fs->n_fatent) /* When it reached end of dynamic table */ - return FR_NO_FILE; /* Report EOT */ - dj->clust = clst; /* Initialize data for new cluster */ - dj->sect = clust2sect(clst); - } - } - } - - dj->index = i; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR *dj, /* Pointer to the directory object linked to the file name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE c; - - - res = dir_rewind(dj); /* Rewind directory object */ - if (res != FR_OK) return res; - - do { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; /* First character */ - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) /* Is it a valid entry? */ - break; - res = dir_next(dj); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR -static -FRESULT dir_read ( - DIR *dj, /* Pointer to the directory object to store read object name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE a, c; - - - res = FR_NO_FILE; - while (dj->sect) { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; - if (c != 0xE5 && c != '.' && !(a & AM_VOL)) /* Is it a valid entry? */ - break; - res = dir_next(dj); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dj->sect = 0; - - return res; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - - -static -FRESULT create_name ( - DIR *dj, /* Pointer to the directory object */ - const char **path /* Pointer to pointer to the segment in the path string */ -) -{ - BYTE c, ni, si, i, *sfn; - const char *p; -#if _USE_LCC -#ifdef _EXCVT - static const BYTE cvt[] = _EXCVT; -#endif -#endif - - /* Create file name in directory form */ - sfn = dj->fn; - mem_set(sfn, ' ', 11); - si = i = 0; ni = 8; - p = *path; - for (;;) { - c = p[si++]; - if (c <= ' ' || c == '/') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') break; - i = 8; ni = 11; - continue; - } -#if _USE_LCC -#ifdef _EXCVT - if (c >= 0x80) /* To upper extended char (SBCS) */ - c = cvt[c - 0x80]; -#endif - if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ - BYTE d = p[si++]; /* Get 2nd byte */ - sfn[i++] = c; - sfn[i++] = d; - } else -#endif - { /* Single byte code */ - if (_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ - sfn[i++] = c; - } - } - *path = &p[si]; /* Rerurn pointer to the next segment */ - - sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR -static -void get_fileinfo ( /* No return code */ - DIR *dj, /* Pointer to the directory object */ - BYTE *dir, /* 32-byte working buffer */ - FILINFO *fno /* Pointer to store the file information */ -) -{ - BYTE i, c; - char *p; - - - p = fno->fname; - if (dj->sect) { - for (i = 0; i < 8; i++) { /* Copy file name body */ - c = dir[i]; - if (c == ' ') break; - if (c == 0x05) c = 0xE5; - *p++ = c; - } - if (dir[8] != ' ') { /* Copy file name extension */ - *p++ = '.'; - for (i = 8; i < 11; i++) { - c = dir[i]; - if (c == ' ') break; - *p++ = c; - } - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir+DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir+DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir+DIR_WrtTime); /* Time */ - } - *p = 0; -} -#endif /* _USE_DIR */ - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR *dj, /* Directory object to return last directory and found object */ - BYTE *dir, /* 32-byte working buffer */ - const char *path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - - - while (*path == ' ') path++; /* Strip leading spaces */ - if (*path == '/') path++; /* Strip heading separator if exist */ - dj->sclust = 0; /* Set start directory (always root dir) */ - - if ((BYTE)*path < ' ') { /* Null path means the root directory */ - res = dir_rewind(dj); - dir[0] = 0; - - } else { /* Follow path */ - for (;;) { - res = create_name(dj, &path); /* Get a segment */ - if (res != FR_OK) break; - res = dir_find(dj, dir); /* Find it */ - if (res != FR_OK) break; /* Could not find the object */ - if (dj->fn[11]) break; /* Last segment match. Function completed. */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ - res = FR_NO_FILE; break; - } - dj->sclust = get_clust(dir); /* Follow next */ - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check a sector if it is an FAT boot record */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ - BYTE *buf, /* Working buffer */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - if (disk_readp(buf, sect, 510, 2)) /* Read the boot record */ - return 3; - if (LD_WORD(buf) != 0xAA55) /* Check record signature */ - return 2; - - if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && LD_WORD(buf) == 0x4146) /* Check FAT12/16 */ - return 0; - if (_FS_FAT32 && !disk_readp(buf, sect, BS_FilSysType32, 2) && LD_WORD(buf) == 0x4146) /* Check FAT32 */ - return 0; - return 1; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Locical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_mount ( - FATFS *fs /* Pointer to new file system object */ -) -{ - BYTE fmt, buf[36]; - DWORD bsect, fsize, tsect, mclst; - - - FatFs = 0; - - if (disk_initialize() & STA_NOINIT) /* Check if the drive is ready or not */ - return FR_NOT_READY; - - /* Search FAT partition on the drive */ - bsect = 0; - fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ - if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ - /* Check a partition listed in top of the partition table */ - if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ - fmt = 3; - } else { - if (buf[4]) { /* Is the partition existing? */ - bsect = LD_DWORD(&buf[8]); /* Partition offset in LBA */ - fmt = check_fs(buf, bsect); /* Check the partition */ - } - } - } - if (fmt == 3) return FR_DISK_ERR; - if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ - - /* Initialize the file system object */ - if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; - - fsize = LD_WORD(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ - if (!fsize) fsize = LD_DWORD(buf+BPB_FATSz32-13); - - fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ - fs->fatbase = bsect + LD_WORD(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ - fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ - fs->n_rootdir = LD_WORD(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ - tsect = LD_WORD(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ - if (!tsect) tsect = LD_DWORD(buf+BPB_TotSec32-13); - mclst = (tsect /* Last cluster# + 1 */ - - LD_WORD(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 - ) / fs->csize + 2; - fs->n_fatent = (CLUST)mclst; - - fmt = 0; /* Determine the FAT sub type */ - if (_FS_FAT12 && mclst < 0xFF7) - fmt = FS_FAT12; - if (_FS_FAT16 && mclst >= 0xFF8 && mclst < 0xFFF7) - fmt = FS_FAT16; - if (_FS_FAT32 && mclst >= 0xFFF7) - fmt = FS_FAT32; - if (!fmt) return FR_NO_FILESYSTEM; - fs->fs_type = fmt; - - if (_FS_32ONLY || (_FS_FAT32 && fmt == FS_FAT32)) - fs->dirbase = LD_DWORD(buf+(BPB_RootClus-13)); /* Root directory start cluster */ - else - fs->dirbase = fs->fatbase + fsize; /* Root directory start sector (lba) */ - fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ - - fs->flag = 0; - FatFs = fs; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_open ( - const char *path /* Pointer to the file name */ -) -{ - FRESULT res; - DIR dj; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - - fs->flag = 0; - dj.fn = sp; - res = follow_path(&dj, dir, path); /* Follow the file path */ - if (res != FR_OK) return res; /* Follow failed */ - if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) /* It is a directory */ - return FR_NO_FILE; - - fs->org_clust = get_clust(dir); /* File start cluster */ - fs->fsize = LD_DWORD(dir+DIR_FileSize); /* File size */ - fs->fptr = 0; /* File pointer */ - fs->flag = FA_OPENED; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ -#if _USE_READ - -FRESULT pf_read ( - void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - DRESULT dr; - CLUST clst; - DWORD sect, remain; - UINT rcnt; - BYTE cs, *rbuff = buff; - FATFS *fs = FatFs; - - - *br = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - remain = fs->fsize - fs->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - while (btr) { /* Repeat until all data transferred */ - if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) /* On the top of the file? */ - clst = fs->org_clust; - else - clst = get_fat(fs->curr_clust); - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - } - rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; - dr = disk_readp(!buff ? 0 : rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); - if (dr) ABORT(FR_DISK_ERR); - fs->fptr += rcnt; rbuff += rcnt; /* Update pointers and counters */ - btr -= rcnt; *br += rcnt; - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ -#if _USE_WRITE - -FRESULT pf_write ( - const void* buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write (0:Finalize the current write operation) */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - CLUST clst; - DWORD sect, remain; - const BYTE *p = buff; - BYTE cs; - UINT wcnt; - FATFS *fs = FatFs; - - - *bw = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - if (!btw) { /* Finalize request */ - if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); - fs->flag &= ~FA__WIP; - return FR_OK; - } else { /* Write data request */ - if (!(fs->flag & FA__WIP)) /* Round-down fptr to the sector boundary */ - fs->fptr &= 0xFFFFFE00; - } - remain = fs->fsize - fs->fptr; - if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ - - while (btw) { /* Repeat until all data transferred */ - if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) /* On the top of the file? */ - clst = fs->org_clust; - else - clst = get_fat(fs->curr_clust); - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ - fs->flag |= FA__WIP; - } - wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ - if (wcnt > btw) wcnt = btw; - if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ - fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ - btw -= wcnt; *bw += wcnt; - if ((UINT)fs->fptr % 512 == 0) { - if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ - fs->flag &= ~FA__WIP; - } - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ -#if _USE_LSEEK - -FRESULT pf_lseek ( - DWORD ofs /* File pointer from top of file */ -) -{ - CLUST clst; - DWORD bcs, sect, ifptr; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ - ifptr = fs->fptr; - fs->fptr = 0; - if (ofs > 0) { - bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fs->fptr; - clst = fs->curr_clust; - } else { /* When seek to back cluster, */ - clst = fs->org_clust; /* start from the first cluster */ - fs->curr_clust = clst; - } - while (ofs > bcs) { /* Cluster following loop */ - clst = get_fat(clst); /* Follow cluster chain */ - if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; - fs->fptr += bcs; - ofs -= bcs; - } - fs->fptr += ofs; - sect = clust2sect(clst); /* Current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directroy Object */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR - -FRESULT pf_opendir ( - DIR *dj, /* Pointer to directory object to create */ - const char *path /* Pointer to the directory path */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - res = follow_path(dj, dir, path); /* Follow the path to the directory */ - if (res == FR_OK) { /* Follow completed */ - if (dir[0]) { /* It is not the root dir */ - if (dir[DIR_Attr] & AM_DIR) /* The object is a directory */ - dj->sclust = get_clust(dir); - else /* The object is not a directory */ - res = FR_NO_FILE; - } - if (res == FR_OK) - res = dir_rewind(dj); /* Rewind dir */ - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entry in Sequense */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_readdir ( - DIR *dj, /* Pointer to the open directory object */ - FILINFO *fno /* Pointer to file information to return */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - if (!fno) { - res = dir_rewind(dj); - } else { - res = dir_read(dj, dir); /* Get current directory item */ - if (res == FR_NO_FILE) res = FR_OK; - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dj, dir, fno); /* Get the object information */ - res = dir_next(dj); /* Increment read index for next */ - if (res == FR_NO_FILE) res = FR_OK; - } - } - } - - return res; -} - -#endif /* _USE_DIR */ - diff --git a/bootloader_zevero_sd_m644p_make/pff/src/pff.h b/bootloader_zevero_sd_m644p_make/pff/src/pff.h deleted file mode 100644 index 76157d0..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/src/pff.h +++ /dev/null @@ -1,159 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module include file R0.03 (C)ChaN, 2014 -/----------------------------------------------------------------------------/ -/ Petit FatFs module is an open source software to implement FAT file system to -/ small embedded systems. This is a free software and is opened for education, -/ research and commercial developments under license policy of following trems. -/ -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/----------------------------------------------------------------------------*/ - -#ifndef _PFATFS -#define _PFATFS 4004 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" -#include "pffconf.h" - -#if _PFATFS != _PFFCONF -#error Wrong configuration file (pffconf.h). -#endif - -#if _FS_FAT32 -#define CLUST DWORD -#else -#define CLUST WORD -#endif - - -/* File system object structure */ - -typedef struct { - BYTE fs_type; /* FAT sub type */ - BYTE flag; /* File status flags */ - BYTE csize; /* Number of sectors per cluster */ - BYTE pad1; - WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */ - CLUST n_fatent; /* Number of FAT entries (= number of clusters + 2) */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */ - DWORD database; /* Data start sector */ - DWORD fptr; /* File R/W pointer */ - DWORD fsize; /* File size */ - CLUST org_clust; /* File start cluster */ - CLUST curr_clust; /* File current cluster */ - DWORD dsect; /* File current data sector */ -} FATFS; - - - -/* Directory object structure */ - -typedef struct { - WORD index; /* Current read/write index number */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ - CLUST sclust; /* Table start cluster (0:Static table) */ - CLUST clust; /* Current cluster */ - DWORD sect; /* Current sector */ -} DIR; - - - -/* File status structure */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - char fname[13]; /* File name */ -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* 0 */ - FR_DISK_ERR, /* 1 */ - FR_NOT_READY, /* 2 */ - FR_NO_FILE, /* 3 */ - FR_NOT_OPENED, /* 4 */ - FR_NOT_ENABLED, /* 5 */ - FR_NO_FILESYSTEM /* 6 */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* Petit FatFs module application interface */ - -FRESULT pf_mount (FATFS* fs); /* Mount/Unmount a logical drive */ -FRESULT pf_open (const char* path); /* Open a file */ -FRESULT pf_read (void* buff, UINT btr, UINT* br); /* Read data from the open file */ -FRESULT pf_write (const void* buff, UINT btw, UINT* bw); /* Write data to the open file */ -FRESULT pf_lseek (DWORD ofs); /* Move file pointer of the open file */ -FRESULT pf_opendir (DIR* dj, const char* path); /* Open a directory */ -FRESULT pf_readdir (DIR* dj, FILINFO* fno); /* Read a directory item from the open directory */ - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - -/* File status flag (FATFS.flag) */ - -#define FA_OPENED 0x01 -#define FA_WPRT 0x02 -#define FA__WIP 0x40 - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* _PFATFS */ diff --git a/bootloader_zevero_sd_m644p_make/pff/src/pffconf.h b/bootloader_zevero_sd_m644p_make/pff/src/pffconf.h deleted file mode 100644 index d6b984e..0000000 --- a/bootloader_zevero_sd_m644p_make/pff/src/pffconf.h +++ /dev/null @@ -1,89 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - Configuration file R0.03 (C)ChaN, 2014 -/---------------------------------------------------------------------------*/ - -#ifndef _PFFCONF -#define _PFFCONF 4004 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Function Configurations -/---------------------------------------------------------------------------*/ - -#define _USE_READ 1 /* Enable pf_read() function */ -#define _USE_DIR 0 /* Enable pf_opendir() and pf_readdir() function */ -#define _USE_LSEEK 0 /* Enable pf_lseek() function */ -#define _USE_WRITE 0 /* Enable pf_write() function */ - -#define _FS_FAT12 0 /* Enable FAT12 */ -#define _FS_FAT16 1 /* Enable FAT16 */ -#define _FS_FAT32 1 /* Enable FAT32 */ - - -/*---------------------------------------------------------------------------/ -/ Locale and Namespace Configurations -/---------------------------------------------------------------------------*/ - -#define _USE_LCC 0 /* Allow lower case characters for path name */ - -#define _CODE_PAGE 437 -/* The _CODE_PAGE specifies the code page to be used on the target system. -/ SBCS code pages with _USE_LCC == 1 requiers a 128 byte of case conversion -/ table. This might occupy RAM on some platforms, e.g. avr-gcc. -/ When _USE_LCC == 0, _CODE_PAGE has no effect. -/ -/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows) -/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows) -/ 949 - Korean (DBCS, OEM, Windows) -/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows) -/ 1250 - Central Europe (Windows) -/ 1251 - Cyrillic (Windows) -/ 1252 - Latin 1 (Windows) -/ 1253 - Greek (Windows) -/ 1254 - Turkish (Windows) -/ 1255 - Hebrew (Windows) -/ 1256 - Arabic (Windows) -/ 1257 - Baltic (Windows) -/ 1258 - Vietnam (OEM, Windows) -/ 437 - U.S. (OEM) -/ 720 - Arabic (OEM) -/ 737 - Greek (OEM) -/ 775 - Baltic (OEM) -/ 850 - Multilingual Latin 1 (OEM) -/ 858 - Multilingual Latin 1 + Euro (OEM) -/ 852 - Latin 2 (OEM) -/ 855 - Cyrillic (OEM) -/ 866 - Russian (OEM) -/ 857 - Turkish (OEM) -/ 862 - Hebrew (OEM) -/ 874 - Thai (OEM, Windows) -*/ - - -/*---------------------------------------------------------------------------/ -/ System Configurations -/---------------------------------------------------------------------------*/ - -#define _WORD_ACCESS 1 -/* The _WORD_ACCESS option is an only platform dependent option. It defines -/ which access method is used to the word data on the FAT volume. -/ -/ 0: Byte-by-byte access. Always compatible with all platforms. -/ 1: Word access. Do not choose this unless under both the following conditions. -/ -/ * Address misaligned memory access is always allowed for ALL instructions. -/ * Byte order on the memory is little-endian. -/ -/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and -/ reduce code size. Following table shows an example of some processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 RX600(LE) 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(BE) 0 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 x86 0/1 -*/ - -#endif /* _PFFCONF */ diff --git a/bootloader_zevero_sd_m644p_make/spi_pins.h b/bootloader_zevero_sd_m644p_make/spi_pins.h deleted file mode 100644 index bda946b..0000000 --- a/bootloader_zevero_sd_m644p_make/spi_pins.h +++ /dev/null @@ -1,76 +0,0 @@ -// MOSI, MISO, and SCK pin definitions for all standard ATmega microcontrollers -#ifndef SPI_PINS_H -#define SPI_PINS_H - -#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega64A__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega128A__) || \ -defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \ -defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) || \ -defined(__AVR_ATmega165__) || defined(__AVR_ATmega165A__) || defined(__AVR_ATmega165P__) || defined(__AVR_ATmega165PA__) || defined(__AVR_ATmega325__) ||defined(__AVR_ATmega325A__) || defined(__AVR_ATmega325P__) || defined(__AVR_ATmega325PA__) || defined(__AVR_ATmega645__) || defined(__AVR_ATmega645A__) || defined(__AVR_ATmega645P__) || \ -defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3250A__) || defined(__AVR_ATmega3250P__) || defined(__AVR_ATmega3250PA__) || defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6450A__) || defined(__AVR_ATmega6450P__) || \ -defined(__AVR_ATmega169__) || defined(__AVR_ATmega169A__) || defined(__AVR_ATmega169P__) || defined(__AVR_ATmega169PA__) || defined(__AVR_ATmega329__) || defined(__AVR_ATmega329A__) || defined(__AVR_ATmega329P__) || defined(__AVR_ATmega329PA__) || defined(__AVR_ATmega3290__) || defined(__AVR_ATmega3290A__) || defined(__AVR_ATmega3290P__) || defined(__AVR_ATmega3290PA__) || defined(__AVR_ATmega649__) || defined(__AVR_ATmega649A__) || defined(__AVR_ATmega649P__) || defined(__AVR_ATmega6490__) || defined(__AVR_ATmega6490A__) || defined(__AVR_ATmega6490P__) || \ -defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U6__) || \ -defined(__AVR_AT90CAN32__ ) || defined(__AVR_AT90CAN64__ ) || defined(__AVR_AT90CAN128__ ) || \ -defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 2 //MMC DI MOSI pin (DDR, PORT) -#define PORT_DI _SFR_IO_ADDR(PORTB), 2 - -#define PIN_DO _SFR_IO_ADDR(PINB), 3 //MMC DO MISO pin (PIN, PORT) -#define PORT_DO _SFR_IO_ADDR(PORTB), 3 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 1 //MMC SCK pin (DDR, PORT) -#define PORT_CK _SFR_IO_ADDR(PORTB), 1 - - -#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega8A__) || defined(__AVR_ATmega48__) || defined(__AVR_ATmega48A__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega48PA__) || defined(__AVR_ATmega48PB__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega88A__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega88PA__) || defined(__AVR_ATmega88PB__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168A__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega168PA__) || defined(__AVR_ATmega168PB__) ||defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328PB__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 3 -#define PORT_DI _SFR_IO_ADDR(PORTB), 3 - -#define PIN_DO _SFR_IO_ADDR(PINB), 4 -#define PORT_DO _SFR_IO_ADDR(PORTB), 4 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 5 -#define PORT_CK _SFR_IO_ADDR(PORTB), 5 - - -#elif defined(__AVR_ATmega16__) || defined(__AVR_ATmega16A__) || defined(__AVR_ATmega32__) || defined(__AVR_ATmega32A__) || \ -defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__) || defined(__AVR_ATmega163__) || \ -defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__) || defined(__AVR_ATmega164PA__) || defined(__AVR_ATmega323__) || defined(__AVR_ATmega324A__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega324PB__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || \ -defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 5 -#define PORT_DI _SFR_IO_ADDR(PORTB), 5 - -#define PIN_DO _SFR_IO_ADDR(PINB), 6 -#define PORT_DO _SFR_IO_ADDR(PORTB), 6 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 7 -#define PORT_CK _SFR_IO_ADDR(PORTB), 7 - - -#elif defined(__AVR_ATmega16M1__) || defined(__AVR_ATmega32M1__) || defined(__AVR_ATmega64M1__) || defined(__AVR_ATmega32C1__) || defined(__AVR_ATmega64C1__) || \ -defined(__AVR_AT90PWM1__) || defined(__AVR_AT90PWM2__) || defined(__AVR_AT90PWM2B__) || defined(__AVR_AT90PWM3__) || defined(__AVR_AT90PWM3B__) || defined(__AVR_AT90PWM216__) || defined(__AVR_AT90PWM316__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 1 -#define PORT_DI _SFR_IO_ADDR(PORTB), 1 - -#define PIN_DO _SFR_IO_ADDR(PINB), 0 -#define PORT_DO _SFR_IO_ADDR(PORTB), 0 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 7 -#define PORT_CK _SFR_IO_ADDR(PORTB), 7 - - -#elif defined(__AVR_AT90PWM81__) || defined(__AVR_AT90PWM161__) -#define DDR_DI _SFR_IO_ADDR(DDRB), 4 -#define PORT_DI _SFR_IO_ADDR(PORTB), 4 - -#define PIN_DO _SFR_IO_ADDR(PINB), 6 -#define PORT_DO _SFR_IO_ADDR(PORTB), 6 - -#define DDR_CK _SFR_IO_ADDR(DDRB), 5 -#define PORT_CK _SFR_IO_ADDR(PORTB), 5 - - -#else -#error SPI pins not defined for your processor. You must modify spi_pins.h -#endif - -#endif //SPI_PINS_H diff --git a/bootloader_zevero_sd_m644p_make/uart/uart.c b/bootloader_zevero_sd_m644p_make/uart/uart.c deleted file mode 100644 index 12f9956..0000000 --- a/bootloader_zevero_sd_m644p_make/uart/uart.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -** This is a simple set of UART routines for debug purposes -** It's Tx only and the baud rate is fixed (see UART_init) -*/ - -#include "uart.h" -#define UCSRA UCSR0A -#define UCSRB UCSR0B -#define UCSRC UCSR0C -#define UBRRH UBRR0H -#define UBRRL UBRR0L -#define UDRE UDRE0 -#define UDR UDR0 -#define RXC RXC0 - -#if BOOT_ADR > 0xFFFF - #define PGM_READ_BYTE(x) pgm_read_byte_far(x) -#else - #define PGM_READ_BYTE(x) pgm_read_byte(x) -#endif - -// Just enable the UART Tx and set baud rate for 38400 on 3.6864MHz (STK500) - -void UART_init(void) { - UCSRB = (1 << TXEN0); - UBRRL = USE_UART; // SEE HERE: http://wormfood.net/avrbaudcalc.php -} - -// The classic Tx one character routine -void UART_put(uint8_t c) { - while (!(UCSRA & (1 << UDRE))); - UDR = c; -} - -// classic Tx a C-string routine -// As there is no .data (in the bootloader) it only makes sense for theis to use PSTR() -void UART_puts(const char * str) { - char c; - do { - c = PGM_READ_BYTE(str++); - if (c) { - UART_put(c); - } - } while (c != 0); -} - -// Just outputs "\r\n" -void UART_newline(void){ - UART_put('\r'); - UART_put('\n'); -} - -// used in printing a 2 digit hex number, outputs one of the two nibbles -// the parameter is expected to be 0..F -void UART_putnibble(uint8_t c) { - if (c < 10) { - UART_put('0' + c); - } - else { - UART_put('A' + c - 10); - } -} - -// print both nibbles of an 8 bit hex number -void UART_puthex(uint8_t c) { - UART_putnibble(c >> 4); - UART_putnibble(c & 0x0F); -} - -// print both bytes of a 16 bit hex number -void UART_puthex16(uint16_t n) { - UART_puthex(n >> 8); - UART_puthex(n & 0xFF); -} -// print both bytes of a 32 bit hex number -void UART_puthex32(uint32_t n) { - UART_puthex(n >> 24); - UART_puthex(n >> 16 & 0xFF); - UART_puthex(n >> 8 & 0xFF); - UART_puthex(n & 0xFF); -} - -// this expect the first parameter to be a string in dlash (that is PSTR()) -// and then the second to be a value to print out in hex. typically used in -// the form UART_putsP(PSTR("SecPerClus = "), SecPerClus) -void UART_putsP(const char * str, uint16_t n) { - UART_puts(str); - UART_puthex16(n); - UART_newline(); -} - -// dump the 512 bytes at the given address in the form: -// CD BF 10 E0 A0 E6 B0 E0 E4 E5 F0 E0 02 C0 05 90 Ϳ ������� � � -void UART_dumpsector(uint8_t * Buff) { - for (uint16_t i=0; i<512; i++) { - if ((i % 16) == 0) { - UART_put(' '); - for(uint16_t j=(i -16); j<=i; j++) { - UART_put(((Buff[j]>=(uint8_t)32) && (Buff[j]<(uint8_t)127)) ? Buff[j] : '.'); - } - UART_newline(); - } - UART_puthex(Buff[i]); - UART_put(' '); - } - UART_newline(); -} diff --git a/bootloader_zevero_sd_m644p_make/uart/uart.h b/bootloader_zevero_sd_m644p_make/uart/uart.h deleted file mode 100644 index 015783e..0000000 --- a/bootloader_zevero_sd_m644p_make/uart/uart.h +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -/* -** This is a simple set of UART routines for debug purposes -** It's Tx only and the baud rate is fixed (see UART_init) -*/ - -// Just enable the UART Tx and set baud rate for 38400 on 3.6864MHz (STK500) -void UART_init(void); -// The classic Tx one character routine -void UART_put(uint8_t c); -// classic Tx a C-string routine (string in PROGMEM) -void UART_puts(const char * str); -// this expect the first parameter to be a string in dlash (that is PSTR()) -// and then the second to be a value to print out in hex. typically used in -// the form UART_putsP(PSTR("SecPerClus = "), SecPerClus) -void UART_putsP(const char * str, uint16_t n); -// Just outputs "\r\n" -void UART_newline(void); -// used in printing a 2 digit hex number, outputs one of the two nibbles -// the parameter is expected to be 0..F -void UART_putnibble(uint8_t c); -// print both nibbles of an 8 bit hex number -void UART_puthex(uint8_t c); -// print both bytes of a 16 bit hex number -void UART_puthex16(uint16_t n); -// print both bytes of a 32 bit hex number -void UART_puthex32(uint32_t n); -// dump the 512 bytes at the given address in the form: -// CD BF 10 E0 A0 E6 B0 E0 E4 E5 F0 E0 02 C0 05 90 Ϳ ������� � � -void UART_dumpsector(uint8_t * Buff);